/**
  * Tests the agent / browser / os parser.
  *
  * @public
  * @return @c true on success @c false on failure.
  */
 function test()
 {
     $tests = array("Mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; Nokia 6630/5.03.08; 6936) Opera 8.50 [it]" => "Symbian OS, Nokia 6630", "Mozilla/4.0 (compatible; MSIE 6.0; Mac_PowerPC Mac OS X; en) Opera 8.5" => "Macintosh - OS X", "Mozilla/4.0 (PSP (PlayStation Portable); 2.00)" => "PlayStation Portable 2.X", "Mozilla/4.01 (Compatible; Acorn Phoenix 2.08 [intermediate]; RISC OS 4.39) Acorn-HTTP/0.84" => "RISC OS 4.X", "Mozilla/4.7C-SGI [en] (X11; I; IRIX 6.5 IP32)" => "UNIX - IRIX 6.X", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; sv-se) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3" => "Macintosh - Intel Mac OS X", "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; da; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6" => "Macintosh - PowerPC Mac OS X", "Mozilla/5.0 (OS/2; U; Warp 4.5; en-US; rv:1.7.12) Gecko/20050922 Firefox/1.0.7" => "OS/2 Warp 4.X", "Mozilla/5.0 (SymbianOS/9.1; U; en-us) AppleWebKit/413 (KHTML, like Gecko) Safari/413" => "Symbian OS 9.X", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.9) Gecko/20070102 Ubuntu/dapper-security Firefox/1.5.0.9" => "UNIX - Linux, Ubuntu", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060926 Debian/1.7.8-1sarge7.3.1" => "UNIX - Linux, Debian", "SonyEricssonK750i/R1CA Browser/SEMC-Browser/4.2 Profile/MIDP-2.0 Configuration/CLDC-1.1" => "SonyEricssonK750i");
     foreach ($tests as $in => $out) {
         $res = ZipStatEngine::platform($in);
         if ($res !== $out) {
             echo "Platform: The string {$in}\nshould give \"{$out}\" but gave \"{$res}\".";
             return false;
         }
     }
     $tests = array("Mozilla/4.0 (compatible; Voyager; AmigaOS)" => "Voyager", "Mozilla/4.0 (PSP (PlayStation Portable); 2.00)" => "PlayStation Portable 2.X", "Mozilla/4.01 (Compatible; Acorn Phoenix 2.08 [intermediate]; RISC OS 4.39) Acorn-HTTP/0.84" => "Acorn Phoenix v2.X", "Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)" => "HTTrack v3.X", "Mozilla/4.5 (compatible; iCab 2.7.1; Macintosh; I; PPC)" => "iCab v2.X", "Mozilla/5.0 (000000000; 0; 000 000 00 0 000000; 00000; 000000) Gecko/20030624 Netscape/7.1" => "Netscape v7.X", "Mozilla/5.0 (BeOS; U; BeOS BePC; en-US; rv:1.9a1) Gecko/20051002 Firefox/1.6a1" => "Firefox v1.X", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; da; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" => "Firefox v2.X", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; da-dk) AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.2" => "Safari", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Galeon/1.3.17 (Debian package 1.3.17-2)" => "Galeon v1.X", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20061022 Iceweasel/1.5.0.7-g2" => "Iceweasel v1.X", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061105 Iceape/1.0.6 (Debian-1.0.6-1)" => "Iceape v1.X", "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.1) Gecko/Debian-1.8.0.1-5 Epiphany/1.8.5" => "Epiphany v1.X", "Mozilla/5.0 (X11; U; SunOS sun4m; en-US; rv:1.4b) Gecko/20030517 Mozilla Firebird/0.6" => "Mozilla Firebird", "Wget/1.8.2" => "Wget v1.X");
     foreach ($tests as $in => $out) {
         $res = ZipStatEngine::short_browser($in);
         if ($res !== $out) {
             echo "Browser: The string {$in}\nshould give \"{$out}\" but gave \"{$res}\".";
             return false;
         }
     }
     return true;
 }
Example #2
0
 }
 //Ignore this visit on this page?
 //'taelop' is danish for count up. nej is danish for no.
 if (!$lib->countVisit(getenv("HTTP_REFERER"), $datafil->getLine(111))) {
     $ind['taelop'] = "nej";
 }
 //Ignore visits from this IP-address?
 if (getenv("REMOTE_ADDR") === $datafil->getLine(52) and $datafil->getLine(52) != "") {
     $ind['taelop'] = "nej";
 }
 //Update the http vars.
 $lib->setHTTPVars($ind);
 //Only register visit if the taelop parameter does not forbid it.
 if (isset($ind['taelop']) and $ind['taelop'] !== "nej" or !isset($ind['taelop'])) {
     //Do the actual registering of the visit.
     $engine = new ZipStatEngine($lib);
     //Set user settings.
     $engine->setCounterIgnoreQuery($datafil->getUserSetting('ignoreQuery') !== 'false');
     //Process the visit.
     $engine->process($lib->getTimeAdjusted(), isset($ind['ssto']) ? $ind['ssto'] : '', isset($ind['referer']) ? $ind['referer'] : '', isset($ind['colors']) ? $ind['colors'] : '', isset($ind['java']) ? $ind['java'] : '', isset($ind['taelnr']) ? $ind['taelnr'] : '', isset($ind['taelnavn']) ? $ind['taelnavn'] : '', isset($ind['js']) ? $ind['js'] : '', getenv('HTTP_USER_AGENT'), getenv('REMOTE_ADDR'), getenv('HTTP_ACCEPT_LANGUAGE'), getenv('HTTP_REFERER'));
 }
 //Is it time to send the user an e-mail with stats - if the user wants it.
 $send = explode("::", $datafil->getLine(67));
 $lastMailSend = array_shift($send);
 $event = new EventCalculator($lib->getTimeAdjusted());
 $found = $event->repeatNow($lastMailSend, $send);
 if ($stier->getOption('send_stat_mails') === 0) {
     $found = false;
 }
 //Yes: Send an e-mail
 if ($found === true) {
Example #3
0
 /**
  * Tests the class ZipStatEngine.
  *
  * @public
  * @return @c true on success @c false on failure.
  */
 function test()
 {
     //Test the page counter function.
     $dummyLib = NULL;
     //We actually not needs the lib for this test.
     $max_counters = 10;
     $engine = new ZipStatEngine($dummyLib);
     $engine->counterNo = '';
     $engine->counterName = '';
     $engine->url = '';
     //Normal with only urls.
     $cntUrls[0] = 'default';
     $cntVisits[0] = '11';
     $cntUrls[1] = 'http://foo.dk/bar/';
     $cntVisits[1] = '22';
     $cntUrls[2] = 'http://www.foo.dk/bar/pi.html';
     $cntVisits[2] = '33';
     $engine->url = 'http://foo.dk/bar/';
     list($cntUrls, $cntVisits) = $engine->applyPageCounter($cntUrls, $cntVisits, $max_counters);
     if ($cntVisits[0] != 11 or $cntVisits[1] != 23 or $cntVisits[2] != 33) {
         echo "Failed (" . __LINE__ . "): " . $cntVisits[0] . " != 11 or " . $cntVisits[1] . " != 23 or " . $cntVisits[2] . " != 33";
         return false;
     }
     $engine->url = 'http://FOO.dk/bar/';
     list($cntUrls, $cntVisits) = $engine->applyPageCounter($cntUrls, $cntVisits, $max_counters);
     if ($cntVisits[1] != 24) {
         echo "Failed (" . __LINE__ . "): " . $cntVisits[1] . " != 24";
         return false;
     }
     //Test new url: Should be added as index 3.
     $engine->url = 'http://foo.dk/new/';
     list($cntUrls, $cntVisits) = $engine->applyPageCounter($cntUrls, $cntVisits, $max_counters);
     if ($cntVisits[3] != 1 or $cntUrls[3] != 'http://foo.dk/new/') {
         echo "Failed (" . __LINE__ . "): " . $cntVisits[3] . " != 1 or " . $cntUrls[3] . " != 'http://foo.dk/new/'";
         return false;
     }
     //Test when an url shall match a counter name and convert.
     $cntUrls[4] = 'countername';
     $cntVisits[4] = '44';
     $engine->url = 'http://foo.dk/countername/';
     list($cntUrls, $cntVisits) = $engine->applyPageCounter($cntUrls, $cntVisits, $max_counters);
     if ($cntVisits[4] != 45 or $cntUrls[4] != 'http://foo.dk/countername/') {
         echo "Failed (" . __LINE__ . "): " . $cntVisits[4] . " != 45 or " . $cntUrls[4] . " != 'http://foo.dk/countername/'";
         return false;
     }
     //Test registration of a hit where the url is registered but here a
     //counter name is given.
     $engine->url = 'http://foo.dk/countername/';
     $engine->counterName = 'countername';
     $cntUrls[4] = 'http://foo.dk/countername/';
     list($cntUrls, $cntVisits) = $engine->applyPageCounter($cntUrls, $cntVisits, $max_counters);
     if ($cntVisits[4] != 46 or $cntUrls[4] != 'http://foo.dk/countername/') {
         echo "Failed (" . __LINE__ . "): " . $cntVisits[4] . " != 46 or " . $cntUrls[4] . " != 'http://foo.dk/countername/'";
         return false;
     }
     $engine->url = 'http://foo.dk/countername/';
     $engine->counterName = 'countername';
     $cntUrls[4] = 'countername';
     list($cntUrls, $cntVisits) = $engine->applyPageCounter($cntUrls, $cntVisits, $max_counters);
     if ($cntVisits[4] != 47 or $cntUrls[4] != 'http://foo.dk/countername/') {
         echo "Failed (" . __LINE__ . "): " . $cntVisits[4] . " != 47 or " . $cntUrls[4] . " != 'http://foo.dk/countername/'";
         return false;
     }
     return true;
 }