public function getInstance() { if (!is_object($this->instance) || $this->instance == '') { $this->instance = core::instance('core_file'); } return $this->instance; }
public static function getInstance() { if (null === self::$instance) { self::$instance = new self(true); } return self::$instance; }
public function index() { $crontabs_model = core::instance('crontabs_model'); $data = $crontabs_model->getList(array(), '*', 'id DESC'); $this->assign('data', $data); $this->display('index.html'); }
public static function test() { $m = core::instance('crontabs_model'); $r = $m->getAdapter()->client; var_dump($r); $cache = core_cache_factory::getInstance('filesystem'); $cache->set('testkey', '123123123'); }
public static function getInstance() { if (!isset(self::$instance)) { $object = __CLASS__; self::$instance = new $object(); } return self::$instance; }
static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public static function getInstance($type = '', $timeout = 0) { $client = "core_request_factory_{$type}"; if (class_exists($client)) { return core::instance($client, $timeout); } else { throw new core_exception("request client error: " . $client . " is not exists."); } }
public function getRender() { $render = core::instance('core_template'); $render->template_dir = core::getConfig('template_dir'); $render->compile_dir = core::getConfig('compile_dir'); $render->tpl_left_delim = core::getConfig('tpl_left_delim'); $render->tpl_right_delim = core::getConfig('tpl_right_delim'); return $render; }
public static function getInstance($type = '', $options = array()) { $client = "core_database_adapter_{$type}"; if (class_exists($client)) { return core::instance($client, $options); } else { throw new core_exception("database client error: " . $client . " is not exists."); } }
public static function getInstance($type = '', $params = array()) { $client = "core_cache_factory_{$type}"; if (class_exists($client)) { return core::instance($client, $params); } else { throw new core_exception("cache client error: " . $client . " is not exists."); } }
/** * 编译模版文件 * * @param string $tpl * @return void */ private function compile($tpl = '') { $tplFile = $this->getTplPath($tpl); $compileFile = $this->getCompilePath($tpl); $tplContent = core::instance('core_file')->read($tplFile); $this->parseVar($tplContent); $this->parseTag($tplContent); $md5 = md5_file($tplFile); $expireTime = time(); $tplHeader = "<?php \n/* \nCore Template Compile \nCreated on: " . date('Y-m-d H:i:s', $expireTime) . " \n*/ \n\$this->checkCompile('{$tpl}','{$md5}','{$expireTime}');\n?>\n"; $tplContent = $tplHeader . $tplContent; core::instance('core_file')->write($compileFile, $tplContent); }
/** * 分派执行 * * @return void */ public static function dispatch() { $controller = self::$boot[self::getConfig('mvc_controller')]; $action = self::$boot[self::getConfig('mvc_action')]; $controllerClassName = $controller . '_controller'; $controllerClass = core::instance($controllerClassName); $hashkey = core_debug::info('controller: ' . $controllerClassName . '::' . $action . '() , run ...'); $controllerClass->exec($action); core_debug::info('controller: ' . $controllerClassName . '::' . $action . '() , end .', $hashkey); if (self::getConfig('core_debug') && strpos(PHP_SAPI, 'cli') === false) { core_debug::output(); } }
/** * 模板渲染输出 * * @param string $template 模板文件 * @return html */ protected function display($template = '') { return core::instance('core_page')->display($template); }
public function __construct() { $this->crontabsModel = core::instance('crontabs_model'); $this->crontabsLogsModel = core::instance('crontabs_logs_model'); }
public function __construct($options = array()) { $this->client = core::instance('core_database_client_pdo', $options); }
public static function output() { $included = self::getIncludedFiles(); $endinfo = end(self::$info); $sql = self::$sql; $sqlQueryTimes = 0; foreach (self::$sql as $v) { $sqlQueryTimes += str_replace('s', '', $v['time']); } $sqlQueryTimes = self::getFomatTime(0, $sqlQueryTimes); $html = "<style>.core-debug-output{ font:12px Consolas,Courier;color:#333;}.core-debug-output b{color:#2B82C7}.core-debug-output span{display:block;height:20px;line-height:20px;text-align:left;padding-left:5px;background:#F3F3F3;}.core-debug-output p{margin:0;padding:3px 5px;border-bottom:0px solid #ddd;}.core-debug-output p font{}.core-debug-table{font-size:12px;}.core-debug-table tr td{background:#F4F4F4;}</style>"; //Basic $html .= "<div class='core-debug-output'><span><b>Basic</b></span>"; $html .= "<table class='core-debug-table'>\r\n <tr>\r\n <td>RunTime</td>\r\n <td>" . $endinfo['time'] . "</td>\r\n </tr>\r\n <tr>\r\n <td>Memory</td>\r\n <td>" . $endinfo['memory'] . "</td>\r\n </tr>\r\n <tr>\r\n <td>Include</td>\r\n <td>" . count($included) . "</td>\r\n </tr>\r\n <tr>\r\n <td>Cache</td>\r\n <td>SET=" . self::getCounter('cache_set') . " GET=" . self::getCounter('cache_get') . " DELETE=" . self::getCounter('cache_delete') . " FLUSH=" . self::getCounter('cache_flush') . "</td>\r\n </tr>\r\n </table>"; $html .= "</div>"; //Flow $html .= "<div class='core-debug-output'><span><b>Flow</b> (" . count(self::$info) . ")</span><table class='core-debug-table'><tr><td width=15%>*Time</td><td width=15%>*Memory</td><td>*Info</td></tr>"; foreach (self::$info as $v) { $html .= "<tr>\r\n <td>" . $v['time'] . "</td>\r\n <td>" . $v['memory'] . "</td>\r\n <td>" . $v['info'] . "</td></tr>"; } $html .= "</table></div>"; //Include $html .= "<div class='core-debug-output'><span><b>Include</b> (" . count($included) . ")</span><table class='core-debug-table'><tr><td width=15%>*Size</td><td>*File</td></tr>"; foreach ($included as $v) { $fileinfo = core::instance('core_file')->getFileInfo($v); $html .= "<tr>\r\n <td>" . self::getSizeUsage($fileinfo['size']) . "</td>\r\n <td>" . $v . "</td></tr>"; } $html .= "</table></div>"; echo $html; }
public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new core(); } return self::$instance; }
<?php define('APP_DIR', realpath(dirname(__FILE__))); include_once '/sites/lnmp/code/core/lib/core.php'; $config = (include_once APP_DIR . '/config/config.php'); core::init($config); $tTime = time(); $crontab = core::instance('core_crontab'); $crontabsModel = core::instance('crontabs_model'); $crontabsLogsModel = core::instance('crontabs_logs_model'); $filter = array('status' => 0, 'dispatch' => 1, 'time|>=' => $tTime - 10, 'time|<=' => $tTime + 10); $crontabsList = $crontabsModel->getList($filter, '*', 0, -1, "id ASC"); if ($crontabsList) { foreach ($crontabsList as $job) { $nextExecTime = $job['time'] + $job['space'] * 60; $crontab->addScript($job['id'], $job['script'], $nextExecTime); $crontabsModel->update(array('status' => 1), array('id' => $job['id'])); } $crontab->exec(); }
public function __construct() { $this->render = core::instance('core_page')->getRender(); $this->render->template_dir = core::getConfig('widget_dir'); $this->render->mark = 'widget'; }