/** * Returns a new TimeZone object. * * @param StringLiteral $name * * @throws InvalidTimeZoneException */ public function __construct(StringLiteral $name) { if (!in_array($name->toNative(), timezone_identifiers_list())) { throw new InvalidTimeZoneException($name); } $this->name = $name; }
static function __generateTimezoneSelectOptions($default_tz) { $timezone_identifiers = timezone_identifiers_list(); sort($timezone_identifiers); $current_continent = ""; $options_list = ""; foreach ($timezone_identifiers as $timezone_identifier) { list($continent, ) = explode("/", $timezone_identifier, 2); if (in_array($continent, array("Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Australia", "Europe", "Indian", "Pacific"))) { list(, $city) = explode("/", $timezone_identifier, 2); if (strlen($current_continent) === 0) { $options_list .= "<optgroup label=\"" . $continent . "\">"; // Start first continent optgroup } elseif ($current_continent != $continent) { $options_list .= "</optgroup><optgroup label=\"" . $continent . "\">"; // End old optgroup and start new continent optgroup } $options_list .= "<option" . ($timezone_identifier == $default_tz ? " selected=\"selected\"" : "") . " value=\"" . $timezone_identifier . "\">" . str_replace("_", " ", $city) . "</option>"; //Timezone } $current_continent = $continent; } $options_list .= "</optgroup>"; // End last continent optgroup return $options_list; }
/** * Check valid time zone * * @param string $time_zone * @return bool */ protected function isValidTimeZone($time_zone) { if (in_array($time_zone, timezone_identifiers_list())) { return true; } return false; }
public function getcontent() { $merger = tlocalmerger::i(); $tabs = new tuitabs(); $html = $this->html; $lang = tlocal::i('options'); $args = targs::i(); foreach ($merger->items as $section => $items) { $tab = new tuitabs(); $tab->add($lang->files, $html->getinput('editor', $section . '_files', tadminhtml::specchars(implode("\n", $items['files'])), $lang->files)); $tabtext = new tuitabs(); foreach ($items['texts'] as $key => $text) { $tabtext->add($key, $html->getinput('editor', $section . '_text_' . $key, tadminhtml::specchars($text), $key)); } $tab->add($lang->text, $tabtext->get()); $tabs->add($section, $tab->get()); } $tabs->add('HTML', $html->getinput('editor', 'adminhtml_files', tadminhtml::specchars(implode("\n", $merger->html)), $lang->files)); $args->formtitle = $lang->optionslocal; $args->dateformat = litepublisher::$options->dateformat; $dirs = tfiler::getdir(litepublisher::$paths->languages); $args->language = tadminhtml::array2combo(array_combine($dirs, $dirs), litepublisher::$options->language); $zones = timezone_identifiers_list(); $args->timezone = tadminhtml::array2combo(array_combine($zones, $zones), litepublisher::$options->timezone); return $html->adminform('[text=dateformat] [combo=language] [combo=timezone]' . $tabs->get(), $args); }
/** * Constructor, given a file to open * * **/ function timezone($file) { $this->tz_file = $file; /* some safe default */ $this->next_update = time() + DAY_IN_SECONDS * 30; $this->valid_names = timezone_identifiers_list(); }
public function __construct(array $options) { if (isset($options['value'])) { if (!isset($options['interval'])) { $options['interval'] = $options['value']; } unset($options['value']); } if (!isset($options['interval'])) { throw new \InvalidArgumentException(sprintf('CronJob exception: Interval not found in @CronJob')); } try { new \DateInterval($options['interval']); } catch (\Exception $e) { throw new \InvalidArgumentException(sprintf('CronJob exception: %s', $e->getMessage())); } if (!isset($options['start'])) { $now = new \DateTime(); $options['start'] = $now->format('Y-m-d H:i:s'); } if (!isset($options['timezone']) || !in_array($options['timezone'], timezone_identifiers_list())) { $options['timezone'] = date_default_timezone_get(); } foreach ($options as $key => $value) { if (!property_exists($this, $key)) { throw new \InvalidArgumentException(sprintf('CronJob exception: Property "%s" does not exist', $key)); } $this->{$key} = $value; } }
function form_fuseau_horaire($defaut) { if (version_compare(PHP_VERSION, '5.2.0', '>=')) { $all_timezones = timezone_identifiers_list(); $liste_fuseau = array(); $cities = array(); foreach ($all_timezones as $tz) { $spos = strpos($tz, '/'); if ($spos !== FALSE) { $continent = substr($tz, 0, $spos); $city = substr($tz, $spos + 1); $liste_fuseau[$continent][] = array('tz_name' => $tz, 'city' => $city); } if ($tz == 'UTC') { $liste_fuseau['UTC'][] = array('tz_name' => 'UTC', 'city' => 'UTC'); } } $form = '<label>' . $GLOBALS['lang']['pref_fuseau_horaire'] . '</label>' . "\n"; $form .= '<select name="fuseau_horaire">' . "\n"; foreach ($liste_fuseau as $continent => $zone) { $form .= "\t" . '<optgroup label="' . ucfirst(strtolower($continent)) . '">' . "\n"; foreach ($zone as $fuseau) { $form .= "\t\t" . '<option value="' . htmlentities($fuseau['tz_name']) . '"'; $form .= $defaut == $fuseau['tz_name'] ? ' selected="selected"' : ''; $timeoffset = date_offset_get(date_create('now', timezone_open($fuseau['tz_name']))); $formated_toffset = '(UTC' . ($timeoffset < 0 ? '–' : '+') . str2(floor(abs($timeoffset) / 3600)) . ':' . str2(floor(abs($timeoffset) % 3600 / 60)) . ') '; $form .= '>' . $formated_toffset . ' ' . htmlentities($fuseau['city']) . '</option>' . "\n"; } $form .= "\t" . '</optgroup>' . "\n"; } $form .= '</select>' . "\n"; return $form; } }
public function render($tpl = null) { //authenticate the current user to make sure they are an admin UsersHelper::authenticateAdmin(); //display toolbar $this->toolbar = new Toolbar(); $this->toolbar->save(); //document $document = JFactory::getDocument(); $document->addScript(JURI::base() . "/src/Cobalt/media/js/cobalt-admin.js"); /* Menu Links **/ $menu = MenuHelper::getMenuModules(); $this->menu = $menu; //get model $model = new ConfigModel(); $layout = $this->getLayout(); $model->set("_layout", $layout); //get config $config = $model->getConfig(); //generate timezones $list = timezone_identifiers_list(); $timezones = array(); foreach ($list as $zone) { $timezones[$zone] = $zone; } //view references $this->imap_found = function_exists('imap_open') ? TRUE : FALSE; $this->config = $config; $this->timezones = $timezones; $this->time_formats = DateHelper::getTimeFormats(); $this->languages = ConfigHelper::getLanguages(); $this->language = ConfigHelper::getLanguage(); //display return parent::render(); }
static function getSql($schema = 'Myisam') { if(!Piwik::isTimezoneSupportEnabled()) { return array(); } // @see http://bugs.php.net/46111 $timezones = timezone_identifiers_list(); $brokenTZ = array(); foreach ($timezones as $timezone) { $testDate = "2008-08-19 13:00:00 " . $timezone; if (!strtotime($testDate)) { $brokenTZ[] = $timezone; } } $timezoneList = '"'. implode('","', $brokenTZ) . '"'; return array( 'UPDATE '. Piwik_Common::prefixTable('site') .' SET timezone = "UTC" WHERE timezone IN ('. $timezoneList .')' => false, 'UPDATE `'. Piwik_Common::prefixTable('option') .'` SET option_value = "UTC" WHERE option_name = "SitesManager_DefaultTimezone" AND option_value IN ('. $timezoneList .')' => false, ); }
function timezonechoice($selectedzone) { $all = timezone_identifiers_list(); $i = 0; foreach ($all as $zone) { $zone = explode('/', $zone); $zonen[$i]['continent'] = $zone[0]; $zonen[$i]['city'] = $zone[1]; $i++; } asort($zonen); foreach ($zonen as $zone) { extract($zone); if ($continent == 'Africa' or $continent == 'America' or $continent == 'Antarctica' or $continent == 'Arctic' or $continent == 'Asia' or $continent == 'Atlantic' or $continent == 'Australia' or $continent == 'Europe' or $continent == 'Indian' or $continent == 'Pacific') { if (!isset($letztercontinent)) { $structure .= ' <optgroup label="' . $continent . '">'; } elseif ($letztercontinent != $continent) { $structure .= '</optgroup> <optgroup label="' . $continent . '">'; } // continent if ($city != '') { $structure .= "\r\n<option " . ($continent . '/' . $city == $selectedzone ? 'selected="selected "' : '') . " value=\"" . ($continent . '/' . $city) . "\">" . str_replace('_', ' ', $city) . "</option>"; } else { $structure .= "\r\n<option " . ($continent == $selectedzone ? 'selected="selected "' : '') . " value=\"" . $continent . "\">" . $continent . "</option>"; } //Timezone $letztercontinent = $continent; } } $structure .= ' </optgroup>'; return $structure; }
public function form() { $timezoneList = timezone_identifiers_list(); sort($timezoneList); $timezoneList = array_combine($timezoneList, $timezoneList); return array('elements' => array('login' => array('type' => 'text'), 'displayname' => array('type' => 'text'), 'email' => array('type' => 'text'), 'password' => array('type' => 'password', 'value' => '', 'hint' => !Yii::app()->user->isGuest ? Yii::t('cms', 'Enter your password only if you want to replace it') : ''), 'password_repeat' => array('type' => 'password'), 'active' => array('type' => 'checkbox'), 'captcha' => array('type' => 'text', 'label' => Yii::t('cms', 'Verify code') . Yii::app()->controller->widget("CCaptcha", array('captchaAction' => 'site/captcha', 'clickableImage' => true), true), 'hint' => Yii::t('cms', 'Enter the symbols from the image')), 'agreed' => array('type' => 'radio'), 'askfill' => array('type' => 'checkbox'), 'show_email' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'send_message' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'timezone' => array('type' => 'dropdownlist', 'items' => $timezoneList), 'extra_fields' => array('type' => 'Fields', 'config' => User::extraFields()), '_roles' => array('type' => 'Select2', 'related' => '_roles', 'showAttribute' => 'title'))); }
public function buildForm(FormBuilderInterface $builder, array $options) { $timeZones = array(); array_walk(timezone_identifiers_list(), function ($timeZone) use(&$timeZones) { $timeZoneGroup = strpos($timeZone, '/') !== false ? substr($timeZone, 0, strpos($timeZone, '/')) : $timeZone; $value = strpos($timeZone, '/') !== false ? substr($timeZone, strpos($timeZone, '/') + 1) : $timeZone; $value = str_replace('_', ' ', $value); $value = str_replace('/', ' - ', $value); $timeZones[$timeZoneGroup][$timeZone] = $value; }); $availableCacheEngines = $options['cacheService']->getAvailableCacheEngines(); $availableTemplateCacheHandlers = \CampTemplateCache::availableHandlers(); $cacheEngines = array(); $cacheTemplate = array(); foreach ($availableCacheEngines as $cacheEngineName => $engineValue) { $cacheEngines[$engineValue] = $cacheEngineName; } foreach ($availableTemplateCacheHandlers as $handler => $value) { $cacheTemplate[$handler] = $handler; } $cacheLifetime = array(); foreach (array(0 => 'newscoop.preferences.label.disabled', 30 => '30 Seconds', 60 => '1 Minute', 300 => '5 Minutes', 900 => '15 Minutes', 1800 => '30 Minutes', 3600 => '1 Hour', 3600 * 24 => '1 Day', 3600 * 24 * 2 => '2 Days', 3600 * 24 * 3 => '3 Days', 3600 * 24 * 4 => '4 Days', 3600 * 24 * 5 => '5 Days', 3600 * 24 * 6 => '6 Days', 3600 * 24 * 7 => '1 Week', 3600 * 24 * 14 => '2 Weeks', 3600 * 24 * 21 => '3 Weeks', 3600 * 24 * 31 => '1 Month', 3600 * 24 * 61 => '2 Months', 3600 * 24 * 91 => '3 Months', 3600 * 24 * 183 => '6 Months', 3600 * 24 * 365 => '1 Year', -1 => 'Infinite') as $k => $v) { $cacheLifetime[$k] = $v; } $language_codes_639_1 = \Language::Get6391List(); asort($language_codes_639_1); $languages = array(); foreach ($language_codes_639_1 as $geo_lang_code => $geo_lang_name) { $languages[$geo_lang_code] = $geo_lang_name; } $builder->add('siteonline', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('title', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('meta_keywords', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('meta_description', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('timezone', 'choice', array('choices' => $timeZones, 'placeholder' => 'newscoop.preferences.label.disabled', 'required' => false))->add('cache_engine', 'choice', array('choices' => $cacheEngines, 'placeholder' => 'Array', 'required' => false))->add('cache_engine_host', 'text', array('error_bubbling' => true, 'required' => false))->add('cache_engine_port', 'text', array('error_bubbling' => true, 'required' => false))->add('cache_template', 'choice', array('choices' => $cacheTemplate, 'placeholder' => 'newscoop.preferences.label.disabled', 'required' => false))->add('cache_image', 'choice', array('choices' => $cacheLifetime, 'constraints' => array(new Assert\NotBlank())))->add('allow_recovery', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('secret_key', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\Length(array('max' => 32)))))->add('session_lifetime', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 86400)))))->add('separator', null, array('attr' => array('size' => '5'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 2)))))->add('captcha', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 99)))))->add('max_upload_size', null, array('attr' => array('size' => '5'), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 12)))))->add('automatic_collection', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('smtp_host', null, array('attr' => array('size' => 64), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('smtp_port', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 1, 'max' => 999999)))))->add('email_from', 'email', array('attr' => array('size' => 64), 'constraints' => array(new Assert\NotBlank(), new Assert\Email(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 100)))))->add('image_ratio', 'integer', array('attr' => array('max' => 100, 'min' => 1), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 1, 'max' => 100)))))->add('image_width', 'integer', array('constraints' => array(new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('image_height', 'integer', array('constraints' => array(new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('zoom', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('mediaRichTextCaptions', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('mediaCaptionLength', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('use_replication', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('use_replication_host', null, array('attr' => array('size' => 30), 'constraints' => array(new Assert\Length(array('max' => 60)))))->add('use_replication_user', null, array('attr' => array('size' => 30), 'constraints' => array(new Assert\Length(array('max' => 20)))))->add('use_replication_password', null, array('attr' => array('size' => 30), 'constraints' => array(new Assert\Length(array('max' => 20)))))->add('use_replication_port', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999999)))))->add('template_filter', 'text', array('attr' => array('size' => 30), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 50)))))->add('mysql_client_command_path', 'text', array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('center_latitude_default', 'number', array('attr' => array('size' => 10), 'precision' => 6, 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'float')))))->add('center_longitude_default', 'number', array('attr' => array('size' => 10), 'precision' => 6, 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'float')))))->add('map_display_resolution_default', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 99)))))->add('map_view_width_default', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_view_height_default', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_auto_cSS_file', null, array('attr' => array('size' => 50), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 80)))))->add('map_auto_focus_default', 'checkbox')->add('map_auto_focus_max_zoom', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 18)))))->add('map_auto_focus_border', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => -99, 'max' => 999)))))->add('map_provider_available_google_v3', 'checkbox')->add('map_provider_available_map_quest', 'checkbox')->add('map_provider_available_oSM', 'checkbox')->add('map_provider_default', 'choice', array('choices' => array('GoogleV3' => 'Google Maps', 'MapQuest' => 'MapQuest Open', 'OSM' => 'OpenStreetMap'), 'constraints' => array(new Assert\NotBlank())))->add('geo_search_local_geonames', 'checkbox', array('required' => false))->add('geo_search_mapquest_nominatim', 'checkbox', array('required' => false))->add('geo_search_preferred_language', 'choice', array('choices' => $languages, 'constraints' => array(new Assert\NotBlank())))->add('map_marker_directory', null, array('attr' => array('size' => 50), 'constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'string')), new Assert\Length(array('max' => 80)))))->add('map_marker_source_default', null, array())->add('map_popup_width_min', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_popup_height_min', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_width_you_tube', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_height_you_tube', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_width_vimeo', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_height_vimeo', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_width_flash', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('map_video_height_flash', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 0, 'max' => 999)))))->add('geo_flash_server', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 80)))))->add('geo_flash_directory', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('facebook_appid', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('facebook_appsecret', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('recaptchaPublicKey', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('recaptchaPrivateKey', null, array('attr' => array('size' => 40), 'constraints' => array(new Assert\Length(array('max' => 200)))))->add('recaptchaSecure', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'data' => 'N', 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('userGarbageActive', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('userGarbageDays', 'integer', array('constraints' => array(new Assert\NotBlank(), new Assert\Type(array('type' => 'integer')), new Assert\Range(array('min' => 1, 'max' => 999)))))->add('smartyUseProtocol', 'choice', array('choices' => array('Y' => 'newscoop.preferences.label.yesoption', 'N' => 'newscoop.preferences.label.nooption'), 'multiple' => false, 'expanded' => true, 'constraints' => array(new Assert\NotBlank())))->add('cronJobNotificationEmail', 'email', array('attr' => array('size' => 64), 'constraints' => array(new Assert\NotBlank(), new Assert\Email(), new Assert\Length(array('max' => 255)))))->add('cronJobSmtpSender', 'email', array('attr' => array('size' => 64), 'constraints' => array(new Assert\Email(), new Assert\Length(array('max' => 255)))))->add('cronJobSmtpSenderName', null, array('attr' => array('size' => '64'), 'constraints' => array(new Assert\Length(array('max' => 100))))); }
function user_settings_submit() { global $phpcid, $vars, $phpcdb, $phpc_user_tz, $phpc_user_lang, $phpc_prefix, $phpc_user, $phpc_script; verify_token(); // If we have a timezone, make sure it's valid if (!empty($vars["timezone"]) && !in_array($vars['timezone'], timezone_identifiers_list())) { soft_error(__("Invalid timezone.")); } // Expire 20 years in the future, give or take. $expiration_time = time() + 20 * 365 * 24 * 60 * 60; // One hour in the past $past_time = time() - 3600; if (!empty($vars["timezone"])) { setcookie("{$phpc_prefix}tz", $vars['timezone'], $expiration_time); } else { setcookie("{$phpc_prefix}tz", '', $past_time); } if (!empty($vars["language"])) { setcookie("{$phpc_prefix}lang", $vars['language'], $expiration_time); } else { setcookie("{$phpc_prefix}lang", '', $past_time); } if (is_user()) { $uid = $phpc_user->get_uid(); $phpcdb->set_user_default_cid($uid, $vars['default_cid']); $phpcdb->set_timezone($uid, $vars['timezone']); $phpcdb->set_language($uid, $vars['language']); $phpc_user_tz = $vars["timezone"]; $phpc_user_lang = $vars["language"]; } return message_redirect(__('Settings updated.'), "{$phpc_script}?action=user_settings&phpcid={$phpcid}"); }
public function getFromList(&$list) { //$list = array(); if (!function_exists("timezone_identifiers_list")) { return; } $zones = timezone_identifiers_list(); foreach ($zones as $zone) { $zone = explode('/', $zone); // 0 => Continent, 1 => City // Only use "friendly" continent names if ($zone[0] == 'Africa' || $zone[0] == 'America' || $zone[0] == 'Antarctica' || $zone[0] == 'Arctic' || $zone[0] == 'Asia' || $zone[0] == 'Atlantic' || $zone[0] == 'Australia' || $zone[0] == 'Europe' || $zone[0] == 'Indian' || $zone[0] == 'Pacific') { if (isset($zone[1]) != '') { $locations[$zone[0]][$zone[0] . '/' . $zone[1]] = str_replace('_', ' ', $zone[1]); // Creates array(DateTimeZone => 'Friendly name') } } } $continent = $this->getContinent(); if ($continent) { $continent_list = $locations[$continent]; } else { $continent_list = $locations['Africa']; } foreach ($continent_list as $name => $value) { array_push($list, array("val" => $name, "txt" => $name, "pic" => "")); } //return $list; }
/** * Returns the database object. * * If none was created before, or if {link $newInstance} is true, * creates a new database object first. * In case of an error, the reference argument $errorMsg is set * to the error message. * @author Comvation Development Team <*****@*****.**> * @access public * @version 1.0.0 * @param string $errorMsg Error message * @param boolean $newInstance Force new instance * @global array Language array * @global array Database configuration * @global integer ADODB fetch mode * @return boolean True on success, false on failure */ function getDatabaseObject(&$errorMsg, $newInstance = false) { global $_DBCONFIG, $ADODB_FETCH_MODE, $_CONFIG; static $objDatabase; if (is_object($objDatabase) && !$newInstance) { return $objDatabase; } else { // open db connection $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $objDb = ADONewConnection($_DBCONFIG['dbType']); @$objDb->Connect($_DBCONFIG['host'], $_DBCONFIG['user'], $_DBCONFIG['password'], $_DBCONFIG['database']); $errorNo = $objDb->ErrorNo(); if ($errorNo != 0) { if ($errorNo == 1049) { $errorMsg = 'The database is unavailable'; } else { $errorMsg = $objDb->ErrorMsg() . "<br />"; } unset($objDb); return false; } if (!empty($_CONFIG['timezone'])) { if (!$objDb->Execute('SET TIME_ZONE="' . $_CONFIG['timezone'] . '"') && array_search($_CONFIG['timezone'], timezone_identifiers_list())) { //calculate and set the timezone offset if the mysql timezone tables aren't loaded $objDateTimeZone = new DateTimeZone($_CONFIG['timezone']); $objDateTime = new DateTime('now', $objDateTimeZone); $offset = $objDateTimeZone->getOffset($objDateTime); $offsetHours = round(abs($offset) / 3600); $offsetMinutes = round((abs($offset) - $offsetHours * 3600) / 60); $offsetString = ($offset > 0 ? '+' : '-') . ($offsetHours < 10 ? '0' : '') . $offsetHours . ':' . ($offsetMinutes < 10 ? '0' : '') . $offsetMinutes; $objDb->Execute('SET TIME_ZONE="' . $offsetString . '"'); } } // Disable STRICT_TRANS_TABLES mode: $res = $objDb->Execute('SELECT @@sql_mode'); if ($res->EOF) { $errorMsg = 'Database mode error'; return; } $sqlModes = explode(',', $res->fields['@@sql_mode']); array_walk($sqlModes, 'trim'); if (($index = array_search('STRICT_TRANS_TABLES', $sqlModes)) !== false) { unset($sqlModes[$index]); } $objDb->Execute('SET sql_mode = \'' . implode(',', $sqlModes) . '\''); if (empty($_DBCONFIG['charset']) || $objDb->Execute('SET NAMES ' . $_DBCONFIG['charset']) && $objDb) { if ($newInstance) { return $objDb; } else { $objDatabase = $objDb; return $objDb; } } else { $errorMsg = 'Cannot connect to database server<i> (' . $objDb->ErrorMsg() . ')</i>'; unset($objDb); } return false; } }
protected function isValidTimeZone($timezone) { if (!is_null($timezone)) { return in_array($timezone, timezone_identifiers_list()); } else { return false; } }
public function index() { requireadmin(); $ipBlock = $this->siteinfo->config('blocked_ips'); $ipWhite = $this->siteinfo->config('allowed_ips'); $defaults = array('site_name' => $this->siteinfo->config('site_name'), 'site_address' => $this->siteinfo->config('site_address'), 'site_copy' => $this->siteinfo->config('site_copy'), 'site_email' => $this->siteinfo->config('site_email'), 'timezones' => timezone_identifiers_list(), 'site_tz' => $this->siteinfo->config('timezone'), 'ip_blocklist' => unserialize($ipBlock), 'ip_whitelist' => unserialize($ipWhite)); generate_json(array('status' => 1, 'defaults' => $defaults)); }
public function getTimeZoneList() { $locations = array(); $zones = timezone_identifiers_list(); foreach ($zones as $zone) { $locations[] = array('value' => $zone, 'name' => str_replace('_', ' ', $zone)); } return $locations; }
function getconf_TimeZone_Identifiers($name) { $tlist = timezone_identifiers_list(); $result = array(); foreach ($tlist as $timezone) { $result[] = array($timezone, $timezone); } return $result; }
/** * @inheritdoc */ public function validate($value, Context $context) { $identifiers = timezone_identifiers_list(); if (in_array($value, $identifiers)) { return true; } $context->message_args['suggestion'] = $this->find_best_match($value, $identifiers); return false; }
/** * Generates an array containing all the available timezones. The key and * the value is the same for each timezone. This method is simply used for * consistency sake between other similar functions such as iana::languages() * and iana::regions() * * @return array */ public function timezones() { $result = array(); $timezone_array = timezone_identifiers_list(); foreach ($timezone_array as $zone) { $result[$zone] = $zone; } return $result; }
public function set_timezone($timezone_identifier = 'UTC') { // Check if the timezone identifier supplied is valid if (in_array($timezone_identifier, timezone_identifiers_list())) { date_default_timezone_set($timezone_identifier); } else { throw new \Exception('Invalid timezone identifier'); } }
/** * Get all timezones * * @return array */ function getTimezones() { $tz = array(); $tzId = timezone_identifiers_list(); foreach ($tzId as $val) { $tz[$val] = $val; } return $tz; }
/** * Генерирует массив опций для HTML::Select функции сорержащий все часовые пояса * @param $val * @return array */ function GetGmtData($val) { $tlist = timezone_identifiers_list(); $gmt = array(); foreach ($tlist as $timezone) { System::site()->DataAdd($gmt, $timezone, $timezone, $val == $timezone); } return $gmt; }
/** * Get timezone dropdown info for profile */ public static function getTimezones() { $list = timezone_identifiers_list(); $zones = array(); foreach ($list as $zone) { $zones[$zone] = $zone; } return $zones; }
/** * Get available timezones * * @access public * @param boolean $prepend Prepend a default value * @return array */ public function getTimezones($prepend = false) { $timezones = timezone_identifiers_list(); $listing = array_combine(array_values($timezones), $timezones); if ($prepend) { return array('' => t('Application default')) + $listing; } return $listing; }
function create_field_entry_timezone() { global $timezone, $zoneinfo_outlook_compatible; $special_group = "Others"; echo "<div>\n"; echo "<label for=\"area_timezone\">" . get_vocab("timezone") . ":</label>\n"; // If possible we'll present a list of timezones that this server supports and // which also have a corresponding VTIMEZONE definition. // Otherwise we'll just have to let the user type in a timezone, which introduces // the possibility of an invalid timezone. if (function_exists('timezone_identifiers_list')) { $timezones = array(); $timezone_identifiers = timezone_identifiers_list(); foreach ($timezone_identifiers as $value) { if (strpos($value, '/') === FALSE) { // There are some timezone identifiers (eg 'UTC') on some operating // systems that don't fit the Continent/City model. We'll put them // into the special group $continent = $special_group; $city = $value; } else { // Note: timezone identifiers can have three components, eg // America/Argentina/Tucuman. To keep things simple we will // treat anything after the first '/' as a single city and // limit the explosion to two list($continent, $city) = explode('/', $value, 2); } // Check that there's a VTIMEZONE definition $tz_dir = $zoneinfo_outlook_compatible ? TZDIR_OUTLOOK : TZDIR; $tz_file = "{$tz_dir}/{$value}.ics"; // UTC is a special case because we can always produce UTC times in iCalendar if ($city == 'UTC' || file_exists($tz_file)) { $timezones[$continent][] = $city; } } echo "<select id=\"area_timezone\" name=\"area_timezone\">\n"; foreach ($timezones as $continent => $cities) { if (count($cities) > 0) { echo "<optgroup label=\"" . htmlspecialchars($continent) . "\">\n"; foreach ($cities as $city) { if ($continent == $special_group) { $timezone_identifier = $city; } else { $timezone_identifier = "{$continent}/{$city}"; } echo "<option value=\"" . htmlspecialchars($timezone_identifier) . "\"" . ($timezone_identifier == $timezone ? " selected=\"selected\"" : "") . ">" . htmlspecialchars($city) . "</option>\n"; } echo "</optgroup>\n"; } } echo "</select>\n"; } else { echo "<input id=\"area_timezone\" name=\"area_timezone\" value=\"" . htmlspecialchars($timezone) . "\">\n"; } echo "</div>\n"; }
/** * List of timezone as array. * * @return array */ public static function listTimeZone() { $timezone = []; $timestamp = time(); foreach (timezone_identifiers_list() as $key => $zone) { date_default_timezone_set($zone); $timezone[$zone] = $zone . ' UTC/GMT ' . date('P', $timestamp); } return $timezone; }
function tz_list() { $zones_array = array(); $timestamp = time(); foreach (timezone_identifiers_list() as $key => $zone) { date_default_timezone_set($zone); $zones_array[$key]['zone'] = $zone; $zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P', $timestamp); } return $zones_array; }
function psp_wplanner_fb_options() { global $wpdb, $psp; /* Here we define the different drop downs for our option page */ // Facebook language $select_fblanguage = array("af_ZA" => "Afrikaans", "sq_AL" => "Albanian", "ar_AR" => "Arabic", "hy_AM" => "Armenian", "eu_ES" => "Basque", "be_BY" => "Belarusian", "bn_IN" => "Bengali", "bs_BA" => "Bosanski", "bg_BG" => "Bulgarian", "ca_ES" => "Catalan", "zh_CN" => "Chinese", "cs_CZ" => "Czech", "da_DK" => "Danish", "fy_NL" => "Dutch", "en_US" => "English", "eo_EO" => "Esperanto", "et_EE" => "Estonian", "et_EE" => "Estonian", "fi_FI" => "Finnish", "fo_FO" => "Faroese", "tl_PH" => "Filipino", "fr_FR" => "French", "gl_ES" => "Galician", "ka_GE" => "Georgian", "de_DE" => "German", "zh_CN" => "Greek", "he_IL" => "Hebrew", "hi_IN" => "Hindi", "hr_HR" => "Hrvatski", "hu_HU" => "Hungarian", "is_IS" => "Icelandic", "id_ID" => "Indonesian", "ga_IE" => "Irish", "it_IT" => "Italian", "ja_JP" => "Japanese", "ko_KR" => "Korean", "ku_TR" => "Kurdish", "la_VA" => "Latin", "lv_LV" => "Latvian", "fb_LT" => "Leet Speak", "lt_LT" => "Lithuanian", "mk_MK" => "Macedonian", "ms_MY" => "Malay", "ml_IN" => "Malayalam", "nl_NL" => "Nederlands", "ne_NP" => "Nepali", "nb_NO" => "Norwegian", "ps_AF" => "Pashto", "fa_IR" => "Persian", "pl_PL" => "Polish", "pt_PT" => "Portugese", "pa_IN" => "Punjabi", "ro_RO" => "Romanian", "ru_RU" => "Russian", "sk_SK" => "Slovak", "sl_SI" => "Slovenian", "es_LA" => "Spanish", "sr_RS" => "Srpski", "sw_KE" => "Swahili", "sv_SE" => "Swedish", "ta_IN" => "Tamil", "te_IN" => "Telugu", "th_TH" => "Thai", "tr_TR" => "Turkish", "uk_UA" => "Ukrainian", "vi_VN" => "Viettitlese", "cy_GB" => "Welsh"); // Facebook OpenGraph Post Types $select_fb_og_type = array("Activities" => array("activity", "sport"), "Businesses" => array("bar", "company", "cafe", "hotel", "restaurant"), "Groups" => array("cause", "sports_league", "sports_team"), "Organizations" => array("band", "government", "non_profit", "school", "university"), "People" => array("actor", "athlete", "author", "director", "musician", "politician", "public_figure"), "Places" => array("city", "country", "landmark", "state_province"), "Products and Entertainment" => array("album", "book", "drink", "food", "game", "product", "song", "movie", "tv_show"), "Websites" => array("blog", "website", "article")); // Inputs available for posting to Facebook displayed on each post/page $inputs_available = array("message" => __("Message", $psp->localizationName), "caption" => __("Caption", $psp->localizationName), "image" => __("Image", $psp->localizationName)); // Facebook privacy options $wplannerfb_post_privacy_options = array("EVERYONE" => __('Everyone', $psp->localizationName), "EVERYONE" => __('Everyone', $psp->localizationName), "ALL_FRIENDS" => __('All Friends', $psp->localizationName), "NETWORKS_FRIENDS" => __('Networks Friends', $psp->localizationName), "FRIENDS_OF_FRIENDS" => __('Friends of Friends', $psp->localizationName), "CUSTOM" => __('Private (only me)', $psp->localizationName)); // all alias of post types $select_post_types = array(); $exclude_post_types = array('attachment', 'revision', 'wplannertw', 'wptw2fbfeed_fb', 'wplannerfb', 'wplannerlin', 'wpsfpb'); // Facebook available user Pages / Groups $fb_user_pages_groups = get_option('psp_fb_planner_user_pages'); if (trim($fb_user_pages_groups) != "") { $fb_all_user_pages_groups = @json_decode($fb_user_pages_groups); } // create query string $querystr = "SELECT DISTINCT({$wpdb->posts}.post_type) FROM {$wpdb->posts} WHERE 1=1"; $pageposts = $wpdb->get_results($querystr, ARRAY_A); if (count($pageposts) > 0) { foreach ($pageposts as $key => $value) { if (!in_array($value['post_type'], $exclude_post_types)) { $select_post_types[$value['post_type']] = ucfirst($value['post_type']); } } } $options = array('inputs_available' => array("title" => __("Publish on facebook optional fields", $psp->localizationName), "desc" => __("What inputs do you want to be available for posting to facebook? It will appear on page/post details", $psp->localizationName), 'size' => 'large', 'force_width' => '130', "type" => "multiselect", "options" => $inputs_available), 'featured_image_size' => array("title" => __("Custom Image size", $psp->localizationName), 'std' => '450x320', "desc" => __("WIDTH x HEIGHT (Without measuring units. Example: 450x320)", $psp->localizationName), 'force_width' => '180', 'size' => 'large', "type" => "text"), 'featured_image_size_crop' => array("title" => __("Crop image?", $psp->localizationName), "desc" => __("If yes, the image will crop to fit the above desired size. If no, the image will just resize with the dimensions provided.", $psp->localizationName), "type" => 'select', 'size' => 'large', 'force_width' => '140', "options" => array('true' => __('Yes', $psp->localizationName), 'false' => __('No', $psp->localizationName))), 'default_privacy_option' => array("title" => __("Publish on facebook default privacy option", $psp->localizationName), "desc" => __("What privacy option would you like to be default when you're posting to facebook? This option can also be adjusted manually when setting the scheduler for each post/page.", $psp->localizationName), 'size' => 'large', 'force_width' => '150', "type" => "select", "options" => $wplannerfb_post_privacy_options), 'email' => array("title" => __("Admin email", $psp->localizationName), 'size' => 'large', 'force_width' => '200', "desc" => __("Notify this email adress each time you post something on facebook.", $psp->localizationName), "type" => "text"), 'email_subject' => array("title" => __("Admin email subject", $psp->localizationName), 'size' => 'large', 'force_width' => '240', "desc" => __("Subject for plugin email notification.", $psp->localizationName), "type" => "text"), 'email_message' => array("title" => __("Admin email message", $psp->localizationName), 'size' => 'large', 'force_width' => '340', "desc" => __("Email content for plugin notification.", $psp->localizationName), "type" => "textarea"), 'timezone' => array("title" => __("Cron timezone", $psp->localizationName), "desc" => __("Use valid timezone format from <a href='http://php.net/manual/en/timezones.php' target='_blank'>php.net</a>. E.g: America/Detroit", $psp->localizationName), "type" => "select", 'size' => 'large', 'force_width' => '150', 'options' => __doRange(timezone_identifiers_list())), 'info' => array("html" => __("\n\t\t\t\t\t<h2>Important Information</h2>\n\t\t\t\t\t<p>You need to create a Facebook App. You can do that <a href='http://developers.facebook.com' target='_blank'>here.</a> and enter its details in to the fields below.</p>", $psp->localizationName), "type" => "message"), 'auth' => array("desc" => __("Facebook Application authorization for cron job.", $psp->localizationName), "type" => "authorization_button", 'size' => 'large', 'value' => __("Authorization facebook app", $psp->localizationName)), 'app_id' => array("title" => __("Facebook App ID", $psp->localizationName), "desc" => __("Insert your Facebook App ID here.", $psp->localizationName), "std" => "", 'size' => 'large', 'force_width' => '250', "type" => "text"), 'app_secret' => array("title" => __("Facebook App Secret.", $psp->localizationName), "desc" => __("Insert your Facebook App Secret here.", $psp->localizationName), "std" => "", 'size' => 'large', 'force_width' => '350', "type" => "text"), 'language' => array("title" => __("Facebook Language", $psp->localizationName), "desc" => __("Select the language for Facebook. More Information about the languages can be found <a target='_blank' href='http://developers.facebook.com/docs/internationalization/'>here</a>.", $psp->localizationName), "std" => "en_US", "type" => "select", 'size' => 'large', 'force_width' => '150', "options" => $select_fblanguage)); // Facebook available user pages / groups if (isset($fb_all_user_pages_groups) && count($fb_all_user_pages_groups) > 0) { // Facebook available user pages if (count($fb_all_user_pages_groups->pages) > 0) { $fb_all_user_pages = array(); foreach ($fb_all_user_pages_groups->pages as $key => $value) { $fb_all_user_pages["{$value->id}"] = $value->name; } $options['page_filter'] = array("title" => __("Activate \"Filter Pages\"", $psp->localizationName), "desc" => __("Select \"Yes\" if you want to limit the pages shown when publishing and then select from above only what you wish to be shown. <i><strong>This is usefull if you have a lot of pages and/or you have a master facebook account and you wish to limit specific users to see other pages.</strong></i>", $psp->localizationName), "type" => "select", 'size' => 'large', 'force_width' => '80', "options" => array('No', 'Yes')); $options['available_pages'] = array("title" => __("What pages do you want to be available when publishing?", $psp->localizationName), "desc" => __("<strong>This option only works if the \"Filter Pages\" option from above is \"Yes\"</strong>", $psp->localizationName), "type" => "multiselect", 'size' => 'large', 'force_width' => '350', "options" => $fb_all_user_pages); } // Facebook available user groups if (count($fb_all_user_pages_groups->groups) > 0) { $fb_all_user_groups = array(); foreach ($fb_all_user_pages_groups->groups as $key => $value) { $fb_all_user_groups["{$value->id}"] = $value->name; } $options['group_filter'] = array("title" => __("Activate \"Filter Groups\"", $psp->localizationName), "desc" => __("Select \"Yes\" if you want to limit the groups shown when publishing and then select from above only what you wish to be shown. <i><strong>This is usefull if you have a lot of groups and/or you have a master facebook account and you wish to limit specific users to see other groups.</strong></i>", $psp->localizationName), "type" => "select", 'size' => 'large', 'force_width' => '80', "options" => array('No', 'Yes')); $options['available_groups'] = array("title" => __("What groups do you want to be available when publishing?", $psp->localizationName), "desc" => __("<strong>This option only works if the \"Filter Groups\" option from above is \"Yes\"</strong>", $psp->localizationName), "type" => "multiselect", 'size' => 'large', 'force_width' => '350', "options" => $fb_all_user_groups); } } return $options; }