private static function initSite() { if (self::$siteList === false) { $host = self::getHostName(); $path = self::getFullPathAsString(); $current = array(); $default = array(); global $g_siteList; self::$siteList = $g_siteList; unset($g_siteList); foreach (self::$siteList as $websiteID => $website) { $lngList = $website["Language"]; $j = 0; foreach ($lngList as $lngCode => $lngDetails) { if (!isset($lngDetails['Domain'])) { send404(); } if (isset($lngDetails['Domain'][$host])) { $langDir = $lngDetails['Domain'][$host]['LangDir']; $len = strlen($website['WebDir']); if (is_array($website['ModuleList'])) { foreach ($website['ModuleList'] as $k => $module) { $website['ModuleList'][$k] = ucfirst(mb_strtolower($module)); } } else { $website['ModuleList'] = array(); } if (substr($path, 0, $len) == $website['WebDir']) { if (isset($lngDetails['Default']) && $lngDetails['Default'] == true || $j == 0) { $default['WebsiteID'] = $websiteID; $default['Folder'] = $website["Folder"]; $default['Name'] = $website["Name"]; $default['ProjectPath'] = $website['WebDir']; $default['LangCode'] = $lngDetails['Folder']; $default['LangDir'] = $langDir; $default['LanguageList'] = $lngList; $default['ModuleList'] = $website["ModuleList"]; } $len = strlen($website['WebDir'] . $langDir); if (substr($path, 0, $len) == $website['WebDir'] . $langDir) { $current['WebsiteID'] = $websiteID; $current['Folder'] = $website["Folder"]; $current['Name'] = $website["Name"]; $current['ProjectPath'] = $website['WebDir']; $current['LangCode'] = $lngDetails['Folder']; $current['LangDir'] = $langDir; $current['LanguageList'] = $lngList; $current['ModuleList'] = $website["ModuleList"]; if ($langDir != '') { break 2; } } } } $j++; } } if (count($current) == 0 && count($default) > 0) { $current = $default; } if (count($current) > 0) { define("BASE_PATH", $current['ProjectPath']); define("HTTP_HOST", 'http://' . $host . BASE_PATH); define("URL_PREFIX", BASE_PATH . $current['LangDir']); define("WEBSITE_ID", (int) $current['WebsiteID']); define("WEBSITE_FOLDER", $current['Folder']); define("WEBSITE_NAME", $current['Name']); define("LANG", $current['LangCode']); $current['DefaultModule'] = array_shift($current['ModuleList']); self::$currentSite = $current; $lngList = array(); foreach ($current['LanguageList'] as $k => $v) { if (isset($v['Domain'][$host])) { $domainInfo = $v['Domain'][$host]; } else { $domainInfo = array_shift($v['Domain']); } unset($v['Domain']); $lngList[$k] = array_merge($v, $domainInfo); } Language::setLanguageList($lngList); } else { send404(); } self::$lngFL = $current['LangCode']; } }
function maxArg($num) { $tree = explode("/", @$_GET['path']); $tree = array_filter($tree); if (count($tree) > $num) { send404(); } }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/init.php'; ensureLogin(); if (!isset($_GET['name'])) { send404('Photo not found'); } header('Pragma: private'); header('Cache-Control: private, max-age=86400'); header('Expires: ' . gmdate('r', time() + 86400)); header('Content-Type: image/png'); $size = ''; if (isset($_GET['size'])) { $size = filter_var($_GET['size'], FILTER_SANITIZE_STRING); } $size == 'sml' ? $size_name = '_sml' : ($size_name = ''); $size == 'med' ? $size_name = '_med' : ($size_name = ''); $filter_name = preg_replace("/[^0-9a-zA-Z_]/", "", filter_var($_GET['name'], FILTER_SANITIZE_STRING)); $default = $_SERVER['DOCUMENT_ROOT'] . '/images/generic_avatar.png'; $path = $_SERVER['DOCUMENT_ROOT'] . '/../var/photos/' . $filter_name . $size_name . '.png'; $getfile = $filter_name == null || !is_readable($path) ? $default : $path; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($getfile)) { header('Last-Modified: ' . gmdate(DATE_RFC1123, filemtime($getfile)), true, 304); exit; } header('Last-Modified: ' . gmdate(DATE_RFC1123, filemtime($getfile))); readfile($getfile);
$found = check_number($array_number[0], $array_number[1]); } } # Check advanced mapping if (!$found) { $array_number = transform_mapping($number_original, $array_temp['Dialplan'], $array_config['Numbers'], '2'); if ($array_number[0] != $number_original) { $found = check_number($array_number[0], $array_number[1]); } } # Remove external prefix if (!$found) { $number_transformed = remove_prefix($number_original, $array_temp['Dialplan'], 'external'); if ($number_transformed != $number_original) { $found = check_number($number_transformed); } } # Remove international prefix if (!$found) { $number_transformed = remove_prefix($number_original, $array_temp['Dialplan'], 'international'); if ($number_transformed != $number_original) { $found = check_number($number_transformed); } } # No number if (!$found) { # Send a 404 send404(); } # Clean exit exit;
/** * Existuje soubor? * @param string $file * @param bool $endScript * @return boolean */ function existsFile($file, $endScript = true) { if (is_file($file)) { return true; } if ($endScript) { send404(); } return false; }