function testGetTimezone()
 {
     // Set environment variable
     date_default_timezone_set('America/Detroit');
     $timezone = OX_Admin_Timezones::getTimezone();
     $this->assertEqual('America/Detroit', $timezone);
 }
 /**
  * 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;
 }
 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);
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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
| but WITHOUT ANY WARRANTY; without even the implied warranty of            |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
| GNU General Public License for more details.                              |
|                                                                           |
| You should have received a copy of the GNU General Public License         |
| along with this program; if not, write to the Free Software               |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |
+---------------------------------------------------------------------------+
$Id: account-preferences-timezone.php 37157 2009-05-28 12:31:10Z andrew.hill $
*/
// Obtain the server timezone information *before* the init script is
// called, to ensure that the timezone information from the server is
// not affected by any calls to date_default_timezone_set() or
// putenv("TZ=...") to set the timezone manually
require_once '../../lib/OX/Admin/Timezones.php';
$timezone = OX_Admin_Timezones::getTimezone();
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/lib/OA/Admin/Option.php';
require_once MAX_PATH . '/lib/OA/Admin/UI/UserAccess.php';
require_once MAX_PATH . '/lib/max/Admin/Languages.php';
require_once MAX_PATH . '/lib/max/Plugin/Translation.php';
require_once MAX_PATH . '/www/admin/config.php';
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER, OA_ACCOUNT_TRAFFICKER);
// Load the account's preferences, with additional information, into a specially named array
$GLOBALS['_MAX']['PREF_EXTRA'] = OA_Preferences::loadPreferences(true, true);
// Create a new option object for displaying the setting's page's HTML form
$oOptions = new OA_Admin_Option('preferences');
$prefSection = "timezone";
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
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 {