Why does it stop working?

Why does it stop working?

am 22.02.2006 06:54:53 von Oil Pine

I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my proble=
m?

---------------------------------- index.php
--------------------------------------



The Counter



color=3D"#CC0000">Page visits:




---------------------------------- counter.php
-------------------------------------------
include("counter_config.php");
$cn =3D implode("",file("counter.txt"));
$cn++;
$fp =3D fopen("counter.txt","w+");
fwrite($fp,$cn);
fclose($fp);

$des =3D imagecreatetruecolor($counter_width,$counter_font_size);

$bgcol =3D HEX2RGB($counter_background);
$tcol =3D HEX2RGB($counter_color);
$bg =3D imagecolorallocate($des,$bgcol[0],$bgcol[1],$bgcol[2]);
$fc =3D imagecolorallocate($des,$tcol[0],$tcol[1],$tcol[2]);
imagecolortransparent($des,$bg);
$font =3D "fonts/$counter_font.ttf";
$tt =3D $counter_numbers - strlen($cn)-1;
$ts =3D 0;
while($ts <=3D $tt)
{
=09$cn =3D '0'.$cn;
=09$ts++;
}
imagettftext($des, $counter_font_size, 0, 0, $counter_font_size, $fc,
$font, $cn);

header("Content-type: image/gif");
imagegif($des);

function HEX2RGB($color){
$color =3D str_replace("#","",$color);
$color_array =3D array();
$hex_color =3D strtoupper($color);
for($i =3D 0; $i < 6; $i++){
$hex =3D substr($hex_color,$i,1);
switch($hex){
case "A": $num =3D 10; break;
case "B": $num =3D 11; break;
case "C": $num =3D 12; break;
case "D": $num =3D 13; break;
case "E": $num =3D 14; break;
case "F": $num =3D 15; break;
default: $num =3D $hex; break;
}
array_push($color_array,$num);
}
$R =3D (($color_array[0] * 16) + $color_array[1]);
$G =3D (($color_array[2] * 16) + $color_array[3]);
$B =3D (($color_array[4] * 16) + $color_array[5]);
return array($R,$G,$B);
unset($color_array,$hex,$R,$G,$B);
}
?>
------------------------------- counter_config.php
-------------------------------
//counter_config.php > Source
// Width in pixels of your counter
$counter_width =3D "100";
// Number of digits you want to display in the counter. Zeros will be
automaticly included
$counter_numbers =3D 6;
// Font size in pixels
$counter_font_size =3D 13;
// Font of your digits
$counter_font =3D 'arial';
// Color of your counter
$counter_color =3D '#FF6600';
// Color of the background. Usualy it should be the same with the
color of the place where will be placed
$counter_background =3D '#FFFFFF';
// Trasparent bacground counter true =3D yes false =3D no
$counter_transparent =3D true;
?>
-------------------------------- counter.txt ---------------------------
572

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Why does it stop working?

am 22.02.2006 07:07:13 von Chris

pine oil wrote:
> I've used the following counter for some time, but I don't seem to
> have it work now after I have moved the directory of the files.
>
> They used to be in /var/www/html, but moved to /home/webroot/test.
>
> Do you think the relocation of the files has something to do with my problem?

It could be a permissions thing (it can't read/write the counter.txt file).

If you could narrow down what's going wrong a bit it'd help.

View the counter only in your browser - does that give an error?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Why does it stop working?

am 22.02.2006 07:39:17 von Oil Pine

On 2/22/06, Chris wrote:
> pine oil wrote:
> > I've used the following counter for some time, but I don't seem to
> > have it work now after I have moved the directory of the files.
> >
> > They used to be in /var/www/html, but moved to /home/webroot/test.
> >
> > Do you think the relocation of the files has something to do with my pr=
oblem?
>
> It could be a permissions thing (it can't read/write the counter.txt file=
).
>
> If you could narrow down what's going wrong a bit it'd help.
>
> View the counter only in your browser - does that give an error?
>
I changed the permission to read/write for the owner and group. That
did not help.

I am sorry I don't know how to view the counter in my browswer. The
counter did not show if I open the index.php when I access the page
through the apache server.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Why does it stop working?

am 22.02.2006 07:43:13 von Chris

pine oil wrote:
> On 2/22/06, Chris wrote:
>
>>pine oil wrote:
>>
>>>I've used the following counter for some time, but I don't seem to
>>>have it work now after I have moved the directory of the files.
>>>
>>>They used to be in /var/www/html, but moved to /home/webroot/test.
>>>
>>>Do you think the relocation of the files has something to do with my problem?
>>
>>It could be a permissions thing (it can't read/write the counter.txt file).
>>
>>If you could narrow down what's going wrong a bit it'd help.
>>
>>View the counter only in your browser - does that give an error?
>>
>
> I changed the permission to read/write for the owner and group. That
> did not help.
>
> I am sorry I don't know how to view the counter in my browswer. The
> counter did not show if I open the index.php when I access the page
> through the apache server.



Instead of going to index.php, go to counter.php

That will run just the counter script and (hopefully) show an error.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Why does it stop working?

am 22.02.2006 08:13:25 von Curt Zirzow

On Tue, Feb 21, 2006 at 11:54:53PM -0600, pine oil wrote:
> I've used the following counter for some time, but I don't seem to
> have it work now after I have moved the directory of the files.
>
>...
> $cn = implode("",file("counter.txt"));
> $cn++;
> $fp = fopen("counter.txt","w+");
> fwrite($fp,$cn);
> fclose($fp);

hmm.. i didn't think these raw counter like things were used
anymore.

Have you considered not even worrying about showing how many people
have viewed the page?

Curt.
--
cat .signature: No such file or directory

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Why does it stop working?

am 22.02.2006 08:44:46 von Sameer N Ingole

Curt Zirzow wrote:
> On Tue, Feb 21, 2006 at 11:54:53PM -0600, pine oil wrote:
>> I've used the following counter for some time, but I don't seem to
>> have it work now after I have moved the directory of the files.
This seems to be Apache problem than PHP problem. Are you sure your
Apache can process PHP pages in your home directory? Check that first.

May be you should see if page with just phpinfo() function executes
properly if kept in your home directory.

Regards,

--
Sameer N. Ingole
Blog: http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php