<script language="php"> #echo "n=$n"; # # add code to # 1) pick a different font counter # put the new fonts in the same subdirecttory # 2) pick a 1 pixel gif image # which of course is a different font # 3) allow it to be called with out any arguments # to make it harder for the censors on indy media # to find it. # ie instead of calling it as # <img src="counter.php?n=mr_liberal"> # just make it # <img src="c.jpg.php"> # and with that make it put out an invisible gif # to some default counter. maybe based on the web page # number # # # # this program has been moved to the root directory and named # counter.php # it was orginally named # counter4.php # in this subdirectory # images_for_counters # with a full path of # images_for_counters/counter4.php # # the argument # d=n # is no longer used. # that was for the digit to display # since we display ALL the digits that is # a moot issue # # the argument # c=name # is used and name is the counter name to fetch # from the SQL database and display # # the argument # l=log_subdirectory # # has been added to the PHP version # it is the subdirectory of the log file # # # added this code so we can include it from # jpg.php # $len is the min number of digits to display if ($len == '') { $len=$_REQUEST['len']; } #echo "len=$len<br>"; if (!preg_match ( "/^[0-9][0-9]*$/", $len)) { #echo "len=$len and is NOT numeric<br>"; $len=1; } # and set n= to something in the jpg.php code # # if $l exists then it has been set by jpg.php # if ($l == '' ) { # # if it doesnt exist then check here to see # if i was passed to us via # counter.php?l=xxxx # $l=$_REQUEST['l']; } # # if the log file is null after all of this use the default log file # if ($l == '' ) { $log_file_subdir="counter/"; } #echo "log directory ='$l'<br>"; # # only allow them to change the log directory to one I chose # if ($l == 'counter_icecream_anarchist' || $l == 'counter_other' || $l == 'counter_mr_liberal') { $log_file_subdir="$l/"; #echo "new log file directory $log_file_subdir<br>"; } # # build the string which is written to the log file # $logout=""; # # get the current date and time in PHOENIX # kind of like the perl code but slightly different # more like the UNIX date command # $logout.=date("Y/m/d H:i:s",(time()-(7*60*60))); $logout.=" ${REMOTE_ADDR} "; $logout.=" ${HTTP_REFERER}"; $logout.=" ${REQUEST_URI} "; #$logout.=" REMOTE_PORT=${REMOTE_PORT} "; #$logout.=" HTTP_X_FORWARDED_FOR=${HTTP_X_FORWARDED_FOR} "; #$logout.=" HTTP_REFERER=${HTTP_REFERER} "; #$logout.=" HTTP_USER_AGENT=${HTTP_USER_AGENT} "; #$logout.=" HTTP_VIA=${HTTP_VIA} "; #$logout.=" REQUEST_URI=${REQUEST_URI} "; #$logout.=" SERVER_ADDR=${SERVER_ADDR} "; #$logout.=" REMOTE_ADDR=${REMOTE_ADDR} "; #echo "<p>$logout<br>"; # # write the stuff to the log file # $file=$log_file_subdir."ip_log.txt"; $F=fopen($file,"a"); fwrite ( $F, "$logout\n" ); $rc=fclose($F); </script> <script language="php"> # # ok their IP address has been written to the log file # now generate a counter and display it # #echo "Database Server: :mysql1.100ws.com<br>"; #echo "database name:miksup_data<br>"; #echo "username <br>"; #echo "table counters<br>"; #echo "more<blockquote>MySQL 4.1.11-Debian_4sarge5 running on<br>mysql1.100ws.com as<br> #miksup_data@ws2.100ws.com</blockquote>"; # # added this code so we can include it from # jpg.php # and set n= to something in the jpg.php code # if ($n == '' ) { $n=$_REQUEST['n']; } # # n=counter_name # n is the counter name and it must be in the SQL table # or this routine dies! # # if the name is null make it one space so we can look it up in the SQL table as a space # if ($n == "") { $n=" "; } // Connecting, selecting database # # connect to the SQL database server # $link = mysql_connect('mysql1.100ws.com', 'miksup_data', 'Amigos666') or die('Could not connect: ' . mysql_error()); #echo 'Connected successfully<br>'; # # use the database miksup_data # mysql_select_db('miksup_data') or die('Could not select database'); #echo 'selected database<br>'; $zcounter_value=do_sql_select($n); #echo "rc from do_sql_select($n)=$zcounter_value<br>"; if ($zcounter_value == -1) { $n=' '; $zcounter_value=do_sql_select($n); } #echo "rc from do_sql_select($n)=$zcounter_value<br>"; # # build the query to run # #$query = 'SELECT count FROM `counters` where name=\''.$n.'\' LIMIT 0, 30 '; #$query = 'SELECT count FROM `counters` where name=\'frog\' LIMIT 0, 30 '; # # run the query # #$result = mysql_query($query) or die('Query failed: ' . mysql_error()); # # loop thru and get the results of the query # but in this case there will only be ONE result # #$zcounter_value=""; #while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { # foreach ($line as $col_value) { # $zcounter_value=$col_value; # } #} #mysql_free_result($result); # # add 1 to the counter # update the counter in the table # $number=$zcounter_value; $nextval=$zcounter_value+1; #$query = 'update `counters` set count='.$nextval.' WHERE name=\'frog\''; $query = 'update `counters` set count='.$nextval.' WHERE name=\''.$n.'\''; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); // Free resultset # # close the SQL connection # // Closing connection mysql_close($link); # # add leading zeros to the number # while( $len > strlen($number)) { $number="0".$number; #echo "$number<br>"; } # # now we take $number and build an image from it # # set these to the image width and height # after we caculate it from the digits in the image $xxheight=1; $xxwidth=0; # # read in the 10 digit images # may have to change this from PNG to GIF to JPG # $ifiles[0]='images_for_counters/0.gif'; $ifiles[1]='images_for_counters/1.gif'; $ifiles[2]='images_for_counters/2.gif'; $ifiles[3]='images_for_counters/3.gif'; $ifiles[4]='images_for_counters/4.gif'; $ifiles[5]='images_for_counters/5.gif'; $ifiles[6]='images_for_counters/6.gif'; $ifiles[7]='images_for_counters/7.gif'; $ifiles[8]='images_for_counters/8.gif'; $ifiles[9]='images_for_counters/9.gif'; # # loop thru and open a gif file for each number from 0 to 9 # for ($i=0;$i<10;$i++) { #list($zwidth, $zheight, $ztype, $zattr)=getimagesize($ifiles[$i]); $size=getimagesize($ifiles[$i]); $gif_width[$i]=$size[0]; $gif_height[$i]=$size[1]; if ($gif_height[$i] > $xxheight ) { $xxheight=$gif_height[$i]; } $gif[$i]=@imagecreatefromgif ($ifiles[$i]); if (!$gif[$i]) { echo "error reading file $ifiles[$i] for image $i<br>"; } } # # get the total width of the image # by adding up the width of each digit in the number # for ($i=0;$i<strlen($number);$i++) { $thisdigit=substr($number,$i,1); $xxwidth+=$gif_width[$thisdigit]; } # # create the image # $image=ImageCreate($xxwidth, $xxheight); # # set the R,G,B background color of the imagee # $background_color=ImageColorAllocate($image,255,255,255); # # define RGB black as a color used on the image # $black=ImageColorAllocate($image,0,0,0); # # copy the color $black into the image between 0,0 and 50,50 # #ImageFilledRectangle($image,0,0,$xxwidth,$xxheight,$black); # # convert the $number to an image # copy each digit of the number to our image from left to right # $next_x=0; for ($i=0;$i<strlen($number);$i++) { $thisdigit=substr($number,$i,1); $zfile=$ifiles[$thisdigit]; $zhandle=$gif[$thisdigit]; # # copy the gif image to our image # $rc=imagecopy ( $image, $zhandle, $next_x, ($xxheight - $gif_height[$thisdigit]) , 0, 0, $gif_width[$thisdigit],$xxheight); $rc=$rc?"true":"failed"; $next_x=$next_x+ $gif_width[$thisdigit]; } # # return the image # header("Content-Type: image/png"); ImagePNG($image); function do_sql_select($counter_name) { # # assume select will fail and return -1 as an error code # $rc=-1; #echo "counter_name=$counter_name<br>"; # # build the query to run # $query = 'SELECT count FROM `counters` where name=\''.$counter_name.'\' LIMIT 0, 30 '; #$query = 'SELECT count FROM `counters` where name=\''.$n.'\' LIMIT 0, 30 '; #$query = 'SELECT count FROM `counters` where name=\'frog\' LIMIT 0, 30 '; # # run the query # $result = mysql_query($query) or die('Query failed: ' . mysql_error()); # # loop thru and get the results of the query # but in this case there will only be ONE result # $zcounter_value=""; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach ($line as $col_value) { $zcounter_value=$col_value; } } mysql_free_result($result); #echo "zcounter_value='$zcounter_value'<br>"; if ($zcounter_value != '') { $rc=$zcounter_value; } #echo "rc=$rc<br>"; return $rc; } </script>
               (
geocities.com/tokyo/market)                   (
geocities.com/tokyo)