Not your usual GET problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Not your usual GET problem

Post by Rovas »

I received a piece of code that I had to debug but unfortunately I don' t have an idea on how to fixed it :(
http://www.example.com/engine%20%messag ... mon/js_get?
file=common/js_get?file=msie/js_get?file=msie/js_get?file=msie/js_get?fi
le=msie/js_get?file=common/js_get?file=common/js_get?file=msie/js_get?fi
Here is the problem the code is stop a user getting the same Javascript file more than once.

Code: Select all

 
 
//in the make_head.php $head contains all the tags with metadata from html tag head
$head="<head>";
//some lines not important
$head.='<script language="javascript" type="text/javascript" src="js_get?file=common"></script>';
$head.='<script language="javascript" type="text/javascript" src="js_get?file='.$GLOBALS["BROWSER"].'_common"></script>';
//in the anti_spam.php this function appends the Javascript to a file that will be cached
    function anti_boot($delay,$calls) {
        if  ($GLOBALS['CALLER_NETWORK']=='localhost') return; 
                //create the temporary file 
        $completfilename=$GLOBALS['BOOTER_ROOT'].'/'.$GLOBALS['CALLER_NETWORK'].'_'.$_SERVER['REMOTE_ADDR'].'.tmp';
                if (file_exists($completfilename)) {
            //check to see if the creation time is the same or smaller than the request
                        if (@filemtime($completfilename) < (time() - $delay)) {@file_put_contents($completfilename,'.'); return;}
                        // more than $cals request delete the temporary file 
            if (@filesize($completfilename) > $calls) {myErrorHandler (-53,'site boot', __FILE__, __LINE__); sleep($delay); @unlink($completfilename); return;} 
        }
        @file_put_contents($completfilename,'.',FILE_APPEND);
    }
//create.php creates the webpage
   anti_boot(2,400);
   //create and display the temporary file 
 
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Not your usual GET problem

Post by pickle »

I'm not totally sure what your problem is or what you've tried to fix it.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Re: Not your usual GET problem

Post by Rovas »

The dude who made the code made a function that doesn' t permit a computer to request more than 400 times.The request is made using GET a file that is in the cache of the webserver. This file is made by putting some javascript files togheter. It' s crazy I know but that' s the way he wants it.
Post Reply