diff --git a/install/controllers/SiteController.php b/install/controllers/SiteController.php index 2c51c202..c3031418 100644 --- a/install/controllers/SiteController.php +++ b/install/controllers/SiteController.php @@ -16,6 +16,7 @@ use backend\models\User; use common\models\Options; use yii\web\Response; +use yii\web\ErrorAction; /** * Site controller @@ -44,7 +45,7 @@ public function actions() { return [ 'error' => [ - 'class' => 'yii\web\ErrorAction', + 'class' => ErrorAction::className(), ], ]; } @@ -65,7 +66,7 @@ public function actionChooseLanguage() } public function actionAccept() - {//var_dump(Yii::$app->session['language']);die; + { return $this->render('accept'); } @@ -202,13 +203,7 @@ public function actionSetinfo() $dbport = $request->post('dbport', '3306'); $dbname = $request->post('dbname', ''); $table_prefix = $request->post("dbprefix", ''); - $dsn = $this->_getDsn($dbtype, $dbhost, $dbuser, $dbpassword, $dbport, $dbname); - switch ($dbtype) { - case "mysql": - case "postgresql": - $dsn .= ";dbname=" . $dbname; - break; - } + $dsn = $this->_getDsn($dbtype, $dbhost, $dbport, $dbname); $db = new Connection([ 'dsn' => $dsn, 'username' => $dbuser, @@ -229,34 +224,34 @@ public function actionSetinfo() $model = Options::findOne(['name' => 'website_title']); $model->value = $request->post('sitename', 'Feehi CMS'); - $model->save(); + $model->save(false); $model = Options::findOne(['name' => 'website_url']); $model->value = $request->post('website_url', ''); - $model->save(); + $model->save(false); $model = Options::findOne(['name' => 'website_url']); $model->value = $request->post('siteurl', ''); - $model->save(); + $model->save(false); $model = Options::findOne(['name' => 'seo_keywords']); $model->value = $request->post('sitekeywords', ''); - $model->save(); + $model->save(false); $model = Options::findOne(['name' => 'seo_description']); $model->value = $request->post('siteinfo', ''); - $model->save(); + $model->save(false); $configFile = yii::getAlias("@common/config/conf/db.php"); $str = << [ 'db' => [ - 'class' => 'yii\db\Connection', - 'dsn' => '{$dbtype}:host={$dbhost};dbname={$dbname}', + 'class' => yii\db\Connection::className(), + 'dsn' => '{$dsn}', 'username' => '{$dbuser}', 'password' => '{$dbpassword}', 'charset' => 'utf8', 'tablePrefix' => '{$table_prefix}', ], 'mailer' => [ - 'class' => 'yii\swiftmailer\Mailer', + 'class' => yii\swiftmailer\Mailer::className(), 'viewPath' => '@common/mail', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport @@ -267,14 +262,15 @@ public function actionSetinfo() 'bootstrap' => ['debug'], 'modules' => [ 'debug' => [ - 'class' => 'yii\debug\Module', - //'allowedIPs' => ['192.168.1.2','120.85.82.47', '127.0.0.1', '::1'] + 'class' => yii\debug\Module::className(), + 'allowedIPs' => ['127.0.0.1', '::1'] ] ] ]; EOF; file_put_contents($configFile, $str); + file_put_contents(yii::getAlias("@common/config/main-local.php"), ""); $_SESSION["_install_setinfo"] = 1; sleep(1); echo ""; @@ -299,7 +295,7 @@ public function actionCreateDatabase() $dbpassword = $request->post('dbpw', ''); $dbport = $request->post('dbport', '3306'); $dbname = $request->post('dbname', ''); - $dsn = $this->_getDsn($dbtype, $dbhost, $dbuser, $dbpassword, $dbport, $dbname); + $dsn = $this->_getDsn($dbtype, $dbhost, $dbport, $dbname); $db = new Connection([ 'dsn' => $dsn, 'username' => $dbuser, @@ -320,13 +316,13 @@ public function actionCreateDatabase() return ['message' => '']; } - private function _getDsn($dbtype, $dbhost, $dbuser, $dbpassword, $dbport, $dbname) + private function _getDsn($dbtype, $dbhost, $dbport, $dbname) { $dsn = ''; switch ($dbtype) { case "postgresql": case "mysql": - $dsn = $dbtype . ":host=" . $dbhost . ';port=' . $dbport; + $dsn = $dbtype . ":host=" . $dbhost . ';port=' . $dbport . ";dbname=" . $dbname; break; case "sqlite": diff --git a/install/sql/data.sql b/install/sql/data.sql index 62abd3b1..b7c13031 100644 --- a/install/sql/data.sql +++ b/install/sql/data.sql @@ -378,10 +378,10 @@ INSERT INTO `%__prefix__%comment` VALUES ('1', '25', '0', '0', 'aaa', '', '', ' COMMIT; -- ---------------------------- --- Table structure for `friend_link` +-- Table structure for `friendly_link` -- ---------------------------- -DROP TABLE IF EXISTS `%__prefix__%friend_link`; -CREATE TABLE `%__prefix__%friend_link` ( +DROP TABLE IF EXISTS `%__prefix__%friendly_link`; +CREATE TABLE `%__prefix__%friendly_link` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT '', @@ -395,10 +395,10 @@ CREATE TABLE `%__prefix__%friend_link` ( ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- ---------------------------- --- Records of `friend_link` +-- Records of `friendly_link` -- ---------------------------- BEGIN; -INSERT INTO `%__prefix__%friend_link` VALUES ('1', '飞嗨博客', '', 'http://blog.feehi.com', '_blank', '0', '1', '1468303851', '0'), ('2', '飞嗨网', '', 'http://www.feehi.com', '_blank', '0', '1', '1468303882', '0'), ('3', '36kr', '', 'http://www.36kr.com', '_blank', '0', '1', '1468303902', '0'), ('4', '破晓电影', '', 'http://www.poxiao.com', '_blank', '0', '1', '1468303938', '0'), ('5', '翠竹林主题', '', 'http://www.cuizl.com/', '_blank', '0', '1', '1468303974', '0'); +INSERT INTO `%__prefix__%friendly_link` VALUES ('1', '飞嗨博客', '', 'http://blog.feehi.com', '_blank', '0', '1', '1468303851', '0'), ('2', '飞嗨网', '', 'http://www.feehi.com', '_blank', '0', '1', '1468303882', '0'), ('3', '36kr', '', 'http://www.36kr.com', '_blank', '0', '1', '1468303902', '0'), ('4', '破晓电影', '', 'http://www.poxiao.com', '_blank', '0', '1', '1468303938', '0'), ('5', '翠竹林主题', '', 'http://www.cuizl.com/', '_blank', '0', '1', '1468303974', '0'); COMMIT; -- ---------------------------- @@ -443,7 +443,7 @@ INSERT INTO `%__prefix__%menu` VALUES ('14', '0', '0', '权限管理', '', 'fa f INSERT INTO `%__prefix__%menu` VALUES ('15', '0', '14', '权限', 'rbac/permissions', '', '0', '_blank', '0', '1', '1505570862', '1505570862'); INSERT INTO `%__prefix__%menu` VALUES ('16', '0', '14', '角色', 'rbac/roles', '', '0', '_blank', '0', '1', '1505570882', '1505570882'); INSERT INTO `%__prefix__%menu` VALUES ('17', '0', '14', '管理员', 'admin-user/index', '', '0', '_blank', '0', '1', '1505570902', '1505570902'); -INSERT INTO `%__prefix__%menu` VALUES ('18', '0', '0', '友情链接', 'friend-link/index', 'fa fa-link', '0', '_blank', '0', '1', '1505570934', '1505571307'); +INSERT INTO `%__prefix__%menu` VALUES ('18', '0', '0', '友情链接', 'friendly-link/index', 'fa fa-link', '0', '_blank', '0', '1', '1505570934', '1505571307'); INSERT INTO `%__prefix__%menu` VALUES ('19', '0', '0', '缓存', '', 'fa fa-file', '0', '_blank', '0', '1', '1505570947', '1505571292'); INSERT INTO `%__prefix__%menu` VALUES ('20', '0', '19', '清除前台', 'clear/frontend', '', '0', '_blank', '0', '1', '1505570974', '1505570974'); INSERT INTO `%__prefix__%menu` VALUES ('21', '0', '19', '清除后台', 'clear/backend', '', '0', '_blank', '0', '1', '1505570994', '1505570994');