Client Ip: 38.107.191.100
Local Time (GMT +1):
September 4th 2010, 01:43AM.
Client Ip: 38.107.191.100
Local Time (GMT +1):
September 4th 2010, 01:43AM.
ViRi's Seal of Approval

ViRi Seal Of Approval
Status: Moved to Leiden, Currently No Internet
From: [03/18/2006 03:53PM] Till: [NO FRIGGIN IDEA!]
Status: Moved to Leiden, Currently No Internet
From: [03/18/2006 03:53PM] Till: [NO FRIGGIN IDEA!]
Command: ?
Solutions
Solutions
Subject: Analog 5.1 HOST Parser
I have a default stats package on this webserver, but it doesn't suit my needs, but untill i find (or make) a package that suits my needs, i have created a small PHP snippet that takes the info directly from the server HDD, rearrange data, sort it, trim and reformat it again :)

To see this script in action, type 'stats' in the 'Console'.


Analog 5.1 HOST Parser
  1.  
  2. function ReadAnalog51HostFile($path2file) {
  3.     $handle = fopen($path2file, "r");
  4.     $contents = fread($handle, filesize($path2file));
  5.     fclose($handle);
  6.     
  7.     $html = preg_replace('/\n/', '', stripslashes($contents));
  8.     preg_match_all('/<tr><td class="alt[1|2]">\d+\.<\/td><td class="alt[1|2]">([\d|\.]+)<\/td><td align="RIGHT" class="alt[1|2]">([\d|\,]+)<\/td><td align="RIGHT" class="alt[1|2]">([\d|\.]+\%)<\/td><\/tr>/i', $html, $matches, PREG_SET_ORDER);
  9.     $data = "";
  10.     $counter = 0;
  11.     foreach ($matches as $val) {
  12.         // Rearrange for sorting
  13.         $amount = str_pad($val[2], 10, "0", STR_PAD_LEFT);
  14.         $data .= $amount . "@" . $val[1] . "@" . $val[3] . "\n";
  15.         $counter++;
  16.     }
  17.     $lines = explode("\n", $data);
  18.     rsort($lines);
  19.     $linecount = count($lines) -1;
  20.     $ret = "<table color=\"white\" border=1><tr><td>#</td><td>Host (IP)</td><td>Hits</td><td>% of total</td></tr>";
  21.     $total = 0;
  22.     for($i = 0; $i < $linecount; $i++) { 
  23.         $line = split("@",$lines[$i]);
  24.         $linenumber = $i +1;
  25.         $ret .= "<tr><td>" . $linenumber . "</td><td>" . gethostbyaddr($line[1]) . "(" . $line[1] . ")</td><td>" . ltrim($line[0], '0') . "</td><td>" . $line[2] . "</td></tr>\n";
  26.         $nocomma = preg_replace('/,/', '', ltrim($line[0], '0'));
  27.         $total = $total + $nocomma;
  28.     }
  29.     $ret .= "<tr><td>-</td><td>Total Hits: </td><td>" . $total . "</td><td>100%</td></tr></table>";
  30.         
  31.     echo NewsArea(NewsBlock($ret));
  32. }
  33.  

Subject: ShadowText
As you might have noticed, most 'info' text on this page has a '3d look', i created a small PHP function to give me these texts on any position i want, for other fixed size and location items, i just use CSS.
ShadowText Code Snippet
  1. function ShadowText($text,$x,$y,$width,$height,$fontsize)
  2. {
  3.     $x2 = $x + 3;
  4.     $y2 = $y + 3;
  5.     $ret = "<div style=\"position:absolute; left: " . $x2 . "px; width: " . $width . "px; top: " . $y2 . "px; height: " . $height . "px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: " . $fontsize . "px; font-weight: bold; color: #000000;\">\n" . $text . "\n</div>\n\n";
  6.     $ret .= "<div style=\"position:absolute; left: " . $x . "px; width: " . $width . "px; top: " . $y . "px; height: " . $height . "px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: " . $fontsize . "px; font-weight: bold; color: #FFFFFF;\">\n" . $text . "\n</div>\n\n";
  7.  
  8.     return $ret;
  9. }


Example
  1.     // NewsBlockHeaderSize() returns 28, i use it this way to change the Header font size on all my pages in an easy manner.
  2.     echo ShadowText("PHP Snippet: ShadowText",345,259,427,37,NewsBlockHeaderSize());