function set_timezone($lang = '') { if (empty($lang)) { return array('UTC', 0); } $l = accept_language::split_locale_str($lang); // When the name of a country is uncertain (国名が不明な場合) if (empty($l[2])) { $obj_l2c = new lang2country(); $l[2] = $obj_l2c->get_lang2country($l[1]); if (empty($l[2])) { return array('UTC', 0); } } $obj = new timezone(); $obj->set_datetime(UTIME); // Setting at judgment time. (判定時刻の設定) $obj->set_country($l[2]); // The acquisition country is specified. (取得国を指定) // With the installation country in case of the same // 設置者の国と同一の場合 if ($lang == DEFAULT_LANG) { if (defined('DEFAULT_TZ_NAME')) { $obj->set_tz_name(DEFAULT_TZ_NAME); } } list($zone, $zonetime) = $obj->get_zonetime(); if ($zonetime == 0 || empty($zone)) { return array('UTC', 0); } return array($zone, $zonetime); }
/** * World Time プラグイン * * @copyright Copyright © 2005-2006, Katsumi Saito <*****@*****.**> * @version $Id: worldtime.inc.php,v 0.4 2006/02/16 01:31:00 upk Exp $ * */ function plugin_worldtime_inline() { switch (func_num_args()) { case 1: return "&worldtime( timezone_name ){format};\n"; default: list($code, $format) = func_get_args(); $format = htmlspecialchars($format, ENT_QUOTES); } if (empty($code)) { return ''; } $obj = new timezone(); $obj->set_datetime(); $obj->set_tz_name($code); list($zone, $zonetime) = $obj->get_zonetime(); if (empty($format)) { $format = 'Y-m-d H:i T'; } $x = gmdate($format, UTIME + $zonetime); $x = str_replace('GMT', $zone, $x); return $x; }
function __construct(&$config, $dn = NULL, $object = NULL) { #definition des variables $attributesInfo = self::getAttributesInfo(); /* Languages */ $languages = get_languages(TRUE); asort($languages); $languages = array_merge(array("" => _("Automatic")), $languages); $attributesInfo['look_n_feel']['attrs'][0]->setChoices(array_keys($languages), array_values($languages)); /* Timezones */ $attributesInfo['look_n_feel']['attrs'][2]->setChoices(timezone::_get_tz_zones()); /* Password methods */ $methods = passwordMethod::get_available_methods(); $methods = $methods['name']; $attributesInfo['password']['attrs'][0]->setChoices($methods); parent::__construct($config, $dn, $object, $attributesInfo); $this->fusionConfigMd5 = md5_file(CACHE_DIR . "/" . CLASS_CACHE); $this->attributesAccess['fdEnableSnapshots']->setManagedAttributes(array('disable' => array(FALSE => array('fdSnapshotBase')))); $this->attributesAccess['fdForceSSL']->setManagedAttributes(array('disable' => array(TRUE => array('fdWarnSSL')))); $this->attributesAccess['fdIdAllocationMethod']->setManagedAttributes(array('erase' => array('traditional' => array('fdUidNumberPoolMin', 'fdUidNumberPoolMax', 'fdGidNumberPoolMin', 'fdGidNumberPoolMax')))); }
/** * Is DST in effect? * @param integer $timestamp When? * @param string $timezone_key Where? * @return boolean Yes, they are saving time, actually. */ function is_dst($timestamp, $timezone_key) { global $is_dst, $auto_dst; $out = $is_dst; if ($auto_dst && $timezone_key && timezone::is_supported()) { $server_tz = date_default_timezone_get(); if ($server_tz) { // switch to client time zone if (date_default_timezone_set($timezone_key)) { $out = date('I', $timestamp); // restore server time zone date_default_timezone_set($server_tz); } } } return $out; }
/** * Renders a HTML <select> list of cities for timezone selection. * * Can be altered by plugins via the 'prefs_ui > gmtoffset' * pluggable UI callback event. * * @param string $name HTML name of the list * @param string $val Initial (or current) selected option * @return string HTML */ function gmtoffset_select($name, $val) { // Fetch *hidden* pref $key = get_pref('timezone_key', '', true); if ($key === '') { $key = (string) Txp::get('Textpattern_Date_Timezone')->getTimezone(); } $tz = new timezone(); $ui = $tz->selectInput('timezone_key', $key, false, '', 'gmtoffset'); return pluggable_ui('prefs_ui', 'gmtoffset', $ui, $name, $val); }
echo form::label('siteDomain', 'Site Domain'); echo '<div>http://' . $_SERVER['HTTP_HOST'] . '</div>' . form::input('siteDomain', $autoURI); ?> </div> <div class="field upload"> <?php echo form::label('uploadDir', 'Upload Directory'); echo form::input('uploadDir'); ?> </div> <div class="field"> <?php echo form::label('defaultTimeZone', 'Default Timezone'); echo timezone::dropdown('defaultTimeZone', $defaultTimeZone); ?> </div> <div class="field"> <?php echo form::label('samples', 'Install Sample Data'); echo form::checkbox('samples'); ?> </div> <?php echo form::close_section(); ?>
function is_dst($name, $val) { $ui = yesnoRadio($name, $val) . n . script_js("textpattern.timezone_is_supported = " . (int) timezone::is_supported() . ";") . script_js(<<<EOS \t\t\t\$(document).ready(function(){ \t\t\t\tvar radio = \$("#prefs-is_dst input"); \t\t\t\tif (radio) { \t\t\t\t\tif (\$("#auto_dst-1").attr("checked") && textpattern.timezone_is_supported) { \t\t\t\t\t\tradio.attr("disabled","disabled"); \t\t\t\t\t} \t\t\t\t\t\$("#auto_dst-0").click( \t\t\t\t\t\tfunction(){ \t\t\t\t\t\t\tradio.removeAttr("disabled"); \t\t\t\t\t\t}); \t\t\t\t \t\$("#auto_dst-1").click( \t\t\t\t\t\tfunction(){ \t\t\t\t\t\t\tradio.attr("disabled","disabled"); \t\t\t\t\t \t}); \t\t\t \t} \t\t\t\tif (!textpattern.timezone_is_supported) { \t\t\t\t\t\$("#prefs-auto_dst input").attr("disabled","disabled"); \t\t\t\t} \t}); EOS ); return pluggable_ui('prefs_ui', 'is_dst', $ui, $name, $val); }
function doDiagnostics() { global $prefs, $files, $txpcfg, $event, $step, $theme; extract(get_prefs()); $urlparts = parse_url(hu); $mydomain = $urlparts['host']; $server_software = @$_SERVER['SERVER_SOFTWARE'] || @$_SERVER['HTTP_HOST'] ? @$_SERVER['SERVER_SOFTWARE'] ? @$_SERVER['SERVER_SOFTWARE'] : $_SERVER['HTTP_HOST'] : ''; $is_apache = ($server_software and stristr($server_software, 'Apache')) or is_callable('apache_get_version'); $real_doc_root = isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : ''; // ini_get() returns string values passed via php_value as a string, not boolean $is_register_globals = (strcasecmp(ini_get('register_globals'), 'on') === 0 or ini_get('register_globals') === '1'); $fail = array('php_version_4_3_0_required' => (!is_callable('version_compare') or version_compare(PHP_VERSION, '4.3.0', '<')) ? gTxt('php_version_4_3_0_required') : '', 'path_to_site_missing' => !isset($path_to_site) ? gTxt('path_to_site_missing') : '', 'dns_lookup_fails' => @gethostbyname($mydomain) == $mydomain ? gTxt('dns_lookup_fails') . cs . $mydomain : '', 'path_to_site_inacc' => !@is_dir($path_to_site) ? gTxt('path_to_site_inacc') . cs . $path_to_site : '', 'site_trailing_slash' => rtrim($siteurl, '/') != $siteurl ? gTxt('site_trailing_slash') . cs . $path_to_site : '', 'index_inaccessible' => (!@is_file($path_to_site . "/index.php") or !@is_readable($path_to_site . "/index.php")) ? "{$path_to_site}/index.php " . gTxt('is_inaccessible') : '', 'dir_not_writable' => trim((!@is_writable($path_to_site . '/' . $img_dir) ? str_replace('{dirtype}', gTxt('img_dir'), gTxt('dir_not_writable')) . ": {$path_to_site}/{$img_dir}" . n : '') . (!@is_writable($file_base_path) ? str_replace('{dirtype}', gTxt('file_base_path'), gTxt('dir_not_writable')) . ": {$file_base_path}" . n : '') . (!@is_writable($tempdir) ? str_replace('{dirtype}', gTxt('tempdir'), gTxt('dir_not_writable')) . ": {$tempdir}" . n : '')), 'cleanurl_only_apache' => ($permlink_mode != 'messy' and !$is_apache) ? gTxt('cleanurl_only_apache') : '', 'htaccess_missing' => ($permlink_mode != 'messy' and !@is_readable($path_to_site . '/.htaccess')) ? gTxt('htaccess_missing') : '', 'mod_rewrite_missing' => ($permlink_mode != 'messy' and is_callable('apache_get_modules') and !apache_module('mod_rewrite')) ? gTxt('mod_rewrite_missing') : '', 'file_uploads_disabled' => !ini_get('file_uploads') ? gTxt('file_uploads_disabled') : '', 'setup_still_exists' => @is_dir(txpath . DS . 'setup') ? txpath . DS . "setup" . DS . ' ' . gTxt('still_exists') : '', 'no_temp_dir' => empty($tempdir) ? gTxt('no_temp_dir') : '', 'warn_mail_unavailable' => is_disabled('mail') ? gTxt('warn_mail_unavailable') : '', 'warn_register_globals_or_update' => $is_register_globals && (version_compare(phpversion(), '4.4.0', '<=') or version_compare(phpversion(), '5.0.0', '>=') and version_compare(phpversion(), '5.0.5', '<=')) ? gTxt('warn_register_globals_or_update') : ''); if ($permlink_mode != 'messy') { $rs = safe_column("name", "txp_section", "1"); foreach ($rs as $name) { if ($name and @file_exists($path_to_site . '/' . $name)) { $fail['old_placeholder_exists'] = gTxt('old_placeholder') . ": {$path_to_site}/{$name}"; } } } $missing = array(); foreach ($files as $f) { $realpath = realpath(txpath . $f); if (is_readable($realpath)) { $found[] = $realpath; } else { $missing[] = txpath . $f; } } $files = $found; unset($found); if ($missing) { $fail['missing_files'] = gTxt('missing_files') . cs . n . t . join(', ' . n . t, $missing); } foreach ($fail as $k => $v) { if (empty($v)) { unset($fail[$k]); } } # Find the highest revision number $file_revs = $file_md5 = array(); $rev = 0; foreach ($files as $f) { $content = @file_get_contents($f); if ($content !== FALSE) { if (preg_match('/^\\$' . 'LastChangedRevision: (\\d+) \\$/m', $content, $match)) { $file_revs[$f] = $match[1]; if ($match[1] > $rev) { $rev = $match[1]; } } $file_md5[$f] = md5(str_replace('$' . 'HeadURL: http:', '$' . 'HeadURL: https:', str_replace("\r\n", "\n", $content))); } } # Check revs & md5 against stable release, if possible $dev_files = $old_files = $modified_files = array(); if ($cs = @file(txpath . '/checksums.txt')) { foreach ($cs as $c) { if (preg_match('@^(\\S+): r?(\\S+) \\((.*)\\)$@', trim($c), $m)) { list(, $file, $r, $md5) = $m; $file = realpath(txpath . $file); if (!empty($file_revs[$file]) and $r and $file_revs[$file] < $r) { $old_files[] = $file; } elseif (!empty($file_revs[$file]) and $r and $file_revs[$file] > $r) { $dev_files[] = $file; } elseif (!empty($file_md5[$file]) and $file_md5[$file] != $md5) { $modified_files[] = $file; } } } } # files that haven't been updated if ($old_files) { $fail['old_files'] = gTxt('old_files') . cs . n . t . join(', ' . n . t, $old_files); } # files that don't match their checksums if ($modified_files) { $fail['modified_files'] = gTxt('modified_files') . cs . n . t . join(', ' . n . t, $modified_files); } # running development code in live mode is not recommended if ($dev_files and $production_status == 'live') { $fail['dev_version_live'] = gTxt('dev_version_live') . cs . n . t . join(', ' . n . t, $dev_files); } # anything might break if arbitrary functions are disabled if (ini_get('disable_functions')) { $disabled_funcs = array_map('trim', explode(',', ini_get('disable_functions'))); # commonly disabled functions that we don't need $disabled_funcs = array_diff($disabled_funcs, array('imagefilltoborder', 'exec', 'system', 'dl', 'passthru', 'chown', 'shell_exec', 'popen', 'proc_open')); if ($disabled_funcs) { $fail['some_php_functions_disabled'] = gTxt('some_php_functions_disabled') . cs . join(', ', $disabled_funcs); } } # not sure about this one #if (strncmp(php_sapi_name(), 'cgi', 3) == 0 and ini_get('cgi.rfc2616_headers')) # $fail['cgi_header_config'] = gTxt('cgi_header_config'); $guess_site_url = $_SERVER['HTTP_HOST'] . preg_replace('#[/\\\\]$#', '', dirname(dirname($_SERVER['SCRIPT_NAME']))); if ($siteurl and strip_prefix($siteurl, 'www.') != strip_prefix($guess_site_url, 'www.')) { $fail['site_url_mismatch'] = gTxt('site_url_mismatch') . cs . $guess_site_url; } # test clean URL server vars if (hu) { if (ini_get('allow_url_fopen') and $permlink_mode != 'messy') { $s = md5(uniqid(rand(), true)); ini_set('default_socket_timeout', 10); $pretext_data = @file(hu . $s . '/?txpcleantest=1'); if ($pretext_data) { $pretext_req = trim(@$pretext_data[0]); if ($pretext_req != md5('/' . $s . '/?txpcleantest=1')) { $fail['clean_url_data_failed'] = gTxt('clean_url_data_failed') . cs . htmlspecialchars($pretext_req); } } else { $fail['clean_url_test_failed'] = gTxt('clean_url_test_failed'); } } } if ($tables = list_txp_tables()) { $table_errors = check_tables($tables); if ($table_errors) { $fail['mysql_table_errors'] = gTxt('mysql_table_errors') . cs . n . t . join(', ' . n . t, $table_errors); } } $active_plugins = array(); if ($rows = safe_rows('name, version, code_md5, md5(code) as md5', 'txp_plugin', 'status > 0')) { foreach ($rows as $row) { $n = $row['name'] . '-' . $row['version']; if (strtolower($row['md5']) != strtolower($row['code_md5'])) { $n .= 'm'; } $active_plugins[] = $n; } } $theme_manifest = $theme->manifest(); // check GD info if (function_exists('gd_info')) { $gd_info = gd_info(); $gd_support = array(); if ($gd_info['GIF Create Support']) { $gd_support[] = 'GIF'; } // Aside: In PHP 5.3, they chose to add a previously unemployed capital "E" to the array key. if (!empty($gd_info['JPEG Support']) || !empty($gd_info['JPG Support'])) { $gd_support[] = 'JPG'; } if ($gd_info['PNG Support']) { $gd_support[] = 'PNG'; } if ($gd_support) { $gd_support = join(', ', $gd_support); } else { $gd_support = gTxt('none'); } $gd = gTxt('gd_info', array('{version}' => $gd_info['GD Version'], '{supported}' => $gd_support)); } else { $gd = gTxt('gd_unavailable'); } if (realpath($prefs['tempdir']) == realpath($prefs['plugin_cache_dir'])) { $fail['tmp_plugin_paths_match'] = gTxt('tmp_plugin_paths_match'); } echo pagetop(gTxt('tab_diagnostics'), ''), '<div id="' . $event . '_container" class="txp-container txp-list">', '<div id="pre_flight_check">', startTable('list', '', 'list', '', '510px'), '<thead>', tr(td(hed(gTxt('preflight_check'), 2))), '</thead>'; echo '<tbody>'; if ($fail) { foreach ($fail as $help => $message) { echo tr(tda(nl2br($message) . sp . popHelp($help), ' class="not-ok"')); } } else { echo tr(tda(gTxt('all_checks_passed'), ' class="ok"')); } echo '</tbody>', endTable(), '</div>'; echo '<div id="diagnostics">', startTable('list', '', 'list'), '<thead>', tr(td(hed(gTxt('diagnostic_info'), 2))), '</thead>'; $fmt_date = '%Y-%m-%d %H:%M:%S'; $out = array('<textarea cols="78" rows="18" readonly="readonly" style="width: 500px; height: 300px;">', gTxt('txp_version') . cs . txp_version . ' (' . ($rev ? 'r' . $rev : 'unknown revision') . ')' . n, gTxt('last_update') . cs . gmstrftime($fmt_date, $dbupdatetime) . '/' . gmstrftime($fmt_date, @filemtime(txpath . '/update/_update.php')) . n, gTxt('document_root') . cs . @$_SERVER['DOCUMENT_ROOT'] . ($real_doc_root != @$_SERVER['DOCUMENT_ROOT'] ? ' (' . $real_doc_root . ')' : '') . n, '$path_to_site' . cs . $path_to_site . n, gTxt('txp_path') . cs . txpath . n, gTxt('permlink_mode') . cs . $permlink_mode . n, ini_get('open_basedir') ? 'open_basedir: ' . ini_get('open_basedir') . n : '', ini_get('upload_tmp_dir') ? 'upload_tmp_dir: ' . ini_get('upload_tmp_dir') . n : '', gTxt('tempdir') . cs . $tempdir . n, gTxt('web_domain') . cs . $siteurl . n, gTxt('php_version') . cs . phpversion() . n, $is_register_globals ? gTxt('register_globals') . cs . $is_register_globals . n : '', gTxt('gd_library') . cs . $gd . n, gTxt('server') . ' TZ: ' . (timezone::is_supported() ? date_default_timezone_get() : (getenv('TZ') ? getenv('TZ') : '-')) . n, gTxt('server_time') . cs . strftime('%Y-%m-%d %H:%M:%S') . n, strip_tags(gTxt('is_dst')) . cs . $is_dst . n, strip_tags(gTxt('auto_dst')) . cs . $auto_dst . n, strip_tags(gTxt('gmtoffset')) . cs . $timezone_key . sp . "({$gmtoffset})" . n, 'MySQL' . cs . mysql_get_server_info() . n, gTxt('locale') . cs . $locale . n, isset($_SERVER['SERVER_SOFTWARE']) ? gTxt('server') . cs . $_SERVER['SERVER_SOFTWARE'] . n : '', is_callable('apache_get_version') ? gTxt('apache_version') . cs . apache_get_version() . n : '', gTxt('php_sapi_mode') . cs . PHP_SAPI . n, gTxt('rfc2616_headers') . cs . ini_get('cgi.rfc2616_headers') . n, gTxt('os_version') . cs . php_uname('s') . ' ' . php_uname('r') . n, $active_plugins ? gTxt('active_plugins') . cs . join(', ', $active_plugins) . n : '', gTxt('theme_name') . cs . $theme_name . sp . $theme_manifest['version'] . n, $fail ? n . gTxt('preflight_check') . cs . n . ln . join("\n", $fail) . n . ln : '', is_readable($path_to_site . '/.htaccess') ? n . gTxt('htaccess_contents') . cs . n . ln . htmlspecialchars(join('', file($path_to_site . '/.htaccess'))) . n . ln : ''); if ($step == 'high') { $mysql_client_encoding = is_callable('mysql_client_encoding') ? mysql_client_encoding() : '-'; $out[] = n . 'Charset (default/config)' . cs . $mysql_client_encoding . '/' . @$txpcfg['dbcharset'] . n; $result = safe_query("SHOW variables like 'character_se%'"); while ($row = mysql_fetch_row($result)) { $out[] = $row[0] . cs . $row[1] . n; if ($row[0] == 'character_set_connection') { $conn_char = $row[1]; } } $table_names = array(PFX . 'textpattern'); $result = safe_query("SHOW TABLES LIKE '" . PFX . "txp\\_%'"); while ($row = mysql_fetch_row($result)) { $table_names[] = $row[0]; } $table_msg = array(); foreach ($table_names as $table) { $ctr = safe_query("SHOW CREATE TABLE " . $table . ""); if (!$ctr) { unset($table_names[$table]); continue; } $ctcharset = preg_replace('#^CREATE TABLE.*SET=([^ ]+)[^)]*$#is', '\\1', mysql_result($ctr, 0, 'Create Table')); if (isset($conn_char) && !stristr($ctcharset, 'CREATE') && $conn_char != $ctcharset) { $table_msg[] = "{$table} is {$ctcharset}"; } $ctr = safe_query("CHECK TABLE " . $table); if (in_array(mysql_result($ctr, 0, 'Msg_type'), array('error', 'warning'))) { $table_msg[] = $table . cs . mysql_result($ctr, 0, 'Msg_Text'); } } if ($table_msg == array()) { $table_msg = count($table_names) < 17 ? array('-') : array('OK'); } $out[] = count($table_names) . ' Tables' . cs . implode(', ', $table_msg) . n; $cf = preg_grep('/^custom_\\d+/', getThings('describe `' . PFX . 'textpattern`')); $out[] = n . get_pref('max_custom_fields', 10) . sp . gTxt('custom') . cs . implode(', ', $cf) . sp . '(' . count($cf) . ')' . n; $extns = get_loaded_extensions(); $extv = array(); foreach ($extns as $e) { $extv[] = $e . (phpversion($e) ? '/' . phpversion($e) : ''); } $out[] = n . gTxt('php_extensions') . cs . join(', ', $extv) . n; if (is_callable('apache_get_modules')) { $out[] = n . gTxt('apache_modules') . cs . join(', ', apache_get_modules()) . n; } if (@is_array($pretext_data) and count($pretext_data) > 1) { $out[] = n . gTxt('pretext_data') . cs . htmlspecialchars(join('', array_slice($pretext_data, 1, 20))) . n; } $out[] = n; foreach ($files as $f) { $checksum = isset($file_md5[$f]) ? $file_md5[$f] : gTxt('unknown'); $revision = isset($file_revs[$f]) ? 'r' . $file_revs[$f] : gTxt('unknown'); $out[] = "{$f}" . cs . n . t . $revision . ' (' . $checksum . ')' . n; } $out[] = n . ln; } $out[] = callback_event('diag_results', $step) . n; $out[] = '</textarea>' . br; $dets = array('low' => gTxt('low'), 'high' => gTxt('high')); $out[] = form(eInput('diag') . n . gTxt('detail') . cs . selectInput('step', $dets, $step, 0, 1)); echo '<tbody>', tr(td(join('', $out))), '</tbody>', endTable(), '</div>', '</div>'; }
/** * Calculates a timezone offset. * * Calculates the offset between the server local time and the * user's selected timezone at a given point in time. * * @param int $timestamp The timestamp. Defaults to time() * @return int The offset in seconds * @package DateTime */ function tz_offset($timestamp = null) { global $gmtoffset, $timezone_key; if (is_null($timestamp)) { $timestamp = time(); } extract(getdate($timestamp)); $serveroffset = gmmktime($hours, $minutes, 0, $mon, $mday, $year) - mktime($hours, $minutes, 0, $mon, $mday, $year); $real_dst = timezone::is_dst($timestamp, $timezone_key); return $gmtoffset - $serveroffset + ($real_dst ? 3600 : 0); }
exit; } /* Check for uniqe ip address */ $ui = session::global_get('ui'); if ($_SERVER['REMOTE_ADDR'] != $ui->ip) { new log('security', 'login', '', array(), 'main.php called with session which has a changed IP address.'); header('Location: index.php?signout=1&message=newip'); exit; } $config = session::global_get('config'); /* If SSL is forced, just forward to the SSL enabled site */ if ($config->get_cfg_value('forcessl') == 'TRUE' && $ssl != '') { header("Location: {$ssl}"); exit; } timezone::setDefaultTimezoneFromConfig(); /* Check for invalid sessions */ if (session::global_get('_LAST_PAGE_REQUEST') != '') { /* check FusionDirectory.conf for defined session lifetime */ $max_life = $config->get_cfg_value('sessionLifetime', 60 * 60 * 2); /* get time difference between last page reload */ $request_time = time() - session::global_get('_LAST_PAGE_REQUEST'); /* If page wasn't reloaded for more than max_life seconds * kill session */ if ($request_time > $max_life) { session::destroy(); new log('security', 'login', '', array(), 'main.php called with expired session - logging out'); header('Location: index.php?signout=1&message=expired'); exit; }
private function viewInstall() { $params = array(); if (file_exists(root . '/install/.lock')) { $params['notify']['prepare']['lock'] = true; } if (file_exists(root . '/config.php') && !is_writable(root . '/config.php')) { $params['notify']['prepare']['cfg_write'] = true; } if (!is_writable(root . '/install/')) { $params['notify']['prepare']['inst_write'] = true; } if (!file_exists(root . '/install/sql/install.sql')) { $params['notify']['prepare']['sql_notfound'] = true; } $timezone_array = timezone::getInstance()->getZoneUTC(); template::getInstance()->set(template::TYPE_SYSTEM, 'timezones', $timezone_array); if (sizeof($params['notify']) == 0) { if (system::getInstance()->post('submit')) { $testCon = null; try { $testCon = @new \PDO("mysql:host=" . system::getInstance()->post('config:db_host') . ";dbname=" . system::getInstance()->post('config:db_name') . "", system::getInstance()->post('config:db_user'), system::getInstance()->post('config:db_pass')); } catch (\PDOException $exception) { $params['notify']['process']['db_conn_miss'] = true; } if ($testCon != null) { $reg_login = system::getInstance()->post('admin:login'); $reg_email = system::getInstance()->post('admin:email'); $reg_pass = system::getInstance()->post('admin:pass'); $reg_repass = system::getInstance()->post('admin:repass'); if (!filter_var($reg_email, FILTER_VALIDATE_EMAIL)) { $params['notify']['process']['reg_email_wrong'] = true; } if (!system::getInstance()->validPasswordLength($reg_pass)) { $params['notify']['process']['reg_pass_wrong'] = true; } if (system::getInstance()->length($reg_login) < 3 || system::getInstance()->length($reg_login) > 64) { $params['notify']['process']['reg_login_wrong'] = true; } if ($reg_pass != $reg_repass) { $params['notify']['process']['reg_repass_nomatch'] = true; } if (sizeof($params['notify']) == 0) { $configs_data = '<?php' . "\n"; foreach (system::getInstance()->post(null) as $var_name => $var_value) { if (system::getInstance()->prefixEquals($var_name, 'config:')) { $var_name = substr($var_name, strlen('config:')); $var_name = system::getInstance()->nohtml($var_name); if ($var_name === 'seo_title') { foreach (language::getInstance()->getAvailable() as $clang) { $configs_data .= '$config[\'' . $var_name . '\'][\'' . $clang . '\'] = "' . system::getInstance()->nohtml($var_value[$clang]) . '";' . "\n"; } } else { $configs_data .= '$config[\'' . $var_name . '\'] = "' . system::getInstance()->nohtml($var_value) . '"' . ";\n"; } } } $random_password_salt = system::getInstance()->randomString(rand(12, 16)); $configs_data .= '$config[\'tpl_dir\'] = "templates"; $config[\'tpl_name\'] = "default"; $config[\'debug\'] = true; $config[\'multi_title\'] = false; $config[\'cache_interval\'] = "120"; $config[\'token_time\'] = "86400"; $config[\'user_friendly_url\'] = false; $config[\'mail_from\'] = "*****@*****.**"; $config[\'mail_ownername\'] = "Site Admin"; $config[\'mail_smtp_use\'] = false; $config[\'mail_smtp_host\'] = "smtp.yandex.ru"; $config[\'mail_smtp_port\'] = "25"; $config[\'mail_smtp_auth\'] = true; $config[\'mail_smtp_login\'] = "*****@*****.**"; $config[\'mail_smtp_password\'] = "madness"; $config[\'password_salt\'] = "' . $random_password_salt . '"; '; $configs_data .= '?>'; file_put_contents(root . '/install/.lock', 'Install success'); file_put_contents(root . '/config.php', $configs_data); $prefix = system::getInstance()->post('config:db_prefix'); if (!system::getInstance()->isLatinOrNumeric($prefix)) { $prefix = "ffcms"; } $query_dump = str_replace('{$db_prefix}', $prefix, file_get_contents(root . '/install/sql/install.sql')); $testCon->exec($query_dump); $md5_doublehash = system::getInstance()->doublemd5($reg_pass, $random_password_salt); $stmt = $testCon->prepare("INSERT INTO " . $prefix . "_user (`login`, `email`, `nick`, `pass`, `access_level`) VALUES(?, ?, 'admin', ?, '3')"); $stmt->bindParam(1, $reg_login, \PDO::PARAM_STR); $stmt->bindParam(2, $reg_email, \PDO::PARAM_STR); $stmt->bindParam(3, $md5_doublehash, \PDO::PARAM_STR, 32); $stmt->execute(); $user_id = $testCon->lastInsertId(); $stmt = null; $stmt = $testCon->prepare("INSERT INTO " . $prefix . "_user_custom(`id`) VALUES (?)"); $stmt->bindParam(1, $user_id, \PDO::PARAM_INT); $stmt->execute(); $stmt = null; $testCon = null; $params['notify']['success'] = true; } } foreach (system::getInstance()->post(null) as $var_name => $var_value) { if (system::getInstance()->prefixEquals($var_name, 'config:')) { $var_name = substr($var_name, strlen('config:')); template::getInstance()->set('cfg', $var_name, $var_value); } } } } return template::getInstance()->twigRender('install.tpl', $params); }
public static function dialplan($number) { $xml = Telephony::getDriver()->xml; $destination = $number['Destination']; if (!empty($destination['time'])) { $parts = explode(';', $destination['time']); if (count($parts) != 2) { kohana::log('error', 'Time was not comprised of two parts'); return FALSE; } $offset = timezone::getUTCOffset($destination['plugins']['timezone']['timezone']) / 60; if ($parts[0] == $parts[1]) { $times[] = $parts - $offset; } else { $times[] = $parts[0] - $offset; $times[] = $parts[1] - $offset; } } else { kohana::log('error', 'Time of day route had no time'); return FALSE; } $weekDayColumns = array('sun', 'mon', 'tue', 'wen', 'thur', 'fri', 'sat'); $wday = array(); foreach ($weekDayColumns as $pos => $weekDayColumn) { if (!empty($destination[$weekDayColumn])) { $wday[] = $pos + 1; } } // TODO: This makes no sense.... if (empty($wday)) { $wday = array(1, 2, 3, 4, 5, 6, 7); } $xml->setXmlRoot($xml->getExtensionRoot()); Kohana::log('debug', 'NODE?'); foreach ($xml->childNodes as $node) { if ($node !== $xml->firstChild) { $node->deleteNode(); } } $time_xml = ""; foreach ($times as $index => $time) { if ($time < 0) { foreach ($wday as $day) { if ($day == 1) { $offsetwday[] = 7; } else { $offsetwday[] = $day - 1; } } $time_xml .= self::createTimeCondition($destination, $offsetwday, 1440 + $time . '-1440'); $times[$index] = 0; } if ($time > 1440) { foreach ($wday as $day) { if ($day == 7) { $offsetwday[] = 1; } else { $offsetwday[] = $day + 1; } } $time_xml .= self::createTimeCondition($destination, $offsetwday, '0-' . ($time - 1440)); $times[$index] = 1440; } } if (sizeof($times) == 1) { $time_xml .= self::createTimeCondition($destination, $wday, $times[0]); } else { if (sizeof($times) == 2) { $time_xml .= self::createTimeCondition($destination, $wday, $times[0] . '-' . $times[1]); } } if (!empty($time_xml)) { $newXmlFragment = $xml->createDocumentFragment(); $newXmlFragment->appendXML($time_xml); $xml->set('')->appendChild($newXmlFragment); } else { $xml->deleteNode(); } }
</h2> </div> <div id="endpoint_global_form" class="update endpoint"> <?php echo form::open(); ?> <?php echo form::open_section('Global Settings'); ?> <div class='field'> <?php echo form::label(array('for' => 'package[registry][defaults][global][timezone]', 'hint' => 'Default timezone for all phones', 'help' => 'Default timezone for all phones'), 'Default Timezone:'); echo timezone::dropdown("package[registry][defaults][global][timezone]", $savedtimezone); ?> </div> <div class='field'> <?php echo form::label(array('for' => 'package[registry][defaults][global][linedisplay]', 'hint' => 'What to display next to line buttons on the phone'), 'Line Display:'); echo form::dropdown("package[registry][defaults][global][linedisplay]", array('name' => 'Device Name', 'extension' => 'SIP Username'), $defaults['global']['linedisplay']); ?> </div> <?php echo $additional_global_questions; ?> <?php echo form::close_section();
</div> <div style="text-align: center; margin: 20px 0 40px 0;"> <?php echo '<div style="width:750px; margin: 0 auto;">' . form::input(array('name' => 'timeofday[time]', 'type' => 'slider')) . '</div>'; ?> </div> <?php echo form::open_section('Timezone'); ?> <div class="field"> <?php echo form::label('timeofday[timezone]', 'Timezone'); echo timezone::dropdown(array('id' => 'timezone', 'name' => 'timeofday[timezone]', 'class' => 'time_selector'), empty($timeofday['timezone']) ? NULL : $timeofday['timezone']); ?> </div> <?php echo form::close_section(); ?> <?php echo form::open_section('During this Range'); ?> <div class="field" style="text-align: center;"> <span id="time_range_text">On Moday through Friday between the hours of 07:00 and 17:00,<br /> route calls to a</span> <?php
<?php echo form::open_section('Timezone'); ?> <div class="field"> <?php echo form::label('timezone[timezone]', 'Timezone'); echo timezone::dropdown('timezone[timezone]', empty($timezone['timezone']) ? NULL : $timezone['timezone']); ?> </div> <?php echo form::close_section();