IP Throttling

    Date: 07/21/05 (PHP Community)    Keywords: php

    So, I was going to ask for some ideas on how to do IP Throttling with PHP, but came up with something before I had a chance to post anything:


    throttle.php

     IP_LIMIT);
    		if(!$denied)
    			$data[$_SERVER['REMOTE_ADDR']]++;
    	}
    
    	// write the data back to the file
    	$data_string = serialize($data);
    	$fp = fopen(DATAFILE, "w");
    	fputs($fp, $data_string);
    	fclose($fp);
    
    	if($denied) {
    		switch(THROTTLING_ACTION) {
    			case "redirect":
    				header("Location: " . THROTTLING_MESSAGE);
    				die;
    				break;
    			default:
    				echo THROTTLING_MESSAGE;
    				die;
    				break;
    		}
    	}
    ?>
    


    Then in a file to be throttled:

    throttleme.php
    
    



    Any thoughts on how to improve this?

    Source: http://www.livejournal.com/community/php/322901.html

« mysql questions || Help merging arrays »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home