So, let’s say you have a stat counter on your website from Let’s say — sitedesigner.safesecureweb.com…. Or any other free web page counter for that matter…
Regardless, you will have a link to your counter that looks something like this:
http://sitedesigner.safesecureweb.com/servlet/CounterServer?_patternID=12&_userID=22533&_pageID=1
Now, we can dissect this link down and find the “userID” section of the URL or URI, whatever you fancy calling it. Regardless — notice the “22533″ — Now, I don’t know who owns this counter, nor do I care — I’m just showing you a proof of concept. For various reasons I created a little web form that would allow you to smack this counter (ie, make the hit # increase) N number of times, where N is a variable determined by the end user.
First, we have the form section with a drop down box with options of how many times to “smack him”:
echo "<form name=\"form\" method=\"post\" action=\"".$PHP_SELF.dominate($_REQUEST['howMany']).”\”>”;
echo “How many times to smack him?<br>”;
echo ” <select name=\”howMany\”>”;
echo ” <option value=\”1\”>1</option>”;
echo ” <option value=\”10\”>10</option>”;
echo ” <option value=\”25\”>25</option>”;
echo ” <option value=\”50\”>50</option>”;
echo ” <option value=\”100\”>100</option>”;
echo ” <option value=\”250\”>250</option>”;
echo ” </select>”;
echo ” <br>”;
echo ” <input type=\”submit\” name=\”Smack him.\” value=\”Submit\”>”;
echo “</form>”;
Now, we include the function call - which essentially creates an HTTP request on port 80 to the given URL/URI we found above as many times as were passed to it via the form! Jackpot.
function dominate($numTimes){
for($i=0;$i<$numTimes;$i++){
echo "Smack
";
$fp = fsockopen("sitedesigner.safesecureweb.com", 80);
$query = "GET /servlet/CounterServer?_patternID=12&_userID=22533&_pageID=1 HTTP/1.1\r\n";
$query .= "Host: sitedesigner.safesecureweb.com\r\n";
$query .= "Accept-Language: en-us\r\n";
$query .= "Connection: Keep-Alive\r\n";
$query .= "\r\n\r\n";
fwrite($fp, $query);
}
}
?>
It may be more efficient to structure the get request before the for loop and simply hit the fwrite() multiple times within the for loop. But this worked for my purposes… Have fun with it!
Let me know if I can help with anything.
Cheers,
–Justin
No user commented in " PHP: A script to increase a stat counter… "
Follow-up comment rss or Leave a TrackbackLeave A Reply