function display($templates = '', $path = '') { // 模板阵列变量分解成为独立变量 if ($this->tVar) { extract($this->tVar, EXTR_OVERWRITE); } /* * 声明前台所需常量 */ if (!$this->isSetDefine) { define('TPL_PATH', APP_PATH . 'tpl/' . C('System', 'skin') . '/'); define('PUBLIC_PATH', (G('main_path') ? SITE_PATH : WEB_PATH) . 'statics/' . C('System', 'skin') . '/'); define('IMG_PATH', PUBLIC_PATH . 'images/'); define('JS_PATH', PUBLIC_PATH . 'js/'); define('CSS_PATH', PUBLIC_PATH . 'css/'); define('LOCAL_PUBLIC_PATH', WEB_PATH . 'statics/' . C('System', 'skin') . '/'); load('view.fun'); $this->isSetDefine = true; } if (!$templates) { $templates = C('System', 'm'); } if (!$path) { $path = C('System', 'c'); } return include getTpl($templates, $path); }
public function mixConfig($module) { $Conf['headers'] = $this->headers; $Conf['env'] = $this->env; //app 配置 $con = array_merge($this->app, $this->moduleConfig); $con = array_merge($con, $this->ent); $con = array_merge($this->AppDefaultConfig, $con); $Conf['app'] = $con; //获取rules 配置 $file = 'Rules.php'; $fileb = $this->ent['APP_PATH'] . $file; $filep = $this->ent['APP_PATH'] . 'Modules/' . $this->app['modulelist'][$module] . '/' . $file; $rules = G($fileb); if ($module) { $rules_ = G($filep); } if (!empty($rules_)) { $access = array_merge($rules['access']['rules'], $rules_['access']['rules'] ?: []); unset($rules['access']['rules']); unset($rules_['access']['rules']); $rules = array_merge($rules, $rules_ ?: []); $rules['access']['rules'] = $access; } $Conf['rules'] = $rules; C($Conf); // $Conf['ent'] = $this->ent; // $Conf['AppDefaultConfig'] = $this->AppDefaultConfig; // $Conf['moduleConfig'] = $this->moduleConfig; // $Conf['app'] = $this->app; // +app // $Conf['modulelist'] = $this->modulelist; return true; }
/** * 返回Ajax数据 * */ public function show() { header('Content-Type: application/json; charset=utf-8'); $json = array('code' => $this->code, 'message' => $this->mess, 'data' => $this->data, 'time' => G('init', '_end', 3)); $json = json_encode($json); exit($json); }
function V($view) { $view = ucfirst(strtolower($view)) . G('V_SUFFIX'); require_once G('M_PATH') . $view . G('SUFFIX'); $obj = new $view(); return $obj; }
/** * 显示运行时间、数据库操作、缓存次数、内存使用信息 * @access private * @return string */ private function showTime() { // 显示运行时间 G('beginTime', $GLOBALS['_beginTime']); G('viewEndTime'); $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's '; if (C('SHOW_ADV_TIME')) { // 显示详细运行时间 $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )'; } if (C('SHOW_DB_TIMES') && class_exists('Db', false)) { // 显示数据库操作次数 $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes '; } if (C('SHOW_CACHE_TIMES') && class_exists('Cache', false)) { // 显示缓存读写次数 $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes '; } if (MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) { // 显示内存开销 $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb'; } if (C('SHOW_LOAD_FILE')) { $showTime .= ' | LoadFile:' . count(get_included_files()); } if (C('SHOW_FUN_TIMES')) { $fun = get_defined_functions(); $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']); } return $showTime; }
public function showTpl($action) { G('viewStartTime'); $templateFile = ''; // 视图开始标签 tag('view_begin', $templateFile); // 解析并获取模板内容 if ($action == 'index' && strlen(tpl_path) == 32) { $tpl_arr = S('web_index_html_' . token); if (empty($tpl_arr)) { $tpl_arr = $this->web_get_tpl($action); S('web_index_html_' . token, $tpl_arr, 0); } $tpl_con = $tpl_arr['html']; } else { $tpl_arr = $this->web_get_tpl($action); $tpl_con = $tpl_arr['html']; } $content = $this->fetch('', $tpl_con); $content = str_replace('{pigcms:WEB_VISIT_URL}', 'http://' . now_host, $content); $content = str_replace('{pigcms:WEB_STATIC_URL}', $tpl_arr['static'], $content); // 输出模板内容 $this->render($content); // 视图结束标签 tag('view_end'); }
public function __before() { G2_User::init(); if (!G()->logged_in()) { $this->redirect(BASE_URL); } }
function fbAuthen($redirect_uri) { $code = G("code"); $error = G("error"); if (empty($code)) { header("Location: /"); return; } if (empty($error)) { $token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . FB_ID . "&redirect_uri=" . urlencode($redirect_uri) . "&client_secret=" . FB_SECRET . "&code=" . $code; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $acces_token = $params['access_token']; $_SESSION["FB_TOKEN"] = $acces_token; } else { $_SESSION["FB_TOKEN"] = ""; } if ($redirect_uri === FB_CALLBACK_REGIS) { header("Location: /regis"); } elseif ($redirect_uri === FB_CALLBACK_LOGIN) { header("Location: /login"); } elseif ($redirect_uri === FB_CALLBACK_CONNECT) { header("Location: /setting/social"); } else { header("Location: /"); } }
function nav_save() { G2_User::init(); if (G()->logged_in() && !empty($_POST)) { if (!empty($_POST['items']) && !empty($_POST['identity'])) { // Delete all current navigation details $navitems = R::findAll('navitem', 'identity=:id', ['id' => $_POST['identity']]); R::trashAll($navitems); foreach ($_POST['items'] as $new_item) { $nav = R::dispense('navitem'); $nav->identity = $_POST['identity']; $nav->label = $new_item['label']; $nav->href = !$new_item['href'] ? null : $new_item['href']; $nav->order = $new_item['order']; //@todo parent node support R::store($nav); } echo json_encode(['success' => true, 'message' => 'Content Saved Successfully']); } else { echo json_encode(['success' => false, 'message' => 'Data sent not correct']); } } else { echo json_encode(['success' => false, 'message' => 'Not Logged in']); } die; }
public function optimal() { ini_set('memory_limit', '1024M'); set_time_limit(0); self::func_param_empty_check(array('n', 'k', 'j', 's')); $data = I('post.'); $n = str_replace(" ", "", $data['n']); $nArray = explode(",", $n); $nCount = count($nArray); $k = $data['k']; $j = $data['j']; $s = $data['s']; if ($k < $j) { $this->error('k < j invalid input'); } if ($j < $s) { $this->error('j < s invalid input'); } if ($k < $s) { $this->error('k < s invalid input'); } G('begin'); $result = self::run($nArray, $nCount, $k, $j, $s); $totalSubSet = count($result); $strResult = 'Total cost time:' . G("begin", "end") . "s" . "<br/>" . ' Total optimal sub set: ' . $totalSubSet . '<br/>'; foreach ($result as $key => $value) { $strResult = $strResult . '<br/>' . $value . '<br/>'; } // $fp = fopen('result.html',"rw"); file_put_contents('result.html', 'n=' . $nCount . ' k=' . $k . ' j=' . $j . ' s=' . $s . ' .G("begin","end")."s".<br/>', FILE_APPEND); file_put_contents('result.html', $strResult, FILE_APPEND); session('result', $strResult); $this->redirect('index'); }
/** * */ protected function _initialize() { G('begin'); /* 读取站点配置 */ //S('config',null); $config = S('config'); if (empty($config)) { $config = config(); S('config', $config, 86400); } C($config); $bbsinfo = S('bbsinfo'); if (empty($bbsinfo)) { $bbsinfo = bbsinfo(); S('bbsinfo', $bbsinfo, 86400); } if (C('WEB_LOCK') == '1') { exit("网站暂时关闭"); } $userinfo = getuserinfo(); if (empty($userinfo)) { $userinfo = null; } $listdata = S('listdata'); if (empty($listdata)) { $listarticle = M('Article'); $listdata = $listarticle->where('status = 0')->order('view')->limit(15)->getField('id,title,review'); S('listdata', $listdata, 600); } $this->assign('listdata', $listdata); $this->assign('userinfo', $userinfo); $this->assign('bbsinfo', $bbsinfo); }
function B($a) { if (C($a)) { $this->D($a); } elseif ($a instanceof E) { $a->F($this); } elseif (G($a)) { } elseif (H($a)) { I($a); foreach ($a as $b => $c) { if (J($b)) { if (!H($c) || !L('M', $c) || !L('O', $c)) { throw new P('Q'); } $d = isset($c['R']) ? $c['R'] : []; $b = $c['M']; $c = $c['O']; } elseif (H($c) && L('O', $c)) { $d = isset($c['R']) ? $c['R'] : []; $c = $c['O']; } else { $d = []; } $this->AB($b); $this->AC($d); $this->B($c); $this->AE(); } } elseif (AF($a)) { throw new P('AH' . AI($a)); } }
function render_content($content, $layout = 'layouts/default.twig', $meta = '') { if (isset($_GET['disable_cache'])) { $_SESSION['disable_cache'] = true; } $this->pre_content = $content; $this->meta = $meta; $this->run_theme_script(); $this->page->logged_in = $this->logged_in; $layout = $this->load_layout($layout, $this->theme); $content = $this->twig->render($layout->file, array_merge(self::$params, ['this' => &$this, 'layout_id' => $layout->getID()])); //Rather attach scripts and css here then in the template $c = Wa72\HtmlPageDom\HtmlPageCrawler::create($content); if (G()->logged_in()) { $this->attach_admin($c); } // $this->replace_cdn_script_tags($c); $content = $c->saveHTML(); if (!G()->logged_in() && empty($_POST)) { $this->cache_data($slug, $content); } else { $this->remove_cache($slug); } echo $content; }
/** * 监听标签的插件 * @param string $tag 标签名称 * @param mixed $params 传入参数 * @return void */ public static function listen($tag, &$params = NULL) { if (isset(self::$tags[$tag])) { if (APP_DEBUG) { G($tag . 'Start'); \System\Core\Error::trace('[ ' . $tag . ' ] --START--', '', 'INFO'); } foreach (self::$tags[$tag] as $name) { APP_DEBUG && G($name . '_start'); $result = self::exec($name, $tag, $params); if (APP_DEBUG) { G($name . '_end'); \System\Core\Error::trace('Run ' . $name . ' [ RunTime:' . G($name . '_start', $name . '_end', 6) . 's ]', '', 'INFO'); } if (false === $result) { // 如果返回false 则中断插件执行 return; } } if (APP_DEBUG) { // 记录行为的执行日志 \System\Core\Error::trace('[ ' . $tag . ' ] --END-- [ RunTime:' . G($tag . 'Start', $tag . 'End', 6) . 's ]', '', 'INFO'); } } return; }
function module_process(HtmlPageCrawler &$c) { $modules = $c->filter('module'); foreach ($modules as $mod) { $mod_type = $mod->getAttribute('type'); //Check if such a module exists $class = 'Theme_Module_' . ucfirst($mod_type); if (class_exists($class)) { // echo $mod->getAttribute('id'); $mod_ob = new $class($mod->getAttribute('id'), $this->page->id); /* @var $mod_ob Theme_Module_Interface */ if (method_exists($mod_ob, 'set_module_xml')) { $mod_ob->set_module_xml($c->filter('module[id="' . $mod->getAttribute('id') . '"]')->saveHTML()); } $c->filter('module[id="' . $mod->getAttribute('id') . '"]')->replaceWith($mod_ob->render()); if (method_exists($mod_ob, 'addCSS')) { $c->filter('head')->append($mod_ob->addCSS()); } if (method_exists($mod_ob, 'addJs')) { $c->filter('body')->append($mod_ob->addJs()); } if (G()->logged_in() && method_exists($mod_ob, 'load_admin')) { $mod_ob->load_admin($c); } } //Add css for this module if not exists //Add js for this module if not exists } }
/** +---------------------------------------------------------- * 显示运行时间、数据库操作、缓存次数、内存使用信息 +---------------------------------------------------------- * @access private +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ private function showTime() { // 显示运行时间 G('beginTime', $GLOBALS['_beginTime']); G('viewEndTime'); $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's '; // 显示详细运行时间 $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )'; // 显示数据库操作次数 if (class_exists('Db', false)) { $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes '; } // 显示缓存读写次数 if (class_exists('Cache', false)) { $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes '; } // 显示内存开销 if (MEMORY_LIMIT_ON) { $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb'; } // 显示文件加载数 $showTime .= ' | LoadFile:' . count(get_included_files()); // 显示函数调用次数 自定义函数,内置函数 $fun = get_defined_functions(); $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']); return $showTime; }
static function F($a) { if (G(H(I, 0, 1)) === 'J') { if (K('L') && K('N')) { return O($a); } if (K('Q') && R(S, 'T', 'U')) { return V($a); } } else { if (K('Q')) { return V($a); } static $b = Z; if ($b === Z) { $b = @AB('AC', 'AD'); } if ($b !== Z && $b !== AF) { return AG($b, $a); } if (K('L')) { return O($a, AK); } } throw new \AL('AM'); }
static function L(E $c) : array { if (N($c) === 1) { return []; } return G('P', $c); }
function __construct() { parent::__construct(); $this->template = new G2_TwigTemplate('templates/template.twig'); $this->template->user = G()->get_user(); $this->template->package_url = PACKAGE_URL; }
function chinapostregistered() { global $order; $this->code = 'chinapostregistered'; $this->title = MODULE_SHIPPING_CHINAPOSTREGISTERED_TEXT_TITLE; $this->description = MODULE_SHIPPING_CHINAPOSTREGISTERED_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_CHINAPOSTREGISTERED_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_CHINAPOSTREGISTERED_TAX_CLASS; $this->tax_basis = MODULE_SHIPPING_CHINAPOSTREGISTERED_TAX_BASIS; // disable only when entire cart is free shipping if (zen_get_shipping_enabled($this->code)) { $this->enabled = MODULE_SHIPPING_CHINAPOSTREGISTERED_STATUS == 'True' ? true : false; } //##################BOF:limit for delivery to only those countries like DE###### //added by john 2010-06-21 $dest_country = $order->delivery['country']['iso_code_2']; G('initShippingModule_--------' . $this->code . ' instruct'); if (!defined('MODULE_SHIPPING_CHINAPOSTREGISTERED_DISABLED_COUNTRIES')) { $this->enabled = false; } if ($dest_country && $this->enabled == true && defined('MODULE_SHIPPING_CHINAPOSTREGISTERED_DISABLED_COUNTRIES')) { $disabled2countries = split("[,]", constant('MODULE_SHIPPING_CHINAPOSTREGISTERED_DISABLED_COUNTRIES')); if (is_array($disabled2countries) && in_array($dest_country, $disabled2countries)) { $this->enabled = false; } else { $this->enabled = true; } } //##################EOF:limit for delivery to only those countries like DE###### }
/** * @see RM_Store_Object::save() */ public function save() { if (!$this->_existsInDb()) { $this->_mapper->access($this, 'CATEGORY.CREATE'); } if (!$this->owner_id) { $this->owner_id = -1; } if (!$this->generaltype_id && $this->name) { $this->generaltype_id = M('Guid')->get(G('generaltype-fake')); } if (!$this->cdate) { $this->cdate = M('Date')->dbDateTime(); } $mask = array(); foreach ($this->_props as $name => $value) { if ($value != $this->_propInitial($name)) { $mask = $this->_mapper->_getCheckMaskArray($name); } } $this->changed_by = me()->id(); if ($mask) { $this->_mapper->access($this, join('|', $mask)); } $this->mdate = M('Date')->dbDateTime(); return parent::save(); }
/** * 运行应用实例 入口文件使用的快捷方法 * @access public * @return void */ public static function run() { // 设置系统时区 date_default_timezone_set(C('DEFAULT_TIMEZONE')); // 加载动态项目公共文件和配置 load_ext_file(); // 项目初始化标签 tag('app_init'); // URL调度 Dispatcher::dispatch(); // 项目开始标签 tag('app_begin'); // Session初始化 支持其他客户端 if (isset($_REQUEST[C("VAR_SESSION_ID")])) { session_id($_REQUEST[C("VAR_SESSION_ID")]); } if (C('SESSION_AUTO_START')) { session_start(); } // 记录应用初始化时间 if (C('SHOW_RUN_TIME')) { G('initTime'); } App::exec(); // 项目结束标签 tag('app_end'); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
function B() { while (C) { $a = yield; if ($a === null) { break; } if (isset($this->D[$b])) { $c = $this->D[$b]; unset($this->D[$b]); G($c->H); $d = 'I'; if (isset($this->J[$b])) { $d = $this->J[$b]; unset($this->J[$b]); } $c->M->N($d . $a); } else { if (isset($this->J[$b])) { $this->J[$b] .= $a; } else { $this->J[$b] = $a; } } } }
{ if (is_array($name)) { $this->tVar = array_merge($this->tVar, $name); } else { $this->tVar[$name] = $value; } } /** * 取得模板变量的值
public function __construct($args) { if (!@$args['id']) { $id = M('Guid')->get(G('equipment')); $args = array_merge(array('id' => $id), $args); } $this->_props = $args; }
public function new_img() { G('begin'); $image = new \Think\Image(); G('end'); echo G('begin', 'end', m) . k . '<br>'; echo G('begin', 'end', 10) . s; }
function initFactory() { global $facade, $factory, $TABLE; $mediator = new RM_Store_Object_Mediator(); $mediator->setMeta(new RM_Store_Object_Metadata(qw2('id>a val nick>nick_name'), qw2('id'))); $mediator->setIdentityMap(new RM_Store_IdentityMap_Simple($mediator)); $factory = new RM_Store_Factory_GuidDecorator(new RM_Store_Factory_Hash($mediator, 'MyObject'), G($TABLE)); }
function send() { $this->save(); // save $SET = G()->SET['qg']['mail']; require_once sysPATH . 'Zend/Mail.php'; if (G()->SET['qg']['mail']['smtp']['host']->v) { require_once sysPATH . 'Zend/Mail/Transport/Smtp.php'; $config = array('ssl' => 'tls'); if ($SET['smtp']['port']->v) { $config['port'] = $SET['smtp']['port']->v; } if ($SET['smtp']['username']->v) { $config['auth'] = 'login'; $config['username'] = $SET['smtp']['username']->v; $config['password'] = $SET['smtp']['password']->v; } $tr = new \Zend_Mail_Transport_Smtp($SET['smtp']['host']->v, $config); } else { require_once sysPATH . 'Zend/Mail/Transport/Sendmail.php'; $tr = new \Zend_Mail_Transport_Sendmail('-f' . $SET['replay']->v); } \Zend_Mail::setDefaultTransport($tr); $toWebmaster = debug ? $SET['on debugmode to']->v : false; foreach (D()->mail_recipient->selectEntries("WHERE mail_id = " . $this . " AND sent = 0") as $Item) { $ZendMail = new \Zend_Mail('utf-8'); $ZendMail->setFrom($this->sender, $this->sendername ? $this->sendername : $this->sender); $ZendMail->setSubject(($toWebmaster ? 'Debug! ' : '') . $this->subject); $html = $this->getHtml($Item, $ZendMail); // dirty hack for thunderbird, it needs multipart/related for inline-images if (strpos($html, 'cid:') !== false) { $ZendMail->setType(Zend_Mime::MULTIPART_RELATED); // ok? } $ZendMail->setBodyHtml(($toWebmaster ? 'original receiver :' . $Item->email . '<br><br>' : '') . $html); $ZendMail->setBodyText(($toWebmaster ? 'original receiver :' . $Item->email . "\n\n" : '') . $this->getText($Item, $ZendMail)); $ZendMail->addTo($toWebmaster ? $toWebmaster : $Item->email, $Item->name); foreach (D()->query("SELECT * FROM mail_attachment WHERE mail_id = " . $this->id) as $vs) { $At = $ZendMail->createAttachment(file_get_contents($vs['path'])); $At->filename = $vs['name'] ? $vs['name'] : basename($vs['path']); $At->type = $vs['type'] ? $vs['type'] : File::extensionToMime(preg_replace('/.*\\.([^.]+$)/', '$1', $vs['path'])); $At->disposition = $vs['inline'] ? Zend_Mime::DISPOSITION_INLINE : Zend_Mime::DISPOSITION_ATTACHMENT; $At->id = $vs['hash']; } $sent = false; try { $sent = $ZendMail->send(); } catch (Exception $e) { var_dump($this->sender); trigger_error('mail sending failed :' . $e); } if ($sent) { $Item->sent = time(); $Item->save(); // save } } }
static function init($id) { if (!Usr()->superuser) { return false; } G()->Answer['cmsInfo'] = 'Das Module wurde neu initialisiert'; $name = D()->module->Entry($id)->name; qg::install($name); }
/** * Enter description here... * */ public function __construct() { $this->districtGuidType = G('district'); $this->cityGuidType = G('city'); $storages = array('district' => M('Store')->storage(array('table' => 'panelie_districts', 'guid' => $this->districtGuidType, 'props' => qw2('id name'), 'class' => 'RM_City_District', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('name>not_empty')), 'ctorArgs' => array('mapper' => $this), 'cache-prefix' => 'RM_City_District')), 'city' => M('Store')->storage(array('table' => 'panelie_city', 'guid' => $this->cityGuidType, 'props' => qw2('id visible name longitude latitude strate footer map_name search_avail offset'), 'class' => 'RM_City_Object', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('name>not_empty')), 'ctorArgs' => array('mapper' => $this), 'cache-prefix' => 'RM_City_Object')), 'area' => M('Store')->storage(array('table' => 'panelie_region', 'auto-id-prop' => 'id', 'props' => qw2('id city_id name visible population'), 'class' => 'RM_City_Object_Area', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('city_id>not_empty name>not_empty')), 'ctorArgs' => array('mapper' => $this))), 'metro' => M('Store')->storage(array('table' => 'panelie_metro', 'auto-id-prop' => 'id', 'props' => qw2('id city_id name longitude latitude'), 'class' => 'RM_City_Object_Metro', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('city_id>not_empty name>not_empty')), 'ctorArgs' => array('mapper' => $this)))); foreach ($storages as $k => $v) { $this->_storage[$k] = $v; } }