Exemple #1
0
 public function actionCreate()
 {
     $make = reqReq('make');
     $page = $page_arr = $page_arr1 = $page_arr2 = null;
     if (!empty($make['index'])) {
         $page = 'index';
         $page_arr = $this->actionCreateIndex();
     } elseif (!empty($make['inner'])) {
         $page = 'inner';
         $page_arr = $this->actionCreateInner();
     } elseif (!empty($make['all'])) {
         $page = 'all';
         $page_arr1 = $this->actionCreateIndex();
         $page_arr2 = $this->actionCreateInner();
         $page_arr = array_merge($page_arr1, $page_arr2);
         unset($page_arr1, $page_arr2);
     }
     $type = reqGet('type');
     $path_inside_page = $this->_conf['path_inside_page'];
     parent::_acl();
     $this->render('create', array('path_inside_page' => $path_inside_page, 'page' => $page, 'page_arr' => $page_arr));
     //        ppr($this->_conf);
 }
Exemple #2
0
 public function actionInstall()
 {
     //        ppr($_REQUEST);
     $opt = null;
     //        $show = new show();
     $step = reqReq('step', 0);
     if (empty($step)) {
         $this->render('step0');
         //            $show->showLowVersion();
     } elseif ($step == 1) {
         $this->render('step1');
         //            $show->showStep1();
     } elseif ($step == 2) {
         $w_check = array(YLMF_ROOT . 'ajax/', YLMF_ROOT . 'html/', YLMF_BACKEND . 'assets/', YLMF_BACKEND . 'uploads/', YLMF_APP . 'runtime/', YLMF_APP . 'data/crond/', YLMF_APP . 'data/cachefile/', APP_DB);
         $check = 1;
         foreach ($w_check as $key => $value) {
             if (!file_exists($value) && !@touch($value)) {
                 $w_check[$key] .= $this->_getLang('no_file');
                 $check = 0;
             } elseif (!is_writable($value)) {
                 $w_check[$key] .= $this->_getLang('777_test');
                 $check = 0;
             } else {
                 $w_check[$key] .= $this->_getLang('test_ok');
             }
         }
         //YII环境配置
         $requirements = array(array(t('yii', 'PHP版本'), true, version_compare(PHP_VERSION, "5.1.0", ">="), '<a href="http://www.yiiframework.com">Yii Framework</a>', t('yii', 'PHP 5.1.0或更高版本是必须的。')), array(t('yii', '$_SERVER变量'), true, '' === ($message = checkServerVar()), '<a href="http://www.yiiframework.com">Yii Framework</a>', $message), array(t('yii', 'Reflection扩展模块'), true, class_exists('Reflection', false), '<a href="http://www.yiiframework.com">Yii Framework</a>', ''), array(t('yii', 'PCRE扩展模块'), true, extension_loaded("pcre"), '<a href="http://www.yiiframework.com">Yii Framework</a>', ''), array(t('yii', 'SPL扩展模块'), false, extension_loaded("SPL"), '<a href="http://www.yiiframework.com">Yii Framework</a>', ''), array(t('yii', 'DOM扩展模块'), false, class_exists("DOMDocument", false), '<a href="http://www.yiiframework.com/doc/api/CHtmlPurifier">CHtmlPurifier</a>, <a href="http://www.yiiframework.com/doc/api/CWsdlGenerator">CWsdlGenerator</a>', ''), array(t('yii', 'PDO扩展模块'), true, extension_loaded('pdo'), t('yii', '所有和<a href="http://www.yiiframework.com/doc/api/#system.db">数据库相关的类</a>'), ''), array(t('yii', 'PDO MySQL扩展模块'), true, extension_loaded('pdo_mysql'), t('yii', 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>'), t('yii', '如果使用MySQL数据库,这是必须的。')), array(t('yii', 'GD extension with<br />FreeType support<br />or ImageMagick<br />extension with<br />PNG support'), false, '' === ($message = checkCaptchaSupport()), '<a href="http://www.yiiframework.com/doc/api/CCaptchaAction">CCaptchaAction</a>', $message));
         $result = 1;
         // 1: all pass, 0: fail, -1: pass with warnings
         foreach ($requirements as $i => $requirement) {
             if ($requirement[1] && !$requirement[2]) {
                 $result = 0;
             } else {
                 if ($result > 0 && !$requirement[1] && !$requirement[2]) {
                     $result = -1;
                 }
             }
             if ($requirement[4] === '') {
                 $requirements[$i][4] = '&nbsp;';
             }
         }
         $viewFile = array('requirements' => $requirements, 'result' => $result);
         //            ppr($viewFile,1);
         if ($result == 0 || !$check) {
             $btn_disabled = 'disabled="disabled"';
         } else {
             $btn_disabled = '';
         }
         $this->render('step2', array('view_file' => $viewFile, 'w_check' => $w_check, 'btn_disabled' => $btn_disabled));
     } elseif ($step == 3) {
         $this->render('step3', array('opt' => $opt, 'error_password' => 0));
     } elseif ($step == 4) {
         $type = reqGet('t');
         $GLOBALS['database']['db_host'] = reqReq('dbhost');
         $GLOBALS['database']['db_name'] = reqReq('dbname');
         $GLOBALS['database']['db_user'] = reqReq('dbuser');
         $GLOBALS['database']['db_pass'] = reqReq('dbpw');
         $GLOBALS['database']['db_charset'] = reqReq('charset');
         $GLOBALS['database']['theme'] = 'default';
         $GLOBALS['database']['table_prefix'] = reqReq('dbpre');
         if (!empty($GLOBALS['database']['table_prefix'])) {
             if (substr($GLOBALS['database']['table_prefix'], -1) != '_') {
                 $GLOBALS['database']['table_prefix'] .= '_';
             }
         }
         $GLOBALS['database']['manager'] = reqReq('manager');
         $GLOBALS['database']['password'] = reqReq('password');
         $password_check = reqReq('password_check');
         if ($GLOBALS['database']['password'] !== $password_check) {
             $error = 1;
             $error_txt = $this->_getLang('no_same_adminpw');
         } else {
             $dbname = $GLOBALS['database']['db_name'];
             $yl_manager = $GLOBALS['database']['manager'];
             $yl_managerpw = md5($GLOBALS['database']['password']);
             $tblpre = $GLOBALS['database']['table_prefix'];
             if (!empty($type) && $type == 'rpw') {
                 $adir = reqReq('admindir');
                 app_db::select_db($dbname);
                 $sql = "UPDATE `{$tblpre}admin` SET `username`='{$yl_manager}',`password`='{$yl_managerpw}' WHERE `id` ='1'";
                 if (app_db::query($sql)) {
                     //跳转到成功页面
                     $this->render('step7', array('t' => 1, 'adir' => $adir));
                     exit;
                 } else {
                     $error = 1;
                     $error_txt = $this->_getLang('no_do_database');
                 }
             } else {
                 app_db::query("SET character_set_connection=utf8, character_set_results=utf8");
                 app_db::query("SET NAMES utf8");
                 /*
                 ppr($GLOBALS,1);
                 $opt['dbhost'] = reqReq('dbhost');
                 $opt['dbname'] = reqReq('dbname');
                 $opt['dbuser'] = reqReq('dbuser');
                 $opt['dbpw'] = reqReq('dbpw');
                 $opt['dbpre'] = reqReq('dbpre');
                 $opt['manager'] = reqReq('manager');
                 $opt['password'] = reqReq('password');
                 $opt['password_check'] = reqReq('password_check');
                 */
                 $error = 0;
                 $error_txt = '';
                 if ($GLOBALS['database']['password'] != $password_check) {
                     //管理员密码错误,显示
                     $this->render('step3', array('opt' => $GLOBALS['database'], 'error_password' => 1));
                 }
                 if (!app_db::select_db($dbname)) {
                     $error = 1;
                     $error_txt = $this->_getLang('no_database');
                 } else {
                     $tb1 = $GLOBALS['database']['table_prefix'] . 'admin';
                     $tb2 = $GLOBALS['database']['table_prefix'] . 'admin_group';
                     $tb3 = $GLOBALS['database']['table_prefix'] . 'admin_logger';
                     $tb4 = $GLOBALS['database']['table_prefix'] . 'catalog';
                     $tb5 = $GLOBALS['database']['table_prefix'] . 'config';
                     $tb6 = $GLOBALS['database']['table_prefix'] . 'links';
                     $sql = "SELECT count( TABLE_NAME ) c FROM `INFORMATION_SCHEMA`.`TABLES` where `TABLE_SCHEMA`='{$dbname}' AND (\n                            `TABLE_NAME`='{$tb1}' OR \n                            `TABLE_NAME`='{$tb2}' OR \n                            `TABLE_NAME`='{$tb3}' OR \n                            `TABLE_NAME`='{$tb4}' OR \n                            `TABLE_NAME`='{$tb5}' OR \n                            `TABLE_NAME`='{$tb6}'\n                            )";
                     //                        $sql = "SELECT count( TABLE_NAME ) c FROM information_schema.TABLES WHERE TABLE_SCHEMA = '$dbname'";
                     app_db::query($sql);
                     $ar = app_db::fetch_one();
                     if (!empty($ar) && $ar['c'] > 0) {
                         $error = 1;
                         $error_txt = $this->_getLang('no_empty_database');
                     }
                 }
                 $result = $check = $this->_showCopy($GLOBALS['database']);
                 if ($result && is_array($result)) {
                     $check = 1;
                 } else {
                     $check = 0;
                 }
                 $installinfo = FALSE;
                 if (!$error) {
                     $installsqlfile = YLMF_INSTALL . 'data/install.sql';
                     $sql = file_get_contents($installsqlfile);
                     $installinfo = $this->_creatTable($sql, $dbname, $yl_manager, $yl_managerpw, $tblpre);
                     if ($installinfo) {
                         //写入超级管理员信息
                         $sql = "INSERT INTO `{$tblpre}admin` SET `id`='1',`username`='{$yl_manager}',`password`='{$yl_managerpw}',`realname`='administrator',`group_id`='1',`last_login_ip`='127.0.0.1'";
                         app_db::query($sql);
                     } else {
                         $error = 1;
                         $error_txt = $this->_getLang('donot_insert');
                     }
                 }
             }
         }
         $this->render('step5', array('error' => $error, 'error_txt' => $error_txt, 'installinfo' => $installinfo, 'check' => $check));
     } elseif ($step == 6) {
         $this->render('step6');
     } elseif ($step == 7) {
         @$this->_delDir(YLMF_INSTALL);
         //若成功删除,则跳转
         if (!file_exists(__FILE__)) {
             header('Location: ../admin/index.php');
             echo "<script type='text/javascript'>window.location.href='../admin/index.php';</script>";
             exit;
         }
         //若未,则显示手动删除页面
         $this->render('step7');
     }
 }