Forum Moderators: phranque

Message Too Old, No Replies

Invalid url, you chould add url ex: http://?http://www.example.org/

My php counter started failing

         

silverbytes

8:22 pm on Feb 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My php counter worked ok. Today I started to receive this.
What is that?
Instead going to the url I put, browser shows that message.
I see tons of sites doing a google search with same problem.

What is happening and how do I fix that?

silverbytes

8:55 pm on Feb 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'll reply myself since I can't edit my post now.
I suspect is something related with permissions or a security measure from hosting.
clicks_counter_data.txt is 777 (chmod)
clicks_counter_admin.php 644
clicks_counter.php 644

script code (click_counter.php)


<?php

// Necessary Variables:

$COUNT_FILE = "clicks_counter_data.txt";
// En: Absolute path and name to count data file.

function error ($error_message) {
echo $error_message."<BR>";
exit;
}

$url = urldecode($QUERY_STRING);

if (! file_exists($COUNT_FILE))
error("Can't find file, check '\$COUNT_FILE' var...");

if ((! $url) ¦¦ (! preg_match("/http:/", $url))) error ("Invalid url, you chould add url ex: <A HREF=\"http://$SERVER_NAME$PHP_SELF?http://www.example.org/\">http://$SERVER_NAME$PHP_SELF?http://www.example.org/</A>");

$file_arry = file($COUNT_FILE); //or error("Can not open \$COUNT_FILE");

while (list($key, $val) = each($file_arry)) {
if ($val!= "") {
list($file_url, $nb) = preg_split("/\t¦\n/", $val);
if ($file_url == $url) {
$nb++; $file_arry[$key] = "$file_url\t$nb\n"; $find = 1;
}
}
}

$file = join ("", $file_arry);
if (! $find) $file .= "$url\t1\n";

$fp = fopen("$COUNT_FILE", "w"); //or error("Can not open \$COUNT_FILE");
flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
header("Location: $url");

?>

It worked great until past week, suddenly start failing.
In case be a security issue what can I do?

[edited by: jatar_k at 9:34 pm (utc) on Feb. 27, 2006]
[edit reason] examplified url [/edit]