hit("2007-09-05 00:01:14", "59.115.201.73", "1","http://firestats.cc/wiki/InstallUpgrade","http://firestats.cc/wiki/Download", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $hit); $this->assertTrue($res, "Failed : $res"); require_once FS_ABS_PATH.'/php/db-sql.php'; $res = fs_getentries(); $this->assertFalse($res == false, "getentries failed"); $this->assertEquals(1, count($res)); $this->assertEquelsHits($hit, $res[0]); $this->assertUrlEquals(array("http://firestats.cc/wiki/InstallUpgrade","http://firestats.cc/wiki/Download")); $this->assertUseragentsEquals(array("Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")); } function testImmediateHit_ipExcluded() { require_once FS_ABS_PATH.'/php/db-sql.php'; fs_add_excluded_ip("59.115.201.73"); $hit = $this->hit("2007-09-05 00:01:14", "59.115.201.73", "blah","http://firestats.cc/wiki/InstallUpgrade","http://firestats.cc/wiki/Download", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $hit); $this->assertTrue($res, "Failed : $res"); $res = fs_getentries(); $this->assertNull($res, "getentries failed"); fs_add_excluded_ip("59.115.100.0","59.115.100.255"); $hit = $this->hit("2007-09-05 00:01:14", "59.115.100.10", "1","http://firestats.cc/wiki/InstallUpgrade","http://firestats.cc/wiki/Download", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $hit); $this->assertTrue($res, "Failed : $res"); $res = fs_getentries(); $this->assertNull($res, "getentries failed"); $this->assertUrlEquals(array()); $this->assertUseragentsEquals(array()); } function testImmediateHit_urlExcluded() { require_once FS_ABS_PATH.'/php/db-sql.php'; fs_add_excluded_url("http://firestats.cc/wiki/InstallUpgrade"); $hit = $this->hit("2007-09-05 00:01:14", "59.115.201.73", "1","http://firestats.cc/wiki/InstallUpgrade","http://firestats.cc/wiki/Download", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $hit); $this->assertTrue($res, "Failed : $res"); $this->assertUrlEquals(array()); $this->assertUseragentsEquals(array()); $this->assertNull(fs_getentries(), "getentries failed"); fs_add_excluded_url("google.com"); $hit = $this->hit("2007-09-05 00:01:14", "59.115.100.10", "1","http://firestats.cc/wiki/InstallUpgrade","http://google.com/blah", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $hit); $this->assertTrue($res, "Failed : $res"); $this->assertUrlEquals(array()); $this->assertUseragentsEquals(array()); $this->assertNull(fs_getentries(), "getentries failed"); } function testImmediateHit_useragentExcluded() { require_once FS_ABS_PATH.'/php/db-sql.php'; fs_add_bot("Googlebot"); fs_add_bot("Nutch"); $hit = $this->hit("2007-09-05 00:01:14", "59.115.201.73", "1","http://firestats.cc/wiki/InstallUpgrade","http://firestats.cc/wiki/Download", "Cabot/Nutch-0.9 (Amfibi\'s web-crawling robot; http://www.amfibi.com/cabot/; agent@amfibi.com)"); $res = $this->insertHit(FS_COMMIT_IMMEDIATE, $hit); $this->assertTrue($res, "Failed : $res"); $this->assertNull(fs_getentries(), "getentries failed"); $this->assertUrlEquals(array()); $this->assertUseragentsEquals(array()); } } ?>