* mereg zentaophp framework to zentao.
This commit is contained in:
+61
-29
@@ -16,37 +16,36 @@ if(!class_exists('config')){class config{}}
|
||||
if(!function_exists('getWebRoot')){function getWebRoot(){}}
|
||||
|
||||
/* Basic settings. */
|
||||
$config = new config();
|
||||
$config->version = '9.2.1'; // The version of zentaopms. Don't change it.
|
||||
$config->charset = 'UTF-8'; // The charset of zentaopms.
|
||||
$config->cookieLife = time() + 2592000; // The cookie life time.
|
||||
$config->timezone = 'Asia/Shanghai'; // The time zone setting, for more see http://www.php.net/manual/en/timezones.php
|
||||
$config->webRoot = ''; // The root path of the pms.
|
||||
$config->checkVersion = true; // Auto check for new version or not.
|
||||
|
||||
/* The request settings. */
|
||||
$config->requestType = 'PATH_INFO'; // The request type: PATH_INFO|GET, if PATH_INFO, must use url rewrite.
|
||||
$config->pathType = 'clean'; // If the request type is PATH_INFO, the path type.
|
||||
$config->requestFix = '-'; // The divider in the url when PATH_INFO.
|
||||
$config->moduleVar = 'm'; // requestType=GET: the module var name.
|
||||
$config->methodVar = 'f'; // requestType=GET: the method var name.
|
||||
$config->viewVar = 't'; // requestType=GET: the view var name.
|
||||
$config->sessionVar = 'zentaosid'; // requestType=GET: the session var name.
|
||||
$config->views = ',html,json,mhtml,';
|
||||
|
||||
/* 支持的主题和语言。Supported thems and languages. */
|
||||
$config->themes['default'] = 'default';
|
||||
$config->langs['zh-cn'] = '简体';
|
||||
$config->langs['en'] = 'English';
|
||||
$config->langs['zh-tw'] = '繁體';
|
||||
|
||||
$config->allowedTags = '<p><span><h1><h2><h3><h4><h5><em><u><strong><br><ol><ul><li><img><a><b><font><hr><pre><div><table><td><th><tr><tbody><embed><style>';
|
||||
$config->accountRule = '|^[a-zA-Z0-9_]{1}[a-zA-Z0-9_\.]{1,}[a-zA-Z0-9_]{1}$|';
|
||||
|
||||
/* Supported views. */
|
||||
$config->views = ',html,json,mhtml,';
|
||||
$config->checkVersion = true; // Auto check for new version or not.
|
||||
|
||||
/* Set the wide window size and timeout(ms) and duplicate interval time(s). */
|
||||
$config->wideSize = 1400;
|
||||
$config->timeout = 30000;
|
||||
$config->duplicateTime = 60;
|
||||
|
||||
/* Supported languages. */
|
||||
$config->langs['zh-cn'] = '简体';
|
||||
$config->langs['zh-tw'] = '繁體';
|
||||
$config->langs['en'] = 'English';
|
||||
|
||||
$config->productCommonList['en'][0] = 'Product';
|
||||
$config->productCommonList['en'][1] = 'Project';
|
||||
@@ -69,6 +68,12 @@ $config->charsets['zh-tw']['big5'] = 'BIG5';
|
||||
$config->charsets['en']['utf-8'] = 'UTF-8';
|
||||
$config->charsets['en']['GBK'] = 'GBK';
|
||||
|
||||
/* IP white list settings.*/
|
||||
$config->ipWhiteList = '*';
|
||||
|
||||
/* 设备类型视图文件前缀。The prefix for view file for different device. */
|
||||
$config->devicePrefix['mhtml'] = 'm.';
|
||||
|
||||
/* Default settings. */
|
||||
$config->default = new stdclass();
|
||||
$config->default->view = 'html'; // Default view.
|
||||
@@ -77,47 +82,74 @@ $config->default->theme = 'default'; // Default theme.
|
||||
$config->default->module = 'index'; // Default module.
|
||||
$config->default->method = 'index'; // Default method.
|
||||
|
||||
/* Upload settings. */
|
||||
$config->file = new stdclass();
|
||||
$config->file->dangers = 'php,php3,php4,phtml,php5,jsp,py,rb,asp,asa,cer,cdx,aspl'; // Dangerous files.
|
||||
$config->file->maxSize = 1024 * 1024; // Max size.
|
||||
|
||||
/* IP white list settings.*/
|
||||
$config->ipWhiteList = '*';
|
||||
|
||||
/* View type settings. */
|
||||
$config->devicePrefix = array();
|
||||
|
||||
/* Master database settings. */
|
||||
$config->db = new stdclass();
|
||||
$config->slaveDB = new stdclass();
|
||||
$config->db->persistant = false; // Pconnect or not.
|
||||
$config->db->driver = 'mysql'; // Must be MySQL. Don't support other database server yet.
|
||||
$config->db->encoding = 'UTF8'; // Encoding of database.
|
||||
$config->db->strictMode = false; // Turn off the strict mode of MySQL.
|
||||
//$config->db->emulatePrepare = true; // PDO::ATTR_EMULATE_PREPARES
|
||||
//$config->db->bufferQuery = true; // PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
|
||||
|
||||
/* Slave database settings. */
|
||||
$config->slaveDB = new stdclass();
|
||||
$config->db->prefix = ''; // 数据库表名前缀。 The prefix of the table name.
|
||||
$config->slaveDB->persistant = false;
|
||||
$config->slaveDB->driver = 'mysql';
|
||||
$config->slaveDB->encoding = 'UTF8';
|
||||
$config->slaveDB->strictMode = false;
|
||||
$config->slaveDB->checkCentOS= true;
|
||||
|
||||
/* Framework config. */
|
||||
$config->framework = new stdclass();
|
||||
$config->framework->jsWithPrefix = false;
|
||||
$config->framework->autoConnectDB = true; // 是否自动连接数据库。 Whether auto connect database or not.
|
||||
$config->framework->multiLanguage = true; // 是否启用多语言功能。 Whether enable multi lanuage or not.
|
||||
$config->framework->multiTheme = true; // 是否启用多风格功能。 Whether enable multi theme or not.
|
||||
$config->framework->multiSite = false; // 是否启用多站点模式。 Whether enable multi site mode or not.
|
||||
$config->framework->extensionLevel = 1; // 0=>无扩展,1=>公共扩展,2=>站点扩展 0=>no extension, 1=> common extension, 2=> every site has it's extension.
|
||||
$config->framework->jsWithPrefix = false; // js::set()输出的时候是否增加前缀。 When us js::set(), add prefix or not.
|
||||
$config->framework->filterBadKeys = true; // 是否过滤不合要求的键值。 Whether filter bad keys or not.
|
||||
$config->framework->filterTrojan = true; // 是否过滤木马攻击代码。 Whether strip trojan code or not.
|
||||
$config->framework->filterXSS = true; // 是否过滤XSS攻击代码。 Whether strip xss code or not.
|
||||
$config->framework->filterParam = 2; // 是否开启过滤参数功能。 Whether strip param or not.
|
||||
$config->framework->purifier = true; // 是否对数据做purifier处理。 Whether purifier data or not.
|
||||
$config->framework->logDays = 14; // 日志文件保存的天数。 The days to save log files.
|
||||
$config->framework->autoRepairTable = true;
|
||||
$config->framework->logDays = 14;
|
||||
$config->framework->purifier = true;
|
||||
$config->framework->autoLang = false;
|
||||
|
||||
$config->framework->detectDevice['zh-cn'] = true; // 在zh-cn语言情况下,是否启用设备检测功能。 Whether enable device detect or not.
|
||||
$config->framework->detectDevice['zh-tw'] = true; // 在zh-tw语言情况下,是否启用设备检测功能。 Whether enable device detect or not.
|
||||
$config->framework->detectDevice['en'] = true; // 在en语言情况下,是否启用设备检测功能。 Whether enable device detect or not.
|
||||
|
||||
/* Include the custom config file. */
|
||||
$configRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||
$myConfig = $configRoot . 'my.php';
|
||||
if(file_exists($myConfig)) include $myConfig;
|
||||
|
||||
/* 文件上传设置。 Upload settings. */
|
||||
$config->file = new stdclass();
|
||||
// 危险文件类型。 Dangerous file types.
|
||||
$config->file->dangers = 'php,php3,php4,phtml,php5,jsp,py,rb,asp,aspx,ashx,asa,cer,cdx,aspl,shtm,shtml,html,htm';
|
||||
// 允许上传的文件类型。 Allowed file types.
|
||||
$config->file->allowed = ',txt,doc,docx,dot,wps,wri,pdf,ppt,xls,xlsx,ett,xlt,xlsm,csv,jpg,jpeg,png,psd,gif,ico,bmp,swf,avi,rmvb,rm,mp3,mp4,3gp,flv,mov,movie,rar,zip,bz,bz2,tar,gz,';
|
||||
|
||||
/* 配置参数过滤。Filter param settings. */
|
||||
/* Like $config->filterParam->param[moduleName][methodname][ruleType] = rule. */
|
||||
$config->filterParam = new stdclass();
|
||||
$config->filterParam->badKeys = '[^a-zA-Z0-9_\.]';
|
||||
$config->filterParam->module['reg'] = '/^[a-zA-Z0-9]+$/';
|
||||
$config->filterParam->method['common']['reg'] = '/^[a-zA-Z0-9]+$/';
|
||||
$config->filterParam->param['common']['name']['reg'] = '/^[a-zA-Z0-9_\.]+$/';
|
||||
$config->filterParam->param['common']['value']['reg'] = '/^[a-zA-Z0-9=_,`#+\^\/\.%\|\x7f-\xff]+$/';
|
||||
|
||||
$config->filterParam->get['common']['hold'] = 'onlybody,HTTP_X_REQUESTED_WITH,' . $config->sessionVar;
|
||||
$config->filterParam->get['common']['params']['onlybody']['reg'] = '/^yes$|^no$/';
|
||||
$config->filterParam->get['common']['params']['HTTP_X_REQUESTED_WITH']['equal'] = 'XMLHttpRequest';
|
||||
$config->filterParam->get['common']['params'][$config->sessionVar]['reg'] = '/^[a-zA-Z0-9]+$/';
|
||||
|
||||
$config->filterParam->cookie['common']['hold'] = 'lang,theme,device,za,zp';
|
||||
$config->filterParam->cookie['common']['params']['lang']['reg'] = '/^[a-zA-Z\-_]+$/';
|
||||
$config->filterParam->cookie['common']['params']['theme']['reg'] = '/^[a-zA-Z0-9_]+$/';
|
||||
$config->filterParam->cookie['common']['params']['device']['reg'] = '/^[a-zA-Z0-9_]+$/';
|
||||
$config->filterParam->cookie['common']['params']['za']['account'] = '';
|
||||
$config->filterParam->cookie['common']['params']['zp']['reg'] = '/^[a-f0-9]{40}$/';
|
||||
|
||||
/* Set default table prefix. */
|
||||
if(!isset($config->db->prefix)) $config->db->prefix = 'zt_';
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
<?php /**
|
||||
* ZenTaoPHP的baseControl类。
|
||||
* The baseControl class file of ZenTaoPHP framework.
|
||||
*
|
||||
* @package framework
|
||||
*
|
||||
* The author disclaims copyright to this source code. In place of
|
||||
* a legal notice, here is a blessing:
|
||||
*
|
||||
@@ -10,13 +11,6 @@
|
||||
* May you find forgiveness for yourself and forgive others.
|
||||
* May you share freely, never taking more than you give.
|
||||
*/
|
||||
|
||||
/**
|
||||
* baseControl基类.
|
||||
* The base class of control.
|
||||
*
|
||||
* @package framework
|
||||
*/
|
||||
class baseControl
|
||||
{
|
||||
/**
|
||||
@@ -254,8 +248,8 @@ class baseControl
|
||||
}
|
||||
|
||||
/**
|
||||
* set the method name.
|
||||
* 设置方法名。
|
||||
* Set the method name.
|
||||
*
|
||||
* @param string $methodName 方法名,如果为空,则从$app中获取。The method name, if empty, get it from $app.
|
||||
* @access public
|
||||
@@ -279,7 +273,7 @@ class baseControl
|
||||
{
|
||||
if(empty($moduleName)) $moduleName = $this->moduleName;
|
||||
if(empty($appName)) $appName = $this->appName;
|
||||
$modelFile = helper::setModelFile($moduleName, $appName);
|
||||
$modelFile = $this->app->setModelFile($moduleName, $appName);
|
||||
|
||||
/**
|
||||
* 如果没有model文件,尝试加载config配置信息。
|
||||
@@ -287,7 +281,7 @@ class baseControl
|
||||
*/
|
||||
if(!helper::import($modelFile))
|
||||
{
|
||||
$this->app->loadConfig($moduleName, $appName, false);
|
||||
$this->app->loadModuleConfig($moduleName, $appName, false);
|
||||
$this->app->loadLang($moduleName, $appName);
|
||||
$this->dao = new dao();
|
||||
return false;
|
||||
@@ -308,7 +302,10 @@ class baseControl
|
||||
* 初始化model对象,在control对象中可以通过$this->$moduleName来引用。同时将dao对象赋为control对象的成员变量,方便引用。
|
||||
* Init the model object thus you can try $this->$moduleName to access it. Also assign the $dao object as a member of control object.
|
||||
*/
|
||||
$this->$moduleName = new $modelClass($appName);
|
||||
static $singleModule = array();
|
||||
if(!isset($singleModule["$moduleName"])) $singleModule["$moduleName"] = new $modelClass($appName);
|
||||
|
||||
$this->$moduleName = $singleModule["$moduleName"];
|
||||
$this->dao = $this->$moduleName->dao;
|
||||
return $this->$moduleName;
|
||||
}
|
||||
@@ -327,7 +324,6 @@ class baseControl
|
||||
$this->server = $this->app->server;
|
||||
$this->session = $this->app->session;
|
||||
$this->cookie = $this->app->cookie;
|
||||
$this->global = $this->app->global;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,19 +368,24 @@ class baseControl
|
||||
|
||||
$modulePath = $this->app->getModulePath($this->appName, $moduleName);
|
||||
$viewExtPath = $this->app->getModuleExtPath($this->appName, $moduleName, 'view');
|
||||
$viewType = $this->viewType == 'mhtml' ? 'html' : $this->viewType;
|
||||
|
||||
$mainViewFile = $modulePath . 'view' . DS . $this->devicePrefix . $methodName . '.' . $viewType . '.php';
|
||||
$commonExtViewFile = $viewExtPath['common'] . $this->devicePrefix . $methodName . ".{$viewType}.php";
|
||||
$siteExtViewFile = empty($viewExtPath['site']) ? '' : $viewExtPath['site'] . $this->devicePrefix . $methodName . ".{$viewType}.php";
|
||||
$viewType = $this->viewType == 'mhtml' ? 'html' : $this->viewType;
|
||||
$mainViewFile = $modulePath . 'view' . DS . $this->devicePrefix . $methodName . '.' . $viewType . '.php';
|
||||
$viewFile = $mainViewFile;
|
||||
|
||||
$viewFile = file_exists($commonExtViewFile) ? $commonExtViewFile : $mainViewFile;
|
||||
$viewFile = (!empty($siteExtViewFile) and file_exists($siteExtViewFile)) ? $siteExtViewFile : $viewFile;
|
||||
if(!is_file($viewFile)) $this->app->triggerError("the view file $viewFile not found", __FILE__, __LINE__, $exit = true);
|
||||
if(!empty($viewExtPath))
|
||||
{
|
||||
$commonExtViewFile = $viewExtPath['common'] . $this->devicePrefix . $methodName . ".{$viewType}.php";
|
||||
$siteExtViewFile = empty($viewExtPath['site']) ? '' : $viewExtPath['site'] . $this->devicePrefix . $methodName . ".{$viewType}.php";
|
||||
|
||||
$commonExtHookFiles = glob($viewExtPath['common'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php");
|
||||
$siteExtHookFiles = empty($viewExtPath['site']) ? '' : glob($viewExtPath['site'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php");
|
||||
$extHookFiles = array_merge((array) $commonExtHookFiles, (array) $siteExtHookFiles);
|
||||
$viewFile = file_exists($commonExtViewFile) ? $commonExtViewFile : $mainViewFile;
|
||||
$viewFile = (!empty($siteExtViewFile) and file_exists($siteExtViewFile)) ? $siteExtViewFile : $viewFile;
|
||||
if(!is_file($viewFile)) $this->app->triggerError("the view file $viewFile not found", __FILE__, __LINE__, $exit = true);
|
||||
|
||||
$commonExtHookFiles = glob($viewExtPath['common'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php");
|
||||
$siteExtHookFiles = empty($viewExtPath['site']) ? '' : glob($viewExtPath['site'] . $this->devicePrefix . $methodName . ".*.{$viewType}.hook.php");
|
||||
$extHookFiles = array_merge((array) $commonExtHookFiles, (array) $siteExtHookFiles);
|
||||
}
|
||||
|
||||
if(!empty($extHookFiles)) return array('viewFile' => $viewFile, 'hookFiles' => $extHookFiles);
|
||||
return $viewFile;
|
||||
@@ -404,9 +405,9 @@ class baseControl
|
||||
* 首先找sitecode下的扩展文件,如果没有,再找ext下的扩展文件。
|
||||
* Find extViewFile in ext/_$siteCode/view first, then try ext/view/.
|
||||
*/
|
||||
if($this->config->site->code)
|
||||
if($this->app->siteCode)
|
||||
{
|
||||
$extPath = dirname(dirname(realpath($viewFile))) . "/ext/_{$this->config->site->code}/view";
|
||||
$extPath = dirname(dirname(realpath($viewFile))) . "/ext/_{$this->app->siteCode}/view";
|
||||
$extViewFile = $extPath . basename($viewFile);
|
||||
|
||||
if(file_exists($extViewFile))
|
||||
@@ -442,8 +443,6 @@ class baseControl
|
||||
|
||||
$modulePath = $this->app->getModulePath($this->appName, $moduleName);
|
||||
$cssExtPath = $this->app->getModuleExtPath($this->appName, $moduleName, 'css') ;
|
||||
$cssMethodExt = $cssExtPath['common'] . $methodName . DS;
|
||||
$cssCommonExt = $cssExtPath['common'] . 'common' . DS;
|
||||
|
||||
$css = '';
|
||||
$mainCssFile = $modulePath . 'css' . DS . $this->devicePrefix . 'common.css';
|
||||
@@ -451,21 +450,27 @@ class baseControl
|
||||
if(file_exists($mainCssFile)) $css .= file_get_contents($mainCssFile);
|
||||
if(is_file($methodCssFile)) $css .= file_get_contents($methodCssFile);
|
||||
|
||||
$cssExtFiles = glob($cssCommonExt . $this->devicePrefix . '*.css');
|
||||
if(!empty($cssExtFiles) and is_array($cssExtFiles)) foreach($cssExtFiles as $cssFile) $css .= file_get_contents($cssFile);
|
||||
|
||||
$cssExtFiles = glob($cssMethodExt . $this->devicePrefix . '*.css');
|
||||
if(!empty($cssExtFiles) and is_array($cssExtFiles)) foreach($cssExtFiles as $cssFile) $css .= file_get_contents($cssFile);
|
||||
|
||||
if(!empty($cssExtPath['site']))
|
||||
if(!empty($cssExtPath))
|
||||
{
|
||||
$cssMethodExt = $cssExtPath['site'] . $methodName . DS;
|
||||
$cssCommonExt = $cssExtPath['site'] . 'common' . DS;
|
||||
$cssMethodExt = $cssExtPath['common'] . $methodName . DS;
|
||||
$cssCommonExt = $cssExtPath['common'] . 'common' . DS;
|
||||
|
||||
$cssExtFiles = glob($cssCommonExt . $this->devicePrefix . '*.css');
|
||||
if(!empty($cssExtFiles) and is_array($cssExtFiles)) foreach($cssExtFiles as $cssFile) $css .= file_get_contents($cssFile);
|
||||
|
||||
$cssExtFiles = glob($cssMethodExt . $this->devicePrefix . '*.css');
|
||||
if(!empty($cssExtFiles) and is_array($cssExtFiles)) foreach($cssExtFiles as $cssFile) $css .= file_get_contents($cssFile);
|
||||
|
||||
if(!empty($cssExtPath['site']))
|
||||
{
|
||||
$cssMethodExt = $cssExtPath['site'] . $methodName . DS;
|
||||
$cssCommonExt = $cssExtPath['site'] . 'common' . DS;
|
||||
$cssExtFiles = glob($cssCommonExt . $this->devicePrefix . '*.css');
|
||||
if(!empty($cssExtFiles) and is_array($cssExtFiles)) foreach($cssExtFiles as $cssFile) $css .= file_get_contents($cssFile);
|
||||
|
||||
$cssExtFiles = glob($cssMethodExt . $this->devicePrefix . '*.css');
|
||||
if(!empty($cssExtFiles) and is_array($cssExtFiles)) foreach($cssExtFiles as $cssFile) $css .= file_get_contents($cssFile);
|
||||
}
|
||||
}
|
||||
|
||||
return $css;
|
||||
@@ -487,8 +492,6 @@ class baseControl
|
||||
|
||||
$modulePath = $this->app->getModulePath($this->appName, $moduleName);
|
||||
$jsExtPath = $this->app->getModuleExtPath($this->appName, $moduleName, 'js');
|
||||
$jsMethodExt = $jsExtPath['common'] . $methodName . DS;
|
||||
$jsCommonExt = $jsExtPath['common'] . 'common' . DS;
|
||||
|
||||
$js = '';
|
||||
$mainJsFile = $modulePath . 'js' . DS . $this->devicePrefix . 'common.js';
|
||||
@@ -496,24 +499,30 @@ class baseControl
|
||||
if(file_exists($mainJsFile)) $js .= file_get_contents($mainJsFile);
|
||||
if(is_file($methodJsFile)) $js .= file_get_contents($methodJsFile);
|
||||
|
||||
$jsExtFiles = glob($jsCommonExt . $this->devicePrefix . '*.js');
|
||||
if(!empty($jsExtFiles) and is_array($jsExtFiles)) foreach($jsExtFiles as $jsFile) $js .= file_get_contents($jsFile);
|
||||
|
||||
$jsExtFiles = glob($jsMethodExt . $this->devicePrefix . '*.js');
|
||||
if(!empty($jsExtFiles) and is_array($jsExtFiles)) foreach($jsExtFiles as $jsFile) $js .= file_get_contents($jsFile);
|
||||
|
||||
if(!empty($jsExtPath['site']))
|
||||
if(!empty($jsExtPath))
|
||||
{
|
||||
$jsMethodExt = $jsExtPath['site'] . $methodName . DS;
|
||||
$jsCommonExt = $jsExtPath['site'] . 'common' . DS;
|
||||
$jsMethodExt = $jsExtPath['common'] . $methodName . DS;
|
||||
$jsCommonExt = $jsExtPath['common'] . 'common' . DS;
|
||||
|
||||
$jsExtFiles = glob($jsCommonExt . $this->devicePrefix . '*.js');
|
||||
if(!empty($jsExtFiles) and is_array($jsExtFiles)) foreach($jsExtFiles as $jsFile) $js .= file_get_contents($jsFile);
|
||||
|
||||
$jsExtFiles = glob($jsMethodExt . $this->devicePrefix . '*.js');
|
||||
if(!empty($jsExtFiles) and is_array($jsExtFiles)) foreach($jsExtFiles as $jsFile) $js .= file_get_contents($jsFile);
|
||||
}
|
||||
|
||||
if(!empty($jsExtPath['site']))
|
||||
{
|
||||
$jsMethodExt = $jsExtPath['site'] . $methodName . DS;
|
||||
$jsCommonExt = $jsExtPath['site'] . 'common' . DS;
|
||||
|
||||
$jsExtFiles = glob($jsCommonExt . $this->devicePrefix . '*.js');
|
||||
if(!empty($jsExtFiles) and is_array($jsExtFiles)) foreach($jsExtFiles as $jsFile) $js .= file_get_contents($jsFile);
|
||||
|
||||
$jsExtFiles = glob($jsMethodExt . $this->devicePrefix . '*.js');
|
||||
if(!empty($jsExtFiles) and is_array($jsExtFiles)) foreach($jsExtFiles as $jsFile) $js .= file_get_contents($jsFile);
|
||||
}
|
||||
}
|
||||
|
||||
return $js;
|
||||
}
|
||||
|
||||
@@ -588,7 +597,7 @@ class baseControl
|
||||
$output['data'] = json_encode($this->view);
|
||||
$output['md5'] = md5(json_encode($this->view));
|
||||
|
||||
$this->output = json_encode($output);
|
||||
$this->output = json_encode($output);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -659,6 +668,10 @@ class baseControl
|
||||
*/
|
||||
public function fetch($moduleName = '', $methodName = '', $params = array(), $appName = '')
|
||||
{
|
||||
/**
|
||||
* 如果模块名为空,则调用该模块、该方法。
|
||||
* If the module name is empty, then use the current module and method.
|
||||
*/
|
||||
if($moduleName == '') $moduleName = $this->moduleName;
|
||||
if($methodName == '') $methodName = $this->methodName;
|
||||
if($appName == '') $appName = $this->appName;
|
||||
@@ -668,20 +681,47 @@ class baseControl
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
$currentModuleName = $this->moduleName;
|
||||
$currentMethodName = $this->methodName;
|
||||
$currentAppName = $this->appName;
|
||||
|
||||
/**
|
||||
* 设置调用指定模块的指定方法。
|
||||
* chang the dir to the previous.
|
||||
*/
|
||||
$this->app->setModuleName($moduleName);
|
||||
$this->app->setMethodName($methodName);
|
||||
|
||||
if(!is_array($params)) parse_str($params, $params);
|
||||
$currentPWD = getcwd();
|
||||
|
||||
/**
|
||||
* 设置引用的文件和路径。
|
||||
* Set the pathes and files to included.
|
||||
**/
|
||||
*/
|
||||
$modulePath = $this->app->getModulePath($appName, $moduleName);
|
||||
$moduleControlFile = $modulePath . 'control.php';
|
||||
$actionExtPath = $this->app->getModuleExtPath($appName, $moduleName, 'control');
|
||||
$file2Included = $moduleControlFile;
|
||||
|
||||
$commonActionExtFile = $actionExtPath['common'] . strtolower($methodName) . '.php';
|
||||
$file2Included = file_exists($commonActionExtFile) ? $commonActionExtFile : $moduleControlFile;
|
||||
if(!empty($actionExtPath['site']))
|
||||
if(!empty($actionExtPath))
|
||||
{
|
||||
$siteActionExtFile = $actionExtPath['site'] . strtolower($methodName) . '.php';
|
||||
$file2Included = file_exists($siteActionExtFile) ? $siteActionExtFile : $file2Included;
|
||||
/**
|
||||
* 设置公共扩展。
|
||||
* set common extension.
|
||||
*/
|
||||
$commonActionExtFile = $actionExtPath['common'] . strtolower($methodName) . '.php';
|
||||
$file2Included = file_exists($commonActionExtFile) ? $commonActionExtFile : $moduleControlFile;
|
||||
|
||||
if(!empty($actionExtPath['site']))
|
||||
{
|
||||
/**
|
||||
* 设置站点扩展。
|
||||
* every site has it's extension.
|
||||
*/
|
||||
$siteActionExtFile = $actionExtPath['site'] . strtolower($methodName) . '.php';
|
||||
$file2Included = file_exists($siteActionExtFile) ? $siteActionExtFile : $file2Included;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -689,7 +729,6 @@ class baseControl
|
||||
* Load the control file.
|
||||
*/
|
||||
if(!is_file($file2Included)) $this->app->triggerError("The control file $file2Included not found", __FILE__, __LINE__, $exit = true);
|
||||
$currentPWD = getcwd();
|
||||
chdir(dirname($file2Included));
|
||||
if($moduleName != $this->moduleName) helper::import($file2Included);
|
||||
|
||||
@@ -704,7 +743,6 @@ class baseControl
|
||||
* 解析参数,创建模块control对象。
|
||||
* Parse the params, create the $module control object.
|
||||
*/
|
||||
if(!is_array($params)) parse_str($params, $params);
|
||||
$module = new $className($moduleName, $methodName, $appName);
|
||||
|
||||
/**
|
||||
@@ -715,13 +753,70 @@ class baseControl
|
||||
call_user_func_array(array($module, $methodName), $params);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
unset($module);
|
||||
|
||||
/**
|
||||
* 切换回之前的模块和方法。
|
||||
* Chang the module、method to the previous.
|
||||
*/
|
||||
$this->app->setModuleName($currentModuleName);
|
||||
$this->app->setMethodName($currentMethodName);
|
||||
|
||||
$currentClassName = class_exists("my$currentModuleName") ? "my$currentModuleName" : $currentModuleName;
|
||||
if(!class_exists($currentClassName)) $this->app->triggerError(" The class $currentClassName not found", __FILE__, __LINE__, $exit = true);
|
||||
|
||||
/* include default value for module*/
|
||||
$defaultValueFiles = glob($this->app->getTmpRoot() . "defaultvalue/*.php");
|
||||
if($defaultValueFiles) foreach($defaultValueFiles as $file) include $file;
|
||||
|
||||
/*
|
||||
* 使用反射机制获取函数参数的默认值。
|
||||
* Get the default settings of the method to be called using the reflecting.
|
||||
*
|
||||
* */
|
||||
$defaultParams = array();
|
||||
$methodReflect = new reflectionMethod($currentClassName, $currentMethodName);
|
||||
foreach($methodReflect->getParameters() as $param)
|
||||
{
|
||||
$name = $param->getName();
|
||||
|
||||
$default = '_NOT_SET';
|
||||
if(isset($paramDefaultValue[$currentAppName][$currentClassName][$currentMethodName][$name]))
|
||||
{
|
||||
$default = $paramDefaultValue[$currentAppName][$currentClassName][$currentMethodName][$name];
|
||||
}
|
||||
elseif(isset($paramDefaultValue[$currentClassName][$currentMethodName][$name]))
|
||||
{
|
||||
$default = $paramDefaultValue[$currentClassName][$currentMethodName][$name];
|
||||
}
|
||||
elseif($param->isDefaultValueAvailable())
|
||||
{
|
||||
$default = $param->getDefaultValue();
|
||||
}
|
||||
|
||||
$defaultParams[$name] = $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据PATH_INFO或者GET方式设置请求的参数。
|
||||
* Set params according PATH_INFO or GET.
|
||||
*/
|
||||
if($this->config->requestType != 'GET')
|
||||
{
|
||||
$this->app->setParamsByPathInfo($defaultParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->app->setParamsByGET($defaultParams);
|
||||
}
|
||||
|
||||
chdir($currentPWD);
|
||||
|
||||
/**
|
||||
* 返回内容。
|
||||
* Return the content.
|
||||
*/
|
||||
unset($module);
|
||||
chdir($currentPWD);
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -754,7 +849,7 @@ class baseControl
|
||||
if($type != 'json') die();
|
||||
|
||||
$data = (array) $data;
|
||||
if(helper::isAjaxRequest()) print(json_encode($data)) and die(helper::removeUTF8Bom(ob_get_clean()));
|
||||
if(helper::isAjaxRequest() or $this->viewType == 'json') print(json_encode($data)) and die(helper::removeUTF8Bom(ob_get_clean()));
|
||||
|
||||
/**
|
||||
* 响应非ajax的请求。
|
||||
|
||||
+312
-827
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,8 @@
|
||||
* ZenTaoPHP的baseModel类。
|
||||
* The baseModel class file of ZenTaoPHP framework.
|
||||
*
|
||||
* @package framework
|
||||
*
|
||||
* The author disclaims copyright to this source code. In place of
|
||||
* a legal notice, here is a blessing:
|
||||
*
|
||||
@@ -10,13 +12,6 @@
|
||||
* May you find forgiveness for yourself and forgive others.
|
||||
* May you share freely, never taking more than you give.
|
||||
*/
|
||||
|
||||
/**
|
||||
* baseModel基类。
|
||||
* The base class of model.
|
||||
*
|
||||
* @package framework
|
||||
*/
|
||||
class baseModel
|
||||
{
|
||||
/**
|
||||
@@ -150,8 +145,8 @@ class baseModel
|
||||
$this->appName = empty($appName) ? $this->app->getAppName() : $appName;
|
||||
|
||||
$moduleName = $this->getModuleName();
|
||||
$this->app->loadLang($moduleName, $this->appName);
|
||||
$this->app->loadConfig($moduleName, $this->appName, $exitIfNone = false);
|
||||
if($this->config->framework->multiLanguage) $this->app->loadLang($moduleName, $this->appName);
|
||||
if($moduleName != 'common') $this->app->loadModuleConfig($moduleName, $this->appName, $exitIfNone = false);
|
||||
|
||||
$this->loadDAO();
|
||||
$this->setSuperVars();
|
||||
@@ -196,7 +191,6 @@ class baseModel
|
||||
$this->server = $this->app->server;
|
||||
$this->cookie = $this->app->cookie;
|
||||
$this->session = $this->app->session;
|
||||
$this->global = $this->app->global;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +207,7 @@ class baseModel
|
||||
{
|
||||
if(empty($moduleName)) return false;
|
||||
if(empty($appName)) $appName = $this->appName;
|
||||
$modelFile = helper::setModelFile($moduleName, $appName);
|
||||
$modelFile = $this->app->setModelFile($moduleName, $appName);
|
||||
|
||||
if(!helper::import($modelFile)) return false;
|
||||
$modelClass = class_exists('ext' . $appName . $moduleName. 'model') ? 'ext' . $appName . $moduleName . 'model' : $appName . $moduleName . 'model';
|
||||
@@ -228,8 +222,17 @@ class baseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载model的class扩展。
|
||||
* Load extension class of a model. Saved to $moduleName/ext/model/class/$extensionName.class.php.
|
||||
* 加载model的class扩展,主要是为了开发加密代码使用。
|
||||
* 可以将主要的逻辑存放到$moduleName/ext/model/class/$extensionName.class.php中。
|
||||
* 然后在ext/model/$extension.php的扩展里面使用$this->loadExtension()来调用相应的方法。
|
||||
* ext/model/class/*.class.php代码可以加密。而ext/model/*.php可以不用加密。
|
||||
* 因为框架对model的扩展是采取合并文件的方式,ext/model/*.php文件不能加密。
|
||||
*
|
||||
* Load extension class of a model thus user can encrypt the code.
|
||||
* You can put the main extension logic codes in $moduleName/ext/model/class/$extensionName.class.php.
|
||||
* And call them by the ext/model/$extension.php like this: $this->loadExtension('myextension')->method().
|
||||
* You can encrypt the code in ext/model/class/*.class.php.
|
||||
* Because the framework will merge the extension files in ext/model/*.php to the module/model.php.
|
||||
*
|
||||
* @param string $extensionName
|
||||
* @param string $moduleName
|
||||
@@ -240,22 +243,22 @@ class baseModel
|
||||
{
|
||||
if(empty($extensionName)) return false;
|
||||
|
||||
/* Set extenson name and extension file. */
|
||||
/* 设置扩展的名字和相应的文件。Set extenson name and extension file. */
|
||||
$extensionName = strtolower($extensionName);
|
||||
$moduleName = $moduleName ? $moduleName : $this->getModuleName();
|
||||
$moduleExtPath = $this->app->getModuleExtPath($this->appName, $moduleName, 'model');
|
||||
if(!empty($moduleExtPath['site']))$extensionFile = $moduleExtPath['site'] . 'class/' . $extensionName . '.class.php';
|
||||
if(!empty($moduleExtPath['site'])) $extensionFile = $moduleExtPath['site'] . 'class/' . $extensionName . '.class.php';
|
||||
if(!isset($extensionFile) or !file_exists($extensionFile)) $extensionFile = $moduleExtPath['common'] . 'class/' . $extensionName . '.class.php';
|
||||
|
||||
/* Try to import parent model file auto and then import the extension file. */
|
||||
/* 载入父类。Try to import parent model file auto and then import the extension file. */
|
||||
if(!class_exists($moduleName . 'Model')) helper::import($this->app->getModulePath($this->appName, $moduleName) . 'model.php');
|
||||
if(!helper::import($extensionFile)) return false;
|
||||
|
||||
/* Set the extension class name. */
|
||||
/* 设置扩展类的名字。Set the extension class name. */
|
||||
$extensionClass = $extensionName . ucfirst($moduleName);
|
||||
if(!class_exists($extensionClass)) return false;
|
||||
|
||||
/* Create an instance of the extension class and return it. */
|
||||
/* 实例化扩展类。Create an instance of the extension class and return it. */
|
||||
$extensionObject = new $extensionClass;
|
||||
$extensionClass = str_replace('Model', '', $extensionClass);
|
||||
$this->$extensionClass = $extensionObject;
|
||||
@@ -275,7 +278,7 @@ class baseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
* 删除记录。
|
||||
* Delete one record.
|
||||
*
|
||||
* @param string $table the table name
|
||||
|
||||
+635
-394
File diff suppressed because it is too large
Load Diff
@@ -112,3 +112,15 @@ class helper extends baseHelper
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否是onlybody模式。
|
||||
* Check exist onlybody param.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function isonlybody()
|
||||
{
|
||||
return helper::inOnlyBodyMode();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,32 @@ class router extends baseRouter
|
||||
$lang->projectCommon = isset($this->config->projectCommonList[$this->clientLang][(int)$projectCommon]) ? $this->config->projectCommonList[$this->clientLang][(int)$projectCommon] : $this->config->projectCommonList['zh-cn'][0];
|
||||
}
|
||||
|
||||
return parent::loadLang($moduleName, $appName);
|
||||
parent::loadLang($moduleName, $appName);
|
||||
|
||||
/* Merge from the db lang. */
|
||||
if($moduleName != 'common' and isset($lang->db->custom[$moduleName]))
|
||||
{
|
||||
foreach($lang->db->custom[$moduleName] as $section => $fields)
|
||||
{
|
||||
if(isset($lang->{$moduleName}->{$section}['']))
|
||||
{
|
||||
$nullKey = '';
|
||||
$nullValue = $lang->{$moduleName}->{$section}[$nullKey];
|
||||
}
|
||||
elseif(isset($lang->{$moduleName}->{$section}[0]))
|
||||
{
|
||||
$nullKey = 0;
|
||||
$nullValue = $lang->{$moduleName}->{$section}[0];
|
||||
}
|
||||
unset($lang->{$moduleName}->{$section});
|
||||
|
||||
if(isset($nullKey))$lang->{$moduleName}->{$section}[$nullKey] = $nullValue;
|
||||
foreach($fields as $key => $value) $lang->{$moduleName}->{$section}[$key] = $value;
|
||||
unset($nullKey);
|
||||
unset($nullValue);
|
||||
}
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,4 +124,9 @@ class router extends baseRouter
|
||||
if(isset($fatalLevel[$level])) $this->config->debug = true;
|
||||
parent::saveError($level, $message, $file, $line);
|
||||
}
|
||||
|
||||
public function loadConfig($moduleName, $appName = '')
|
||||
{
|
||||
return parent::loadModuleConfig($moduleName, $appName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ class baseDAO
|
||||
$this->sqlError($e);
|
||||
}
|
||||
|
||||
return $row->recTotal;
|
||||
return is_object($row) ? $row->recTotal : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -513,6 +513,7 @@ class baseDAO
|
||||
if($this->autoLang and !isset($data->lang))
|
||||
{
|
||||
$data->lang = $this->app->getClientLang();
|
||||
if(isset($this->app->config->cn2tw) and $this->app->config->cn2tw and $data->lang == 'zh-tw') $data->lang = 'zh-cn';
|
||||
if(defined('RUN_MODE') and RUN_MODE == 'front' and !empty($this->app->config->cn2tw)) $data->lang = str_replace('zh-tw', 'zh-cn', $data->lang);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ class baseValidater
|
||||
*/
|
||||
public static function checkTel($var)
|
||||
{
|
||||
return preg_match("/^([0-9]{3,4}-)?[0-9]{7,8}$/", $var);
|
||||
return preg_match("/^([0-9]{3,4}-?)?[0-9]{7,8}$/", $var);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ class baseValidater
|
||||
*/
|
||||
public static function checkMobile($var)
|
||||
{
|
||||
return preg_match("/^1[3-5,8]{1}[0-9]{9}$/", $var);
|
||||
return preg_match("/^1[3-5,7,8]{1}[0-9]{9}$/", $var);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,6 +214,43 @@ class baseValidater
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证号检查。
|
||||
* Idcard checking.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function checkIdcard($idcard)
|
||||
{
|
||||
if(strlen($idcard)!=18) return false;
|
||||
$idcard = strtoupper($idcard);
|
||||
$cityList = array(
|
||||
'11','12','13','14','15','21','22',
|
||||
'23','31','32','33','34','35','36',
|
||||
'37','41','42','43','44','45','46',
|
||||
'50','51','52','53','54','61','62',
|
||||
'63','64','65','71','81','82','91'
|
||||
);
|
||||
|
||||
if (!preg_match('/^([\d]{17}[xX\d]|[\d]{15})$/', $idcard)) return false;
|
||||
|
||||
if (!in_array(substr($idcard, 0, 2), $cityList)) return false;
|
||||
|
||||
$baseCode = substr($idcard, 0, 17);
|
||||
$verifyCode = substr($idcard, 17, 1);
|
||||
$interference = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
|
||||
|
||||
$verifyConfig = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
|
||||
|
||||
$total = 0;
|
||||
for($i=0; $i<17; $i++) $total += substr($baseCode, $i, 1) * $interference[$i];
|
||||
|
||||
$mod = $total % 11;
|
||||
|
||||
return $verifyCode == $verifyConfig[$mod];
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期检查。注意,2009-09-31是一个合法日期,系统会将它转换为2009-10-01。
|
||||
* Date checking. Note: 2009-09-31 will be an valid date, because strtotime auto fixed it to 10-01.
|
||||
@@ -480,6 +517,227 @@ class baseValidater
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤附件。
|
||||
* Filter files.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function filterFiles()
|
||||
{
|
||||
global $config;
|
||||
if(empty($_FILES)) return $_FILES;
|
||||
|
||||
foreach($_FILES as $varName => $files)
|
||||
{
|
||||
if(is_array($files['name']))
|
||||
{
|
||||
foreach($files['name'] as $i => $fileName)
|
||||
{
|
||||
$extension = ltrim(strrchr($fileName, '.'), '.');
|
||||
if(stripos(",{$config->file->dangers},", ",{$extension},") !== false)
|
||||
{
|
||||
unset($_FILES);
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$extension = ltrim(strrchr($files['name'], '.'), '.');
|
||||
if(stripos(",{$config->file->dangers},", ",{$extension},") !== false)
|
||||
{
|
||||
unset($_FILES);
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤超级变量。
|
||||
* Filter super vars.
|
||||
*
|
||||
* @param array $super
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function filterSuper($super)
|
||||
{
|
||||
if(!is_array($super)) return $super;
|
||||
|
||||
$super = self::filterBadKeys($super);
|
||||
foreach($super as $key => $item)
|
||||
{
|
||||
if(is_array($item))
|
||||
{
|
||||
$item = self::filterBadKeys($item);
|
||||
foreach($item as $subkey => $subItem)
|
||||
{
|
||||
if(is_array($subItem)) continue;
|
||||
$subItem = self::filterTrojan($subItem);
|
||||
$super[$key][$subkey] = self::filterXSS($subItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$item = self::filterTrojan($item);
|
||||
$super[$key] = self::filterXSS($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $super;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤不符合规则的键值。
|
||||
* Filter bad keys.
|
||||
*
|
||||
* @param mix $var
|
||||
* @access public
|
||||
* @return mix
|
||||
*/
|
||||
public static function filterBadKeys($var)
|
||||
{
|
||||
global $config;
|
||||
if(empty($config->framework->filterBadKeys)) return $var;
|
||||
foreach($var as $key => $value) if(preg_match('/[^a-zA-Z0-9_\.\-]/', $key)) unset($var[$key]);
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤木马代码。
|
||||
* Filter trojan codes.
|
||||
*
|
||||
* @param string $var
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function filterTrojan($var)
|
||||
{
|
||||
global $config;
|
||||
if(empty($config->framework->filterTrojan)) return $var;
|
||||
if(strpos(htmlspecialchars_decode($var), '<?') === false) return $var;
|
||||
|
||||
$var = (string) $var;
|
||||
$evils = array('eval', 'exec', 'passthru', 'proc_open', 'shell_exec', 'system', '$$', 'include', 'require', 'assert');
|
||||
$replaces = array('e v a l', 'e x e c', ' p a s s t h r u', ' p r o c _ o p e n', 's h e l l _ e x e c', 's y s t e m', '$ $', 'i n c l u d e', 'r e q u i r e', 'a s s e r t');
|
||||
$var = str_ireplace($evils, $replaces, $var);
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤 XSS代码。
|
||||
* Filter XSS codes.
|
||||
*
|
||||
* @param string $var
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function filterXSS($var)
|
||||
{
|
||||
global $config;
|
||||
if(empty($config->framework->filterXSS)) return $var;
|
||||
|
||||
if(stripos($var, '<script') !== false)
|
||||
{
|
||||
$var = (string) $var;
|
||||
$evils = array('appendchild(', 'createElement(', 'xss.re', 'onfocus', 'onclick', 'innerHTML', 'replaceChild(', 'html(', 'append(', 'appendTo(', 'prepend(', 'prependTo(', 'after(', 'insertBefore', 'before(', 'replaceWith(');
|
||||
$replaces = array('a p p e n d c h i l d (', 'c r e a t e E l e m e n t (', 'x s s . r e', 'o n f o c u s', 'o n c l i c k', 'i n n e r H T M L', 'r e p l a c e C h i l d (', 'h t m l (', 'a p p e n d (', 'a p p e n d T o (', 'p r e p e n d (', 'p r e p e n d T o (', 'a f t e r (', 'i n s e r t B e f o r e(', 'b e f o r e (', 'r e p l a c e W i t h (');
|
||||
$var = str_ireplace($evils, $replaces, $var);
|
||||
}
|
||||
|
||||
/* Process like 'javascript:' */
|
||||
$var = preg_replace('/j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:/Ui', 'j a v a s c r i p t :', $var);
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter param.
|
||||
*
|
||||
* @param array $var
|
||||
* @param string $type
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function filterParam($var, $type)
|
||||
{
|
||||
global $config, $app;
|
||||
|
||||
if(!isset($config->filterParam->$type)) return array();
|
||||
|
||||
$moduleName = $app->getModuleName();
|
||||
$methodName = $app->getMethodName();
|
||||
$params = $app->getParams();
|
||||
$filterConfig = $config->filterParam->$type;
|
||||
|
||||
$holdVars = '';
|
||||
if(isset($filterConfig['common']['hold'])) $holdVars .= $filterConfig['common']['hold'] . ',';
|
||||
if(isset($filterConfig[$moduleName]['common']['hold'])) $holdVars .= $filterConfig[$moduleName]['common']['hold'] . ',';
|
||||
if(isset($filterConfig[$moduleName][$methodName]['hold'])) $holdVars .= $filterConfig[$moduleName][$methodName]['hold'] . ',';
|
||||
if($type == 'cookie') $holdVars .= 'pager' . ucfirst($moduleName) . ucfirst($methodName) . ',';
|
||||
foreach($var as $key => $value)
|
||||
{
|
||||
if($config->requestType == 'GET' and $type == 'get' and isset($params[$key])) continue;
|
||||
if(strpos(",$holdVars", ",$key,") === false)
|
||||
{
|
||||
unset($var[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$rules = '';
|
||||
if(isset($filterConfig[$moduleName][$methodName]['params'][$key]))
|
||||
{
|
||||
$rules = $filterConfig[$moduleName][$methodName]['params'][$key];
|
||||
}
|
||||
elseif(isset($filterConfig[$moduleName]['common']['params'][$key]))
|
||||
{
|
||||
$rules = $filterConfig[$moduleName]['common']['params'][$key];
|
||||
}
|
||||
elseif(isset($filterConfig['common']['params'][$key]))
|
||||
{
|
||||
$rules = $filterConfig['common']['params'][$key];
|
||||
}
|
||||
if(!self::checkByRules($value, $rules)) unset($var[$key]);
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check by rules.
|
||||
*
|
||||
* @param string $var
|
||||
* @param array $rules
|
||||
* @static
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkByRules($var, $rules)
|
||||
{
|
||||
if(empty($rules)) return false;
|
||||
foreach($rules as $type => $rule)
|
||||
{
|
||||
$checkMethod = 'check' . $type;
|
||||
if(method_exists('baseValidater', $checkMethod))
|
||||
{
|
||||
if(empty($rule) and self::$checkMethod($var) === false) return false;
|
||||
if(!empty($rule) and self::$checkMethod($var, $rule) === false) return false;
|
||||
}
|
||||
elseif(function_exists('is_' . $type))
|
||||
{
|
||||
$checkFunction = 'is_' . $type;
|
||||
if(!$checkFunction($var)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用一个方法进行检查。
|
||||
* Call a function to check it.
|
||||
@@ -718,7 +976,7 @@ class baseFixer
|
||||
$fields = $this->processFields($fieldName);
|
||||
foreach($fields as $fieldName)
|
||||
{
|
||||
if(version_compare(phpversion(), '5.4', '<') and get_magic_quotes_gpc()) $this->data->$fieldName = stripslashes($this->data->$fieldName);
|
||||
if(function_exists('get_magic_quotes_gpc') and get_magic_quotes_gpc()) $this->data->$fieldName = stripslashes($this->data->$fieldName);
|
||||
|
||||
if(!in_array($fieldName, $this->stripedFields))
|
||||
{
|
||||
@@ -728,6 +986,8 @@ class baseFixer
|
||||
* purifier会把 替换空格,kindeditor在会吧行首的空格去掉。
|
||||
* purifier will change to ' ', and edit it will no space in line head use kindeditor.
|
||||
**/
|
||||
$this->data->$fieldName = preg_replace('/<[^>]+</', '<', $this->data->$fieldName);
|
||||
$this->data->$fieldName = preg_replace('/>[^<]+>/', '>', $this->data->$fieldName);
|
||||
if($usePurifier) $this->data->$fieldName = str_replace(' ', '&spnb;', $this->data->$fieldName);
|
||||
$this->data->$fieldName = $usePurifier ? $purifier->purify($this->data->$fieldName) : strip_tags($this->data->$fieldName, $allowedTags);
|
||||
if($usePurifier) $this->data->$fieldName = str_replace('&spnb;', ' ', $this->data->$fieldName);
|
||||
@@ -929,7 +1189,7 @@ class baseFixer
|
||||
foreach($this->data as $field => $value)
|
||||
{
|
||||
if(!isset($fields[$field])) unset($this->data->$field);
|
||||
if(!in_array($field, $this->stripedFields)) $this->data->$field = $this->specialChars($this->data->field);
|
||||
if(!in_array($field, $this->stripedFields)) $this->specialChars($field);
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
|
||||
@@ -77,7 +77,6 @@ class baseHTML
|
||||
{
|
||||
$class = empty($class) ? ('icon-' . $name) : ('icon-' . $name . ' ' . $class);
|
||||
return "<i class='$class'></i>";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,16 +109,11 @@ class baseHTML
|
||||
static public function a($href = '', $title = '', $misc = '', $newline = true)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(empty($title)) $title = $href;
|
||||
$newline = $newline ? "\n" : '';
|
||||
|
||||
/* if page has onlybody param then add this param in all link. the param hide header and footer. */
|
||||
if(strpos($href, 'onlybody=yes') === false and isonlybody())
|
||||
{
|
||||
$onlybody = strpos($href, '?') === false ? "?onlybody=yes" : "&onlybody=yes";
|
||||
$href .= $onlybody;
|
||||
}
|
||||
|
||||
$href = helper::processOnlyBodyParam($href);
|
||||
|
||||
return "<a href='$href' $misc>$title</a>$newline";
|
||||
}
|
||||
|
||||
@@ -491,7 +485,7 @@ class baseHTML
|
||||
*/
|
||||
public static function backButton($label = '', $misc = '', $class = '')
|
||||
{
|
||||
if(isonlybody()) return false;
|
||||
if(helper::inOnlyBodyMode()) return false;
|
||||
|
||||
global $lang;
|
||||
if(empty($label))
|
||||
@@ -537,14 +531,9 @@ class baseHTML
|
||||
{
|
||||
global $config, $lang;
|
||||
|
||||
if(isonlybody() and $lang->goback == $label) return false;
|
||||
if(helper::inOnlyBodyMode() and $lang->goback == $label) return false;
|
||||
$link = helper::processOnlyBodyParam($link);
|
||||
|
||||
/* if page has onlybody param then add this param in all link. the param hide header and footer. */
|
||||
if(strpos($link, 'onlybody=') === false and isonlybody())
|
||||
{
|
||||
$onlybody = strpos($link, '?') === false ? "?onlybody=yes" : "&onlybody=yes";
|
||||
$link .= $onlybody;
|
||||
}
|
||||
return " <button type='button' class='$class' $misc onclick='$target.location.href=\"$link\"'>$label</button>";
|
||||
}
|
||||
|
||||
@@ -703,7 +692,7 @@ EOT;
|
||||
$string .= "<a id='allchecker' class='btn btn-select-all check-all $appendClass' data-scope='$scope' href='javascript:;' >{$lang->selectAll}</a>";
|
||||
$string .= "<a id='reversechecker' class='btn btn-select-reverse check-inverse $appendClass' data-scope='$scope' href='javascript:;'>{$lang->selectReverse}</a>";
|
||||
if($asGroup) $string .= "</div>";
|
||||
return $string;
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -282,13 +282,14 @@ class basePager
|
||||
}
|
||||
|
||||
parse_str(strip_tags(urldecode($_SERVER['QUERY_STRING'])), $query);
|
||||
if(!empty($query['m']) && !empty($query['f']) && $query['m'] == $this->moduleName && $query['f'] == $this->methodName)
|
||||
{
|
||||
unset($query['m']);
|
||||
unset($query['f']);
|
||||
unset($query['t']);
|
||||
|
||||
unset($query['m']);
|
||||
unset($query['f']);
|
||||
unset($query['t']);
|
||||
|
||||
$this->params = array_merge($this->params, $query);
|
||||
|
||||
$this->params = array_merge($this->params, $query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +302,7 @@ class basePager
|
||||
public function limit()
|
||||
{
|
||||
$limit = '';
|
||||
if($this->pageTotal > 1) $limit = ' limit ' . ($this->pageID - 1) * $this->recPerPage . ", $this->recPerPage";
|
||||
if($this->pageTotal > 1) $limit = ' lImiT ' . ($this->pageID - 1) * $this->recPerPage . ", $this->recPerPage";
|
||||
return $limit;
|
||||
}
|
||||
|
||||
@@ -341,7 +342,7 @@ class basePager
|
||||
$pager = '';
|
||||
|
||||
$pager .= "<li class='previous" . ($this->pageID == 1 ? ' disabled' : '') . "'>";
|
||||
$this->params['pageID'] = 1;
|
||||
$this->params['pageID'] = min(1, $this->pageID - 1);
|
||||
$pager .= $this->createLink('« ' . $this->lang->pager->previousPage) . '</li>';
|
||||
|
||||
$pager .= "<li class='caption'>";
|
||||
@@ -602,7 +603,7 @@ EOT;
|
||||
public function createLink($title)
|
||||
{
|
||||
global $config;
|
||||
if(helper::inSeoMode() && method_exists('uri', 'create' . $this->moduleName . $this->methodName))
|
||||
if($config->requestType != 'GET' && method_exists('uri', 'create' . $this->moduleName . $this->methodName))
|
||||
{
|
||||
$link = strip_tags(urldecode($_SERVER['REQUEST_URI']));
|
||||
|
||||
@@ -611,7 +612,8 @@ EOT;
|
||||
if(preg_match('/\/p\d+/', $link)) return html::a(preg_replace('/\/p\d+\./', '/p' . $this->params['pageID'] . '.', $link), $title);
|
||||
|
||||
if($config->requestType == 'PATH_INFO2') $link = str_replace('index.php/', 'index_php/', $link);
|
||||
$link = str_replace('.', "/p{$this->params['pageID']}.", $link);
|
||||
if(strpos($link, '.') !== false) $link = str_replace('.', "/p{$this->params['pageID']}.", $link);
|
||||
if(strpos($link, '.') === false) $link .= "/p{$this->params['pageID']}.html";
|
||||
if($config->requestType == 'PATH_INFO2') $link = str_replace('index_php/', 'index.php/', $link);
|
||||
return html::a($link, $title);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user