// if code does not exists - get off if (!$keyExists) { $errors['key'] = 'invalid'; } else { // keys can be used only one $q = 'DELETE FROM `keys` WHERE `key`=' . (PDOAvailable ? ':key' : '?'); $query = $db->prepare($q); if (PDOAvailable) { $query->bindValue(':key', $request['key'], PDO::PARAM_STR); } else { $query->bind_param('s', $request['key']); } $query->execute(); // register autoload and load our storage spl_autoload_register(); $storage = Storage\StorageFactory::build(array('type' => 'MySQL', 'db' => $database, 'tableName' => 'servers', 'tableMap' => array('host' => 'server_name', 'port' => 'port_number'))); // create new server record $server = new stdClass(); $server->host = $request['server']; $server->port = (int) $request['port']; $server->create_time = date('Y-m-d H:i:s'); // put it to the storage $storage->put($server); // and try to save everything try { $storage->save(); ?> <meta http-equiv="Refresh" content="0;url=thankyou.php" /> <?php } catch (\Exception $e) { ?>
<?php spl_autoload_extensions('.php'); spl_autoload_register(); $storage = Storage\StorageFactory::build(array('type' => 'MySQL', 'db' => array('host' => 'localhost', 'dbname' => 'test', 'user' => 'test', 'password' => '53w5eg'), 'tableName' => 'servers', 'tableMap' => array('host' => 'server_name', 'port' => 'port_number'), 'order' => 'create_time DESC', 'limit' => 10)); $monitor = Server\ServerFactory::build(array('type' => 'CounterStrike', 'storage' => $storage, 'useCache' => true, 'cache' => array('type' => 'ArrayFile', 'file' => 'cache/csPoll.php', 'pollResultLifetime' => 600))); $monitor->run();