Exemplo n.º 1
0
    static function init() {

        if ($_SERVER[debug][report]) {
            profiler::add("Autoexec", "MySQL: Выполнение скриптов до подключения");
        }

        self::$db = &self::$lang;
        self::$sh = &self::$shared;

        $_SERVER[mysql][lang][encoding] = $_SERVER[EncodingSQL];

        self::$lang = new sql_PDO(
                        SQL_CONNECTION_LANG,
                        $_SERVER[mysql][lang]
        );
//        self::$lang = new sql_PDO(
//                        SQL_CONNECTION_LANG,
//                        $_SERVER[mysql][lang]
//        );        

        if ($_SERVER[debug][report]) {
            profiler::add("Autoexec", "MySQL: Подключение языковой БД");
        }

        // REVERSE

        self::$errors = &sql::$lang->_errors;
        self::$lastQuery = &sql::$lang->_lastQuery;
    }
Exemplo n.º 2
0
 /**
  *
  * Enter description here ...
  * @return profiler
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 3
0
 public function internalQuery($sql)
 {
     if (isset($_COOKIE['debug'])) {
         echo $sql . "<br />";
     }
     $time = microtime(true);
     $result = mysql_query($sql, $this->getConnection());
     profiler::getInstance()->addSql($sql, $time);
     return $result;
 }
Exemplo n.º 4
0
    static function add($type, $name = "") {

        if (!$name) {
            $name = $type;
            $type = self::$default;
        }

        $time = microtime(true);
        $last = $time - self::$previous;

        self::$i++;
        self::$full += $last;
        self::$time[$type][self::$i . ". {$name}"] = $last;
        self::$memory[self::$i . ". {$name}"] = 
                self::formatMemory(memory_get_usage()) . 
                " <small>(" . self::formatMemory(memory_get_usage(true)) . 
                ")</small>";
        self::$previous = $time;
    }
Exemplo n.º 5
0
 /**
  * Run controller - select methods and run them
  */
 public function run($methodToRun = null)
 {
     $time = microtime(true);
     kanon::setFinalController($this);
     $methodFound = false;
     $class = get_class($this);
     if (strlen($this->_relativeUri) > 1) {
         // longer than "/"
         if ($this->getCurrentUrl() != $this->getCanonicalUrl()) {
             //echo $this->getCurrentUrl().'<br >';
             //echo $this->getCanonicalUrl().'<br >';
             // TODO FIX INCORRECT REDIRECTS (resulted in loops)
             //$this->movedPermanently($this->getCanonicalUrl());
         }
     }
     if ($action = $this->_relativeUri->getBasePath()) {
         $this->_action = $action;
         if (strpos($action, '.') !== false) {
             $this->_type = end(explode('.', $action));
             $action = substr($action, 0, strlen($action) - strlen($this->_type) - 1);
             // cut .html, .js etc
         } else {
             $this->_type = '';
         }
     }
     profiler::getInstance()->addSql("run() before onConstruct()", $time);
     $this->onConstruct();
     if ($action == 'assets' && $this->_useAssets) {
         $this->assets();
         return;
     }
     if ($methodToRun !== null) {
         if (method_exists($this, $methodToRun)) {
             $this->_call($methodToRun, $action, $this->_getArgs($methodToRun));
             //call_user_func_array(array($this, $methodToRun), $this->_getArgs($methodToRun));
         }
         return;
     } else {
         if (extension_loaded('eAccelerator')) {
             throw new Exception('eAccelerator strips phpdoc blocks. Turn it off.');
         } else {
             if (list($actions, $methodName, $pathArgs) = $this->_getRouteMethod($this->_relativeUri, '!RouteInit')) {
                 $this->_makeChildUri($actions);
                 $methodFound = true;
                 if (method_exists($this, $methodName)) {
                     $this->_call($methodName, $action, $this->_getArgs($methodName, $pathArgs));
                     //call_user_func_array(array($this, $methodName), $this->_getArgs($methodName, $pathArgs));
                 }
             }
             if (list($actions, $methodName, $pathArgs) = $this->_getRouteMethod($this->_relativeUri, '!Route')) {
                 $this->_makeChildUri($actions);
                 $methodFound = true;
                 if (method_exists($this, $methodName)) {
                     if ($this->getHttpMethod() == 'GET') {
                         $this->_header();
                     }
                     $this->_call($methodName, $action, $this->_getArgs($methodName, $pathArgs));
                     //call_user_func_array(array($this, $methodName), $this->_getArgs($methodName, $pathArgs));
                     if ($this->getHttpMethod() == 'GET') {
                         $this->_footer();
                     }
                     return;
                 }
             }
         }
         if (!$methodFound) {
             if ($action) {
                 $uc = ucfirst($action);
                 $this->_makeChildUri(array($this->_action));
                 $initFunction = 'init' . $uc;
                 if ($controller = kanon::getActionController(get_class($this), $action)) {
                     $this->runController($controller);
                     return;
                 }
                 if (method_exists($this, $initFunction)) {
                     $methodFound = true;
                     $time = microtime(true);
                     call_user_func_array(array($this, $initFunction), $this->_getArgs($initFunction));
                     profiler::getInstance()->addSql("method " . $initFunction, $time);
                 }
                 $actionFunction = 'action' . $uc;
                 if (method_exists($this, $actionFunction)) {
                     $methodFound = true;
                     call_user_func_array(array($this, $actionFunction), $this->_getArgs($actionFunction));
                 }
                 $showFunction = 'show' . $uc;
                 if (method_exists($this, $showFunction)) {
                     $methodFound = true;
                     $this->_header();
                     $time = microtime(true);
                     call_user_func_array(array($this, $showFunction), $this->_getArgs($showFunction));
                     profiler::getInstance()->addSql("method " . $showFunction, $time);
                     $this->_footer();
                 }
                 if (!$methodFound) {
                     return $this->_action($action);
                 }
             } else {
                 if (method_exists($this, 'customIndex')) {
                     $this->customIndex();
                 } else {
                     //$this->_initIndex();
                     if (method_exists($this, '_initIndex')) {
                         call_user_func_array(array($this, '_initIndex'), $this->_getArgs('_initIndex'));
                         $methodFound = true;
                     }
                     if (method_exists($this, 'index')) {
                         $time = microtime(true);
                         $this->_header();
                         profiler::getInstance()->addSql("method _header", $time);
                         $time = microtime(true);
                         call_user_func_array(array($this, 'index'), $this->_getArgs('index'));
                         profiler::getInstance()->addSql("method index", $time);
                         $this->_footer();
                         $methodFound = true;
                     }
                     if (!$methodFound) {
                         return $this->_action('');
                     }
                     //$this->index();
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
if (!isset($_SERVER['DOCUMENT_ROOT']) || !strlen($_SERVER['DOCUMENT_ROOT'])) {
    $_SERVER['DOCUMENT_ROOT'] = rtrim(realpath(pathinfo(__FILE__, PATHINFO_DIRNAME) . '/../../'), '/');
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stdf.php';
//require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/config.php");
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/profiler.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/smail.php';
//------------------------------------------------------------------------------
$results = array();
$profiler = new profiler();
//------------------------------------------------------------------------------
$profiler->start('spam');
//------------------------------------------------------------------------------
$mail = new smail();
$results['cnt'] = $mail->sendFrlOffer();
//------------------------------------------------------------------------------
$profiler->stop('spam');
//------------------------------------------------------------------------------
$results += array('execution_time (sec)' => number_format($profiler->get('spam'), 5));
//------------------------------------------------------------------------------
array_walk($results, function (&$value, $key) {
    $value = sprintf('%s = %s' . PHP_EOL, $key, $value);
});
print_r(implode('', $results));
exit;
Exemplo n.º 7
0
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/mem_storage.php";
//------------------------------------------------------------------------------
/*
$test = array(
    11 => 'aa',
    22 => 'bb'
);

unset($test[11],$test[22]);

var_dump(isset($test));
exit;
*/
//------------------------------------------------------------------------------
$results = array();
$profiler = new profiler();
$profiler->start('update_frl_mem');
//------------------------------------------------------------------------------
$ms = new MemStorage('newsletter_freelancer');
//$results['ID found in mem page'] = $ms->isExistItem(333);
//------------------------------------------------------------------------------
//update
/*
$uid = 333;

$item = freelancer::GetPrjRecp($uid);

//print_r($item);
//exit;

$item['login'] = '******';
Exemplo n.º 8
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
if (!isset($_SERVER['DOCUMENT_ROOT']) || !strlen($_SERVER['DOCUMENT_ROOT'])) {
    $_SERVER['DOCUMENT_ROOT'] = rtrim(realpath(pathinfo(__FILE__, PATHINFO_DIRNAME) . '/../../'), '/');
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/profiler.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/mem_storage.php';
//------------------------------------------------------------------------------
$results = array();
$profiler = new profiler();
$profiler->start('read_frl_mem');
//------------------------------------------------------------------------------
$ms = new MemStorage('newsletter_freelancer');
//------------------------------------------------------------------------------
/*
$profiler->start('read_frl_db');

$page = 0;
$cnt = 0;

while ( $users = freelancer::GetPrjRecps($error, ++$page, 200) ) {
    $cnt += count($users);
    unset($users);
}
Exemplo n.º 9
0
    /**
     * Render a {@link ProfilerNode} step node and it's children recursively
     *
     * @param ProfilerNode $node The node to render
     * @param int $max_depth the maximum depth of the tree to traverse and render.  -1 to traverse entire tree
     */
    public static function renderNode($node, $max_depth = -1)
    {
        ?>

		<tr class="depth_<?php 
        echo $node->getDepth();
        ?>
 <?php 
        echo profiler::isTrivial($node) && !$node->hasNonTrivialChildren() ? 'profiler-trivial' : '';
        ?>
">
			<td class="profiler-step_id"><?php 
        echo str_repeat('&nbsp;&nbsp;&nbsp;', $node->getDepth() - 1);
        echo $node->getName();
        ?>
</td>
			<td class="profiler-stat profiler-monospace profiler-step_self_duration"><?php 
        echo $node->getSelfDuration();
        ?>
</td>
			<td class="profiler-stat profiler-monospace profiler-step_total_duration"><?php 
        echo $node->getTotalDuration();
        ?>
</td>
			<td class="profiler-stat profiler-monospace profiler-start_delay">
				<span class="profiler-unit">+</span><?php 
        echo round($node->getStart() - profiler::getGlobalStart(), 1);
        ?>
			</td>
			<td class="profiler-stat profiler-monospace profiler-query_count">
				<a href="#" class="profiler-show-queries-button" data-node-id="<?php 
        echo md5($node->getName() . $node->getStart());
        ?>
"><?php 
        echo $node->getSQLQueryCount() . " sql";
        ?>
</a>
			</td>
			<td class="profiler-stat profiler-monospace profiler-query_time"><?php 
        echo $node->getTotalSQLQueryDuration();
        ?>
</td>
		</tr>
		
		<?php 
        if ($node->hasChildren() && ($max_depth == -1 || $max_depth > $node->getDepth())) {
            foreach ($node->getChildren() as $childNode) {
                self::renderNode($childNode, $max_depth);
            }
        }
    }
Exemplo n.º 10
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
if (!isset($_SERVER['DOCUMENT_ROOT']) || !strlen($_SERVER['DOCUMENT_ROOT'])) {
    $_SERVER['DOCUMENT_ROOT'] = rtrim(realpath(pathinfo(__FILE__, PATHINFO_DIRNAME) . '/../../'), '/');
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/profiler.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/memBuff2.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer.php';
//------------------------------------------------------------------------------
$results = array();
$profiler = new profiler();
$profiler->start('fill_frl_mem');
//------------------------------------------------------------------------------
//Обьем занимаемый 1 милионом записей (пожатые скорей всего)
//http://monosnap.com/image/Av6zqOhHG5XTTu1jee4tIstCLkn7WY.png
//http://monosnap.com/image/uvvNljrvWdaAqKcyECSawSeKzm5xCR.png
//http://monosnap.com/image/XnPzZYgfbqvJwGKMdH3TEJzxWLnNwb.png
//http://monosnap.com/image/zaHlyosCO4bxDZOlzOv4S2vwF49OIu.png
define('LIFE_TIME', 86400);
define('FRL_KEY', 'newsletter_freelancer');
define('FRL_TAG', 'newsletter_freelancer');
define('FRL_PAGES', 'newsletter_freelancer_pages');
define('FRL_INDEX', 'newsletter_freelancer_index');
$page = 0;
$page_size = 200;
$indexs = array();
Exemplo n.º 11
0
 /**
  * Отрработать вывод по шаблону
  * @param string $template
  * @return string
  */
 public function fetch($template)
 {
     /* TODO: тут проблемы с отрисовкой, нужно наследовать шаблоны
      */
     if ($_SERVER[debug][report]) {
         profiler::add("Выполнение", "{$this->name}: {$template} начало отрисовки");
     }
     // найдем шаблон
     $obj = $this;
     while ($obj) {
         if (file_exists($obj->getViewDir() . '/' . $template)) {
             $templatedir = Output::getTemplateCompiler()->getTemplateDir();
             Output::getTemplateCompiler()->setTemplateDir($obj->getViewDir());
             $content = Output::fetch($template);
             Output::getTemplateCompiler()->setTemplateDir($templatedir);
             break;
         }
         $parentclass = get_parent_class($obj);
         if ($parentclass) {
             $obj = new $parentclass();
         } else {
             $obj = false;
         }
     }
     if ($_SERVER[debug][report]) {
         profiler::add("Выполнение", "{$this->name}: {$template} конец отрисовки");
     }
     return $content;
 }
Exemplo n.º 12
0
 public static function autoload($class)
 {
     $time = microtime(true);
     if (isset(self::$_autoload[$class])) {
         require_once self::$_autoload[$class];
         profiler::getInstance()->addSql("autoload({$class})", $time);
         return true;
     }
     profiler::getInstance()->addSql("autoload({$class})", $time);
     return false;
 }
Exemplo n.º 13
0
Arquivo: _setup.php Projeto: GGF/baza4
// при правильном использовании namespace достаточно только (PSR-0  https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)
spl_autoload_register();
// а так придестя зарегить функцию вслед за дефолтной
spl_autoload_register('Autoloader::loadPackages');
// сам класс 'Autoloader' описан по PSR-0
// очень внимательно файлы будут искаться в МАЛЕНЬКИМИ буквами autoloader.php - Это известный БАГ и скоро может быть пофиксен
/*
 * Строки ниже  есть в файле autoload
 * НО с использованием SPL приишлось вставить сюда потому, что
 * auttoload включался  каждый раз, а теперь используется include_once
 */
if (!$_SERVER["debug"]["noCache"]["php"]) {
    if (!empty($_SESSION["cache"]) && is_array($_SESSION["cache"])) {
        require_once realpath($_SERVER['DOCUMENT_ROOT']) . cache::buildScript($_SESSION["cache"], 'php');
    }
}
/*
 * пожалуй уберу строчку из файла autoload и поставлю включение сюда
 */
//include_once __DIR__ . '/_engine/autoload.php'; // инклудим автозагрузку модулей
ob_get_clean();
/*
 * Делать хоть один инстанс нужно для включения скриптов в заголовки
 */
Lang::getInstance()->setLang('ru');
// перехватим ошибки
if ($_SERVER[debug][report]) {
    console::getInstance();
    //->out(print_r($_REQUEST, true));
    profiler::add('Autoexec', 'Выполнение начальных установок');
}