public static function setToken()
{
if (!isset($_COOKIE['CML_TOKEN']) || empty($_COOKIE['CML_TOKEN'])) {
$str = substr(md5(Cml::$nowTime . Request::getService('HTTP_USER_AGENT')), 5, 8);
setcookie('CML_TOKEN', $str, null, '/');
$_COOKIE['CML_TOKEN'] = $str;
}
}
/** * 渲染模板获取内容 调用内置的模板引擎显示方法, * * @param string $templateFile 指定要调用的模板文件 默认为空 由系统自动定位模板文件 * @param bool $inOtherApp 是否为载入其它应用的模板 * * @return string */ public function fetch($templateFile = '', $inOtherApp = false) { if (Config::get('form_token')) { Secure::setToken(); } if (!empty($this->args)) { extract($this->args, EXTR_PREFIX_SAME, "xxx"); $this->args = array(); } ob_start(); require $this->getFile($this->initBaseDir($templateFile, $inOtherApp)); return ob_get_clean(); }