Log in

View Full Version : Verifying if a source has a script



cursed
08-28-2006, 02:40 AM
Is this possible?

If a script is on a page, then it will show

echo "Hello World";

on another website.



If a script isn't on the page, then it will change another website into
this:

echo "You need the script";




I got some of this already:
if ($_GET['affcode'] && is_numeric($_GET['affcode']) {
echo 'Welcome Affiliate!!';
} else {
echo 'Welcome Guest';
}

but what should i do to replace affcode? A website link? because the php code is on an external site.

Twey
08-28-2006, 02:44 AM
I've got no idea what you're talking about.

Another website? What website? A script? What sort of script?

cursed
08-28-2006, 02:45 AM
ok..

If a website has a script, then it will make another section of a different website to show.

If a website DIDNT have the script, then nothing wouldshow on the different website.

blm126
08-28-2006, 02:48 AM
Do you mean like some kind of Affiliate link?

blm126
08-28-2006, 02:50 AM
Looking at your code closer you just need to do this. Use the code you have. And all links should have ?affcode=2 added to the end. Like So


<a href="http://somepage.com/blah.php?affcode=2">Some page</a>

cursed
08-28-2006, 02:50 AM
yeah basically.

is it possible for a php script to "verify" if an affilate link is there?
without someone clicking the link?

blm126
08-28-2006, 02:53 AM
Ok, you've got #1. That is your page. and #2 that is your affiliates page. You want #1 to check if #2 has an affiliate link. If so when a visitor comes from #2 to #1 via a link it should say Welcome Affiliate. Is that what you want?

Twey
08-28-2006, 02:55 AM
If a website has a script, then it will make another section of a different website to show.
if(stripos(file_get_contents('http://www.othersite.com/page.html'), '<script') !== false)
echo('You\'re an affiliate.');
else
echo('You\'re a guest.');

cursed
08-28-2006, 02:56 AM
yeah, except when a visitor comes from 2 to 1 via a link it shouldnt say welcome affiliate. only a special link only affilates should know would say that.

cursed
08-28-2006, 02:56 AM
wow thanks twee..

except 1 thing.. for <script is that for javascript?
and would i be able to change that?

Twey
08-28-2006, 02:58 AM
except 1 thing.. for <script is that for javascript?Yes. You never specified what sort of script you were talking about, so I naturally assumed the most obvious one.
and would i be able to change that?Unlikely. Server-side scripts are very different from client-side scripts from the point of view of the client (which is what the PHP script would be acting as); you'd need to devise an entirely different method, if it were possible at all.

blm126
08-28-2006, 03:06 AM
<?php
$affiliate = 'somesite.com'; //Don't add anyhting that isn't ALWAYS in the URL
if(strpos(strtolower($_SERVER['HTTP_REFERER']),$affiliate) !== false){
echo 'Welcome Affiliate';
}
else{
echo 'Welcome Guest';
}
?>

This should work for both #1 #2 as long as you change somesite.com to the opposite;

Twey
08-28-2006, 03:13 AM
strpos(strtolower(What's wrong with stripos()?

Relying on HTTP_REFERER (except as a convenience) is dangerous, since a lot of firewalls strip it.

blm126
08-28-2006, 03:19 AM
What's wrong with stripos()?

The large number of PHP 4 servers :(


Relying on HTTP_REFERER (except as a convenience) is dangerous, since a lot of firewalls strip it.

As long as it is not mission critical I don't see why HTTP_REFERER should not be used. If it has to be one hundred percent accurate then the get variable method I posted a couple posts ago should be used.

Twey
08-28-2006, 03:48 AM
Ah, so 'tis.

cursed
08-28-2006, 04:32 AM
Thanks..

is it possible to only do it once?

Because i want a script that also includes to another website, and that same script that checks another website.

and if this wont stop, then it would be an endless loop.