📄 configcontroller.php
字号:
<?php
/*
秀影EasyFramework框架
qq:24498936
msn:jdzcn_net@hotmail.com
website:http://www.vodcms.com
*/
class ConfigController extends Easy_Controller_Action {
public function init(){
$this->_IO = new Easy_Filesystem();
$this->_View->config = $this->config;
}
public function IndexAction(){
$filename = ROOT.'config/config.inc.php';
@chmod($filename, 0777);
$Group = new GroupModel();
$this->_View->vipoption = $Group->CreateOption((int)$this->config['vip']);
if ($this->_Request->isPost()){
$POST = $this->_Request->getPost();
$POST['basedir'] = substr( strtolower($_SERVER['PHP_SELF']), 0, stripos(strtolower($_SERVER['PHP_SELF']), 'admin.php' ));
$domain = str_replace('\\', '/', $config['domain']);
$POST['domain'] = 'http://'.$_SERVER['HTTP_HOST'];
$text = $this->_IO->getContent($filename);
foreach ($POST as $key=>$value){
if (is_numeric($value) === false){
$text = preg_replace("/[$]config\[\'$key\'](\s+)\=(.+?);/is",
"\$config['$key']$1= '".addslashes($value)."';",$text);
}else{
$text = preg_replace("/[$]config\[\'$key\'](\s+)\=(.+?);/is",
"\$config['$key']$1= ".$value.";",$text);
}
}
if ($this->_IO->wfile($filename, $text)===false){
$this->_View->message = $IO->error;
}else{
$this->_View->message = _('保存配置成功!');
}
Easy_Cache::clear(); //清理缓存
exit($this->_View->render('message'));
}
}
public function SeoAction(){
}
public function ucenterAction(){
$filename = ROOT.'api/config.inc.php';
if ( $this->_Request->isPost() === false ){
require( $filename );
}else {
$contents = $this->_IO->getContent($filename);
$dbhost = trim($this->_Request->getPost('dbhost'));
$ucenter = (int)$this->_Request->getPost('ucenter');
$credit = intval($this->_Request->getPost('credit'));
$dbname = trim($this->_Request->getPost('dbname'));
$dbuser = trim($this->_Request->getPost('dbuser'));
$dbpass = trim($this->_Request->getPost('dbpass'));
$tablepre = '`'.$dbname.'`.'.trim($this->_Request->getPost('tablepre'));
$dbcharset = trim($this->_Request->getPost('dbcharset'));
$appid = intval($this->_Request->getPost('appid'));
$uckey = trim($this->_Request->getPost('uckey'));
$ucurl = addslashes(trim($this->_Request->getPost('ucurl')));
$ucappid = intval($this->_Request->getPost('ucappid'));
$inuc = (int)$this->_Request->getPost('ucenter');
$credit = (int)$this->_Request->getPost('credit');
$this->_View->message = array();
if ( empty($dbhost)){
$this->_View->message[]= _('您没有填写UC数据库服务器地址');
}
if ( empty($dbname)){
$this->_View->message[] = _('您没有填写UC数据库名称');
}
if ( empty($tablepre) ){
$this->_View->message[] = _('您没有填写UC表前缀');
}
if ( empty($uckey) ){
$this->_View->message[] = _('您没有填写UC通信密钥');
}
if ( !preg_match('/http:\/\/(.+?)/', $ucurl) ){
$this->_View->message[] = _('UC安装地址格式不正确!');
}
if (count($this->_View->message)>0){
$this->_View->subject = _('保存配置出错!');
exit($this->_View->render('message'));
}else{
$contents = preg_replace("/define\('UC_DBHOST', (.+?)\)/is", "define('UC_DBHOST', '{$dbhost}')", $contents);
$contents = preg_replace("/define\('UC_DBUSER',(.+?)\)/is", "define('UC_DBUSER','{$dbuser}')", $contents);
$contents = preg_replace("/define\('UC_DBPW',(.+?)\)/is", "define('UC_DBPW','{$dbpass}')", $contents);
$contents = preg_replace("/define\('UC_DBNAME',(.+?)\)/is", "define('UC_DBNAME','{$dbname}')", $contents);
$contents = preg_replace("/define\('UC_DBCHARSET',(.+?)\)/is", "define('UC_DBCHARSET','{$dbcharset}')", $contents);
$contents = preg_replace("/define\('UC_DBTABLEPRE',(.+?)\)/is", "define('UC_DBTABLEPRE','{$tablepre}')", $contents);
$contents = preg_replace("/define\('UC_KEY',(.+?)\)/is", "define('UC_KEY','{$uckey}')", $contents);
$contents = preg_replace("/define\('UC_API',(.+?)\)/is", "define('UC_API','{$ucurl}')", $contents);
$contents = preg_replace("/define\('DZ_APPID',(.+?)\)/is", "define('DZ_APPID','{$appid}')", $contents);
$contents = preg_replace("/define\('UC_APPID',(.+?)\)/is", "define('UC_APPID','{$ucappid}')", $contents);
$contents = preg_replace("/define\('UC_IP',(.+?)\)/is", "define('UC_IP','')", $contents);
if ($contents){
$this->_IO->wfile($filename, $contents);
}
unset($contents);
$filename = ROOT.'config/config.inc.php';
$text = $this->_IO->getContent($filename);
$text = preg_replace('/\$config\[\'ucenter\']+\s+\=+\s+(\d+);/is', "\$config['ucenter'] = ".intval($inuc).";", $text);
$text = preg_replace('/\$config\[\'credit\']+\s+\=+\s+(\d+);/is', "\$config['credit'] = ".intval($credit).";", $text);
if ($text){
$this->_IO->wfile($filename, $text);
}
$this->_View->subject = _('保存配置!');
$this->_View->message = _('UCENTER配置信息保存成功');
unset($text);
exit($this->_View->render('message'));
}
}
}
public function userAction(){
$filename = ROOT.'config/config.inc.php';
$contents = '';
$contents = $this->_IO->getContent($filename);
$this->_User = new UsersModel();
$this->_View->groupOption = $this->_User->groupOption($this->config['usergroup']);
if ($this->_Request->isPost()){
$data = '';
foreach ($this->_Request->getPost() as $key=>$value){
$contents = preg_replace('/\$config\[\''.$key.'\'\]+\s+\=+\s+(\d+);/is', '$config[\''.$key.'\'] = '.(int)$value.';', $contents);
}
if ($contents){
$this->_IO->wfile($filename, $contents);
}
$this->_View->message = _('保存成功!');
exit($this->_View->render('message'));
}
}
}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -