Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. $base_url = $_SERVER['DOCUMENT_ROOT'] . '/RedSparrowTech/counter/';
  4. $style = 'web1';
  5. $ext = 'png';
  6. $min_digits = 5;
  7. $log_file = $base_url . 'counter.txt';
  8. $style_dir = $base_url . $style . '/';
  9.  
  10. if (file_exists($log_file))
  11. {
  12.     $unique_list = file($log_file);
  13.     $unique_count = count($unique_list);
  14.  
  15.     if (!(in_array($_SERVER['REMOTE_ADDR'] . "\n", $unique_list)))
  16.     {
  17.         if ($funique = fopen($log_file, "a"))
  18.         {
  19.             fwrite($funique, $_SERVER['REMOTE_ADDR'] . "\n");
  20.             fclose($funique);
  21.         }
  22.         else
  23.         {
  24.             echo "error opening logfile";
  25.         }
  26.         $unique_count++;
  27.     }
  28.  
  29.     if ($min_digits > 0)
  30.     {
  31.         $digits = sprintf('%0' . $min_digits . 's', $unique_count);
  32.     }
  33.    
  34.     $len = strlen($unique_count);
  35.     for ($x = 0; $x < $len; $x++)
  36.     {
  37.         $my_image = imagecreatefrompng( $style_dir . $style . '/' . $unique_list[$x] . '.png');
  38.         header("Content-type: image/png");
  39.         echo imagepng($my_image);      
  40.     }
  41.     imagedestroy($my_image);
  42.  
  43.     exit;
  44. }
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement