/** * Checks if a resource exists and returns it if so. * * @param string $filename The resource name * @param bool $return_url If true returns an URL, else returns true or false depending on if the resource exists * @param bool $as_local_path If true returns not URL, but a filepath in local filesystem. Needs $return_url=true. * @param bool $nocache If true skips all internal caches and peforms a search now * @return string Depending on $return_url returns: (the resource URL or false on error) OR (true or false) */ function resourceExists($filename, $return_url = false, $as_local_path = false, $nocache = false) { global $CONFIG; $cnc = substr(appendVersion('/'), 1); $key = (isSSL() ? "resource_ssl_{$filename}" : "resource_{$filename}") . "_{$cnc}" . ($as_local_path ? "_l" : ""); if (!$nocache && ($res = cache_get($key)) !== false) { return $return_url ? $res : $res != "0"; } $ext = pathinfo($filename, PATHINFO_EXTENSION); $reg = "/(^{$ext}\$|^{$ext}\\||\\|{$ext}\$)/i"; foreach ($CONFIG['resources'] as $conf) { if (strpos("|" . $conf['ext'] . "|", "|" . $ext . "|") === false) { continue; } if (!file_exists($conf['path'] . '/' . $filename)) { continue; } if ($as_local_path) { return $conf['path'] . '/' . $filename; } $nc = $conf['append_nc'] ? $cnc : ''; $res = can_nocache() ? $conf['url'] . $nc . $filename : $conf['url'] . $filename . "?_nc=" . substr($nc, 2, -1); if (!$nocache) { cache_set($key, $res); } return $return_url ? $res : true; } cache_set($key, "0"); return false; }
/** * Route the application. */ public function route() { $uri = JURI::getInstance(); //forward to https $scheme = isSSL() ? 'https' : 'http'; $uri->setScheme($scheme); $this->redirect($uri->toString()); }
/** * {@inheritdoc} */ protected function _getUrl($path) { if (isSSL()) { $url = 'https://s3.amazonaws.com/' . $this->_params->bucket . '/' . $path; } else { $url = 'http://' . $this->_params->bucket . '.s3.amazonaws.com/' . $path; } return $url; }
public function generate($path) { $this->output = (string) ''; $http = isSSL() ? 'https://' : 'http://'; $http_host = $http . $_SERVER['HTTP_HOST']; if (is_dir($path) && file_exists($path . '/index.htm')) { $this->output .= '<urlset '; $this->output .= 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '; $this->output .= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '; $this->output .= 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL; $dir = opendir($path); $this->output .= '<url>'; $this->output .= '<loc>'; $this->output .= $http_host . '/'; $this->output .= '</loc>'; $this->output .= '<lastmod>' . date('Y-m-d', filemtime($path . '/index.htm')) . '</lastmod>'; $this->output .= '<changefreq>weekly</changefreq>'; $this->output .= '<priority>0.5</priority>'; $this->output .= '</url>'; while ($file = readdir($dir)) { if ($file[0] != '-' && $file != 'index.htm' && is_file($path . '/' . $file) && substr($file, -3) == 'htm') { $this->output .= '<url>'; $this->output .= '<loc>'; $this->output .= $http_host . '/' . str_replace('_', '/', $file); $this->output .= '</loc>'; $this->output .= '<lastmod>' . date('Y-m-d', filemtime($path . '/' . $file)) . '</lastmod>'; $this->output .= '<changefreq>weekly</changefreq>'; $this->output .= '<priority>0.5</priority>'; $this->output .= '</url>'; } } $this->output .= '</urlset>'; return $this->output; } else { trigger_error('Sitemap could not be created because the directory (' . $path . ') or the index file (index.htm) was not found.', E_USER_ERROR); } // end function }
/** * @internal Performs CSS minifying */ function minify_css($paths, $target_file, $nc_argument = false) { require_once __DIR__ . "/minify/cssmin.php"; global $current_url; $files = minify_collect_files($paths, 'css'); $files = array_merge($files, minify_collect_files($paths, 'less')); log_debug("CSS files to minify: ", $files); //die("stopped"); $code = ""; $res = array(); $map = array(); foreach ($files as $f) { if (!$f) { continue; } if (starts_with($f, "/") && !starts_with($f, "//")) { $f = (isSSL() ? "https" : "http") . "://{$_SERVER['SERVER_NAME']}" . $f; } $css = sendHTTPRequest($f, false, false, $response_header); if (stripos($response_header, "404 Not Found") !== false) { continue; } if (mb_detect_encoding($css) != "UTF-8") { $css = mb_convert_encoding($css, "UTF-8"); } $current_url = parse_url($f); $current_url['onlypath'] = dirname($current_url['path']) . "/"; if ($nc_argument) { $current_url['onlypath'] = preg_replace('|/nc(.*)/|U', "/nc{$nc_argument}/", $current_url['onlypath']); } $css = preg_replace_callback("/url\\s*\\((.*)\\)/siU", "minify_css_translate_url", $css); $css = preg_replace_callback("/AlphaImageLoader\\(src='([^']*)'/siU", "minify_css_translate_url", $css); $css = "/* FILE: {$f} */\n{$css}"; if (!isset($GLOBALS['nominify'])) { $code .= cssmin::minify($css) . "\n"; } else { $code .= "{$css}\n"; $test = str_replace("\r", "", str_replace("\n", "", $css)); $test = preg_replace('|/\\*.*\\*/|U', "", $test); preg_match_all("/([^}]+){([^:]+:[^}]+)}/U", $test, $items, PREG_SET_ORDER); foreach ($items as $item) { $keys = explode(",", $item[1]); foreach ($keys as $k) { $k = trim($k); if (isset($res[$k])) { if ($f != $map[$k]) { $mem = $res[$k]; } } else { $map[$k] = $f; $res[$k] = array(); } foreach (explode(";", $item[2]) as $e) { $e = trim($e); if ($e === "") { continue; } $res[$k][] = $e; } sort($res[$k]); $res[$k] = array_unique($res[$k]); if (isset($mem)) { if (implode(",", $res[$k]) != implode(",", $mem)) { if (count($res[$k]) == count($mem)) { log_debug("[{$k}] defninition overrides previously defined\nFILE: {$f}\nPREV: {$map[$k]}\nNEW : " . implode(";", $res[$k]) . "\nORIG: " . implode(";", $mem) . "\n"); } else { foreach ($mem as $m) { if (!in_array($m, $res[$k])) { log_debug("[{$k}] defninition extends/overrides previously defined\nFILE: {$f}\nPREV: {$map[$k]}\nNEW : " . implode(";", $res[$k]) . "\nORIG: " . implode(";", $mem) . "\n"); } } } } unset($mem); } } } } } foreach (array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f') as $c) { $code = str_ireplace("#{$c}{$c}{$c}{$c}{$c}{$c}", "#{$c}{$c}{$c}", $code); } file_put_contents($target_file, $code); }
/** * @return bool * @see http://stackoverflow.com/a/2886224/2728507 */ function isSSL() { return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443; } date_default_timezone_set('UTC'); error_reporting(E_ALL); ini_set('display_errors', 0); ini_set('display_startup_errors', 1); ini_set('log_errors', '1'); ini_set('error_log', dirname(__FILE__) . '/php_error.log'); $protocol = isSSL() ? 'https' : 'http'; $url = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $current_url = pathinfo($url, PATHINFO_DIRNAME); $root_url = str_replace('/install', '', $current_url) . '/'; define('BB_URL', $root_url); define('BB_URL_INSTALL', BB_URL . 'install/'); define('BB_URL_ADMIN', BB_URL . 'index.php?_url=/bb-admin'); define('BB_PATH_ROOT', realpath(dirname(__FILE__) . '/..')); define('BB_PATH_LIBRARY', BB_PATH_ROOT . '/bb-library'); define('BB_PATH_VENDOR', BB_PATH_ROOT . '/bb-vendor'); define('BB_PATH_THEMES', BB_PATH_ROOT . '/install'); define('BB_PATH_LICENSE', BB_PATH_ROOT . '/LICENSE.txt'); define('BB_PATH_SQL', BB_PATH_ROOT . '/install/structure.sql'); define('BB_PATH_SQL_DATA', BB_PATH_ROOT . '/install/content.sql'); define('BB_PATH_INSTALL', BB_PATH_ROOT . '/install'); define('BB_PATH_CONFIG', BB_PATH_ROOT . '/bb-config.php');
function getHash($prefix = "", $vars = array()) { // OLD // the hash is an expression of the variables compiled to render the template // note that constantly updated values (like timestamps) should be avoided to allow the hash to be reproduced... //$string = serialize( $vars ); // NEW method // the hash is a combination of : // - the protocol // - the request url // - the request parameters // - the session id // $protocol = isSSL() ? "secure" : "public"; // use serialize( $_REQUEST ) instead? $key = session_id() . json_encode($_REQUEST) . $protocol . $_SERVER['REQUEST_URI']; // generate a hash form the string return $prefix . hash("md5", $key); }
/** * Returns current URL scheme * * That is one of http, https, http:// or https:// * @param bool $append_slashes If true appends '//' to the result * @return string The current scheme */ function urlScheme($append_slashes = false) { if ($append_slashes) { return isSSL() ? "https://" : "http://"; } return isSSL() ? "https" : "http"; }
function feed() { $many = 20; $board = ''; //wait for more fix $result = inget('`id`, `post_title`, `post_author`, `post_author_nicename`, `post_content`, `post_date`, `post_board`', 'posts', $board . 'ORDER BY `post_date` DESC LIMIT 0, ' . $many); $board = board_info(); $who = member_who(); $prefix = isSSL() ? 'https:' : 'http:'; $row = mysql_fetch_all($result); if ($row) { foreach ($row as $id => $list) { $row[$id]['post_board'] = $board[$list['post_board']]['name']; $row[$id]['post_board_nicename'] = $board[$list['post_board']]['nicename']; if ($list['post_author']) { $row[$id]['post_author'] = $who[$list['post_author']]['nicename']; } else { $row[$id]['post_author'] = $list['post_author_nicename']; } $row[$id]['post_content'] = html_transfer(show_text($list['post_content'])); } } header('Content-type: application/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; include load_template('feed'); }
function cdn($file = '') { // get the full uri for the file $uri = uri($file); // first check if we have already defined a CDN if (defined("CDN")) { // add protocol $protocol = isSSL() ? 'https://' : 'http://'; // remove trailing slash, if any $domain = substr(CDN, -1) == "/" ? substr(CDN, 0, -1) : CDN; // remove protocol from cdn address $domain = substr($domain, 0, 4) == "http" ? str_replace(array("http://", "https://"), "", $domain) : $domain; // #108 remove www from cdn address (if set by SERVER_NAME) $domain = str_replace("www.", '', $domain); return $protocol . $domain . $uri; } else { // fallback to the domain name return url($file); } }
function validateSession() { // 3/6/2010 Current Server does not allow for Server side detection. Now using forceSSL() in functions.js // see function isSSL() above. if (!isSSL()) { header("Location: logout.php"); } slashAllInputs(); connectDatabase(); validateUser(); // if they are not valid, they don't come back from here. }
/** * Set session cookie parameters * * @access private */ private function _setCookieParams() { $cookie = session_get_cookie_params(); $cookie['secure'] = isSSL(); session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure']); }
function iflychat_init() { global $modSettings, $context, $user_info, $settings, $scripturl, $txt; header('Content-type: application/javascript'); if ($modSettings['iflychat_theme'] == 1) { $iflychat_theme = 'light'; } else { $iflychat_theme = 'dark'; } if (isset($context['language'])) { $language = $context['language']; } else { $language = 'English'; } $iflychat_settings = array('current_timestamp' => time(), 'polling_method' => '3', 'pollUrl' => '', 'sendUrl' => '', 'statusUrl' => '', 'status' => '1', 'goOnline' => $txt['MOD_GO_ONLINE'], 'goIdle' => $txt['MOD_GO_IDLE'], 'newMessage' => $txt['MOD_NEW_CHAT_MESSAGE'], 'images' => $settings['default_theme_url'] . '/iflychat-static/themes/' . $iflychat_theme . '/images/', 'sound' => $settings['default_theme_url'] . '/iflychat-static/swf/sound.swf', 'soundFile' => $settings['default_theme_url'] . '/iflychat-static/wav/notification.mp3', 'noUsers' => '<div class="item-list"><ul><li class="drupalchatnousers even first last">No users online</li></ul></div>', 'smileyURL' => $settings['default_theme_url'] . '/iflychat-static/smileys/very_emotional_emoticons-png/png-32x32/', 'addUrl' => ' ', 'notificationSound' => $modSettings['iflychat_notification_sound'], 'exurl' => $scripturl . '?action=iflychat-get', 'mobileWebUrl' => $scripturl . '?action=iflychat-mob-auth', 'chat_type' => $modSettings['iflychat_show_admin_list'], 'guestPrefix' => $modSettings['iflychat_anon_prefix'], 'allowSmileys' => $modSettings['iflychat_enable_smileys'], 'admin' => iflychat_check_chat_admin() ? '1' : '0', 'theme' => $iflychat_theme); if (iflychat_check_chat_admin()) { $groups = list_getGroups(0, 1000, 'id'); $iflychat_settings['arole'] = array(); foreach ($groups as $group) { $iflychat_settings['arole'][$group['id']] = $group['name']; } } $iflychat_settings['iup'] = $modSettings['iflychat_user_picture']; if ($modSettings['iflychat_user_picture'] == '1') { $iflychat_settings['default_up'] = $settings['default_theme_url'] . '/iflychat-static/themes/' . $iflychat_theme . '/images/default_avatar.png'; $iflychat_settings['default_cr'] = $settings['default_theme_url'] . '/iflychat-static/themes/' . $iflychat_theme . '/images/default_room.png'; $iflychat_settings['default_team'] = $settings['default_theme_url'] . '/iflychat-static/themes/' . $iflychat_theme . '/images/default_team.png'; } //if SSL enabled use https else http if ($iflychat_settings['polling_method'] == '3') { if (isSSL()) { $iflychat_settings['external_host'] = SMFCHAT_EXTERNAL_A_HOST; $iflychat_settings['external_port'] = SMFCHAT_EXTERNAL_A_PORT; $iflychat_settings['external_a_host'] = SMFCHAT_EXTERNAL_A_HOST; $iflychat_settings['external_a_port'] = SMFCHAT_EXTERNAL_A_PORT; } else { $iflychat_settings['external_host'] = SMFCHAT_EXTERNAL_HOST; $iflychat_settings['external_port'] = SMFCHAT_EXTERNAL_PORT; $iflychat_settings['external_a_host'] = SMFCHAT_EXTERNAL_HOST; $iflychat_settings['external_a_port'] = SMFCHAT_EXTERNAL_PORT; } } $iflychat_settings['text_currently_offline'] = $txt['MOD_USER_CURRENTLY_OFFLINE']; $iflychat_settings['text_is_typing'] = $txt['MOD_USER_IS_TYPING']; $iflychat_settings['text_close'] = $txt['MOD_CLOSE']; $iflychat_settings['text_minimize'] = $txt['MOD_MINIMIZE']; $iflychat_settings['text_mute'] = $txt['MOD_CLICK_TO_MUTE']; $iflychat_settings['text_unmute'] = $txt['MOD_CLICK_TO_UNMUTE']; $iflychat_settings['text_available'] = $txt['MOD_AVAILABLE']; $iflychat_settings['text_idle'] = $txt['MOD_IDLE']; $iflychat_settings['text_busy'] = $txt['MOD_BUSY']; $iflychat_settings['text_offline'] = $txt['MOD_OFFLINE']; $iflychat_settings['text_lmm'] = $txt['MOD_LOAD_MORE_MESSAGES']; $iflychat_settings['text_nmm'] = $txt['MOD_NO_MORE_MESSAGES']; $iflychat_settings['text_clear_room'] = $txt['MOD_CLEAR_ALL_MESSAGES']; $iflychat_settings['msg_p'] = $txt['MOD_TYPE_AND_PRESS_ENTER']; $iflychat_settings['text_user_list_reconnect'] = $txt['MOD_USER_LIST_RECONNECT']; $iflychat_settings['text_user_list_loading'] = $txt['MOD_USER_LIST_LOADING']; //if chat admin show admin options if (iflychat_check_chat_admin()) { $iflychat_settings['text_ban'] = $txt['MOD_BAN']; $iflychat_settings['text_ban_ip'] = $txt['MOD_BAN_IP']; $iflychat_settings['text_kick'] = $txt['MOD_KICK']; $iflychat_settings['text_ban_window_title'] = $txt['MOD_BANNED_USERS']; $iflychat_settings['text_ban_window_default'] = $txt['MOD_NO_BAN']; $iflychat_settings['text_ban_window_loading'] = $txt['MOD_LOADING']; $iflychat_settings['text_manage_rooms'] = $txt['MOD_MANAGE_ROOMS']; $iflychat_settings['text_unban'] = $txt['MOD_UNBAN']; $iflychat_settings['text_unban_ip'] = $txt['MOD_UNBAN_IP']; } //if support chat, show support options if ($modSettings['iflychat_show_admin_list'] == '1') { $iflychat_settings['text_support_chat_init_label'] = $modSettings['iflychat_support_chat_init_label']; $iflychat_settings['text_support_chat_box_header'] = $modSettings['iflychat_support_chat_box_header']; $iflychat_settings['text_support_chat_box_company_name'] = $modSettings['iflychat_support_chat_box_company_name']; $iflychat_settings['text_support_chat_box_company_tagline'] = $modSettings['text_support_chat_box_company_tagline']; $iflychat_settings['text_support_chat_auto_greet_enable'] = $modSettings['text_support_chat_auto_greet_enable']; $iflychat_settings['text_support_chat_auto_greet_message'] = $modSettings['text_support_chat_auto_greet_message']; $iflychat_settings['text_support_chat_auto_greet_time'] = $modSettings['text_support_chat_auto_greet_time']; $iflychat_settings['text_support_chat_offline_message_label'] = $modSettings['text_support_chat_offline_message_label']; $iflychat_settings['text_support_chat_offline_message_contact'] = $modSettings['text_support_chat_offline_message_contact']; $iflychat_settings['text_support_chat_offline_message_send_button'] = $modSettings['text_support_chat_offline_message_send_button']; $iflychat_settings['text_support_chat_offline_message_desc'] = $modSettings['text_support_chat_offline_message_desc']; $iflychat_settings['text_support_chat_init_label_off'] = $modSettings['text_support_chat_init_label_off']; } $iflychat_settings['open_chatlist_default'] = $modSettings['iflychat_minimize_chat_user_list'] == 2 ? '1' : '2'; $iflychat_settings['useStopWordList'] = $modSettings['iflychat_use_stop_word_list']; $iflychat_settings['blockHL'] = $modSettings['iflychat_stop_links']; $iflychat_settings['allowAnonHL'] = $modSettings['iflychat_allow_anon_links']; $iflychat_settings['renderImageInline'] = $modSettings['iflychat_allow_render_images'] == '1' ? '1' : '2'; $iflychat_settings['searchBar'] = $modSettings['iflychat_enable_search_bar'] == '1' ? '1' : '2'; $iflychat_settings['text_search_bar'] = $txt['MOD_TYPE_HERE_TO_SEARCH']; //$iflychat_protocol = isset($_SERVER["HTTPS"]) ? 'https://' : 'http://'; $iflychat_settings['geturl'] = $scripturl; $iflychat_settings['soffurl'] = $scripturl; $iflychat_settings['changeurl'] = $scripturl; //code for rendering $output = "Drupal={};Drupal.settings={};Drupal.settings.drupalchat=" . json_encode($iflychat_settings, TRUE) . ";"; exit($output); }
/** * @param $session bool - pokud ma overovat i SESSION, nebo jen https * Funkce presmeruje admina na https, a overi jestli jeho session je validni */ function adminLoginValidate($session = true) { global $conf; if ((!isset($_SESSION["admin"]["id"]) || !isset($_SESSION["admin"]["login"])) && $session) { header("location: " . getUrl("adminLogin", array(), true)); } if (isSSL() != true && $conf["httpsAdminEnable"] == true) { header("location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); } }
$tempRegVeh = $reguserinfo['vehicleKey']; $tempRegQuery = "SELECT * FROM vehicles WHERE vehicleID='{$tempRegVeh}'"; $tempvehcheck = mysql_query($tempRegQuery); if ($tempvehinfo = mysql_fetch_array($tempvehcheck)) { echo "<td>" . $tempvehinfo['year'] . " " . $tempvehinfo['make'] . " " . $tempvehinfo['model'] . "</td>"; echo "<td>" . $tempvehinfo['scca_class'] . "</td>"; } echo "</tr>"; } } echo "</table>"; } } } } } } ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// ////////////BEGIN SCRIPT EXECUTION BELOW////////////////////// ////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// if (!isSSL()) { header("Location: logout.php"); } else { validateSession(); displayRegisteredEntrants(); echoFrameFooter(); die; // attempt to guard against any code insertion at the end of the file }
/** * Create the user session. * * Old sessions are flushed based on the configuration value for the cookie * lifetime. If an existing session, then the last access time is updated. * If a new session, a session id is generated and a record is created in * the #__sessions table. * * @access private * @param string The sessions name. * @return object JSession on success. May call exit() on database error. * @since 1.5 */ function &_createSession($name) { $options = array(); $options['name'] = $name; $options['force_ssl'] = isSSL(); $session =& JFactory::getSession($options); jimport('joomla.database.table'); $storage =& JTable::getInstance('session'); $storage->purge($session->getExpire()); // Session exists and is not expired, update time in session table if ($storage->load($session->getId())) { $storage->update(); return $session; } //Session doesn't exist yet, initalise and store it in the session table $session->set('registry', new JRegistry('session')); $session->set('user', new JUser()); if (!$storage->insert($session->getId(), $this->getClientId())) { jexit($storage->getError()); } return $session; }
/** * Checks whether the current URI is using HTTPS * * @access public * @return boolean True if using SSL via HTTPS * @since 1.5 */ function isSSL() { if ($this->getScheme() == 'https') { return true; } if (isSSL()) { return true; } return false; }