Пример #1
0
<?php

// ---------------------------------------
// This is how to set up an announce URL.
// ---------------------------------------
// Registering autoloader, essential to use the library.
require dirname(__FILE__) . '/lib/PHPTracker/Autoloader.php';
PHPTracker_Autoloader::register();
// Creating a simple config object. You can replace this with your object
// implementing PHPTracker_Config_Interface.
$config = new PHPTracker_Config_Simple(array('persistence' => new PHPTracker_Persistence_Mysql(new PHPTracker_Config_Simple(array('db_host' => 'localhost', 'db_user' => 'misc', 'db_password' => 'misc', 'db_name' => 'misc'))), 'ip' => $_SERVER['REMOTE_ADDR'], 'interval' => 60));
// Core class managing the announcements.
$core = new PHPTracker_Core($config);
// We take the parameters the client is sending and initialize a config
// object with them. Again, you can implement your own Config class to do this.
$get = new PHPTracker_Config_Simple($_GET);
// We simply send back the results of the announce method to the client.
echo $core->announce($get);
 public function testAutoload()
 {
     $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with PHPTracker');
     $autoloader = new PHPTracker_Autoloader();
     $this->assertNull($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class');
 }