private function _format($id, $data, $type) { switch ($type) { case '1': // json if (CHARSET == 'gbk') { $data = array_iconv($data, 'gbk', 'utf-8'); } return json_encode($data); break; case '2': // xml $xml = Loader::lib('Xml'); return $xml->xml_serialize($data); break; case '3': // js Loader::func('dbsource:global'); ob_start(); include template_url($id); $html = ob_get_contents(); ob_clean(); return format_js($html); break; } }
public function initialize() { //获取站点配置 if (!isset($_SERVER['QUERY_STRING'])) { $_SERVER['QUERY_STRING'] = ''; } $setting = model('setting')->where('siteid', 1)->getOne(); $data['SEO'] = array(); $data['SEO']['title'] = $setting['title']; $data['SEO']['keywords'] = $setting['keywords']; $data['SEO']['description'] = $setting['description']; $template = $setting['template']; //站点配置中的前台模板 $data['page'] = isset($_GET['page']) ? $_GET['page'] : 1; $this->assign($data); unset($setting); Config::set(array('cache' => 1), 'database'); Config::template(); //载入模板配置,防止将所有的配置替换 //==配置模板风格和静态缓存生存时间 Config::set(array('view_name' => $template, 'template_parse' => 'template_parse', 'view_cache' => Config::cms('view_cache'), 'leftDelim' => Config::cms('tpl_leftDelim'), 'rightDelim' => Config::cms('tpl_rightDelim')), 'template'); Loader::func('gouwanmei'); //error_reporting(1); Config::set(array('debug' => 0), 'config'); }
public function __construct($config = array()) { if (!empty($config)) { $this->set_config($config); } $this->config['gateway_url'] = 'https://pay3.chinabank.com.cn/PayGate'; $this->config['gateway_method'] = 'POST'; $this->config['return_url'] = return_url('chinabank'); Loader::func('pay:alipay'); }
public function __construct($config = array()) { if (!empty($config)) { $this->set_config($config); } if ($this->config['service_type'] == 1) { $this->config['service'] = 'trade_create_by_buyer'; } elseif ($this->config['service_type'] == 2) { $this->config['service'] = 'create_direct_pay_by_user'; } else { $this->config['service'] = 'create_partner_trade_by_buyer'; } $this->config['gateway_url'] = 'https://www.alipay.com/cooperate/gateway.do?_input_charset=' . CHARSET; $this->config['gateway_method'] = 'POST'; $this->config['notify_url'] = return_url('alipay', 1); $this->config['return_url'] = return_url('alipay'); Loader::func('pay:alipay'); }
public function initialize() { Config::database(); //加载数据库配置 Loader::func('gouwanmei'); //引入全局函数 Config::set(array('cache' => 1), 'database'); if (!isset($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = ''; } //var_dump($_SERVER); $this->cacheKey = $_SERVER['REQUEST_URI']; //获取站点配置 $setting = model('website')->where('siteid', 1)->getOne(); $this->setting = $setting; $data['SEO'] = array(); $data['SEO']['title'] = $setting['title']; $data['SEO']['keywords'] = $setting['keywords']; $data['SEO']['description'] = $setting['description']; $template = $setting['template']; //站点配置中的前台模板 $data['website'] = $setting; $data['page'] = isset($_GET['page']) ? $_GET['page'] : 1; $data['user'] = Module('member')->isLogin($data['website']['membertokentype']); //用户登录状态 $this->assign($data); unset($setting); Config::template(); //载入模板配置,防止将所有的配置替换 //==配置模板风格和静态缓存生存时间 //==配置模板风格和静态缓存生存时间 Config::set(array('view_name' => $template, 'template_parse' => 'template_parse', 'view_cache' => Config::cms('view_cache'), 'leftDelim' => Config::cms('tpl_leftDelim'), 'rightDelim' => Config::cms('tpl_rightDelim'), 'img_path' => Config::cms('img_path'), 'js_path' => Config::cms('js_path'), 'css_path' => Config::cms('css_path')), 'template'); //如果使用手机进入则会用mobile模板 if (isset($_SERVER['HTTP_USER_AGENT'])) { if (preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT'])) { Config::set(array('view_name' => 'mobile'), 'template'); } } Config::set(array('debug' => Config::cms('debug')), 'config'); }
<?php if (!defined('__ROOT__')) { exit('Sorry,Please from entry!'); } /** * init 入口引入文件 * 项目自动初始化文件 * 创建时间:2014-08-08 14:56 PGF */ Loader::core('Debug'); //加载DEBUG类 Debug::start(); //程序开始 Loader::func('Base'); //加载基础全局函数 Loader::core('Cache'); //加载缓存处理类 Cache::init(); //初始化缓存类 //向日志中添加已经加载的Loader Debug::add(__ROOT__ . Config::config('core_dir') . '/bases/' . 'Loader.class.php', 1); Loader::core('Router'); //加载Router Router::run(); //Router运行 Debug::stop(); //程序结束 //==================== END Initialize.php ========================//