示例#1
0
 public static function view($removefieldset = false)
 {
     if (!self::$_started) {
         return;
     }
     self::$timeEnd = self::getmicrotime();
     $time = sprintf('%.5f', self::$timeEnd - self::$timeStart);
     $files = sprintf('%.5f', self::$filesTime);
     $rapportSQL = sprintf('%.2f', 100 * self::$totalTime / $time);
     $rapportPHP = 100 - $rapportSQL;
     $memoryPeak = round(memory_get_peak_usage() / 1048576, 3);
     $content = 'File ' . $_SERVER['SCRIPT_NAME'] . "\n" . 'Loaded in ' . $time . ' seconds' . "\n" . 'Loaded PHP files : ' . self::$filesLoaded . "\n" . 'SQL requests : ' . sprintf('%.5f', self::$totalTime) . ' seconds (' . self::$sqlNbRequests . ' requests)' . "\n" . '% SQL/PHP : ' . $rapportSQL . ' / ' . $rapportPHP . ' %' . "\n" . 'Memory Peak : ' . $memoryPeak . 'Mo' . "\n";
     if (function_exists('xdebug_get_profiler_filename') && xdebug_get_profiler_filename()) {
         $content .= 'XDebug Profile : ' . xdebug_get_profiler_filename() . "\n";
     }
     if (function_exists('xdebug_get_profiler_filename') && xdebug_get_tracefile_name()) {
         $content .= 'XDebug Trace : ' . xdebug_get_tracefile_name() . "\n";
     }
     $content .= 'User : '******' (' . CMS_session::getUserId() . ')' : 'none') . "\n";
     $content .= 'Session Id ' . Zend_Session::getId() . "\n";
     //$content .= 'Current page '.CMS_session::getPageID()."\n";
     if (VIEW_SQL && $_SERVER["SCRIPT_NAME"] != PATH_ADMIN_WR . '/stat.php') {
         $stat = array('stat_time_start' => self::$timeStart, 'stat_time_end' => self::$timeEnd, 'stat_total_time' => self::$totalTime, 'stat_sql_nb_requests' => self::$sqlNbRequests, 'stat_sql_table' => self::$sqlTable, 'stat_content_name' => basename($_SERVER["SCRIPT_NAME"]), 'stat_files_table' => self::$filesTable, 'stat_memory_table' => self::$memoryTable, 'stat_memory_peak' => $memoryPeak, 'stat_files_loaded' => self::$filesLoaded);
         $statName = 'stat_' . md5(rand());
         //save stats to cache (for 10 min)
         $cache = new CMS_cache($statName, 'atm-stats', 600, false);
         if ($cache) {
             $cache->save($stat);
         }
     }
     $content = !$removefieldset ? '<fieldset style="width:200px;" class="atm-debug"><legend>Debug Statistics</legend><pre>' . $content . '</pre>' : 'Debug Statistics :' . "\n" . $content;
     if (isset($statName)) {
         $content .= '<a href="' . PATH_ADMIN_WR . '/stat.php?stat=' . $statName . '" target="_blank">View statistics detail</a>';
     }
     //end xhprof profiling
     if (defined('APPLICATION_ENABLE_PROFILING') && APPLICATION_ENABLE_PROFILING && function_exists('xhprof_disable')) {
         $xhprof_data = xhprof_disable();
         include_once APPLICATION_XHPROF_ROOT_FS . "/xhprof_lib/utils/xhprof_lib.php";
         include_once APPLICATION_XHPROF_ROOT_FS . "/xhprof_lib/utils/xhprof_runs.php";
         $xhprof_runs = new XHProfRuns_Default();
         $profileName = md5($_SERVER['REQUEST_URI']);
         $run_id = $xhprof_runs->save_run($xhprof_data, md5($_SERVER['REQUEST_URI']));
         $content .= '<br /><a href="' . APPLICATION_XHPROF_URI . 'xhprof_html/index.php?run=' . $run_id . '&amp;source=' . $profileName . '" target="_blank">View profiling detail</a>';
     }
     $content .= !$removefieldset ? '</fieldset>' : '';
     return $content;
 }
示例#2
0
 case 'logout':
     //Disconnect user
     CMS_session::authenticate(array('disconnect' => true, 'type' => 'admin'));
     //Reset session (start fresh)
     Zend_Session::destroy();
     break;
 case 'reconnect':
     //display error login window on top of login form
     $loginError = "\n\t\tAutomne.message.popup({\n\t\t\tmsg: '{$cms_language->getJsMessage(MESSAGE_ERROR_SESSION_EXPIRED)}',\n\t\t\tbuttons: Ext.MessageBox.OK,\n\t\t\ticon: Ext.MessageBox.ERROR,\n\t\t\tfn:function() {\n\t\t\t\tloginWindow.body.mask('{$cms_language->getJsMessage(MESSAGE_PAGE_PLEASE_WAIT)}');\n\t\t\t\tloginWindow.reload();\n\t\t\t}\n\t\t});";
     //Disconnect user
     CMS_session::authenticate(array('disconnect' => true, 'type' => 'admin'));
     break;
 case '':
     //launch authentification process (for modules which can use it)
     CMS_session::authenticate(array('authenticate' => true, 'type' => 'admin'));
     $cms_user = CMS_session::getUser();
     if ($cms_user && $cms_user->hasAdminAccess()) {
         //launch the daily routine incase it's not in the cron
         CMS_module_standard::processDailyRoutine();
         //then set context and load Automne interface
         $userSessionsInfos = CMS_session::getSessionInfos();
         $cms_language = $cms_user->getLanguage();
         //welcome message
         $welcome = $cms_language->getJsMessage(MESSAGE_PAGE_USER_WELCOME, array($userSessionsInfos['fullname']));
         $welcomeMsg = '';
         //last login
         $logs = CMS_log_catalog::search('', 0, $cms_user->getUserId(), array(CMS_log::LOG_ACTION_AUTO_LOGIN, CMS_log::LOG_ACTION_LOGIN), false, false, 0, 2, 'datetime', 'desc', false);
         if (isset($logs[1])) {
             $welcomeMsg .= '<br /><br />' . $cms_language->getJsMessage(MESSAGE_PAGE_PREVIOUS_LOGIN) . ' ' . $logs[1]->getDateTime()->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s');
         }
         //validations
示例#3
0
 /**
  * Get all JS locales for current user (in current language)
  *
  * @return string : JS locales
  * @access public
  */
 public static function getJSLocales()
 {
     $locales = '';
     $user = CMS_session::getUser();
     if (!$user) {
         return $locales;
     }
     //add all JS locales
     $language = $user->getLanguage();
     $languageCode = $language->getCode();
     //Get Ext locales
     if ($languageCode != 'en') {
         //english is defined as default language so we should not add it again
         $extLocaleFile = PATH_MAIN_FS . '/ext/src/locale/ext-lang-' . $languageCode . '.js';
         if (file_exists($extLocaleFile)) {
             $fileContent = file_get_contents($extLocaleFile);
             //remove BOM if any
             if (substr($fileContent, 0, 3) == '') {
                 $fileContent = substr($fileContent, 3);
             }
             $locales .= io::strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8' ? utf8_decode($fileContent) : $fileContent;
         }
     }
     //add Automne locales
     $locales .= $language->getMessage(self::MESSAGE_USER_JS_LOCALES);
     return $locales;
 }