示例#1
0
 public function render($content_view, $data = null)
 {
     if (is_array($data)) {
         extract($data);
     }
     ob_start();
     include 'application/views/' . mb_strtolower($this->controller) . '/' . $content_view . '.php';
     $content = ob_get_contents();
     ob_end_clean();
     include 'application/views/layouts/' . $this->layout . '.php';
     Mi::app()->log->draw();
 }
示例#2
0
 function __construct()
 {
     $path = explode('?', $_SERVER['REQUEST_URI'])[0];
     $routes = explode('/', $path);
     if (!empty($routes[1])) {
         $this->controller = ucfirst($routes[1]);
     }
     if (!empty($routes[2])) {
         $this->action = $routes[2];
     }
     $this->controller = $this->controller . 'Controller';
     $this->action = 'action' . ucfirst($this->action);
     $rules = Mi::app()->urlRules();
     if (isset($rules[$path])) {
         $routes = explode('/', $rules[$path]);
         $this->controller = ucfirst($routes[0]) . 'Controller';
         $this->action = 'action' . ucfirst($routes[1]);
     }
 }
示例#3
0
 public function draw()
 {
     if (!LOG) {
         return false;
     }
     $find = ['select', 'from', 'where', 'order by', 'limit', 'offset', '(', ')'];
     $replace = ['<span class="op">select</span>', '<span class="op">from</span>', '<span class="op">where</span>', '<span class="op">order by</span>', '<span class="op">limit</span>', '<span class="op">offset</span>', '<span class="op">(</span>', '<span class="op">)'];
     $querys = $this->mysql();
     $data = [];
     $i = 0;
     foreach ($querys as $query) {
         $data[$i]['sql'] = str_replace($find, $replace, strtolower($query['sql']));
         $data[$i]['time'] = $query['time'];
         $i++;
     }
     if (!isset($querys[Mi::app()->session->get('log_sql_session_id')])) {
         $data = [];
     }
     include 'views/log.php';
 }
示例#4
0
文件: Mi.php 项目: razzman/mi
 /**
  * cakeVersion method
  *
  * @return void
  * @access protected
  */
 protected static function cakeVersion()
 {
     if (Mi::$cakeVersion) {
         return Mi::$cakeVersion;
     }
     return Mi::$cakeVersion = substr(Configure::version(), 0, 3);
 }
示例#5
0
 /**
  * exec method
  *
  * @param mixed $cmd
  * @param mixed $out null
  * @return true on success, false on failure
  * @access protected
  */
 protected function _exec($cmd, &$out = null)
 {
     if (!class_exists('Mi')) {
         APP::import('Vendor', 'Mi.Mi');
     }
     return Mi::exec($cmd, $out);
 }
示例#6
0
 public function actionIndex()
 {
     $this->pageTitle = 'Главная страница';
     $this->render('index', ['time' => Mi::app()->timeRequest, 'data' => User::model()->findByPk(1)]);
 }
示例#7
0
 function __construct($class_name)
 {
     $this->model = new $class_name();
     $this->db = Mi::app()->db;
 }
示例#8
0
<?php

// Показываем все ошибки
ini_set('display_errors', 1);
// Корневая директория
define('ROOT', $_SERVER['DOCUMENT_ROOT']);
// Логировать запросы и прочее?
define('LOG', TRUE);
// Ядро
require_once 'core/mi.php';
// Запускаем Micros
Mi::init();
// Загружаем роутер
$router = new Router();
// Запускаем роутер
$router->start();
示例#9
0
 public function timeRequest()
 {
     $time = microtime(true) - Mi::app()->session->get('microtime');
     return sprintf('%.4F сек.', $time);
 }
示例#10
0
 private function prepareQuery($args)
 {
     $query = '';
     $raw = array_shift($args);
     $array = preg_split('~(\\?[nsiuap])~u', $raw, null, PREG_SPLIT_DELIM_CAPTURE);
     $anum = count($args);
     $pnum = floor(count($array) / 2);
     if ($pnum != $anum) {
         $this->error("Number of args ({$anum}) doesn't match number of placeholders ({$pnum}) in [{$raw}]");
     }
     foreach ($array as $i => $part) {
         if ($i % 2 == 0) {
             $query .= $part;
             continue;
         }
         $value = array_shift($args);
         switch ($part) {
             case '?n':
                 $part = $this->escapeIdent($value);
                 break;
             case '?s':
                 $part = $this->escapeString($value);
                 break;
             case '?i':
                 $part = $this->escapeInt($value);
                 break;
             case '?a':
                 $part = $this->createIN($value);
                 break;
             case '?u':
                 $part = $this->createSET($value);
                 break;
             case '?p':
                 $part = $value;
                 break;
         }
         $query .= $part;
     }
     Mi::app()->log->query($query);
     return $query;
 }
示例#11
0
 /**
  * exec method
  *
  * @param mixed $cmd
  * @param mixed $out null
  * @return void
  * @access protected
  */
 protected function _exec($cmd, &$out = array())
 {
     MiInstall::_progress($cmd, '  ');
     if (defined('CAKE_SHELL') && CAKE_SHELL) {
         system($cmd, $return);
         return $return;
     }
     MiInstall::_progress($out, '    ');
     if (!class_exists('Mi')) {
         App::import('Vendor', 'Mi.Mi');
     }
     Mi::exec($cmd, $out);
 }
示例#12
0
文件: MiCache.php 项目: razzman/mi
 /**
  * exec method
  *
  * @param mixed $cmd
  * @param mixed $out null
  * @return void
  * @access protected
  */
 protected static function _exec($cmd, &$out = null)
 {
     if (!class_exists('Mi')) {
         App::uses('Mi', 'Mi.Vendor');
     }
     return Mi::exec($cmd, $out);
 }
示例#13
0
 /**
  * populateVendorMap method
  *
  * @param bool $reset false
  * @static
  * @return void
  * @access protected
  */
 protected static function _populateVendorMap($reset = false)
 {
     if ($reset || !self::$vendorMap) {
         App::import('Vendor', 'Mi.MiCache');
         $plugins = MiCache::mi('plugins');
         foreach ($plugins as $path => $plugin) {
             if (is_dir($path . DS . 'webroot')) {
                 if (!class_exists('Mi')) {
                     APP::import('Vendor', 'Mi.Mi');
                 }
                 $files = Mi::files($path . DS . 'webroot', null, '.*\\.(css|js)$');
                 foreach ($files as $fPath) {
                     $fPath = realpath($fPath);
                     self::$vendorMap[str_replace(realpath($path . DS . 'webroot') . DS, $plugin . DS, $fPath)] = $fPath;
                 }
             }
         }
         self::log("Populating Vendor Map");
         if (!class_exists('MiCache')) {
             self::log("\tMiCache doesn't exist. Skipping.");
             return;
         }
         self::$vendorMap = am(self::$vendorMap, MiCache::mi('vendors', null, array('shells'), array('excludeFolders' => array('shells', 'simpletest'), 'extension' => array('css', 'js'), 'excludePattern' => false)));
         self::log("\tDone.");
     }
 }
示例#14
0
<?php

spl_autoload_register(function ($class) {
    if (file_exists(ROOT . '/application/models/' . $class . '.php')) {
        include ROOT . '/application/models/' . $class . '.php';
    } else {
        $map = Mi::app()->map;
        if (count($map) > 0) {
            foreach ($map as $path) {
                if (file_exists(ROOT . $path . $class . '.php')) {
                    include ROOT . $path . $class . '.php';
                }
            }
        }
    }
});