public static function &sharedCenter() { if (!self::$sharedCenter) { self::$sharedCenter = new self(); } return self::$sharedCenter; }
define("TLDIR_INDEX", $_SERVER['DOCUMENT_ROOT']); @(include_once TLDIR_INDEX . '/php/LTConfig.php'); @(include_once TLDIR_INDEX . '/php/LTJson.php'); @(include_once TLDIR_INDEX . '/php/LTMySQL.php'); @(include_once TLDIR_INDEX . '/php/LTUserCommand.php'); $id = trim(strip_tags(urldecode(stripslashes($_GET['id'])))); $command = trim(strip_tags(urldecode(stripslashes($_POST['command'])))); try { if ((!preg_match('/^[1-9][0-9]{0,4}$/', $id) || LTAuthConfig::MAXID < $id) && 'add' !== $command) { throw new RuntimeException('Inexisting ID.'); } switch ($command) { case 'add': // Add new user $command = new LTUserAdd(); break; case 'rm': // Remove user $command = new LTUserRemove($id); break; default: // Assume ls: retrieve User Info from DB $command = new LTUserGet($id); break; } LTJsonCenter::sharedCenter()->chain($command->execute()); } catch (Exception $exception) { LTJsonCenter::sharedCenter()->chain(new LTJsonError($exception->getMessage())); } echo LTJsonCenter::sharedCenter();