cache = ( ); $this->data['baseUrl'] = ( )->APP_URL."setup.php/"; } public function beforeRun( $resource, $action ) { $zym_2 = array( "index", "auth", "database" ); if ( in_array( $action, $zym_2 ) ) { $this->setuped( ); } } public function index( ) { $requirements = array( array( "PHP 版本", TRUE, version_compare( PHP_VERSION, "5.2.0", ">=" ) && version_compare( PHP_VERSION, "5.4.0", "<" ), "只支持PHP5.2或PHP5.3,当前版本: ".PHP_VERSION ), array( "PDO支持", TRUE, extension_loaded( "pdo" ), "" ), array( "PDO MySQL支持", TRUE, extension_loaded( "pdo_mysql" ), "" ), array( "开启allow_url_fopen", TRUE, ini_get( "allow_url_fopen" ) == 1, "" ), array( "curl", TRUE, function_exists( "curl_init" ) && function_exists( "curl_exec" ), "" ), array( "core/cache 目录写入权限", TRUE, is_writable( ( )->CACHE_PATH ), "" ), array( "core/config 目录写入权限", TRUE, is_writable( ( )->SITE_PATH.( )->PROTECTED_FOLDER."config/" ), "" ), array( "core/session 目录写入权限", TRUE, is_writable( ( )->SITE_PATH.( )->PROTECTED_FOLDER."session/" ), "" ) ); $Result = 1; foreach ( $requirements as $dos_skipping => $requirement ) { if ( $requirement[1] && !$requirement[2] ) { $Result = 0; } else if ( 0 < $Result && !$requirement[1] && !$requirement[2] ) { $Result = -1; } if ( $requirement[3] === "" ) { $requirements[$dos_skipping][3] = " "; } } $this->data['requirements'] = $requirements; $this->data['result'] = $Result; if ( $Result != 0 ) { $this->cache->setIn( "setup", "step", "auth" ); } $this->setPageTitle( "环境检测" ); $this->data( "setup/setup_index", $this->data ); } public function auth( ) { if ( $this->cache->getIn( "setup", "step" ) != "auth" ) { ( "环境检测尚未通过。", "-1" ); } $zym_4 = array( "status" => FALSE, "message" => "未知错误" ); $domainName = ( ); if ( $domainName ) { ( "域名获取失败,请检查服务器的\$_SERVER变量。", "-1" ); } $params = array( "domain" => $domainName ); $arrOtherGoods = "http://".Mil::AUTH_HOST."/license/requestByDomain?"; $urlParams = http_build_query( $params ); $STREAM = stream_context_create( array( "http" => array( "timeout" => 30 ) ) ); $Result = @file_get_contents( @$arrOtherGoods.$urlParams, 0, $STREAM ); if ( $Result ) { $zym_7 = "http://".Mil::AUTH_HOST_HK."/license/requestByDomain?"; $zym_11 = stream_context_create( array( "http" => array( "timeout" => 30 ) ) ); $Result = @file_get_contents( @$zym_7.$urlParams, 0, $zym_11 ); } if ( $Result ) { ( "出错啦,您的网站所在的服务器无法获取授权。", "-1" ); } $formatResult = json_decode( $Result ); if ( isset( $formatResult->status ) ) { if ( $formatResult->status && isset( $formatResult->result->key ) ) { $zym_1 = $formatResult->result->key; $saveStatus = $this->cache->setIn( "auth", "license", $zym_1 ); if ( $saveStatus ) { $this->cache->setIn( "setup", "step", "database" ); ( "正版检测通过,正在进入下一步。", $this->data['baseUrl']."database" ); } else { ( "失败,请检查文件夹 core/cache/setup 是否有写入权限", "-1" ); } } else { ( "正版检测失败:".$formatResult->message."
需要授权的域名为:".$domainName."。", "-1", 0, 50000 ); } } else { ( "失败,返回结果出错", "-1" ); } $this->setPageTitle( "正版检测" ); $this->data( "setup/setup_auth", $this->data ); } public function database( ) { if ( $this->cache->getIn( "setup", "step" ) != "database" ) { ( "正版检测尚未通过。", "-1" ); } $this->data['errorMsg'] = ""; ( "DooForm" ); $action = ( )->APP_URL."setup.php/database"; $FORM = new DooForm( array( "method" => "post", "action" => $action, "elements" => array( "mysqlHost" => array( "text", array( "value" => "localhost", "label" => "MYSQL服务器:", "attributes" => array( "class" => "text-input small-input" ), "field-wrapper" => "p", "validators" => array( array( "required", "请输入MYSQL服务器" ), array( "minlength", 1, "请输入MYSQL服务器" ) ) ) ), "mysqlDatabase" => array( "text", array( "required" => TRUE, "label" => "MYSQL数据库名称: ", "attributes" => array( "class" => "text-input small-input" ), "field-wrapper" => "p", "validators" => array( array( "required", "请输入MYSQL数据库名称" ), array( "minlength", 1, "请输入MYSQL数据库名称" ) ) ) ), "mysqlUsername" => array( "text", array( "required" => TRUE, "label" => "MYSQL数据库用户: ", "attributes" => array( "class" => "text-input small-input" ), "field-wrapper" => "p", "validators" => array( array( "required", "请输入MYSQL数据库用户" ), array( "minlength", 1, "请输入MYSQL数据库用户" ) ) ) ), "mysqlPassword" => array( "text", array( "required" => TRUE, "label" => "MYSQL数据库密码: ", "attributes" => array( "class" => "text-input small-input" ), "field-wrapper" => "p", "validators" => array( array( "required", "请输入MYSQL数据库密码" ), array( "minlength", 1, "请输入MYSQL数据库密码" ) ) ) ), "submit" => array( "submit", array( "label" => "提交" ) ) ) ) ); if ( $this->isPost( ) && $_POST( $_POST ) ) { $zym_10 = trim( $_POST['mysqlHost'] ); $zym_3 = trim( $_POST['mysqlDatabase'] ); $zym_6 = trim( $_POST['mysqlUsername'] ); $zym_5 = trim( $_POST['mysqlPassword'] ); $dbconfig['prod'] = array( $zym_10, $zym_3, $zym_6, $zym_5, "mysql", FALSE, "collate" => "utf8_general_ci", "charset" => "utf8" ); $zym_8 = FALSE; try { $b0e9 = ( ); $b0e9->setDb( $dbconfig, "prod" ); $b0e9->connect( ); $zym_8 = $b0e9->connected; } catch ( Exception $? ) { $this->data['errorMsg'] = "数据库连接失败"; } if ( $zym_8 ) { $zym_9 = @file_put_contents( @( )->SITE_PATH.@( )->PROTECTED_FOLDER."config/app.conf.php", @"updateToLatestVersion( ); $updated = TRUE; } catch ( Exception $? ) { $this->data['errorMsg'] = "数据库安装失败".$a_list->getMessage( ); } if ( $updated ) { $this->cache->setIn( "setup", "step", "finish" ); $this->cache->setIn( "setuped", "setup", TRUE ); ( "安装完毕。", $this->data['baseUrl']."finish" ); } } else { $this->data['errorMsg'] = "数据库配置文件保存失败,请检查core/config的写入权限。"; } } } $this->view( )->form = $FORM->render( ); $this->setPageTitle( "初始化数据库" ); $this->data( "setup/setup_database", $this->data ); } public function finish( ) { if ( $this->cache->getIn( "setup", "step" ) != "finish" ) { ( "数据库未成功初始化。", "-1" ); } $this->setPageTitle( "安装完毕" ); $this->data( "setup/setup_finish", $this->data ); } public function setuped( ) { if ( $this->cache->getIn( "setuped", "setup" ) ) { $this->setPageTitle( "您已安装" ); $this->data( "setup/setup_setuped", $this->data ); exit( ); } } protected function setPageTitle( $Title ) { $this->data['pageTitle'] = $Title."-".Mil::NAME."安装"; } protected function isPost( ) { if ( $_SERVER['REQUEST_METHOD'] == "POST" ) { return TRUE; } return FALSE; } } ?>