/** * 构造函数 * * @return FLEA_Rbac */ function FLEA_Rbac() { $this->_sessionKey = FLEA::getAppInf('RBACSessionKey'); if ($this->_sessionKey == 'RBAC_USERDATA') { trigger_error(_ET(0x701005), E_USER_WARNING); } }
/** * 根据应用程序设置 'urlMode' 分析 $_GET 参数 * * 该函数由框架自动调用,应用程序不需要调用该函数。 */ function ___uri_filter() { static $firstTime = true; if (!$firstTime) { return; } $firstTime = false; $pathinfo = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); $parts = explode('/', substr($pathinfo, 1)); if (isset($parts[0]) && strlen($parts[0])) { $_GET[FLEA::getAppInf('controllerAccessor')] = $parts[0]; } if (isset($parts[1]) && strlen($parts[1])) { $_GET[FLEA::getAppInf('actionAccessor')] = $parts[1]; } $style = FLEA::getAppInf('urlParameterPairStyle'); if ($style == '/') { for ($i = 2; $i < count($parts); $i += 2) { if (isset($parts[$i + 1])) { $_GET[$parts[$i]] = $parts[$i + 1]; } } } else { for ($i = 2; $i < count($parts); $i++) { $p = $parts[$i]; $arr = explode($style, $p); if (isset($arr[1])) { $_GET[$arr[0]] = $arr[1]; } } } // 将 $_GET 合并到 $_REQUEST, // 有时需要使用 $_REQUEST 统一处理 url 中的 id=? 这样的参数 $_REQUEST = array_merge($_REQUEST, $_GET); }
/** * 显示异常信息及调用堆栈 * * @param FLEA_Exception $ex */ function __error_dump_trace($ex) { echo '<strong>Exception: </strong>' . get_class($ex) . "<br />\n"; if ($ex->getMessage() != '') { echo '<strong>Message: </strong>' . $ex->getMessage() . "<br />\n"; } echo "<br />\n"; if (!FLEA::getAppInf('displaySource')) { return; } $trace = $ex->getTrace(); $ix = count($trace); foreach ($trace as $point) { $file = isset($point['file']) ? $point['file'] : null; $line = isset($point['line']) ? $point['line'] : null; $id = md5("{$file}({$line})"); $function = isset($point['class']) ? "{$point['class']}::{$point['function']}" : $point['function']; $args = array(); if (is_array($point['args']) && count($point['args']) > 0) { foreach ($point['args'] as $arg) { switch (gettype($arg)) { case 'array': $args[] = 'array(' . count($arg) . ')'; break; case 'resource': $args[] = gettype($arg); break; case 'object': $args[] = get_class($arg); break; case 'string': if (strlen($arg) > 30) { $arg = substr($arg, 0, 27) . ' ...'; } $args[] = "'{$arg}'"; break; default: $args[] = $arg; } } } $args = implode(", ", $args); echo <<<EOT <hr /> <strong>Filename:</strong> <a href="javascript:switch_filedesc('{$id}');">{$file} [{$line}]</a><br /> #{$ix} {$function}({$args}) <div id="{$id}" class="filedesc" style="display: none;"> ARGS: EOT; dump($point['args']); echo "SOURCE CODE: <br />\n"; echo __error_show_source($file, $line); echo "\n</div>\n"; echo "<br />\n"; $ix--; } }
/** * 构造函数 * * @return Controller_Default */ function Controller_Default() { /** * FLEA::getSingleton() 会自动载入指定类的定义文件,并且返回该类的唯一一个实例 */ $this->_metas =& FLEA::getAppInf('metas'); $this->_modelNews =& FLEA::getSingleton('Model_News'); $this->_modelMessage =& FLEA::getSingleton('Model_Message'); $this->_modelGoods =& FLEA::getSingleton('Model_Goods'); }
/** * 构造函数 * * @return Controller_Default */ function Controller_About() { /** * FLEA::getSingleton() 会自动载入指定类的定义文件,并且返回该类的唯一一个实例 */ //$this->_modelAbout =& FLEA::getSingleton('Model_About'); $this->_metas =& FLEA::getAppInf('metas'); //$this->_metas['description'] = "辽宁万维医药有限公司关于万维"; //$this->_metas['keywords'] = "辽宁万维医药,辽宁,吉林省,黑龙江省,关于万维"; //$this->_metas['title'] = $this->_metas['title'] . "关于万维"; }
/** * 构造函数 * * 负责根据用户的 session 设置载入语言文件 * * @return Controller_OfficeBase */ function Controller_ZobBase() { if (isset($_SESSION['LANG'])) { $lang = $_SESSION['LANG']; $languages = FLEA::getAppInf('languages'); if (in_array($lang, $languages, true)) { FLEA::setAppInf('defaultLanguage', $lang); } } load_language('ui, exception'); }
/** * 构造函数 * * @return Controller_Default */ function Controller_News() { /** * FLEA::getSingleton() 会自动载入指定类的定义文件,并且返回该类的唯一一个实例 */ $this->_modelNews =& FLEA::getSingleton('Model_News'); $this->_metas =& FLEA::getAppInf('metas'); $this->_metas['description'] = "辽宁万维医药有限公司新闻中心"; $this->_metas['keywords'] = "辽宁万维医药,辽宁,吉林省,黑龙江省,医药新闻"; $this->_metas['title'] = $this->_metas['title'] . "新闻中心"; }
/** * 构造函数 * * @return Controller_Default */ function Controller_Feedback() { /** * FLEA::getSingleton() 会自动载入指定类的定义文件,并且返回该类的唯一一个实例 */ $this->_modelMessage =& FLEA::getSingleton('Model_Message'); $this->_metas =& FLEA::getAppInf('metas'); $this->_metas['description'] = "辽宁万维医药经销渠道客户回馈"; $this->_metas['keywords'] = "辽宁万维医药,辽宁,吉林省,黑龙江省,医药客户回馈"; $this->_metas['title'] = $this->_metas['title'] . "客户回馈"; }
protected function setNav($aNav) { if (!is_array($aNav)) { $aNav = array($aNav); } $sessionKey = FLEA::getAppInf('RBACSessionKey'); $username = $_SESSION[$sessionKey]['USERNAME']; $sNav = implode(" <span style='color:#FF0000;'>>></span> ", $aNav); $this->_V->assign("username", $username); $this->_V->assign("sNav", $sNav); }
/** * 构造函数 * * @return Controller_Default */ function Controller_Products() { /** * FLEA::getSingleton() 会自动载入指定类的定义文件,并且返回该类的唯一一个实例 */ $this->_modelGoods =& FLEA::getSingleton('Model_Goods'); $this->_metas =& FLEA::getAppInf('metas'); $this->_metas['description'] = "辽宁万维医药经销渠道产品世界"; $this->_metas['keywords'] = "辽宁万维医药,辽宁,吉林省,黑龙江省,医药产品,思清,柴芩清宁胶囊"; $this->_metas['title'] = $this->_metas['title'] . "产品世界"; }
/** * 构造函数 * * @return Controller_Default */ function Controller_Distribution() { /** * FLEA::getSingleton() 会自动载入指定类的定义文件,并且返回该类的唯一一个实例 */ //$this->_modelAbout =& FLEA::getSingleton('Model_Message'); $this->_metas =& FLEA::getAppInf('metas'); $this->_metas = FLEA::getAppInf('metas'); $this->_metas['description'] = "辽宁万维医药经销渠道面向东三省招商"; $this->_metas['keywords'] = "辽宁万维医药,辽宁,吉林省,黑龙江省,招商"; $this->_metas['title'] = $this->_metas['title'] . "经销网络"; }
/** * 权限认证失败时的错误处理 * */ function onAuthFailedCallback($controller, $action) { $sessionKey = FLEA::getAppInf('RBACSessionKey'); $username = $_SESSION[$sessionKey]['USERNAME']; if (empty($username)) { $rurl = url('Default', 'Index'); echo "<script language='javascript'>window.top.location.href='" . $rurl . "'</script>"; // redirect(url('Default', 'Index')); } else { echo "你没有访问控制器" . $controller . "中" . $action . "方法的权限"; } }
/** * 构造函数 * * @return FLEA_View_SmartTemplate */ function FLEA_View_SmartTemplate() { parent::SmartTemplate(); $viewConfig = FLEA::getAppInf('viewConfig'); if (is_array($viewConfig)) { foreach ($viewConfig as $key => $value) { if (isset($this->{$key})) { $this->{$key} = $value; } } } }
/** * 向浏览器发送文件内容 * * @param string $serverPath 文件在服务器上的路径(绝对或者相对路径) * @param string $filename 发送给浏览器的文件名(尽可能不要使用中文) * @param string $mimeType 指示文件类型 */ function sendFile($serverPath, $filename, $mimeType = 'application/octet-stream') { header("Content-Type: {$mimeType}"); $filename = '"' . htmlspecialchars($filename) . '"'; $filesize = filesize($serverPath); $charset = FLEA::getAppInf('responseCharset'); header("Content-Disposition: attachment; filename={$filename}; charset={$charset}"); header('Pragma: cache'); header('Cache-Control: public, must-revalidate, max-age=0'); header("Content-Length: {$filesize}"); readfile($serverPath); exit; }
function isLogin() { $this->singleloginechek(); //检测单点登录 //$rbac =& get_singleton('FLEA_Com_RBAC'); $sk = FLEA::getAppInf("RBACSessionKey"); if (isset($_SESSION[$sk])) { return true; } else { return false; } //dump($rbac->getUser()); }
public function Controller_FLGL() { //$this->_M =& FLEA::getSingleton('Model_FLGL'); $this->_V =& $this->_getView(); // ЁУй╪╩╞оШо╒╤тоС FLEA::loadClass("Util_Msg"); $this->_G = new Util_Msg(); // п╢хКCSS,IMG,JSд©б╪ $this->_V->assign(FLEA::getAppInf("vdir")); // ЁУй╪╩╞╣╪╨╫ FLEA::loadClass("Util_Nav"); $this->_N = new Util_Nav(); }
function Controller_Prem() { $this->_M =& FLEA::getSingleton('Model_Prem'); $this->_V =& $this->_getView(); // 初始化消息对象 FLEA::loadClass("Util_Msg"); $this->_G = new Util_Msg(); // 写入CSS,IMG,JS目录 $this->_V->assign(FLEA::getAppInf("vdir")); // 初始化导航 FLEA::loadClass("Util_Nav"); $this->_N = new Util_Nav(); }
/** * 构造函数 * * @return FLEA_View_Lite */ function FLEA_View_Lite() { parent::Template_Lite(); $viewConfig = FLEA::getAppInf('viewConfig'); if (is_array($viewConfig)) { foreach ($viewConfig as $key => $value) { if (isset($this->{$key})) { $this->{$key} = $value; } } } FLEA::loadClass('FLEA_View_SmartyHelper'); new FLEA_View_SmartyHelper($this); }
public function Controller_time() { $this->M_timeinfo =& FLEA::getSingleton('Model_time'); $this->M_chninfo =& FLEA::getSingleton('Model_chninfo'); $this->socketClient = FLEA::getSingleton('Util_socketclient'); $this->_V =& $this->_getView(); FLEA::loadClass("Util_Msg"); $this->_G = new Util_Msg(); // 写入CSS,IMG,JS目录 $this->_V->assign(FLEA::getAppInf("vdir")); // 初始化导航 FLEA::loadClass("Util_Nav"); $this->_N = new Util_Nav(); }
function connect($dsn = false) { $this->lasterr = null; $this->lasterrcode = null; if ($this->conn && $dsn == false) { return true; } if (!$dsn) { $dsn = $this->dsn; } else { $this->dsn = $dsn; } if (isset($dsn['port']) && $dsn['port'] != '') { $host = $dsn['host'] . ':' . $dsn['port']; } else { $host = $dsn['host']; } if (!isset($dsn['login'])) { $dsn['login'] = ''; } if (!isset($dsn['password'])) { $dsn['password'] = ''; } if (!empty($dsn['options'])) { $this->conn = mysql_connect($host, $dsn['login'], $dsn['password'], false, $dsn['options']); } else { $this->conn = mysql_connect($host, $dsn['login'], $dsn['password']); } if (!$this->conn) { FLEA::loadClass('FLEA_Db_Exception_SqlQuery'); return __THROW(new FLEA_Db_Exception_SqlQuery("mysql_connect('{$host}', '{$dsn['login']}') failed!", mysql_error(), mysql_errno())); } if (!empty($dsn['database'])) { if (!$this->selectDb($dsn['database'])) { return false; } } $this->_mysqlVersion = $this->getOne('SELECT VERSION()'); if (isset($dsn['charset']) && $dsn['charset'] != '') { $charset = $dsn['charset']; } else { $charset = FLEA::getAppInf('databaseCharset'); } if ($this->_mysqlVersion >= '4.1' && $charset != '') { if (!$this->execute("SET NAMES '" . $charset . "'")) { return false; } } return true; }
/** * 构造函数 * * @param string $path 模板文件所在路径 * * @return FLEA_View_Simple */ function FLEA_View_Simple($path = null) { log_message('Construction FLEA_View_Simple', 'debug'); $this->path = $path; $this->cacheLifetime = 900; $this->enableCache = true; $this->cacheDir = './cache'; $viewConfig = (array) FLEA::getAppInf('viewConfig'); $keys = array('templateDir', 'cacheDir', 'cacheLifeTime', 'enableCache'); foreach ($keys as $key) { if (array_key_exists($key, $viewConfig)) { $this->{$key} = $viewConfig[$key]; } } }
public function Controller_edit() { $this->_M =& FLEA::getSingleton('Model_devinfo'); $this->M_chninfo = FLEA::getSingleton('Model_chninfo'); $this->_V =& $this->_getView(); // 初始化消息对象 FLEA::loadClass("Util_Msg"); $this->_G = new Util_Msg(); // 写入CSS,IMG,JS目录 $this->_V->assign(FLEA::getAppInf("vdir")); // 初始化导航 FLEA::loadClass("Util_Nav"); $this->_N = new Util_Nav(); $this->log = FLEA::getSingleton('Util_log'); }
/** * @desc 手动判断权限 * @param $rs 需要判断的控制器_操作数组 * @return 权限真假数组 */ public function judgeRight($rs) { // 载入调度器 $dispatcherClass = FLEA::getAppInf('dispatcher'); //FLEA::loadClass($dispatcherClass); $dispatcher = new $dispatcherClass($_GET); //FLEA::register($dispatcher, $dispatcherClass); $right = array(); // 手动检测权限 foreach ($rs as $key => $value) { $i = explode("_", $value); //echo $i[1]."----"; $right[$key] = $dispatcher->check($i[0], $i[1]); //dump($right); } unset($dispatcher); return $right; }
function connect($dsn = false) { $this->lasterr = null; $this->lasterrcode = null; if ($this->conn && $dsn == false) { return true; } if (!$dsn) { $dsn = $this->dsn; } else { $this->dsn = $dsn; } if (isset($dsn['charset']) && $dsn['charset'] != '') { $charset = $dsn['charset']; } else { $charset = FLEA::getAppInf('databaseCharset'); } if (strtoupper($charset) == 'GB2312') { $charset = 'GBK'; } if (empty($dsn['database'])) { $dsn['database'] = null; } if ($charset != '') { $this->conn = ocilogon("{$dsn['login']}", $dsn['password'], $dsn['database'], $charset); } else { $this->conn = ocilogon($dsn['login'], $dsn['password'], $dsn['database']); } if (!$this->conn) { FLEA::loadClass('FLEA_Db_Exception_SqlQuery'); $err = ocierror(); __THROW(new FLEA_Db_Exception_SqlQuery("ocilogon('{$dsn['login']}') failed.", $err['message'], $err['code'])); return false; } $this->execute("ALTER SESSION SET NLS_DATE_FORMAT = '{$this->NLS_DATE_FORMAT}'"); return true; }
/** * 提供对 FLEA::getAppInf() 方法的支持 */ function _pi_func_get_app_inf($params) { return FLEA::getAppInf($params['key']); }
/** * 执行指定的视图 * * @param string $__flea_internal_viewName * @param array $data */ function _executeView($__flea_internal_viewName, $data = null) { $viewClass = FLEA::getAppInf('view'); if ($viewClass == 'PHP') { if (strtolower(substr($__flea_internal_viewName, -4)) != '.php') { $__flea_internal_viewName .= '.php'; } $view = null; foreach ((array) $this->_renderCallbacks as $callback) { call_user_func_array($callback, array(&$data, &$view)); } if (is_array($data)) { extract($data); } include $__flea_internal_viewName; } else { $view =& $this->_getView(); foreach ((array) $this->_renderCallbacks as $callback) { call_user_func_array($callback, array(&$data, &$view)); } if (is_array($data)) { $view->assign($data); } $view->display($__flea_internal_viewName); } }
/** * 分析 url 地址,找出控制器名字和动作名 * * @param string $url * * @return array */ function parseUrl($url) { $url = parse_url($url); $args = array(); parse_str($url['query'], $args); $args = array_change_key_case($args, CASE_LOWER); $controllerAccessor = strtolower(FLEA::getAppInf('controllerAccessor')); $actionAccessor = strtolower(FLEA::getAppInf('actionAccessor')); $controllerName = isset($args[$controllerAccessor]) ? $args[$controllerAccessor] : null; $actionName = isset($args[$actionAccessor]) ? $args[$actionAccessor] : null; unset($args[$controllerAccessor]); unset($args[$actionAccessor]); return array($controllerName, $actionName, $args); }
/** * 准备当前数据表的元数据 * * @param boolean $flushCache * * @return boolean */ function _prepareMeta($flushCache = false) { $cached = FLEA::getAppInf('dbMetaCached'); $cacheId = $this->dbo->dsn['id'] . '/' . $this->fullTableName; $readFromCache = $cached != false && $flushCache == false; if ($readFromCache) { /** * 尝试从缓存读取 */ $meta = FLEA::getCache($cacheId, FLEA::getAppInf('dbMetaLifetime')); if (is_array($meta)) { $this->meta = $meta; return true; } } /** * 从数据库获得 meta */ $this->meta = $this->dbo->metaColumns($this->qtableName); if (!is_array($this->meta) || empty($this->meta)) { FLEA::loadClass('FLEA_Db_Exception_MetaColumnsFailed'); return __THROW(new FLEA_Db_Exception_MetaColumnsFailed($this->qtableName)); } if ($cached) { return FLEA::writeCache($cacheId, $this->meta); } else { return true; } }
/** * 从默认 ACT 文件中载入指定控制器的 ACT * * @param string $controllerName */ function getControllerACTFromDefaultFile($controllerName) { $actFilename = realpath(FLEA::getAppInf('defaultControllerACTFile')); if (!$actFilename) { if (FLEA::getAppInf('controllerACTLoadWarning')) { trigger_error(sprintf(_ET(0x701006), $controllerName), E_USER_WARNING); } return FLEA::getAppInf('defaultControllerACT'); } $ACT = $this->_loadACTFile($actFilename); if ($ACT === false) { return false; } $ACT = array_change_key_case($ACT, CASE_UPPER); $controllerName = strtoupper($controllerName); return isset($ACT[$controllerName]) ? $ACT[$controllerName] : FLEA::getAppInf('defaultControllerACT'); }
/** * 生成 ajax 请求需要的 javascript 脚本 * * @param array $event * @param array $bindEvents * * @return string */ function _insertAjaxRequest($eventArr, &$bindEvents) { list($control, $event, $url, $attribs, $functionName) = $eventArr; $this->_formatAttribs($attribs); $bindEvents[] = " \$(\"{$control}\").bind(\"{$event}\", function() { return {$functionName}(); });"; /** * 构造 ajax 请求函数 */ $beforeRequest = array(); $call = $event == 'submit' ? "\$(\"{$control}\").ajaxSubmit" : "\$.ajax"; /** * 处理 params 属性 */ if (isset($attribs['params'])) { $params = array(); parse_str($attribs['params'], $params); $params = (array) $params; if (!empty($params)) { $params = encode_url_args($params, FLEA::getAppInf('urlMode')); switch (FLEA::getAppInf('urlMode')) { case URL_PATHINFO: case URL_REWRITE: $url .= '/' . $params; break; default: if (strpos($url, '?') === false) { $url .= '?'; } else { $url .= '&'; } $url .= $params; } } unset($attribs['params']); } $attribs['url'] = '"' . t2js($url) . '"'; /** * 默认使用 post 提交请求 */ if (!isset($attribs['type'])) { $attribs['type'] = '"post"'; } /** * 为 target、targetValue 和 clearTarget 属性生成对应的处理代码 */ if (isset($attribs['target']) || isset($attribs['targetValue'])) { $targetType = isset($attribs['target']) ? 'html' : 'val'; $target = $targetType == 'html' ? $attribs['target'] : $attribs['targetValue']; if (isset($attribs['clearTarget']) && $attribs['clearTarget']) { $beforeRequest[] = " {$target}.{$targetType}(\"\");"; } $success = isset($attribs['success']) ? trim($attribs['success']) : ''; if ($success) { $success = preg_replace('/function.+{/i', '{', $success); if (substr($success, -1) != ';') { $success .= ';'; } $success = " {$success}\n"; } $attribs['success'] = <<<EOT function(data) { {$target}.{$targetType}(data); {$success} } EOT; unset($attribs['target']); unset($attribs['targetValue']); unset($attribs['clearTarget']); } $options = ''; foreach ($attribs as $option => $value) { $options .= " {$option}: {$value},\n"; } $options = substr($options, 0, -2); $beforeRequest = implode("\n", $beforeRequest); if ($beforeRequest) { $beforeRequest = "\n{$beforeRequest}"; } $function = <<<EOT function {$functionName}() {{$beforeRequest} {$call}({ {$options} }); return false; } EOT; return $function; }