function api_user() { $this->ci->load->library('tweet'); $remote_user = $this->ci->tweet->call('get', 'account/verify_credentials'); $user = array('sso_twitter' => $remote_user->id, 'username' => 'twitter_' . $remote_user->id); $name = explode(' ', $remote_user->name); if (empty($name)) { $name = explode(' ', $remote_user->screen_name); } $user['first_name'] = $name[0]; $user['last_name'] = $name[count($name) - 1]; $this->ci->load->helper('date'); $timezones = timezones(); if ($remote_user->utc_offset > 0) { $t = '+' . $remote_user->utc_offset / 3600; } else { $t = '-' . abs($remote_user->utc_offset / 3600); } $timezone = 'UTC'; foreach ($timezones as $key => $val) { if ($t == $val) { $timezone = $key; break; } } $user['timezone'] = $timezone; $user['locale'] = $remote_user->lang; $user['sso_verified'] = $remote_user->verified; $user['image'] = $remote_user->profile_image_url; $db_user = $this->ci->_model('user')->get_login(array('sso_twitter' => $user['sso_twitter'])); $user['row_status'] = empty($db_user) ? 'new' : 'existing'; return $user; }
function api_user() { $user_sso = $this->ci->facebook->user(); if (isset($user_sso) && isset($user_sso->__resp) && !empty($user_sso->__resp->data)) { $user_sso = @$user_sso->__resp->data; } else { return array(); } $user = array('sso_facebook' => $user_sso->id, 'username' => 'twitter_' . $user_sso->id); if ($this->facebook_download_picture) { $pic_types = array('small', 'normal', 'large', 'square'); foreach ($pic_types as $pic_type) { @mkdir('data/user/image/' . $pic_type, 0777, true); fork('wget "http://graph.facebook.com/' . $user_sso->id . '/picture?type=' . $pic_type . '" -O "./data/user/image/' . $pic_type . '/fb_' . $user_sso->id . '"'); } $user['image'] = 'user/image/fb_' . $user_sso->id; } else { $user['image'] = 'http://graph.facebook.com/' . $user_sso->id . '/picture'; } $user['email'] = $user_sso->email; $user['first_name'] = $user_sso->first_name; $user['last_name'] = $user_sso->last_name; $user['address'] = $user_sso->location->name; $user['locale'] = $user_sso->locale; $user['sso_verified'] = $user_sso->verified; $genders = array('male' => 1, 'female' => 2); $user['gender'] = empty($user_sso->gender) ? 0 : $genders[$user_sso->gender]; if (!empty($user_sso->timezone)) { $this->ci->load->helper('date'); $timezones = timezones(); if ($user_sso->timezone > 0) { $t = '+' . $user_sso->timezone; } else { $t = '-' . abs($user_sso->timezone); } $timezone = 'UTC'; foreach ($timezones as $key => $val) { if ($t == $val) { $timezone = $key; break; } } $user['timezone'] = $timezone; } else { $user['timezone'] = 'UTC'; } if (!empty($user_sso->birthday)) { $b = $user_sso->birthday; $e = explode('/', $b); if (count($e) == 3) { $user['dob'] = $e[2] . '-' . $e[0] . '-' . $e[1]; } else { $user['dob'] = ''; } } $db_user = $this->ci->_model('user')->get_login(array('sso_facebook' => $user['sso_facebook'])); $user['row_status'] = empty($db_user) ? 'new' : 'existing'; return $user; }
function gmt_to_local($time = '', $timezone = 'UP8', $dst = FALSE) { if ($time == '') { return now(); } $time += timezones($timezone) * 3600; if ($dst == TRUE) { $time += 3600; } return $time; }
function _to_gmt($time, $timezone, $format = 'Y-m-d H:i:s') { $dst = FALSE; $time = !is_numeric($time) ? strtotime(str_replace('/', '-', $time)) : $time; $daylight_saving = date("I") == 1 ? TRUE : FALSE; $time -= timezones($timezone) * 3600; if ($daylight_saving == TRUE) { $time -= 3600; } return date($format, $time); }
function is_int_multiple_unit_time($ts, $unit) { $timezone_offset = timezones('UP8') * 3600; foreach ((array) $ts as $t) { if (empty($t)) { continue; } $t += $timezone_offset; if ($t % $unit != 0) { return FALSE; } } return TRUE; }
public function test_timezones() { $zones = array('UM12' => -12, 'UM11' => -11, 'UM10' => -10, 'UM95' => -9.5, 'UM9' => -9, 'UM8' => -8, 'UM7' => -7, 'UM6' => -6, 'UM5' => -5, 'UM45' => -4.5, 'UM4' => -4, 'UM35' => -3.5, 'UM3' => -3, 'UM2' => -2, 'UM1' => -1, 'UTC' => 0, 'UP1' => +1, 'UP2' => +2, 'UP3' => +3, 'UP35' => +3.5, 'UP4' => +4, 'UP45' => +4.5, 'UP5' => +5, 'UP55' => +5.5, 'UP575' => +5.75, 'UP6' => +6, 'UP65' => +6.5, 'UP7' => +7, 'UP8' => +8, 'UP875' => +8.75, 'UP9' => +9, 'UP95' => +9.5, 'UP10' => +10, 'UP105' => +10.5, 'UP11' => +11, 'UP115' => +11.5, 'UP12' => +12, 'UP1275' => +12.75, 'UP13' => +13, 'UP14' => +14); foreach ($zones as $test => $expected) { $this->assertEquals($expected, timezones($test)); } $this->assertArrayHasKey('UP3', timezones()); $this->assertEquals(0, timezones('non_existant')); }
echo _t("mod_rewrite is required"); ?> </td> </tr> </table> </fieldset> <fieldset> <legend>Time settings</legend> <table cellspacing="0" width="100%"> <tr> <td width="120px"><?php echo _t("Timezone"); ?> :</td> <td><select name="offset"><?php echo timezones($time->offset); ?> </select></td> </tr> <tr> <td><?php echo _t("Time format"); ?> :</td> <td><input name="time_long" type="text" value="<?php echo $time->long; ?> " size="14" /> <?php echo get_date(time(), "", 1, 0); ?> </td>
<div class="grid_24"> <?php //$mysql = '20061124092345'; //$now = time(); $datestring = "%Y-%m-%d %H:%i"; $time = time(); echo mdate($datestring, $time); echo timezones('UP7'); ?> <ul> <li>ºÑ¹·Ö¡Ë¹èǧҹ</li> <li>ÃÒ¡ÒÃ˹èǧҹ</li> </ul> <span style="float: right;"><a href="javascript:void(0)" id="customer-form-hide"><img src="<?php echo base_url()?>imgs/directional_down.png" /></a></span></div> <div class="clear"></div> <div class="grid_24"> <div> <form id="customer-form"> <div id="customer-info"> <table> <thead> <tr> <th colspan="5"><?php echo $this->lang->line('customers_title');?></th> </tr> </thead>
/** * Timezones * * This array is used to render the localization pull-down menu * * @access public * @return array */ function zones() { ee()->load->library('logger'); ee()->logger->deprecated('2.6', 'Date helper\'s timezones()'); ee()->load->helper('date'); return timezones(); }
} if ($pass == false) { return 0; } else { return 1; } } $oops = true; $do_fallback = false; foreach ($start as $k => $b) { if (!isset($ci_timezone)) { $ci_timezone = "UM8"; } $ci->config->set_item('time_reference', 'local'); $ci->load->helper('date'); $offset = (int) timezones($ci_timezone); $hour = date("G") + $offset; $server_time = mktime($hour, date("i"), date("s")); $server_time_formatted = date("G:i", $server_time); $server_day = date("w", $server_time); $currentTime = $server_time_formatted; $finish_time = $finish[$k]; //debug - set a time here to restate $currentTime //$currentTime = "17:00"; //echo $currentTime.' - '.$b.' - '.$finish_time; if (verify_time($currentTime, $b, $finish_time) == 1 and verify_day($k, $server_day)) { $response->addRedirect($choice_array[$k]); $response->Respond(); $oops = false; $do_fallback = false; //echo "passed check ";
function timezone_menu($default = 'UTC', $class = "", $name = 'timezones') { call('lang', 'load', 'date'); if ($default == 'GMT') { $default = 'UTC'; } $menu = '<select name="' . $name . '"'; if ($class != '') { $menu .= ' class="' . $class . '"'; } $menu .= ">\n"; foreach (timezones() as $key => $val) { $selected = $default == $key ? " selected='selected'" : ''; $menu .= "<option value='{$key}'{$selected}>" . call('lang', 'line', $key) . "</option>\n"; } $menu .= "</select>"; return $menu; }
function timezone_menu($default = 'UTC', $class = "", $name = 'timezones') { $CI =& get_instance(); $CI->lang->load('date'); if ($default == 'GMT') { $default = 'UTC'; } $menu = '<select name="' . $name . '"'; if ($class != '') { $menu .= ' class="' . $class . '"'; } $menu .= ">\n"; foreach (timezones() as $key => $val) { $selected = $default == $key ? " selected='selected'" : ''; $menu .= "<option value='{$key}'{$selected}>" . $CI->lang->line($key) . "</option>\n"; } $menu .= "</select>"; return $menu; }
/** * Get timezone offset from legacy or modern * * @access public * @return int */ public function timezone_offset() { ee()->load->helper('date'); $offset = 0; $timezones = timezones(); $timezone = $this->either_or(ee()->config->item('default_site_timezone'), ee()->config->item('server_timezone'), date_default_timezone_get()); // Check legacy timezone formats if (isset($timezones[$timezone])) { $offset = $timezones[$timezone] * 3600; } else { if (class_exists('DateTime')) { $dt = new DateTime('now', new DateTimeZone($timezone)); if ($dt) { $offset = $dt->getOffset(); } } } return $offset; }
/** * Function: general_settings * General Settings page. */ public function general_settings() { if (!Visitor::current()->group->can("change_settings")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to change settings.")); } $locales = array(); if ($open = opendir(INCLUDES_DIR . "/locale/")) { while (($folder = readdir($open)) !== false) { $split = explode(".", $folder); if (end($split) == "mo") { $locales[] = array("code" => $split[0], "name" => lang_code($split[0])); } } closedir($open); } if (empty($_POST)) { return $this->display("general_settings", array("locales" => $locales, "timezones" => timezones())); } if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) { show_403(__("Access Denied"), __("Invalid security key.")); } $config = Config::current(); $set = array($config->set("name", $_POST['name']), $config->set("description", $_POST['description']), $config->set("chyrp_url", rtrim($_POST['chyrp_url'], "/")), $config->set("url", rtrim(oneof($_POST['url'], $_POST['chyrp_url']), "/")), $config->set("email", $_POST['email']), $config->set("timezone", $_POST['timezone']), $config->set("locale", $_POST['locale'])); if (!in_array(false, $set)) { Flash::notice(__("Settings updated."), "/admin/?action=general_settings"); } }
/** * _ci_to_php_zone() * * Converts a CI timezone ($zone) to a PHP timezone identifier * * @return string PHP timezone identifier * * Thoughts: * - timezone_name_from_abbr() needs false for param 3 always? should that be the value of dst_supported()? * */ private function _ci_to_php_zone($zone = null) { if ($zone === null) { $zone = $this->current_zone; } $offset = timezones($zone); $php_zone = timezone_name_from_abbr('', $offset * 3600, -1); if ($php_zone === false) { // might be in DST $php_zone = timezone_name_from_abbr('', $offset * 3600 + 3600, true); } return $php_zone; }
/** * Timezone Menu * * Generates a drop-down menu of timezones. * * @param string timezone * @param string classname * @param string menu name * @param mixed attributes * @return string */ function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '') { $CI =& get_instance(); $CI->lang->load('date'); $default = $default === 'GMT' ? 'UTC' : $default; $menu = '<select name="' . $name . '"'; if ($class !== '') { $menu .= ' class="' . $class . '"'; } // Generate a string from the attributes submitted, if any if (is_array($attributes)) { $atts = ''; foreach ($attributes as $key => $val) { $atts .= ' ' . $key . '="' . $val . '"'; } $attributes = $atts; } elseif (is_string($attributes) && strlen($attributes) > 0) { $attributes = ' ' . $attributes; } $menu .= $attributes . ">\n"; foreach (timezones() as $key => $val) { $selected = $default === $key ? ' selected="selected"' : ''; $menu .= '<option value="' . $key . '"' . $selected . '>' . $CI->lang->line($key) . "</option>\n"; } return $menu . '</select>'; }
/** * Generate a drop-down menu of timezones. * * @internal A similar version of the timezone_menu function was originally * accepted as a commit to CodeIgniter in June 2012 (see link below). The * signature of the function remains the same in the CI 3.x base, though the * internals have changed somewhat. Pulling in the current version would require * bringing in changes outside of this file. The $attributes argument could take * the place of the $class and $name arguments, but this allows for backwards * compatibility (since the $class and $name arguments were already in place). * If/when the CI date_helper is updated in Bonfire, this function should be * removed (to allow the CI function to be used). * @link https://github.com/EllisLab/CodeIgniter/commit/7540dede0f01acd7aa1ffd224defc5189305a815 * * @param string $default The default/selected timezone. * @param string $class The class attribute of the select element. * @param string $name The name attribute of the select element. * @param mixed $attributes Additional attributes to set on the menu's * select element. If a name or class are passed here, the behavior is likely * to be browser-dependant, as the function does not attempt to prevent it. * * @return string The HTML for the timezone menu. */ function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '') { $CI =& get_instance(); $CI->lang->load('date'); $default = $default === 'GMT' ? 'UTC' : $default; $menu = "<select name='{$name}'"; if ($class != '') { $menu .= " class='{$class}'"; } // Add the submitted attributes submitted, if any. if (is_array($attributes)) { foreach ($attributes as $key => $val) { $menu .= " {$key}='{$val}'"; } } elseif (is_string($attributes) && strlen($attributes) > 0) { $menu .= " {$attributes}"; } $menu .= ">\n"; // The timezones() function should be defined in the CI date_helper. foreach (timezones() as $key => $val) { $selected = $default == $key ? " selected='selected'" : ''; $menu .= "<option value='{$key}'{$selected}>" . $CI->lang->line($key) . "</option>\n"; } return "{$menu}</select>"; }
function timezone_name($default = 'UTC', $class = "", $name = 'timezones') { $CI =& get_instance(); $CI->lang->load('date'); if ($default == 'GMT') { $default = 'UTC'; } $menu = ''; foreach (timezones() as $key => $val) { if ($default == $key) { $menu = $CI->lang->line($key); } } return $menu; }
/** * Converts GMT time to a localized value * * Takes a Unix timestamp (in GMT) as input, and returns * at the local value based on the timezone and DST setting * submitted * * Credit: http://codeigniter.com/user_guide/helpers/date_helper.html * License: http://codeigniter.com/user_guide/license.html * * @param int $time Unix timestamp * @param string $timezone timezone * @param bool $dst whether DST is active * * @return int */ public static function gmtToLocal($time = '', $timezone = 'UTC', $dst = false) { if (empty($time)) { return now(); } $time += timezones($timezone) * 3600; if ($dst) { $time += 3600; } return $time; }
/** * Converts GMT time to a localized value * * Takes a Unix timestamp (in GMT) as input, and returns * at the local value based on the timezone and DST setting * submitted * * @param int Unix timestamp * @param string timezone * @param bool whether DST is active * @return int */ function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) { if ($time === '') { return now(); } $time += timezones($timezone) * 3600; return $dst === TRUE ? $time + 3600 : $time; }
public function date_helper() { $this->load->helper('date'); echo now('Australia/Victoria'); echo "<br>"; echo now('+8'); echo "<br>"; $datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a'; $time = time(); echo mdate($datestring, $time); //at UTC echo "<br>"; $format = 'DATE_RFC822'; $time = time(); echo standard_date($format, $time); //Deprecated echo "<br>"; echo date(DATE_RFC822, time()); echo "<br>"; echo local_to_gmt(time()); echo "<br>"; $timestamp = 1140153693; $timezone = 'UM8'; $daylight_saving = TRUE; echo gmt_to_local($timestamp, $timezone, $daylight_saving); echo "<br>"; echo "<br>"; $unix = mysql_to_unix('20061124092345'); echo $unix; echo "<br>"; echo "<br>"; $now = time(); echo unix_to_human($now); // U.S. time, no seconds echo "<br>"; echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds echo "<br>"; echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds echo "<br>"; echo "<br>"; $now = time(); $human = unix_to_human($now); $unix = human_to_unix($human); echo $human; echo "<br>"; echo $unix; echo "<br>"; echo "<br>"; echo "<br>"; $bad_date = '199605'; // Should Produce: 1996-05-01 $better_date = nice_date($bad_date, 'Y-m-d'); echo $bad_date; echo "<br>"; echo $better_date; echo "<br>"; echo "<br>"; $bad_date = '9-11-2001'; // Should Produce: 2001-09-11 $better_date = nice_date($bad_date, 'Y-m-d'); echo $bad_date; echo "<br>"; echo $better_date; echo "<br>"; echo "<br>"; $post_date = '1079621429'; $now = time(); $units = 2; echo timespan($post_date, $now, $units); echo "<br>"; echo "<br>"; echo days_in_month(06, 2005); echo "<br>"; echo "<br>"; $range = date_range('2012-01-01', '2012-01-15'); echo "First 15 days of 2012:"; foreach ($range as $date) { echo $date . "\n"; } echo "<br>"; echo "<br>"; echo timezones('UM5'); echo "<br>"; echo "<br>"; echo timezone_menu('UM8'); echo "<br>"; echo "<br>"; }
/* Filters */ Route::action('check', function () { /* Check if you have installed credit to Striker */ if (file_exists(APP . 'install.lock')) { return Layout::create('installed', array('installed' => true)); } }); /* Start (Language Select) */ Route::get(array('/', 'start'), array('before' => 'check', 'main' => function () { $vars['languages'] = languages(); $vars['prefered_languages'] = prefered_languages(); $vars['timezones'] = timezones(); $vars['current_timezone'] = current_timezone(); return Layout::create('start', $vars); })); Route::post('start', array('before' => 'check', 'main' => function () { $i18n = Input::get(array('language', 'timezone')); $validator = new Validator($i18n); $validator->check('language')->is_max(2, 'Please select a language'); $validator->check('timezone')->is_max(2, 'Please select a timezone'); if ($errors = $validator->errors()) { Input::flash(); Notify::error($errors); return Response::redirect('start'); } Session::put('install.i18n', $i18n); return Response::redirect('database');
/** * Prep View Vars * * Populates form elements with the initial value, or the submitted * value in case of a form validation error * * @access public * @param string $type The type of config fields to be prepared * @param mixed[] $values An optional associative array of values to use * e.g. 'is_system_on' => 'y' * @return array The prepared array for use in views */ public function prep_view_vars($type, $values = array()) { ee()->load->library('form_validation'); $f_data = $this->get_config_fields($type); $subtext = $this->get_config_field_subtext(); // Blast through the array // If we're dealing with a database configuration we need to pull the // data out of the DB config file. To make thigs simple we will set the // DB config items as general config values if ($type == 'db_cfg') { $database_config = ee('Database')->getConfig(); $this->set_item('pconnect', $database_config->get('pconnect') ? 'y' : 'n'); $this->set_item('db_debug', $database_config->get('db_debug') ? 'y' : 'n'); } ee()->load->helper('date'); $timezones = timezones(); foreach ($f_data as $name => $options) { $value = isset($values[$name]) ? $values[$name] : $this->item($name); $sub = ''; $details = ''; $selected = ''; if (isset($subtext[$name])) { foreach ($subtext[$name] as $txt) { $sub .= lang($txt); } } switch ($options[0]) { case 's': // Select fields foreach ($options[1] as $k => $v) { $details[$k] = lang($v); if (ee()->form_validation->set_select($name, $k, $k == $value) != '') { $selected = $k; } } break; case 'r': // Radio buttons foreach ($options[1] as $k => $v) { // little cheat for some values popped into a build update if ($value === FALSE) { // MSM override // The key 'multiple_sites_enabled' is listed in admin_model->get_config_fields() as it must be, // but its possible that this install doesn't have it available as a config option. In these cases // the below code will cause neither "yes" or "no" to be preselected, but instead we want // "enable multiple site manager" in General Configuration to be "no". if ($name == 'multiple_sites_enabled' and $k == 'n') { $checked = TRUE; } else { $checked = isset($options['2']) && $k == $options['2'] ? TRUE : FALSE; } } else { $checked = $k == $value ? TRUE : FALSE; } $details[] = array('name' => $name, 'value' => $k, 'id' => $name . '_' . $k, 'label' => $v, 'checked' => ee()->form_validation->set_radio($name, $k, $checked)); } break; case 't': // Textareas // The "kill_pipes" index instructs us to turn pipes into newlines if (isset($options['1']['kill_pipes']) && $options['1']['kill_pipes'] === TRUE) { $text = str_replace('|', NL, $value); } else { $text = $value; } $rows = isset($options['1']['rows']) ? $options['1']['rows'] : '20'; $text = str_replace("\\'", "'", $text); $details = array('name' => $name, 'class' => 'module_textarea', 'value' => ee()->form_validation->set_value($name, $text), 'rows' => $rows, 'id' => $name); break; case 'f': // Function calls ee()->load->model('admin_model'); switch ($options['1']) { case 'language_menu': $options[0] = 's'; $details = ee()->lang->language_pack_names(); $selected = $value; break; case 'fetch_encoding': $options[0] = 's'; $details = ee()->admin_model->get_xml_encodings(); $selected = $value; break; case 'site_404': $options[0] = 's'; $details = ee()->admin_model->get_template_list(); $selected = $value; break; case 'theme_menu': $options[0] = 's'; $details = ee()->admin_model->get_cp_theme_list(); $selected = $value; break; case 'timezone': $options[0] = 'v'; $details = ee()->localize->timezone_menu($value); break; case 'caching_driver': $options[0] = 'v'; $details = ee()->cache->admin_setting(); break; } break; case 'p': // Fall through intended. // Fall through intended. case 'i': // Input fields $details = array('name' => $name, 'value' => ee()->form_validation->set_value($name, $value), 'id' => $name); break; } $vars['fields'][$name] = array('type' => $options[0], 'value' => $details, 'subtext' => $sub, 'selected' => $selected); } $vars['type'] = $type; return $vars; }
echo __("Description"); ?> </label> <textarea name="description" rows="2" cols="40"><?php value_fallback("description"); ?> </textarea> </p> <p id="timezone_field"> <label for="timezone"><?php echo __("What time is it?"); ?> </label> <select name="timezone" id="timezone"> <?php foreach (timezones() as $zone) { ?> <option value="<?php echo $zone["name"]; ?> "<?php selected($zone["name"], oneof(@$_POST['timezone'], $default_timezone)); ?> > <?php echo strftime("%I:%M %p on %B %d, %Y", $zone["now"]); ?> — <?php echo str_replace(array("_", "St "), array(" ", "St. "), $zone["name"]); ?>
/** * Channel "month links" */ public function month_links() { $return = ''; // Build query // Fetch the timezone array and calculate the offset so we can localize the month/year ee()->load->helper('date'); $zones = timezones(); $offset = (!isset($zones[ee()->session->userdata['timezone']]) or $zones[ee()->session->userdata['timezone']] == '') ? 0 : $zones[ee()->session->userdata['timezone']] * 60 * 60; if (substr($offset, 0, 1) == '-') { $calc = 'entry_date - ' . substr($offset, 1); } elseif (substr($offset, 0, 1) == '+') { $calc = 'entry_date + ' . substr($offset, 1); } else { $calc = 'entry_date + ' . $offset; } $sql = "SELECT DISTINCT year(FROM_UNIXTIME(" . $calc . ")) AS year,\n\t\t\t\t\t\tMONTH(FROM_UNIXTIME(" . $calc . ")) AS month\n\t\t\t\t\t\tFROM exp_channel_titles\n\t\t\t\t\t\tWHERE entry_id != ''\n\t\t\t\t\t\tAND site_id IN ('" . implode("','", ee()->TMPL->site_ids) . "') "; $timestamp = ee()->TMPL->cache_timestamp != '' ? ee()->TMPL->cache_timestamp : ee()->localize->now; if (ee()->TMPL->fetch_param('show_future_entries') != 'yes') { $sql .= " AND exp_channel_titles.entry_date < " . $timestamp . " "; } if (ee()->TMPL->fetch_param('show_expired') != 'yes') { $sql .= " AND (exp_channel_titles.expiration_date = 0 OR exp_channel_titles.expiration_date > " . $timestamp . ") "; } /**------ /** Limit to/exclude specific channels /**------*/ if ($channel = ee()->TMPL->fetch_param('channel')) { $wsql = "SELECT channel_id FROM exp_channels WHERE site_id IN ('" . implode("','", ee()->TMPL->site_ids) . "') "; $wsql .= ee()->functions->sql_andor_string($channel, 'channel_name'); $query = ee()->db->query($wsql); if ($query->num_rows() > 0) { $sql .= " AND "; if ($query->num_rows() == 1) { $sql .= "channel_id = '" . $query->row('channel_id') . "' "; } else { $sql .= "("; foreach ($query->result_array() as $row) { $sql .= "channel_id = '" . $row['channel_id'] . "' OR "; } $sql = substr($sql, 0, -3); $sql .= ") "; } } } /**------ /** Add status declaration /**------*/ if ($status = ee()->TMPL->fetch_param('status')) { $status = str_replace('Open', 'open', $status); $status = str_replace('Closed', 'closed', $status); $sstr = ee()->functions->sql_andor_string($status, 'status'); if (stristr($sstr, "'closed'") === FALSE) { $sstr .= " AND status != 'closed' "; } $sql .= $sstr; } else { $sql .= "AND status = 'open' "; } $sql .= " ORDER BY entry_date"; switch (ee()->TMPL->fetch_param('sort')) { case 'asc': $sql .= " asc"; break; case 'desc': $sql .= " desc"; break; default: $sql .= " desc"; break; } if (is_numeric(ee()->TMPL->fetch_param('limit'))) { $sql .= " LIMIT " . ee()->TMPL->fetch_param('limit'); } $query = ee()->db->query($sql); if ($query->num_rows() == 0) { return ''; } $year_limit = is_numeric(ee()->TMPL->fetch_param('year_limit')) ? ee()->TMPL->fetch_param('year_limit') : 50; $total_years = 0; $current_year = ''; foreach ($query->result_array() as $row) { $tagdata = ee()->TMPL->tagdata; $month = strlen($row['month']) == 1 ? '0' . $row['month'] : $row['month']; $year = $row['year']; $month_name = ee()->localize->localize_month($month); // Dealing with {year_heading} if (isset(ee()->TMPL->var_pair['year_heading'])) { if ($year == $current_year) { $tagdata = ee()->TMPL->delete_var_pairs('year_heading', 'year_heading', $tagdata); } else { $tagdata = ee()->TMPL->swap_var_pairs('year_heading', 'year_heading', $tagdata); $total_years++; if ($total_years > $year_limit) { break; } } $current_year = $year; } /** --------------------------------------- /** prep conditionals /** ---------------------------------------*/ $cond = array(); $cond['month'] = ee()->lang->line($month_name[1]); $cond['month_short'] = ee()->lang->line($month_name[0]); $cond['month_num'] = $month; $cond['year'] = $year; $cond['year_short'] = substr($year, 2); $tagdata = ee()->functions->prep_conditionals($tagdata, $cond); // parse path foreach (ee()->TMPL->var_single as $key => $val) { if (strncmp($key, 'path', 4) == 0) { $tagdata = ee()->TMPL->swap_var_single($val, ee()->functions->create_url(ee()->functions->extract_path($key) . '/' . $year . '/' . $month), $tagdata); } // parse month (long) if ($key == 'month') { $tagdata = ee()->TMPL->swap_var_single($key, ee()->lang->line($month_name[1]), $tagdata); } // parse month (short) if ($key == 'month_short') { $tagdata = ee()->TMPL->swap_var_single($key, ee()->lang->line($month_name[0]), $tagdata); } // parse month (numeric) if ($key == 'month_num') { $tagdata = ee()->TMPL->swap_var_single($key, $month, $tagdata); } // parse year if ($key == 'year') { $tagdata = ee()->TMPL->swap_var_single($key, $year, $tagdata); } // parse year (short) if ($key == 'year_short') { $tagdata = ee()->TMPL->swap_var_single($key, substr($year, 2), $tagdata); } } $return .= trim($tagdata) . "\n"; } return $return; }
/** * Timezone Menu * * Generates a drop-down menu of timezones. * * @param string timezone * @param string classname * @param string menu name * @param mixed attributes * @return string */ function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '') { $CI =& get_instance(); $CI->lang->load('date'); $default = $default === 'GMT' ? 'UTC' : $default; $menu = '<select name="' . $name . '"'; if ($class !== '') { $menu .= ' class="' . $class . '"'; } $menu .= _stringify_attributes($attributes) . ">\n"; foreach (timezones() as $key => $val) { $selected = $default === $key ? ' selected="selected"' : ''; $menu .= '<option value="' . $key . '"' . $selected . '>' . $CI->lang->line($key) . "</option>\n"; } return $menu . '</select>'; }
/** * Config Manager * * Used to display the various preference pages * * @access public * @return void */ function _config_manager($type, $return_loc) { $this->jquery->tablesorter('.mainTable', '{ widgets: ["zebra"], headers: { 1: { sorter: false } }, textExtraction: function(node) { var c = $(node).children(); if (c.length) { return c.text(); } else { return node.innerHTML; } } }'); $this->load->library('table'); $this->load->model('admin_model'); if (!in_array($type, array('general_cfg', 'cp_cfg', 'channel_cfg', 'member_cfg', 'output_cfg', 'debug_cfg', 'db_cfg', 'security_cfg', 'throttling_cfg', 'localization_cfg', 'email_cfg', 'cookie_cfg', 'image_cfg', 'captcha_cfg', 'template_cfg', 'censoring_cfg', 'mailinglist_cfg', 'emoticon_cfg', 'tracking_cfg', 'avatar_cfg', 'search_log_cfg'))) { show_error(lang('unauthorized_access')); } $vars['type'] = $type; $vars['form_action'] = 'C=admin_content' . AMP . 'M=update_config'; $f_data = $this->admin_model->get_config_fields($type); $subtext = $this->admin_model->get_config_field_subtext(); /** ----------------------------- /** Blast through the array /** -----------------------------*/ // If we're dealing with a database configuration we need to pull the data // out of the DB config file. To make thigs simple we will set the DB config // items as general config values if ($type == 'db_cfg') { require $this->config->database_path; if (!isset($active_group)) { $active_group = 'expressionengine'; } if (isset($db[$active_group])) { $db[$active_group]['pconnect'] = $db[$active_group]['pconnect'] === TRUE ? 'y' : 'n'; $db[$active_group]['cache_on'] = $db[$active_group]['cache_on'] === TRUE ? 'y' : 'n'; $db[$active_group]['db_debug'] = $db[$active_group]['db_debug'] === TRUE ? 'y' : 'n'; $this->config->set_item('pconnect', $db[$active_group]['pconnect']); $this->config->set_item('cache_on', $db[$active_group]['cache_on']); $this->config->set_item('cachedir', $db[$active_group]['cachedir']); $this->config->set_item('db_debug', $db[$active_group]['db_debug']); } } $this->load->helper('date'); $timezones = timezones(); foreach ($f_data as $name => $options) { $value = $this->config->item($name); $sub = ''; $details = ''; $selected = ''; if (isset($subtext[$name])) { foreach ($subtext[$name] as $txt) { $sub .= lang($txt); } } switch ($options[0]) { case 's': // Select fields foreach ($options[1] as $k => $v) { $details[$k] = lang($v); } $selected = $value; break; case 'r': // Radio buttons foreach ($options[1] as $k => $v) { // little cheat for some values popped into a build update if ($value === FALSE) { $checked = isset($options['2']) && $k == $options['2'] ? TRUE : FALSE; } else { $checked = $k == $value ? TRUE : FALSE; } $details[] = array('name' => $name, 'value' => $k, 'id' => $name . '_' . $k, 'label' => $v, 'checked' => $checked); } break; case 't': // Textareas // The "kill_pipes" index instructs us to turn pipes into newlines if (isset($options['1']['kill_pipes']) && $options['1']['kill_pipes'] === TRUE) { $text = str_replace('|', NL, $value); } else { $text = $value; } $rows = isset($options['1']['rows']) ? $options['1']['rows'] : '20'; $text = str_replace("\\'", "'", $text); $details = array('name' => $name, 'value' => $text, 'rows' => $rows, 'id' => $name); break; case 'f': // Function calls switch ($options['1']) { case 'language_menu': $options[0] = 's'; $details = $this->admin_model->get_installed_language_packs(); $selected = $value; break; case 'fetch_encoding': $options[0] = 's'; $details = $this->admin_model->get_xml_encodings(); $selected = $value; break; case 'site_404': $options[0] = 's'; $details = array('' => lang('none')); if (is_array($list = $this->admin_model->get_template_list())) { $details = array_merge($details, $list); } $selected = $value; break; case 'theme_menu': $options[0] = 's'; $details = $this->admin_model->get_cp_theme_list(); $selected = $value; break; case 'timezone': $options[0] = 's'; foreach ($timezones as $k => $v) { $details[$k] = lang($k); } $selected = $value; break; } break; case 'i': // Input fields $details = array('name' => $name, 'value' => str_replace("\\'", "'", $value), 'id' => $name); break; } $vars['fields'][$name] = array('type' => $options[0], 'value' => $details, 'subtext' => $sub, 'selected' => $selected); } // if this is an update, show the success message $vars['return_loc'] = BASE . AMP . 'C=admin_content' . AMP . 'M=' . $return_loc; $this->view->cp_page_title = lang($type); $this->cp->render('admin/config_pages', $vars); }