This code request at least PHP version ' . $r_ver # . ', Current version: ' . PHP_VERSION . ".
" . PHP_EOL); } } /** * 检查配置文件 */ public static function CheckConfig() { echoLine("检查配置:"); echoLine("GameOnline: " . PLAT); echoLine("MySQL Connect Settings; " . var_export(config::Inst()->paydb, true)); self::TestMysql_RW(); echoLine("NoSql(Redis) Connect Settings: " . var_export(config::Inst()->nosql, true)); self::TestNoSQL_RW(); echoLine("MongoDB参数: " . var_export(config::Inst()->mongo, true)); self::TestMongo_RW(); echoLine("Upload path Settings: " . "本框架暂未涉及."); } /** * DNS检查 * @param type $url */ public static function CheckDNS($url = 'qq.com') { echoLine("DNS check $url is " . (checkdnsrr($url, "A") ? "ok!" : "failed!")); } public static function CheckNetRead($url = 'qq.com') { $ret = HttpUtil::makeRequest($url, array()); if ($ret["result"]) { echoLine("Request to $url ok!"); } else { echoLine("Net Request Failed!:" . $ret['msg']); } } // /** * 测试NoSql连接,以及读写性能 */ private static function TestNoSQL_RW() { $key = "test-" . TimeUtil::tsYmdHis(); echoLine("Redis Server is running: " . gMem()->ping()); echoLine("Redis Write($key, 'Hello world!'):" . gMem()->set($key, "Hello world!")); echoLine("Redis Read($key): " . gMem()->get($key)); echo("Profile Redis set/get: "); RenderTime::Test(function ()use ($key) { gMem()->set($key, "Hello world!"); gMem()->get($key); }, 100); } private static function TestMongo_RW() { $CName = "T_T_Collection"; $mdb = gMongo(); $addArr = ['Name' => "王刚", 'Date' => TimeUtil::dtCurrent()]; gMongo()->insert($CName, $addArr); $corsor = gMongo()->find($CName, ['Name' => "王刚"]); if ($corsor->valid()) { var_dump($corsor->toArray()); // ok gMongo()->delete($CName, ['Name' => "王刚"]); } else { return false; } } /** * 测试MySQL连接,以及读写性能 */ private static function TestMysql_RW() { $tableName = "test-" . date('Ymd'); echoLine("Connection is " . (daoInst()->Ping() ? "ok!" : "gone!")); $bCretaTable = daoInst()->tableExist($tableName); if ($bCretaTable) { echoLine("Table $tableName is Existing."); } else { echoLine("Table $tableName is not Existing."); $sql = " CREATE TABLE if NOT exists `$tableName` (`row` INT(11) NOT NULL AUTO_INCREMENT COMMENT '自增行号',`msg` TEXT NULL DEFAULT NULL COMMENT '消息内容' COLLATE 'utf8_general_ci', PRIMARY KEY (`row`) USING BTREE) COLLATE='utf8_general_ci' ENGINE=INNODB ; "; daoInst()->exec($sql); echoLine("create table $tableName " . (daoInst()->tableExist($tableName) ? "success!" : "failed!")); } $row = daoInst()->insert("`$tableName`")->data(array('msg' => 'Hello world!'))->exec(); echoLine("Insert into `$tableName` " . ($row == 1 ? "ok!" : "failed!")); echo("Profile Insert: "); RenderTime::Test(function ()use ($tableName) { daoInst()->insert("`$tableName`")->data(array('msg' => 'Hello world!'))->exec(); }, 100); $sql = "Drop Table `$tableName`;"; daoInst()->exec($sql); echoLine("delete table $tableName " . (daoInst()->tableExist($tableName) ? "failed!" : "success!")); } // } SelfChecker::checkkPHPVersion(); # 检查PHP版本 SelfChecker::checkModules(); # 检查PHP模块