function test_convertOffset()
 {
     $aOffset = array('18000000' => '0500', '11224000' => '0307', '34200000' => '0930', '45900000' => '1245');
     foreach ($aOffset as $offset => $result) {
         $this->assertEqual(OX_Admin_Timezones::_convertOffset($offset), $result);
     }
 }
 /**
  * Process the EnviromentManager checkSystem result table
  *
  * @param array $aSysInfo
  *
  * @return SystemCheckModel object
  */
 public function processEnvironmentCheck($aSysInfo)
 {
     $aResult = array();
     //cookie section
     $aEnvCookie = $aSysInfo['COOKIES'];
     $aSection = $this->buildCheckSection($aEnvCookie, $GLOBALS['strBrowserCookies']);
     $aSection['checks']['enabled'] = $this->buildCheckEntry('enabled', $aEnvCookie, true, 'OK', 'DISABLED');
     $aSection = $this->buildCheckSectionMessages($aEnvCookie, $aSection);
     $aResult['cookies'] = $aSection;
     //PHP section
     $aEnvPhp = $aSysInfo['PHP'];
     //for some reason installer discards timzone check and does its own..
     $timezone = OX_Admin_Timezones::getTimezone();
     $timezoneErr = 'System/Localtime' == $timezone;
     $aSection = $this->buildCheckSection($aEnvPhp, $GLOBALS['strPHPConfiguration']);
     $aSection['hasWarning'] = $timezoneErr;
     $aSection['checks']['timezone'] = array('name' => 'timezone', 'value' => $timezone, 'hasWarning' => $timezoneErr, 'warnings' => $timezoneErr ? array($GLOBALS['strTimezoneLocal']) : null);
     $aSection['checks']['version'] = array('name' => 'version', 'value' => $aEnvPhp['actual']['version'], 'hasWarning' => !empty($aEnvPhp['warning']['version']), 'hasError' => !empty($aEnvPhp['error']['version']));
     $memLimit = $aEnvPhp['actual']['memory_limit'];
     $memLimit = $memLimit != '' ? $memLimit : 'Not Set';
     if (is_numeric($memLimit)) {
         // convert into MB
         $memLimit = $memLimit / 1048576 . ' MB';
     }
     $aSection['checks']['memory_limit'] = array('name' => 'memory_limit', 'value' => $memLimit, 'warning' => $aEnvPhp['warning']['memory_limit'], 'error' => $aEnvPhp['error']['memory_limit']);
     $aSection['checks']['safe_mode'] = $this->buildCheckEntry('safe_mode', $aEnvPhp, 0, 'OFF', 'ON');
     $aSection['checks']['magic_quotes_runtime'] = $this->buildCheckEntry('magic_quotes_runtime', $aEnvPhp, 0, 'OFF', 'ON');
     $aSection['checks']['file_uploads'] = $this->buildCheckEntry('file_uploads', $aEnvPhp, 0, 'OFF', 'ON');
     $aSection['checks']['timeout'] = $this->buildCheckEntry('timeout', $aEnvPhp, false, 'OFF', $aEnvPhp['actual']['timeout']);
     $aSection['checks']['register_argc_argv'] = $this->buildCheckEntry('register_argc_argv', $aEnvPhp, 0, 'OFF', 'ON');
     if ($aEnvPhp['actual']['register_argc_argv'] == 0) {
         $aSection['checks']['register_argc_argv']['warning'] = $GLOBALS['strWarningRegisterArgcArv'];
     }
     $aSection['checks']['pcre'] = $this->buildExtensionCheckEntry('pcre', $aEnvPhp);
     $aSection['checks']['xml'] = $this->buildExtensionCheckEntry('xml', $aEnvPhp);
     $aSection['checks']['zlib'] = $this->buildExtensionCheckEntry('zlib', $aEnvPhp);
     $aSection['checks']['spl'] = $this->buildExtensionCheckEntry('spl', $aEnvPhp);
     $aSection['checks']['mbstring.func_overload'] = $this->buildCheckEntry('mbstring.func_overload', $aEnvPhp, true, 'NOT OK', 'OK');
     $aSection['checks']['mysql'] = $this->buildExtensionCheckEntry('mysql', $aEnvPhp);
     $aSection['checks']['pgsql'] = $this->buildExtensionCheckEntry('pgsql', $aEnvPhp);
     $aSection = $this->buildCheckSectionMessages($aEnvPhp, $aSection);
     $aResult['php'] = $aSection;
     //PERMS section
     $aEnvPerms = $aSysInfo['PERMS'];
     $aSection = $this->buildCheckSection($aEnvPerms, 'File Permissions');
     foreach ($aEnvPerms['actual'] as $idx => $aVal) {
         $aSection['checks'][$aVal['file']] = array('name' => $aVal['file'], 'value' => $aVal['result'], 'errors' => empty($aVal['message']) ? null : array($aVal['message']), 'hasError' => $aVal['error']);
     }
     $aSection = $this->buildCheckSectionMessages($aEnvPerms, $aSection);
     $aResult['perms'] = $aSection;
     foreach ($aResult as $aSection) {
         $hasError = $hasError || $aSection['hasError'];
         $hasWarning = $hasWarning || $aSection['hasWarning'];
     }
     $oCheckModel = new SystemCheckModel($aResult, $hasError, $hasWarning);
     return $oCheckModel;
 }
예제 #3
0
 /**
  * This function recreates the data_summary_ad_hourly table rolls-up hourly stats to daily totals
  * The roll-up is done in accordance to the user's (currently) selected timezone
  *
  * @param PEAR_Date $oDate The date before which hourly stats should be rolled up
  */
 function _rollUpHourlyStatsToDaily($oDate)
 {
     $sDate = $oDate->format('%Y-%m-%d 00:00:00');
     $updated = OA::getNowUTC('Y-m-d h:i:s');
     OA::debug("Beginning stats rollup for pre-{$sDate}", PEAR_LOG_INFO);
     // First create a temporary table with ad_id/offset pairs, this can then be joined in a (compled) INSERT INTO ... SELECT FROM statement
     $aTimezones = OX_Admin_Timezones::availableTimezones(false);
     $aAdminPreferences = OA_Preferences::loadAdminAccountPreferences(true);
     $aAdminTzOffset = $this->_getSqlOffsetFromString($aTimezones[$aAdminPreferences['timezone']]);
     // CREATE a timezone string => offset table (since the format we use in PHP is incompatible with the format used by MySQL)
     $this->oDbh->exec("DROP TABLE IF EXISTS {$this->prefix}tmp_tz_offset");
     $this->oDbh->exec("CREATE TABLE `{$this->prefix}tmp_tz_offset`\n                               (`timezone` varchar(32) NOT NULL PRIMARY KEY, `offset` char(6) NOT NULL DEFAULT '+00:00') ENGINE={$this->conf['table']['type']}");
     foreach ($aTimezones as $tzString => $tzData) {
         $tzData = $this->_getSqlOffsetFromString($tzData);
         $this->oDbh->exec("INSERT INTO {$this->prefix}tmp_tz_offset (timezone, offset) VALUES('{$tzString}', '{$tzData}')");
     }
     OA::debug("Created timezone/offset mapping table", PEAR_LOG_DEBUG);
     // CREATE an ad_id => offset table
     $this->oDbh->exec("DROP TABLE IF EXISTS {$this->prefix}tmp_ad_offset");
     $this->oDbh->exec("CREATE TABLE `{$this->prefix}tmp_ad_offset`\n                               (`ad_id` int(11) NOT NULL PRIMARY KEY, `offset` char(6) NOT NULL DEFAULT '+00:00') ENGINE={$this->conf['table']['type']}");
     $this->oDbh->exec("INSERT INTO {$this->prefix}tmp_ad_offset SELECT bannerid, '{$aAdminTzOffset}' FROM {$this->prefix}banners AS b");
     $this->oDbh->exec("UPDATE\n                            {$this->prefix}tmp_ad_offset AS ao,\n                            {$this->prefix}banners AS b,\n                            {$this->prefix}campaigns AS c,\n                            {$this->prefix}clients AS cl,\n                            {$this->prefix}agency AS ag,\n                            {$this->prefix}account_preference_assoc AS apa,\n                            {$this->prefix}preferences AS p,\n                            {$this->prefix}tmp_tz_offset AS tzo\n                          SET ao.offset = tzo.offset\n                          WHERE\n                              p.preference_name = 'timezone'\n                            AND apa.preference_id = p.preference_id\n                            AND apa.account_id = ag.account_id\n                            AND cl.agencyid=ag.agencyid\n                            AND ao.ad_id=b.bannerid\n                            AND c.campaignid=b.campaignid\n                            AND cl.clientid=c.clientid\n                            AND ag.agencyid=cl.agencyid\n                            AND apa.value = tzo.timezone;\n                        ");
     OA::debug("Created ad/offset mapping table", PEAR_LOG_DEBUG);
     // So, now we have a table tmp_ad_offset which contains every banner id, and the offset of the account it belongs to.
     // We can use this to do a complex GROUP BY to collapse data down into the user's timzone's midday
     $this->oDbh->exec("DROP TABLE IF EXISTS {$this->prefix}data_summary_ad_hourly_rolledup");
     $this->oDbh->exec("DROP TABLE IF EXISTS {$this->prefix}data_summary_ad_hourly_backup");
     // Create a new stats table, we do this because trying to delete a bunch of records from the existing table would just fragment the index
     $this->oDbh->exec("CREATE TABLE {$this->prefix}data_summary_ad_hourly_rolledup LIKE {$this->prefix}data_summary_ad_hourly;");
     // Copy stats over from the existing table to the new table, rolling up according to each ad's offset
     OA::debug("Beginning rolled-up stats copy...", PEAR_LOG_DEBUG);
     $this->oDbh->exec("INSERT INTO {$this->prefix}data_summary_ad_hourly_rolledup (\n                               date_time, ad_id, creative_id, zone_id, requests, impressions, clicks, conversions,\n                               total_basket_value, total_num_items, total_revenue, total_cost, total_techcost, updated )\n                           SELECT\n                               CONVERT_TZ(DATE_FORMAT(CONVERT_TZ(dsah.date_time, '+00:00', ao.offset), '%Y-%m-%d 12:00:00'), ao.offset, '+00:00') AS tz_date_time,\n                               dsah.ad_id, dsah.creative_id, dsah.zone_id, SUM(dsah.requests), SUM(dsah.impressions), SUM(dsah.clicks), SUM(dsah.conversions),\n                               SUM(dsah.total_basket_value), SUM(dsah.total_num_items), SUM(dsah.total_revenue), SUM(dsah.total_cost), SUM(dsah.total_techcost), '{$updated}'\n                           FROM\n                               {$this->prefix}data_summary_ad_hourly AS dsah,\n                               {$this->prefix}tmp_ad_offset AS ao\n                           WHERE\n                               ao.ad_id=dsah.ad_id\n                             AND CONVERT_TZ(dsah.date_time, '+00:00', ao.offset) < '{$sDate}'\n                           GROUP BY\n                               tz_date_time, ad_id, creative_id, zone_id;\n                           ");
     OA::debug("Completed rolled-up stats copy...", PEAR_LOG_DEBUG);
     // Copy any un-rolled up stats records over into the new table
     OA::debug("Beginning *non* rolled-up stats copy...", PEAR_LOG_DEBUG);
     $this->oDbh->exec("INSERT INTO {$this->prefix}data_summary_ad_hourly_rolledup (\n                               date_time, ad_id, creative_id, zone_id, requests, impressions, clicks, conversions,\n                               total_basket_value,  total_num_items,  total_revenue, total_cost, total_techcost, updated)\n                           SELECT\n                               dsah.date_time AS tz_date_time, dsah.ad_id, dsah.creative_id, dsah.zone_id, dsah.requests, dsah.impressions, dsah.clicks, dsah.conversions,\n                               dsah.total_basket_value, dsah.total_num_items, dsah.total_revenue, dsah.total_cost, dsah.total_techcost, '{$updated}'\n                           FROM\n                               {$this->prefix}data_summary_ad_hourly AS dsah,\n                               {$this->prefix}tmp_ad_offset AS ao\n                           WHERE\n                               ao.ad_id=dsah.ad_id\n                             AND CONVERT_TZ(dsah.date_time, '+00:00', ao.offset) >= '{$sDate}'\n                         ");
     OA::debug("Completed *non* rolled-up stats copy...", PEAR_LOG_DEBUG);
     // Swap the old table with the new
     $this->oDbh->exec("RENAME TABLE {$this->prefix}data_summary_ad_hourly TO {$this->prefix}data_summary_ad_hourly_backup");
     $this->oDbh->exec("RENAME TABLE {$this->prefix}data_summary_ad_hourly_rolledup TO {$this->prefix}data_summary_ad_hourly");
     OA::debug("Swapped new table for old...", PEAR_LOG_DEBUG);
     // Cleanup
     $this->oDbh->exec("DROP TABLE {$this->prefix}tmp_ad_offset;");
     $this->oDbh->exec("DROP TABLE {$this->prefix}tmp_tz_offset;");
     OA::debug("Woo hoo stats rolled up for pre-{$sDate}", PEAR_LOG_INFO);
 }
 public function configurationAction()
 {
     $oWizard = new OX_Admin_UI_Install_Wizard($this->getInstallStatus());
     $this->setCurrentStepIfReachable($oWizard, 'configuration');
     $oUpgrader = $this->getUpgrader();
     $isUpgrade = $this->getInstallStatus()->isUpgrade();
     //setup form
     $aPluginsVerifyResult = OX_Admin_UI_Install_InstallUtils::checkPluginsVerified();
     $prevPathRequired = !$aPluginsVerifyResult['verified'];
     $oLanguage = new MAX_Admin_Languages();
     $aLanguages = $oLanguage->AvailableLanguages();
     $aTimezones = OX_Admin_Timezones::AvailableTimezones(true);
     $oForm = new OX_Admin_UI_Install_ConfigForm($this->oTranslation, $oWizard->getCurrentStep(), $aLanguages, $aTimezones, $isUpgrade, $prevPathRequired);
     $aStepData = $oWizard->getStepData();
     //setup defaults
     if ($this->getRequest()->isGet() && empty($aStepData)) {
         $aConfig = $oUpgrader->getConfig();
         if ($prevPathRequired) {
             $aConfig['previousInstallationPath'] = $aPluginsVerifyResult['path'];
         }
         $aStepData['config'] = $aConfig;
         //admin part
         $aStepData['prefs'] = array();
         $aStepData['prefs']['timezone'] = OX_Admin_Timezones::getTimezone();
         $aStepData['admin'] = array();
         $aStepData['admin']['language'] = 'en';
     }
     //populate form
     $oForm->populateForm($aStepData);
     //process if install
     if ($oForm->isSubmitted() && $oForm->validate()) {
         if ($this->processConfigurationAction($oForm, $oWizard, $isUpgrade)) {
             $aConfig = $oForm->populateConfig();
             $oWizard->setStepData($aConfig);
             $oWizard->markStepAsCompleted();
             $this->redirect('jobs');
         }
     }
     $this->setModelProperty('form', $oForm->serialize());
     $this->setModelProperty('oWizard', $oWizard);
     $this->setModelProperty('isUpgrade', $isUpgrade);
     $this->setModelProperty('loaderMessage', $GLOBALS['strConfigureProgressMessage']);
     $this->setModelProperty('isUpgrade', $isUpgrade);
 }
예제 #5
0
 /**
  * Returns an array of available timezones.
  *
  * @static
  * @param boolean $addBlank If set to true an empty entry will be added
  *                          to the beginning of the array.
  * @return array An array containing all the available timezones.
  */
 function availableTimezones($addBlank = false)
 {
     global $_DATE_TIMEZONE_DATA;
     $_aTimezoneBcData = array('Brazil/Acre', 'Brazil/DeNoronha', 'Brazil/East', 'Brazil/West', 'Canada/Atlantic', 'Canada/Central', 'Canada/East-Saskatchewan', 'Canada/Eastern', 'Canada/Mountain', 'Canada/Newfoundland', 'Canada/Pacific', 'Canada/Saskatchewan', 'Canada/Yukon', 'CET', 'Chile/Continental', 'Chile/EasterIsland', 'CST6CDT', 'Cuba', 'EET', 'Egypt', 'Eire', 'EST', 'EST5EDT', 'Etc/GMT', 'Etc/GMT+0', 'Etc/GMT+1', 'Etc/GMT+10', 'Etc/GMT+11', 'Etc/GMT+12', 'Etc/GMT+2', 'Etc/GMT+3', 'Etc/GMT+4', 'Etc/GMT+5', 'Etc/GMT+6', 'Etc/GMT+7', 'Etc/GMT+8', 'Etc/GMT+9', 'Etc/GMT-0', 'Etc/GMT-1', 'Etc/GMT-10', 'Etc/GMT-11', 'Etc/GMT-12', 'Etc/GMT-13', 'Etc/GMT-14', 'Etc/GMT-2', 'Etc/GMT-3', 'Etc/GMT-4', 'Etc/GMT-5', 'Etc/GMT-6', 'Etc/GMT-7', 'Etc/GMT-8', 'Etc/GMT-9', 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', 'Etc/Universal', 'Etc/UTC', 'Etc/Zulu', 'Factory GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich', 'Hongkong', 'HST', 'Iceland', 'Iran', 'Israel', 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'Mexico/BajaNorte', 'Mexico/BajaSur', 'Mexico/General', 'MST', 'MST7MDT', 'Navajo', 'NZ', 'NZ-CHAT', 'Poland', 'Portugal', 'PRC', 'PST8PDT', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT', 'Universal', 'US/Alaska', 'US/Aleutian', 'US/Arizona', 'US/Central', 'US/East-Indiana', 'US/Eastern', 'US/Hawaii', 'US/Indiana-Starke', 'US/Michigan', 'US/Mountain', 'US/Pacific', 'US/Pacific-New', 'US/Samoa', 'UTC', 'W-SU', 'WET', 'Zulu');
     // Load translations
     require_once MAX_PATH . '/lib/max/language/Loader.php';
     Language_Loader::load('timezone');
     // Load global array of timezones
     require_once MAX_PATH . '/lib/pear/Date/TimeZone.php';
     $aTimezoneKey = Date_TimeZone::getAvailableIDs();
     if (!defined('MAX_PATH')) {
         $tz = OX_Admin_Timezones::getTimezone();
     } else {
         $tz = $GLOBALS['_MAX']['PREF']['timezone'];
         if (is_null($tz)) {
             $tz = OX_Admin_Timezones::getTimezone();
         }
     }
     foreach ($aTimezoneKey as $key) {
         if (in_array($tz, $_aTimezoneBcData) && $key == $tz || !in_array($key, $_aTimezoneBcData)) {
             // Calculate the timezone offset
             $offset = OX_Admin_Timezones::_convertOffset($_DATE_TIMEZONE_DATA[$key]['offset']);
             // Build the arrays used for sorting time zones
             $origOffset = $_DATE_TIMEZONE_DATA[$key]['offset'];
             $key = !empty($GLOBALS['strTimezoneList'][$key]) ? $GLOBALS['strTimezoneList'][$key] : $key;
             if ($origOffset >= 0) {
                 $aTimezone[$offset][$key] = "(GMT+{$offset}) {$key}";
             } else {
                 $aNegTimezone[$key] = "(GMT-{$offset}) {$key}";
             }
         }
     }
     // Sort timezones with positive offsets descending, and negative
     // offests ascending.
     // Add initial empty key/value pair
     if ($addBlank) {
         $aResult[] = '';
     }
     // Sort time zones
     asort($aNegTimezone);
     // Reverse array element order while preserving alphabetical order
     $hasRun = false;
     foreach ($aTimezone as $offset => $aValue) {
         if ($hasRun == false) {
             $aRevTimezone[] = $aValue;
             $hasRun = true;
         } else {
             array_unshift($aRevTimezone, $aValue);
         }
     }
     // Build the result array
     foreach ($aRevTimezone as $aValue) {
         foreach ($aValue as $k => $v) {
             $aResult[$k] = $v;
         }
     }
     foreach ($aNegTimezone as $key => $value) {
         $aResult[$key] = $value;
     }
     return $aResult;
 }
예제 #6
0
*/
/**
 * A script file to run the Maintenance Statistics Engine and the
 * Maintenance Priority Engine processes.
 *
 * @package    OpenXMaintenance
 * @subpackage Tools
 */
// Set the current path
// Done this way so that it works in CLI PHP
$path = dirname(__FILE__);
// Require the timezone class, and get the system timezone,
// storing in a global variable
global $serverTimezone;
require_once $path . '/../../lib/OX/Admin/Timezones.php';
$serverTimezone = OX_Admin_Timezones::getTimezone();
// Require the initialisation file
require_once $path . '/../../init.php';
// Set longer time out, and ignore user abort
if (!ini_get('safe_mode')) {
    @set_time_limit($conf['maintenance']['timeLimitScripts']);
    @ignore_user_abort(true);
}
// Required files
require_once RV_PATH . '/lib/RV.php';
require_once MAX_PATH . '/lib/Max.php';
require_once OX_PATH . '/lib/OX.php';
require_once LIB_PATH . '/Maintenance.php';
$oMaint = new OX_Maintenance();
$oMaint->run();
// Update scheduled maintenance last run record
        $translated_message = $translation->translate($GLOBALS['strXPreferencesHaveBeenUpdated'], array(htmlspecialchars($title)));
        OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
        OX_Admin_Redirect::redirect(basename($_SERVER['PHP_SELF']));
    }
    // Could not write the preferences to the database, store this
    // error message and continue
    $aErrormessage[0][] = $strUnableToWritePrefs;
}
// Set the correct section of the preference pages and display the drop-down menu
$setPref = $oOptions->getSettingsPreferences($prefSection);
$title = $setPref[$prefSection]['name'];
// Display the settings page's header and sections
$oHeaderModel = new OA_Admin_UI_Model_PageHeaderModel($title);
phpAds_PageHeader('account-preferences-index', $oHeaderModel);
// Get timezone dropdown information
$aTimezones = OX_Admin_Timezones::availableTimezones(true);
$oConfigTimezone = trim($GLOBALS['_MAX']['PREF']['timezone']);
if (empty($oConfigTimezone)) {
    // There is no value stored in the configuration file, as it
    // is not required (ie. the TZ comes from the environment) -
    // so set that environment value in the config file now
    $GLOBALS['_MAX']['PREF']['timezone'] = $timezone;
}
// What display string do we need to show for the timezone?
if (!empty($oConfigTimezone)) {
    $strTimezoneToDisplay = $oConfigTimezone;
} else {
    $strTimezoneToDisplay = $timezone;
}
$strTimezoneToDisplay = $GLOBALS['_MAX']['PREF']['timezone'];
// Prepare an array of HTML elements to display for the form, and
예제 #8
0
파일: OA.php 프로젝트: villos/tree_admin
 /**
  * A method to log debugging messages to the location configured by the user.
  *
  * Note: If the global variable $currentTimezone is set, where the array
  * is the result of OX_Admin_Timezones::getTimezone(), called BEFORE any
  * timezone information has been set (i.e. before the init script has been
  * called), then this method will ensure that all debug messages are logged
  * in the SERVER TIME ZONE, rather than the time zone that the software
  * happens to be running in (i.e. the current manager timezone, or UTC for
  * maintenance).
  *
  * @static
  * @param mixed $message     Either a string or a PEAR_Error object.
  * @param integer $priority  The priority of the message. One of:
  *                           PEAR_LOG_EMERG, PEAR_LOG_ALERT, PEAR_LOG_CRIT
  *                           PEAR_LOG_ERR, PEAR_LOG_WARNING, PEAR_LOG_NOTICE
  *                           PEAR_LOG_INFO, PEAR_LOG_DEBUG
  * @return boolean           True on success or false on failure.
  *
  * @TODO Logging to anything other than a file is probably broken - test!
  */
 function debug($message = null, $priority = PEAR_LOG_INFO)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     global $tempDebugPrefix;
     // Logging is not activated
     if ($aConf['log']['enabled'] == false) {
         unset($GLOBALS['tempDebugPrefix']);
         return true;
     }
     // Is this a "no message" log?
     if (is_null($message) && $aConf['log']['type'] == 'file') {
         // Set the priority to the highest level, so it is always logged
         $priority = PEAR_LOG_EMERG;
     }
     // Deal with the config file containing the log level by
     // name or by number
     $priorityLevel = is_numeric($aConf['log']['priority']) ? $aConf['log']['priority'] : @constant($aConf['log']['priority']);
     if (is_null($priorityLevel)) {
         $priorityLevel = $aConf['log']['priority'];
     }
     if ($priority > $priorityLevel) {
         unset($GLOBALS['tempDebugPrefix']);
         return true;
     }
     // Grab DSN if we are logging to a database
     $dsn = $aConf['log']['type'] == 'sql' ? Base::getDsn() : '';
     // Instantiate a logger object based on logging options
     $aLoggerConf = array($aConf['log']['paramsUsername'], $aConf['log']['paramsPassword'], 'dsn' => $dsn, 'mode' => octdec($aConf['log']['fileMode']), 'timeFormat' => '%b %d %H:%M:%S %z');
     if (is_null($message) && $aConf['log']['type'] == 'file') {
         $aLoggerConf['lineFormat'] = '%4$s';
     } else {
         if ($aConf['log']['type'] == 'file') {
             $aLoggerConf['lineFormat'] = '%1$s %2$s [%3$9s]  %4$s';
         }
     }
     $ident = !empty($GLOBALS['_MAX']['LOG_IDENT']) ? $GLOBALS['_MAX']['LOG_IDENT'] : $aConf['log']['ident'];
     if ($ident == $aConf['log']['ident'] . '-delivery' && empty($aConf['deliveryLog']['enabled'])) {
         unset($GLOBALS['tempDebugPrefix']);
         return true;
     }
     $logFile = $ident == $aConf['log']['ident'] . '-delivery' ? $aConf['deliveryLog']['name'] : $aConf['log']['name'];
     $oLogger =& Log::singleton($aConf['log']['type'], MAX_PATH . '/var/' . $logFile, $ident, $aLoggerConf);
     // If log message is an error object, extract info
     if (PEAR::isError($message)) {
         $userinfo = $message->getUserInfo();
         $message = $message->getMessage();
         if (!empty($userinfo)) {
             if (is_array($userinfo)) {
                 $userinfo = implode(', ', $userinfo);
             }
             $message .= ' : ' . $userinfo;
         }
     }
     // Obtain backtrace information
     $aBacktrace = debug_backtrace();
     if ($aConf['log']['methodNames']) {
         // Show from four calls up the stack, to avoid the
         // showing the PEAR error call info itself
         $aErrorBacktrace = $aBacktrace[4];
         if (isset($aErrorBacktrace['class']) && $aErrorBacktrace['type'] && isset($aErrorBacktrace['function'])) {
             $callInfo = $aErrorBacktrace['class'] . $aErrorBacktrace['type'] . $aErrorBacktrace['function'] . ': ';
             $message = $callInfo . $message;
         }
     }
     // Show entire stack, line-by-line
     if ($aConf['log']['lineNumbers']) {
         foreach ($aBacktrace as $aErrorBacktrace) {
             if (isset($aErrorBacktrace['file']) && isset($aErrorBacktrace['line'])) {
                 $message .= "\n" . str_repeat(' ', 20 + strlen($aConf['log']['ident']) + strlen($oLogger->priorityToString($priority)));
                 $message .= 'on line ' . $aErrorBacktrace['line'] . ' of "' . $aErrorBacktrace['file'] . '"';
             }
         }
     }
     // Log messages in the local server timezone, if possible
     global $serverTimezone;
     if (!empty($serverTimezone)) {
         $currentTimezone = OX_Admin_Timezones::getTimezone();
         OA_setTimeZone($serverTimezone);
     }
     // Log the message
     if (is_null($message) && $aConf['log']['type'] == 'file') {
         $message = ' ';
     } else {
         if (!is_null($tempDebugPrefix) && $aConf['log']['type'] == 'file') {
             $message = $tempDebugPrefix . $message;
         }
     }
     $result = $oLogger->log($message, $priority);
     // Restore the timezone
     if (!empty($currentTimezone)) {
         OA_setTimeZone($currentTimezone);
     }
     unset($GLOBALS['tempDebugPrefix']);
     return $result;
 }
예제 #9
0
             }
         }
     }
     $action = OA_UPGRADE_CONFIGSETUP;
 } else {
     if (array_key_exists('btn_adminsetup', $_POST)) {
         if (!OA_Upgrade_Login::checkLogin()) {
             $message = $strUsernameOrPasswordWrong;
             $action = OA_UPGRADE_LOGIN;
         } else {
             // Acquire the sync settings from session in order to add them
             session_start();
             $syncEnabled = !empty($_SESSION['checkForUpdates']);
             // Store the detected timezone of the system, whatever that is
             require_once '../../lib/OX/Admin/Timezones.php';
             $timezone['timezone'] = OX_Admin_Timezones::getTimezone();
             if ($oUpgrader->saveConfig($_POST['aConfig']) && $oUpgrader->putSyncSettings($syncEnabled) && $oUpgrader->putTimezoneAccountPreference($aTimezone, true)) {
                 if (!checkFolderPermissions($_POST['aConfig']['store']['webDir'])) {
                     $aConfig = $_POST['aConfig'];
                     $aConfig['store']['webDir'] = stripslashes($aConfig['store']['webDir']);
                     $errMessage = $strImageDirLockedDetected;
                     $action = OA_UPGRADE_CONFIGSETUP;
                 } else {
                     if ($_COOKIE['oat'] == OA_UPGRADE_INSTALL) {
                         $action = OA_UPGRADE_ADMINSETUP;
                     } else {
                         $message = $strUpgradeComplete;
                         $action = OA_UPGRADE_PLUGINS;
                     }
                 }
             } else {