示例#1
0
文件: page.php 项目: Junec/core
 /**
  * 模板渲染
  * 
  * @param string $template 模板文件
  * @return htmlcode
  */
 public function fetch($template = '')
 {
     $hashkey = core_debug::info('compile template: ' . $template);
     $html = $this->getRender()->fetch($template);
     core_debug::upTime($hashkey);
     return $html;
 }
示例#2
0
 public function __construct()
 {
     $this->_properties = array_keys(get_object_vars($this));
     if (array_pop($this->_properties) != '_properties') {
         core_debug::i()->add('500', 'Core Error', '_properties is not last item in array');
     }
 }
示例#3
0
 public static function i()
 {
     if (self::$instance === null) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
示例#4
0
文件: filesystem.php 项目: Junec/core
 public function __construct($params = array())
 {
     if (!isset($params['cache_dir']) || !$this->getInstance()->isDir($params['cache_dir'])) {
         $this->savepath = core::getConfig('cache_filesystem_dir');
     } else {
         $this->savepath = $params['cache_dir'];
     }
     core_debug::info('set filesystem dir: ' . $this->getSavePath());
 }
示例#5
0
 public function grabEventsFromEmailAction()
 {
     //echo phpinfo();
     $m = new manage_model_event();
     $m->emailGrab();
     core_debug::dump($m);
     core_debug::dump(imap_errors());
     die('at ctrl');
 }
示例#6
0
文件: widget.php 项目: Junec/core
 public function display($params = array())
 {
     $loadWidgetHashkey = core_debug::info('load widget: ' . get_class($this));
     $params = $this->params($params);
     $compileWidgetHashkey = core_debug::info('compile widget: ' . $this->tpl());
     $this->render->display($this->tpl());
     core_debug::upTime($loadWidgetHashkey);
     core_debug::upTime($compileWidgetHashkey);
 }
示例#7
0
文件: redis.php 项目: Junec/core
 public function __construct($params = array())
 {
     $host = $params['host'];
     $port = !empty($params['port']) ? $params['port'] : 6379;
     if ($host != '') {
         core_debug::info('add redis server: ' . $host . ":" . $port);
         $this->getInstance()->connect($host, $port);
     } else {
         throw new Exception('can\'t load cache_redis_host, please check it.');
     }
 }
示例#8
0
文件: log.php 项目: vgalitsky/moze
 static function log($message, $logfile = 'core.log')
 {
     if (!is_string($message)) {
         $message = core_debug::dump($message, false);
     }
     $message = date('[m-d-Y H:i:s]:') . $message;
     $fpath = app::getConfig('dir/sd') . DS . self::LOG_DIR . DS . $logfile;
     core_fs::createDirIfNotExists(dirname($fpath));
     $fh = fopen($fpath, 'a+');
     fputs($fh, $message . "\n");
     fclose($fh);
     return $message;
 }
示例#9
0
 public function rndAction()
 {
     for ($i = 0; $i < 100; $i++) {
         $lt = rand(1, 10);
         $lng = rand(1, 10);
         $a = rand(1, 3);
         $u = rand(24, 27);
         $c = rand(1, 4);
         $e = new manage_model_event();
         $data = array('lat' => 49.26 + $lt / 10, 'long' => 27.69 + $lng / 10, 'user_id' => $u, 'activity_id' => $a, 'city_id' => $c, 'date' => strtotime(rand(1, 29) . '.' . rand(1, 7) . '.' . '2015'), 'marker_color' => '#efefef');
         $e->setData($data);
         core_debug::dump($e);
         $e->save();
     }
 }
示例#10
0
文件: memcached.php 项目: Junec/core
 public function __construct($params = array())
 {
     $hosts = array();
     if ($params['host'] != '') {
         $config = explode(',', $params['host']);
         foreach ($config as $v) {
             $v = trim($v);
             $tmp = explode(':', $v);
             $hosts[] = array($tmp[0], $tmp[1]);
             core_debug::info('add memcached server: ' . $v);
         }
         $this->getInstance()->addServers($hosts);
     } else {
         throw new Exception('can\'t load cache_memcache_host, please check it.');
     }
 }
示例#11
0
 function read($query = false, $query_column = false, $query_order = false, $query_dir = false, $query_start = false, $query_limit = false)
 {
     $int_time_start = lib_datetime_microtime();
     parent::read($query, $query_column, $query_order, $query_dir, $query_start, $query_limit);
     $array_data['results'] = count($this->array_result);
     if (count($this->array_result) > 0) {
         for ($i = 0; $i < count($this->array_result); $i++) {
             try {
                 $array_data['nodes'][] = new model_forum_categories($this->array_result[$i]);
             } catch (Exception $e) {
                 core_debug::i()->add('500', $e->getMessage(), '');
             }
         }
     }
     $array_data['elapsed'] = lib_datetime_microtime() - $int_time_start;
     return $array_data;
 }
示例#12
0
文件: curl.php 项目: Junec/core
 /**
  * 发起请求
  * 
  * @param string $url 请求地址
  * @param array $method 请求方式
  * @param array $params 请求参数
  * @return void
  */
 private function _request($url = '', $method = 'POST', $params = array())
 {
     $hashkey = core_debug::info("curl {$method} request: {$url} , requesting ...");
     curl_setopt($this->client, CURLOPT_CONNECTTIMEOUT, 20);
     curl_setopt($this->client, CURLOPT_URL, $url);
     curl_setopt($this->client, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($this->client, CURLOPT_CONNECTTIMEOUT, $this->getTimeout());
     curl_setopt($this->client, CURLOPT_TIMEOUT, $this->getTimeout());
     if ($method == 'POST') {
         curl_setopt($this->client, CURLOPT_POST, count($params));
         curl_setopt($this->client, CURLOPT_POSTFIELDS, $params);
     }
     $this->response = curl_exec($this->client);
     curl_close($this->client);
     if ($this->response === false) {
         $debugInfo = "curl {$method} request: {$url} , timeout(" . $this->getTimeout() . " Seconds).";
     } else {
         $debugInfo = "curl {$method} request: {$url} , ok.";
     }
     core_debug::info($debugInfo, $hashkey);
     return $this->response;
 }
示例#13
0
 public final function connect()
 {
     if (core_settings::i()->get('CONFIG_SETTINGS_AUTH') == 2) {
         if ($_SERVER['REMOTE_ADDR'] == core_settings::i()->get('CONFIG_AUTH_NTLM_IP') && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
             if (!$this->connect_ntlm()) {
                 if ($this->http_auth_complete) {
                     // Only display a 403 if the NTLM is complete.
                     core_debug::i()->add('403', 'Cannot find user in Database: ', '');
                 } else {
                     exit;
                 }
             }
         } else {
             if (!$this->connect_ldap()) {
                 header('HTTP/1.0 401 Unauthorized');
                 header('WWW-Authenticate: Basic realm="iTrafford Login"');
                 exit('Unauthorized <a href="/">Retry</a>');
             }
         }
     }
     if (core_settings::i()->get('CONFIG_SETTINGS_AUTH') == 1) {
         $this->connect_db();
     }
 }
示例#14
0
 /**
  * Prints the Paper buffer to the screen 
  */
 public function display()
 {
     try {
         header('Content-Type: ' . $this->mime . '; charset=' . strtoupper($this->encoding) . '');
         header('Expires: ' . date('D, d M Y H:i:s ', time() + core_settings::i()->get('CONFIG_PAPER_EXPIRES')) . 'GMT');
         $handle = fopen($this->template, "r");
         $contents = fread($handle, filesize($this->template));
         fclose($handle);
         $find = array_keys($this->data);
         $replace = array_values($this->data);
         $xhtml = str_replace($find, $replace, $contents);
         print $xhtml;
     } catch (Exception $e) {
         core_debug::i()->add('500', $e->getMessage(), '');
     }
 }
        global $Plugins;
        switch ($this->OutputType) {
            case "XML":
                break;
            case "HTML":
                $text = _("Plugin Summary");
                $V .= "<H2>{$text}</H2>";
                foreach ($Plugins as $key => $val) {
                    $V .= "{$key} : {$val->Name} (state={$val->State})<br>\n";
                }
                $text = _("Plugin State Details");
                $V .= "<H2>{$text}</H2>";
                $V .= "<pre>";
                $V .= print_r($Plugins, 1);
                $V .= "</pre>";
                break;
            case "Text":
                print_r($Plugins);
                break;
            default:
                break;
        }
        if (!$this->OutputToStdout) {
            return $V;
        }
        print "{$V}";
        return;
    }
}
$NewPlugin = new core_debug();
$NewPlugin->Initialize();
示例#16
0
 public function columns($table)
 {
     if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
         $starttime = lib_datetime_microtime();
     }
     $store = array();
     $object_result = core_database::i()->query("\n\t\t\t\tselect * from `" . core_database::i()->real_escape_string($table) . "` LIMIT 1;\n\t\t\t");
     $object_fields = $object_result->fetch_fields();
     for ($i = 0; $i < count($object_fields); $i++) {
         $store[] = $object_fields[$i]->name;
     }
     if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
         $endtime = lib_datetime_microtime();
         core_debug::i()->add('query', $query, round($endtime - $starttime, 6));
     }
     return $store;
 }
示例#17
0
 /**
  * F*****G SHIT FUNCTION . SORRY FOR THS F**K
  * @param $csv
  * @param $orig
  * @return array
  * @throws Exception
  */
 protected function _pareseEmailBodyCsv($csv, $orig)
 {
     //$orig = $this->_prepareCsvString($csv);
     $csv = $this->_prepareCsvString($orig);
     $array = explode(';', $csv);
     if (!is_array($array) || !isset($array[0]) || !isset($array[1]) || !isset($array[2]) || !isset($array[3]) || !isset($array[4])) {
         $csv = $this->tryEncodeUtf8($orig);
         $csv = $this->_prepareCsvString($csv);
         core_debug::dump($csv);
         $array = str_getcsv($csv, ';');
     }
     if (!is_array($array) || !isset($array[0]) || !isset($array[1]) || !isset($array[2]) || !isset($array[3]) || !isset($array[4])) {
         $csv = $this->tryEncodebase64($orig);
         $csv = $this->_prepareCsvString($csv);
         core_debug::dump($csv);
         $array = str_getcsv($csv, ';');
     }
     if (!is_array($array) || !isset($array[0]) || !isset($array[1]) || !isset($array[2]) || !isset($array[3]) || !isset($array[4])) {
         throw new Exception('Error while parsing email body');
     }
     $lat = $array[1];
     $long = $array[2];
     $user_id = $this->_getUserByImei($array[0]);
     $user = new manage_model_user();
     $user->load($user_id);
     $city_name = core_google_geo::findCityName($lat, $long);
     if (!$city_name) {
         $city_id = $user->getData('city_id');
     } else {
         $city_id = $this->_getCityIdByName($city_name);
     }
     $data = array('imei' => $array[0], 'user_id' => $user_id, 'lat' => $lat, 'long' => $long, 'date' => $array[3] / 1000, 'activity_id' => $array[4], 'city_id' => $city_id);
     core_log::log($data, self::$grabtime . '.event.imap.log');
     return $data;
 }
示例#18
0
文件: core.php 项目: optiva/xGlide
        }
    } else {
        // Can't find the presenter at all.
        // Show a 404
        core_debug::i()->add('404', 'File not found: ', __DIR__ . '/../../application/presenters/presenter_' . core_requests::i()->get('presenter') . '.php');
    }
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="DISPLAY RESULTS">
core_paper::i()->add($presenter->data);
core_paper::i()->template = core_requests::i()->get('presenter') . '.html';
core_paper::i()->display();
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="DEBUGGING + LOGGING">
if (core_settings::i()->get('CONFIG_SETTINGS_DEBUG')) {
    // Only display the debug data in xml or html files
    if (core_paper::i()->mime == 'text/html' && core_paper::i()->mime == 'text/xml') {
        print "<!--[\n\n";
        if (isset($_SESSION)) {
            print session_id() . "\n\n";
            print_r($_SESSION);
            print "\n\n";
        }
        print_r(core_debug::i()->get());
        print "\n]-->";
    }
}
if (core_settings::i()->get('CONFIG_SETTINGS_LOGFILE')) {
    core_logging::i()->write();
}
// </editor-fold>
示例#19
0
文件: core.php 项目: Junec/core
 /**
  * 设置参数信息
  * 
  * @return void
  */
 private static function setBoot()
 {
     $pathinfo = self::instance('core_url')->getPathInfo();
     $queryString = self::instance('core_router')->parse($pathinfo);
     $get = self::instance('core_url')->getQueryParams($queryString);
     $controller = $get[self::$config['mvc_controller']];
     $action = $get[self::$config['mvc_action']];
     if ($controller == '') {
         $controller = self::$config['default_controller'];
     }
     if ($action == '') {
         $action = self::$config['default_action'];
     }
     self::$boot[self::$config['mvc_controller']] = $controller;
     self::$boot[self::$config['mvc_action']] = $action;
     self::$boot['pathinfo'] = $pathinfo;
     core_debug::info('path info: ' . $pathinfo);
     core_debug::info('query string: ' . $queryString);
 }
示例#20
0
 /**
  * Sets $request_method
  * Throws an error if not GET, POST, PUT or DELETE
  * 
  * @param string $method 
  */
 private function set_request_method($method)
 {
     if ($method == "GET" || $method == "POST" || $method == "PUT" || $method == "DELETE") {
         $this->request_method = $method;
     } else {
         core_debug::i()->add('500', $e->getMessage(), '');
     }
 }
示例#21
0
 /**
  * Delete record prototype
  */
 public function delete()
 {
     // <editor-fold defaultstate="collapsed" desc="BUILD QUERY">
     $pad = '                       ';
     $str_ident = '##' . get_called_class() . ' ' . __FUNCTION__ . '()' . " \n";
     $obj_data->sanitize();
     $str_update = 'DELETE FROM ' . static::$db_table . " \n";
     if (array_key_exists($query_column, static::$db_columns)) {
         $str_where = 'WHERE `' . core_database::i()->real_escape_string($query_column) . '` = "' . core_database::i()->real_escape_string($query) . '"' . " \n";
     } else {
         core_debug::i()->add('500', 'Unknown db_column', '"' . $query_column . '"');
     }
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="QUERY DATABASE">
     try {
         $this->array_result = core_database::i()->debug_query($str_update . $pad . $str_set . $pad . $str_where);
     } catch (Exception $e) {
         core_debug::i()->add('500', $e->getMessage(), '');
     }
     // </editor-fold>
 }