コード例 #1
0
ファイル: SJB_Profiler.php プロジェクト: Maxlander/shixi
 /**
  * @static
  * @return SJB_Profiler
  */
 public static function getInstance()
 {
     if (self::$instance === null || self::$instance->isProfilerEnable() === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
ファイル: profiler.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $profiler = SJB_Profiler::getInstance();
     if ($profiler->isProfilerEnable() && !SJB_Request::isAjax()) {
         $memory = $profiler->getMemoryUsage();
         $time = $profiler->getTimeElapsed();
         $queries = $profiler->getQueries();
         $functions = $profiler->getFunctions();
         $countOfQueries = count($queries);
         for ($i = 0; $i < $countOfQueries; $i++) {
             $debugCount = count($queries[$i]['debug']);
             for ($j = 0; $j <= $debugCount; $j++) {
                 if (isset($queries[$i]['debug'][$j]['args'])) {
                     unset($queries[$i]['debug'][$j]['args']);
                 }
                 if (isset($queries[$i]['debug'][$j]['object'])) {
                     unset($queries[$i]['debug'][$j]['object']);
                 }
             }
         }
         $tp = SJB_System::getTemplateProcessor();
         $tp->assign('functionCount', count($functions));
         $tp->assign('queryCount', count($queries));
         $tp->assign('functionInfo', $functions);
         $tp->assign('queryInfo', $queries);
         $tp->assign('memory', $memory);
         $tp->assign('time', $time);
         $tp->display('profiler.tpl');
     }
 }
コード例 #3
0
ファイル: DB.php プロジェクト: Maxlander/shixi
 /**
  * @param  string $sql
  * @param  array $params
  * @param  array $requestArgs
  * @return array
  */
 private static function mysqlQueryProfiled($sql, array $params, array $requestArgs)
 {
     $db = Zend_Registry::get('db');
     $debug = debug_backtrace();
     $timeBegin = microtime(true);
     $result = array();
     try {
         $result['query'] = $db->createStatement($sql)->execute($params);
         $result['error'] = false;
         Zend_Registry::set('affectedRows', $result['query']->count());
     } catch (Exception $e) {
         $result['query'] = false;
         $result['error'] = $e->getMessage();
     }
     $time = microtime(true) - $timeBegin;
     $sqlString = call_user_func_array(array('SJB_DB', 'getProfileSql'), $requestArgs);
     SJB_Profiler::getInstance()->gatherQueryInfo($debug, $sqlString, $time, self::$function, self::$module);
     return $result;
 }
コード例 #4
0
ファイル: ModuleManager.php プロジェクト: Maxlander/shixi
 /**
  * Execute module function
  *
  * This function will execute function of the module
  * If function does not exists, it will display error message
  *
  * @param string $module_name name of the module
  * @param string $function_name function's name
  * @param array $parameters_override _REQUEST parameters to rewrite
  */
 function executeFunction($module_name, $function_name, $parameters_override = array(), $pageID = false)
 {
     if (SJB_Users_CookiePreferences::isModuleDisabled($function_name)) {
         return;
     }
     ob_start();
     if ($this->isFunctionAccessible($module_name, $function_name)) {
         $script_filename = $this->getFunctionScriptFilename($module_name, $function_name);
         if ($script_filename != null && is_readable($script_filename)) {
             $adminAccessType = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE');
             $this->prepareFunctionEnvironment($parameters_override);
             $this->pushExecutionStack($module_name, $function_name);
             $function = $this->getFunction($function_name, $module_name, $parameters_override);
             // permissions checking
             if (!$function->isAccessible()) {
                 if ($adminAccessType && SJB_SubAdmin::admin_authed()) {
                     $function = $this->getFunction('function_is_not_accessible_for_subadmin', 'miscellaneous');
                 } else {
                     $function = $this->getFunction('function_is_not_accessible', 'miscellaneous');
                 }
                 SJB_Request::getInstance()->setPageTemplate('index.tpl');
             }
             if (SJB_Profiler::getInstance()->isProfilerEnable()) {
                 SJB_DB::setFunctionInfo($function_name, $module_name);
                 $startTime = microtime(true);
                 $function->execute();
                 $spendTime = microtime(true) - $startTime;
                 $spendTime = number_format($spendTime, 8);
                 SJB_Profiler::getInstance()->gatherFunctionInfo($module_name, $function_name, $spendTime);
             } else {
                 $function->execute();
             }
             if (SJB_FlashMessages::getInstance()->isErrors()) {
                 $errors = SJB_FlashMessages::getInstance()->getErrorsAndRemove();
                 $function = $this->getFunctionForErrors($errors);
                 if ($function) {
                     ob_clean();
                     $function->execute();
                     SJB_Request::getInstance()->setPageTemplate('index.tpl');
                 }
             }
             $this->popExecutionStack();
             $this->restoreEnvironment();
         } else {
             return "<!-- Either wrong module/function or function script file does not exist for {$module_name}, {$function_name} -->";
         }
     } else {
         return "<!-- No such function or function is not accessible for {$module_name}, {$function_name} -->";
     }
     return ob_get_clean();
 }
コード例 #5
0
ファイル: index.php プロジェクト: Maxlander/shixi
<?php

$timeBegin = microtime(true);
error_reporting(-1);
ini_set('display_errors', 'on');
define('PATH_TO_SYSTEM_CLASS', '../system/core/System.php');
$DEBUG = array();
$PATH_BASE = str_replace('/admin', '', dirname(__FILE__));
require_once PATH_TO_SYSTEM_CLASS;
define('SJB_BASE_DIR', realpath(dirname(__FILE__) . "/..") . '/');
SJB_System::loadSystemSettings('../system/admin-config/DefaultSettings.php');
SJB_System::loadSystemSettings('../config.php');
$GLOBALS['system_settings']['USER_SITE_URL'] = $GLOBALS['system_settings']['SITE_URL'];
$GLOBALS['system_settings']['SITE_URL'] = $GLOBALS['system_settings']['ADMIN_SITE_URL'];
// load installed SJB version info
SJB_System::setGlobalTemplateVariable('version', SJB_System::getSystemSettings('version'));
SJB_System::boot();
SJB_System::init();
if (SJB_Profiler::getInstance()->isProfilerEnable()) {
    SJB_Profiler::getInstance()->setStartTime($timeBegin);
}
// bind send notification emails if listing deactivated/deleted
SJB_Event::handle('listingDeactivated', array('SJB_Notifications', 'notifyOnUserListingDeactivated'));
SJB_Event::handle('beforeListingDelete', array('SJB_Notifications', 'notifyOnUserListingDeleted'));
// bind send notification emails if user deactivated/deleted
SJB_Event::handle('onBeforeUserDelete', array('SJB_Notifications', 'notifyOnUserDeleted'));
SJB_Event::handle('onBeforeUserDeactivate', array('SJB_Notifications', 'notifyOnUserDeactivated'));
SJB_Request::getInstance()->execute();
SJB_HelperFunctions::debugInfoPrint();