Why does it stop working?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

---------------------------------- index.php
--------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>The Counter</title>
</head>
<body>
<p>
<strong><font size="2" face="Arial, Helvetica, sans-serif"
color="#CC0000">Page visits:</font></strong><br />
<img src="counter.php" /> </p>
</body>
</html>
---------------------------------- counter.php
-------------------------------------------
<?
include("counter_config.php");
$cn = implode("",file("counter.txt"));
$cn++;
$fp = fopen("counter.txt","w+");
fwrite($fp,$cn);
fclose($fp);

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

$bgcol = HEX2RGB($counter_background);
$tcol = HEX2RGB($counter_color);
$bg = imagecolorallocate($des,$bgcol[0],$bgcol[1],$bgcol[2]);
$fc = imagecolorallocate($des,$tcol[0],$tcol[1],$tcol[2]);
imagecolortransparent($des,$bg);
$font = "fonts/$counter_font.ttf";
$tt = $counter_numbers  - strlen($cn)-1;
$ts = 0;
while($ts <= $tt)
{
	$cn = '0'.$cn;
	$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 = str_replace("#","",$color);
 $color_array = array();
 $hex_color = strtoupper($color);
 for($i = 0; $i < 6; $i++){
  $hex = substr($hex_color,$i,1);
  switch($hex){
   case "A": $num = 10; break;
   case "B": $num = 11; break;
   case "C": $num = 12; break;
   case "D": $num = 13; break;
   case "E": $num = 14; break;
   case "F": $num = 15; break;
   default: $num = $hex; break;
  }
  array_push($color_array,$num);
 }
 $R = (($color_array[0] * 16) + $color_array[1]);
 $G = (($color_array[2] * 16) + $color_array[3]);
 $B = (($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 = "100";
// Number of digits you want to display in the counter. Zeros will be
automaticly included
$counter_numbers = 6;
// Font size in pixels
$counter_font_size = 13;
// Font of your digits
$counter_font = 'arial';
// Color of your counter
$counter_color = '#FF6600';
// Color of the background. Usualy it should be the same with the
color  of the place where will be placed
$counter_background = '#FFFFFF';
// Trasparent bacground counter true = yes false = no
$counter_transparent = true;
?>
-------------------------------- counter.txt ---------------------------
572

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux