function recode_html_vers_latin1($s0) { // retourne un nom recode $s = ""; if (is_string($s0) && preg("/&/", $s0)) { // ����� // ëçöùñ $s0 = preg_replace("/é/", "�", $s0); $s0 = preg_replace("/è/", "�", $s0); $s0 = preg_replace("/ê/", "�", $s0); $s0 = preg_replace("/ë/", "�", $s0); $s0 = preg_replace("/ï/", "�", $s0); $s0 = preg_replace("/î/", "�", $s0); $s0 = preg_replace("/à/", "�", $s0); $s0 = preg_replace("/â/", "�", $s0); $s0 = preg_replace("/ô/", "�", $s0); $s0 = preg_replace("/&oulm;/", "�", $s0); $s0 = preg_replace("/â/", "�", $s0); $s0 = preg_replace("/ç/", "�", $s0); $s0 = preg_replace("/ù/", "�", $s0); $s0 = preg_replace("/ñ/", "�", $s0); $s0 = preg_replace("/°/", "�", $s0); $s0 = preg_replace("/œ/", "�", $s0); $s0 = preg_replace("/Ê/", "�", $s0); } return $s0; }
function xx($id = '') { $file = file_get_contents("http://www.xx.com/?id=" . $id); //静态的JS和CSS不考虑 $img = '/<img.*?src=[\'\\" ]?(.+?)[\'\\" ]+.*?[\\/|>]+/is'; $imgs = preg($img, $file, 'all'); if ($imgs) { $date = date("Ymd"); if (!file_exists("./img/" . $date)) { @mkdir("./img/" . $date . "/"); //简单处理,放在同一文件夹即可 } $path = "/img/" . $date; foreach ($imgs[1] as $key => $val) { //放在统一的文件夹里面就可以了 //$name = basename($val); $name = pathinfo($val); $name = $name['basename']; $filepath = $path . "/" . $name; //echo PHPSHOW.'__'.$filepath."\r\n"; if ($val) { if (!stristr($val, 'http')) { $val = "http://www.xx.com" . $val; } $tmp = file_get_contents($val); //实际使用curl更好 file_put_contents(PHPSHOW . $filepath, $tmp); $file = str_replace($val, $filepath, $file); } } } $file = str_replace('</body>', $GLOBALS['frame_test'] . '</body>', $file); file_put_contents(PHPSHOW . "/xb{$id}.html", $file); }
function validate($value, &$error_message) { if (preg('/^[0-9]{4}[A-Z]{2}/', $value)) { // Nederlandse postcode notatie return true; } else { $error_message = 'Invalid postalcode'; return false; } }
function cut_preg($str, $start, $end, $preg) { $title_str = cut($str, $start, $end); if (!empty($title_str)) { $title_arr = preg($title_str, $preg); $title = empty($title_arr[1]) ? '' : strip_tags($title_arr[1]); return $title; } else { return false; } }
public function getFromCW($cw, $bypassSqlInjectionDetection = '') { if (preg('/DELETE/', $cw) || preg('/UPDATE/', $cw) || preg('/SELECT/', $cw) || preg('/GRANT/', $cw)) { return caEnvironnement::addException('Tentative de sql injection détectée'); } $requete = caObjetBase::getRequete(caObjetBasePeer::DATABASE_ID, caObjetBasePeer::TABLE_NAME); $res = $requete->getGen($cw, 'tab'); $tabReturn = array(); foreach ($res as $datarow) { $tabReturn[] = $this->fill($datarow); } return $tabReturn; }
function lib_group(&$ctag, &$refObj) { global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl; //属性处理 $attlist = "row|6,orderby|threads,titlelen|30"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); if (!$dsql->IsTable("{$cfg_dbprefix}groups")) { return '没安装圈子模块'; } if (!preg("#\\/\$#", $cfg_cmsurl)) { $cfg_group_url = $cfg_cmsurl . '/group'; } else { $cfg_group_url = $cfg_cmsurl . 'group'; } $innertext = $ctag->GetInnerText(); if (trim($innertext) == '') { $innertext = GetSysTemplets("groups.htm"); } $list = ''; $dsql->SetQuery("SELECT groupimg,groupid,groupname FROM `#@__groups` WHERE ishidden=0 ORDER BY {$orderby} DESC LIMIT 0,{$row}"); $dsql->Execute(); $ctp = new DedeTagParse(); $ctp->SetNameSpace('field', '[', ']'); while ($rs = $dsql->GetArray()) { $ctp->LoadSource($innertext); $rs['groupname'] = cn_substr($rs['groupname'], $titlelen); $rs['url'] = $cfg_group_url . "/group.php?id={$rs['groupid']}"; $rs['icon'] = $rs['groupimg']; foreach ($ctp->CTags as $tagid => $ctag) { if (!empty($rs[strtolower($ctag->GetName())])) { $ctp->Assign($tagid, $rs[$ctag->GetName()]); } } $list .= $ctp->GetResult(); } return $list; }
<?php $filename = $_GET['filename'] ? trim($_GET['filename']) : ''; if (!$filename) { die('filename is null!'); } $row = 1; if (($handle = fopen($filename . ".php", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { preg($data[0]); } fclose($handle); } function preg($string) { global $array; $_array = explode('.', $string); $extension = $_array['1']; $length = strlen($_array[0]); $numOnly = '/^[0-9]+$/'; $stringOnly = '/^[a-zA-Z]+$/'; $mixed = '/^[a-zA-Z0-9-]+/'; if (preg_match($numOnly, $_array[0])) { //纯数字 $array[$extension][$length]['num'][] = $string; } elseif (preg_match($stringOnly, $_array[0])) { //纯字母 // $array[$extension][$length]['string'][] = $string; } elseif (preg_match($mixed, $_array[0])) { //字母数字混合 // $array[$extension][$length]['mix'][] = $string;
include INSTALL_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'sql.tpl.php'; break; } extract($_POST); // check database info empty($dbhost) && ($error_arr['dbhost'] = L('dbhost_cannot_be_null')); empty($dbname) && ($error_arr['dbname'] = L('dbname_cannot_be_null')); empty($dbuser) && ($error_arr['dbuser'] = L('dbaccount_cannot_be_null')); empty($dbpw) && ($error_arr['dbpw'] = L('dbpwd_cannot_be_null')); // check admin account empty($admin_account) && ($error_arr['admin_account'] = L('admin_account_cannot_be_null')); empty($admin_password) && ($error_arr['admin_password'] = L('admin_pwd_cannot_be_null')); (empty($admin_password2) || $admin_password2 != $admin_password) && ($error_arr['admin_password2'] = L('password_different_wrong')); empty($data_type) && ($error_arr['data_type'] = L('select_init_type')); preg($dbname) == false && ($error_arr['dbname'] = L('error_formate')); (strpos($tablepre, '.') !== false || preg($tablepre) == false) && ($error_arr['tablepre'] = L('table_pre_error')); if ($error_arr) { include INSTALL_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'sql.tpl.php'; break; } if (!($link = mysql_connect($dbhost, $dbuser, $dbpw))) { $error_arr['dbpw'] = L('connect_error_login_failed'); $error_arr['dbname'] = L('connect_error_login_failed'); $error_arr['dbuser'] = L('connect_error_login_failed'); include INSTALL_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'sql.tpl.php'; break; } $_SESSION['link'] = mysql_get_server_info(); // 检测数据库是否存在,并提示是否覆盖安装 if (mysql_select_db($dbname, $link) && !$cover_data[0] == 'cover') { $error_arr['cover_data'] = L('cover_db_tips');
} } } } //短视频采集 $short_wrap = preg($single_html, '/<div\\s+class=[\'\\"]v[\'\\"]>\\s*[\\w\\W]*?\\s*<\\/div>\\s*<\\/div>\\s*<\\/div>/six', 2); $short_str = $short_wrap[0]; //var_dump($short_wrap);exit; if (is_array($short_str) && count($short_str) > 0) { foreach ($short_str as $v) { $short_movie = array(); $v_img = preg($v, '/src=\\"(?<image>\\s*[\\w\\W]*?\\s*)\\"/six'); $short_movie['vod_pic'] = $v_img['image']; $v_title = preg($v, '/alt=\\"(?<title>\\s*[\\w\\W]*?\\s*)\\"/six'); $short_movie['vod_title'] = $v_title['title']; $v_url = preg($v, '/href=\\"http\\:\\/\\/www\\.soku\\.com\\/u\\?url\\=(?<url>\\s*[\\w\\W]*?\\s*)\\"/six'); $short_movie['vod_url'] = $v_url[1]; $play_url = $short_movie['vod_url']; if (strstr($play_url, 'v.youku.com')) { $short_movie['vod_site'] = 'youku'; } else { if (strstr($play_url, 'www.tudou.com')) { $short_movie['vod_site'] = 'tudou'; } else { if (strstr($play_url, 'tv.sohu.com')) { $short_movie['vod_site'] = 'sohu'; } else { if (strstr($play_url, 'v.pptv.com')) { $short_movie['vod_site'] = 'pptv'; } else { if (strstr($play_url, 'www.letv.com')) {
/** * Checks if it's a valid token. * * @access private * @param mixed $token The token to check. * @return mixed The checked token or false on failure */ function _match($token) { switch ($token) { case SPREADSHEET_EXCEL_WRITER_ADD: return $token; break; case SPREADSHEET_EXCEL_WRITER_SUB: return $token; break; case SPREADSHEET_EXCEL_WRITER_MUL: return $token; break; case SPREADSHEET_EXCEL_WRITER_DIV: return $token; break; case SPREADSHEET_EXCEL_WRITER_OPEN: return $token; break; case SPREADSHEET_EXCEL_WRITER_CLOSE: return $token; break; case SPREADSHEET_EXCEL_WRITER_COMA: return $token; break; case SPREADSHEET_EXCEL_WRITER_SEMICOLON: return $token; break; case SPREADSHEET_EXCEL_WRITER_GT: if ($this->_lookahead == '=') { // it's a GE token break; } return $token; break; case SPREADSHEET_EXCEL_WRITER_LT: // it's a LE or a NE token if ($this->_lookahead == '=' or $this->_lookahead == '>') { break; } return $token; break; case SPREADSHEET_EXCEL_WRITER_GE: return $token; break; case SPREADSHEET_EXCEL_WRITER_LE: return $token; break; case SPREADSHEET_EXCEL_WRITER_EQ: return $token; break; case SPREADSHEET_EXCEL_WRITER_NE: return $token; break; default: // if it's a reference if (preg_match('/^\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/', $token) and !preg_match("/[0-9]/", $this->_lookahead) and $this->_lookahead != ':' and $this->_lookahead != '.' and $this->_lookahead != '!') { return $token; } elseif (preg_match("/^\\w+(\\:\\w+)?\\![A-Ia-i]?[A-Za-z][0-9]+\$/u", $token) and !preg("/[0-9]/", $this->_lookahead) and $this->_lookahead != ':' and $this->_lookahead != '.') { return $token; } elseif (preg_match("/^'[\\w -]+(\\:[\\w -]+)?'\\![A-Ia-i]?[A-Za-z][0-9]+\$/u", $token) and !preg("/[0-9]/", $this->_lookahead) and $this->_lookahead != ':' and $this->_lookahead != '.') { return $token; } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\$/", $token) and !preg_match("/[0-9]/", $this->_lookahead)) { return $token; } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\\.\\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\$/", $token) and !preg_match("/[0-9]/", $this->_lookahead)) { return $token; } elseif (preg_match("/^\\w+(\\:\\w+)?\\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+\$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) { return $token; } elseif (preg_match("/^'[\\w -]+(\\:[\\w -]+)?'\\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+\$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) { return $token; } elseif (is_numeric($token) and (!is_numeric($token . $this->_lookahead) or $this->_lookahead == '') and $this->_lookahead != '!' and $this->_lookahead != ':') { return $token; } elseif (preg_match("/^\"[^\"]{0,255}\"\$/", $token)) { return $token; } elseif (preg_match("/^[A-Z0-9À-Ü\\.]+\$/i", $token) and $this->_lookahead == "(") { return $token; } return ''; } }
function swBrowserFree() { $agent = $_SERVER['HTTP_USER_AGENT']; // initialize properties $bd['platform'] = "Unknown"; $bd['swBrowserFree'] = "Unknown"; $bd['version'] = "Unknown"; $this->UserAgent = $agent; // find operating system if (preg_match("/win/i", $agent)) { $bd['platform'] = "Windows"; } elseif (preg_match("/mac/i", $agent)) { $bd['platform'] = "MacIntosh"; } elseif (preg_match("/linux/i", $agent)) { $bd['platform'] = "Linux"; } elseif (preg_match("/OS2/i", $agent)) { $bd['platform'] = "OS/2"; } elseif (preg_match("/BeOS/i", $agent)) { $bd['platform'] = "BeOS"; } // test for Opera if (preg_match("/opera/i", $agent)) { $val = stristr($agent, "opera"); if (preg_match("//i", $val)) { $val = explode("/", $val); $bd['swBrowserFree'] = $val[0]; $val = explode(" ", $val[1]); $bd['version'] = $val[0]; } else { $val = explode(" ", stristr($val, "opera")); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; } // test for WebTV } elseif (preg_match("/webtv/i", $agent)) { $val = explode("/", stristr($agent, "webtv")); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for MS Internet Explorer version 1 } elseif (preg_match("/microsoft internet explorer/i", $agent)) { $bd['swBrowserFree'] = "MSIE"; $bd['version'] = "1.0"; $var = stristr($agent, "/"); if (preg("/308|425|426|474|0b1/", $var)) { $bd['version'] = "1.5"; } // test for NetPositive } elseif (preg_match("/NetPositive/i", $agent)) { $val = explode("/", stristr($agent, "NetPositive")); $bd['platform'] = "BeOS"; $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for MS Internet Explorer } elseif (preg_match("/msie/i", $agent) && !preg_match("/opera/i", $agent)) { $val = explode(" ", stristr($agent, "msie")); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for MS Pocket Internet Explorer } elseif (preg_match("/mspie/i", $agent) || preg_match('/pocket/i', $agent)) { $val = explode(" ", stristr($agent, "mspie")); $bd['swBrowserFree'] = "MSPIE"; $bd['platform'] = "WindowsCE"; if (preg_match("/mspie/i", $agent)) { $bd['version'] = $val[1]; } else { $val = explode("/", $agent); $bd['version'] = $val[1]; } // test for Galeon } elseif (preg_match("/galeon/i", $agent)) { $val = explode(" ", stristr($agent, "galeon")); $val = explode("/", $val[0]); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for Konqueror } elseif (preg_match("/Konqueror/i", $agent)) { $val = explode(" ", stristr($agent, "Konqueror")); $val = explode("/", $val[0]); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for iCab } elseif (preg_match("/icab/i", $agent)) { $val = explode(" ", stristr($agent, "icab")); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for OmniWeb } elseif (preg_match("/omniweb/i", $agent)) { $val = explode("/", stristr($agent, "omniweb")); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; // test for Phoenix } elseif (preg_match("/Phoenix/i", $agent)) { $bd['swBrowserFree'] = "Phoenix"; $val = explode("/", stristr($agent, "Phoenix/")); $bd['version'] = $val[1]; // test for Firebird } elseif (preg_match("/firebird/i", $agent)) { $bd['swBrowserFree'] = "Firebird"; $val = stristr($agent, "Firebird"); $val = explode("/", $val); $bd['version'] = $val[1]; // test for Firefox } elseif (preg_match("/Firefox/i", $agent)) { $bd['swBrowserFree'] = "Firefox"; $val = stristr($agent, "Firefox"); $val = explode("/", $val); $bd['version'] = $val[1]; // test for Mozilla Alpha/Beta Versions } elseif (preg_match("/mozilla/i", $agent) && preg_match("/rv:[0-9].[0-9][a-b]/i", $agent) && !preg_match("/netscape/i", $agent)) { $bd['swBrowserFree'] = "Mozilla"; $val = explode(" ", stristr($agent, "rv:")); preg_match("/rv:[0-9].[0-9][a-b]/i", $agent, $val); $bd['version'] = str_replace("rv:", "", $val[0]); // test for Mozilla Stable Versions } elseif (preg_match("/mozilla/i", $agent) && preg_match("/rv:[0-9]\\.[0-9]/i", $agent) && !preg_match("/netscape/i", $agent)) { $bd['swBrowserFree'] = "Mozilla"; $val = explode(" ", stristr($agent, "rv:")); preg_match("/rv:[0-9]\\.[0-9]\\.[0-9]/i", $agent, $val); $bd['version'] = str_replace("rv:", "", $val[0]); // test for Lynx & Amaya } elseif (preg_match("/libwww/i", $agent)) { if (preg_match("/amaya/i", $agent)) { $val = explode("/", stristr($agent, "amaya")); $bd['swBrowserFree'] = "Amaya"; $val = explode(" ", $val[1]); $bd['version'] = $val[0]; } else { $val = explode("/", $agent); $bd['swBrowserFree'] = "Lynx"; $bd['version'] = $val[1]; } // test for Safari } elseif (preg_match("/safari/i", $agent)) { $bd['swBrowserFree'] = "Safari"; $bd['version'] = ""; // remaining two tests are for Netscape } elseif (preg_match("/netscape/i", $agent)) { $val = explode(" ", stristr($agent, "netscape")); $val = explode("/", $val[0]); $bd['swBrowserFree'] = $val[0]; $bd['version'] = $val[1]; } elseif (preg_match("/mozilla/i", $agent) && !preg_match("/rv:[0-9]\\.[0-9]\\.[0-9]/i", $agent)) { $val = explode(" ", stristr($agent, "mozilla")); $val = explode("/", $val[0]); $bd['swBrowserFree'] = "Netscape"; $bd['version'] = $val[1]; } // clean up extraneous garbage that may be in the name $bd['swBrowserFree'] = preg_replace("[^a-z,A-Z]", "", $bd['swBrowserFree']); // clean up extraneous garbage that may be in the version $bd['version'] = preg_replace("[^0-9,.,a-z,A-Z]", "", $bd['version']); // check for AOL if (preg_match("/AOL/i", $agent)) { $var = stristr($agent, "AOL"); $var = explode(" ", $var); $bd['aol'] = preg_replace("[^0-9,.,a-z,A-Z]", "", $var[1]); } // finally assign our properties $this->Name = $bd['swBrowserFree']; $this->Version = $bd['version']; $this->Platform = $bd['platform']; // $this->AOL = $bd['aol']; //echo $this->Name; }
$desc = str_ireplace('显示详情', '', $desc); $instr['剧情简介'] = $desc; //优酷评分 $pinfen = cut($rs, '<div class="rating">', '</div>'); $pinfen = preg($pinfen, '/<em\\s+class=\'num\'>([\\d\\.]*)<\\/em>/six'); $instr['优酷评分'] = empty($pinfen[1]) ? '暂无' : $pinfen[1]; $basicinfo['infos'] = $instr; //采集播放地址 $juji_wrap = preg($rs, '/<ul\\s+class=[\\"\']linkpanel\\s*[\\w\\W]*?\\s*<\\/ul>/six', 2); $juji_str = ''; foreach ($juji_wrap[0] as $val) { $juji_str .= $val; } $juji = preg($juji_str, '/<a\\s+href=[\\"\'](?P<url>\\S+?)[\\"\']\\s*[\\w\\W]*?\\s*>\\s*(?P<benji>[\\w\\W]*?)\\s*<\\/a>/six', 1); //添加预告片 $herald = preg($rs, '/<a\\s+class="btn_herald"\\s+target="\\_blank"\\s+href=[\\"\'](?P<url>\\S+?)[\\"\']\\s*[\\w\\W]*?\\s*>\\s*(?P<benji>[\\w\\W]*?)\\s*<\\/a>/six'); if (!empty($herald)) { $juji[] = $herald; } if (!empty($juji)) { //倒转array $movies_play = array(); foreach ($juji as $k => $v) { if (strstr($v['url'], 'http')) { unset($v[0]); unset($v[1]); unset($v[2]); $play_url = $v['url']; if (strstr($play_url, 'youku.com')) { $v['site'] = 'youku'; } else {
function _discoverJFLanguage() { static $discovered; if (isset($discovered) && $discovered) { return; } $discovered = true; $registry = JFactory::getConfig(); // Find language without loading strings $locale = $registry->getValue('config.language'); // Attention - we need to access the site default values // #12943 explains that a user might overwrite the orignial settings based on his own profile $langparams = JComponentHelper::getParams('com_languages'); $defLanguage = $langparams->get("site"); $registry->setValue("config.defaultlang", isset($defLanguage) && $defLanguage != '' ? $defLanguage : $locale); // get params from registry in case function called statically $params = $registry->getValue("jfrouter.params"); $determitLanguage = $params->get('determitLanguage', 1); $newVisitorAction = $params->get('newVisitorAction', 'browser'); $use302redirect = $params->get('use302redirect', 0); $enableCookie = $params->get('enableCookie', 1); // get instance of JoomFishManager to obtain active language list and config values $jfm = JoomFishManager::getInstance(); $client_lang = ''; $lang_known = false; $jfcookie = JRequest::getVar('jfcookie', null, "COOKIE"); if (isset($jfcookie["lang"]) && $jfcookie["lang"] != "") { $client_lang = $jfcookie["lang"]; $lang_known = true; } $uri = JURI::getInstance(); if ($requestlang = JRequest::getVar('lang', null, "REQUEST")) { if ($requestlang != '') { $client_lang = $requestlang; $lang_known = true; } } // no language choosen - Test plugin e.g. IP lookup tool if (!$lang_known) { // setup Joomfish pluginds $dispatcher = JDispatcher::getInstance(); $iplang = ""; JPluginHelper::importPlugin('joomfish'); $dispatcher->trigger('onDiscoverLanguage', array(&$iplang)); if ($iplang != "") { $client_lang = $iplang; $lang_known = true; } } if (!$lang_known && $determitLanguage && key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { switch ($newVisitorAction) { // usesing the first defined Joom!Fish language case 'joomfish': $activeLanguages = $jfm->getActiveLanguages(); reset($activeLanguages); $first = key($activeLanguages); $client_lang = $activeLanguages[$first]->getLanguageCode(); break; case 'site': // We accept that this default locale might be overwritten by user settings! $jfLang = TableJFLanguage::createByJoomla($locale); $client_lang = $jfLang->getLanguageCode(); break; // no language chooses - assume from browser configuration // no language chooses - assume from browser configuration case 'browser': default: // language negotiation by Kochin Chang, June 16, 2004 // retrieve active languages from database $active_iso = array(); $active_isocountry = array(); $active_code = array(); $activeLanguages = $jfm->getActiveLanguages(); if (count($activeLanguages) == 0) { return; } foreach ($activeLanguages as $alang) { $active_iso[] = $alang->iso; if (preg_match('/[_-]/i', $alang->iso)) { $isocountry = preg_split('[_-]', $alang->iso); $active_isocountry[] = $isocountry[0]; } $active_code[] = $alang->shortcode; } // figure out which language to use - browser languages are based on ISO codes $browserLang = explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]); foreach ($browserLang as $blang) { if (in_array($blang, $active_iso)) { $client_lang = $blang; break; } $shortLang = substr($blang, 0, 2); if (in_array($shortLang, $active_isocountry)) { $client_lang = $shortLang; break; } // compare with code if (in_array($shortLang, $active_code)) { $client_lang = $shortLang; break; } } break; } } // get the name of the language file for joomla $jfLang = TableJFLanguage::createByShortcode($client_lang, false); if ($jfLang === null && $client_lang != "") { $jfLang = TableJFLanguage::createByISO($client_lang, false); } else { if ($jfLang === null) { $jfLang = TableJFLanguage::createByJoomla($locale); } } if (!$lang_known && $use302redirect) { // using a 302 redirect means that we do not change the language on the fly the first time, but with a clean reload of the page $href = "index.php"; $hrefVars = ''; $queryString = JRequest::getVar('QUERY_STRING', null, "SERVER"); if (!empty($queryString)) { $vars = explode("&", $queryString); if (count($vars) > 0 && $queryString) { foreach ($vars as $var) { if (preg('/=/i', $var)) { list($key, $value) = explode("=", $var); if ($key != "lang") { if ($hrefVars != "") { $hrefVars .= "&"; } // ignore mosmsg to ensure it is visible in frontend if ($key != 'mosmsg') { $hrefVars .= "{$key}={$value}"; } } } } } } // Add the existing variables if ($hrefVars != "") { $href .= '?' . $hrefVars; } if ($jfLang->getLanguageCode() != null) { $ulang = 'lang=' . $jfLang->getLanguageCode(); } else { // it's important that we add at least the basic parameter - as of the sef is adding the actual otherwise! $ulang = 'lang='; } // if there are other vars we need to add a & otherwiese ? if ($hrefVars == '') { $href .= '?' . $ulang; } else { $href .= '&' . $ulang; } $registry->setValue("config.multilingual_support", true); global $mainframe; $mainframe->setUserState('application.lang', $jfLang->code); $registry->setValue("config.jflang", $jfLang->code); $registry->setValue("config.lang_site", $jfLang->code); $registry->setValue("config.language", $jfLang->code); $registry->setValue("joomfish.language", $jfLang); $href = JRoute::_($href, false); header('HTTP/1.1 303 See Other'); header("Location: " . $href); exit; } if (isset($jfLang) && $jfLang->code != "" && ($jfLang->active || $jfm->getCfg("frontEndPreview"))) { $locale = $jfLang->code; } else { $jfLang = TableJFLanguage::createByJoomla($locale); if (!$jfLang->active) { ?> <div style="background-color: #c00; color: #fff"> <p style="font-size: 1.5em; font-weight: bold; padding: 10px 0px 10px 0px; text-align: center; font-family: Arial, Helvetica, sans-serif;"> Joom!Fish config error: Default language is inactive!<br /> <br /> Please check configuration, try to use first active language</p> </div> <?php $activeLanguages = $jfm->getActiveLanguages(); if (count($activeLanguages) > 0) { $jfLang = $activeLanguages[0]; $locale = $jfLang->code; } else { // No active language defined - using system default is only alternative! } } $client_lang = $jfLang->shortcode != '' ? $jfLang->shortcode : $jfLang->iso; } // TODO set the cookie domain so that it works for all subdomains if ($enableCookie) { setcookie("lang", "", time() - 1800, "/"); setcookie("jfcookie", "", time() - 1800, "/"); setcookie("jfcookie[lang]", $client_lang, time() + 24 * 3600, '/'); } if (defined("_JLEGACY")) { $GLOBALS['iso_client_lang'] = $client_lang; $GLOBALS['mosConfig_lang'] = $jfLang->code; } $registry->setValue("config.multilingual_support", true); global $mainframe; $mainframe->setUserState('application.lang', $jfLang->code); $registry->setValue("config.jflang", $jfLang->code); $registry->setValue("config.lang_site", $jfLang->code); $registry->setValue("config.language", $jfLang->code); $registry->setValue("joomfish.language", $jfLang); // Force factory static instance to be updated if necessary $lang =& JFactory::getLanguage(); if ($jfLang->code != $lang->getTag()) { // Must not assign by reference in order to overwrite the existing reference to the static instance of the language $lang = JFactory::_createLanguage(); } // no need to set locale for this ISO code its done by JLanguage // overwrite with the valued from $jfLang $jfparams = JComponentHelper::getParams("com_joomfish"); $overwriteGlobalConfig = $jfparams->get('overwriteGlobalConfig', 0); if ($overwriteGlobalConfig) { // We should overwrite additional global variables based on the language parameter configuration $params = new JParameter($jfLang->params); $paramarray = $params->toArray(); foreach ($paramarray as $key => $val) { $registry->setValue("config." . $key, $val); if (defined("_JLEGACY")) { $name = 'mosConfig_' . $key; $GLOBALS[$name] = $val; } } } }
public function validateObservation() { global $loggedUser, $objUtil, $objObservation, $objObserver, $maxFileSize, $entryMessage, $objPresentations, $inIndex, $instDir, $objSession, $objAccomplishments; if (!$loggedUser) { throw new Exception(LangException002b); } elseif ($objUtil->checkSessionKey('addObs', 0) != $objUtil->checkPostKey('timestamp', -1)) { $_GET['indexAction'] = "default_action"; $_GET['dalm'] = 'D'; // $_GET['observation']=$current_observation; } elseif (!$_POST['day'] || !$_POST['month'] || !$_POST['year'] || $_POST['site'] == "1" || !$_POST['instrument'] || !$_POST['description']) { if ($objUtil->checkPostKey('limit')) { if (preg_match('/([0-9]{1})[.,]{0,1}([0-9]{0,1})/', $_POST['limit'], $matches)) { // limiting magnitude like X.X or X,X with X a number between 0 and 9 $_POST['limit'] = $matches[1] . "." . ($matches[2] ? $matches[2] : "0"); } else { $_POST['limit'] = 0; } } else { if ($objUtil->checkPostKey('sqm')) { if (preg_match('/([0-9]{1})([0-9]{1})[.,]{0,1}([0-9]{0,1})/', $_POST['sqm'], $matches)) { // sqm value $_POST['sqm'] = $matches[1] . $matches[2] . "." . ($matches[3] ? $matches[3] : "0"); } else { $_POST['sqm'] = -1; } } else { $_POST['limit'] = 0; $_POST['sqm'] = -1; } } $entryMessage .= LangValidateObservationMessage1; $_GET['indexAction'] = 'add_observation'; } else { $time = -9999; if (strlen($_POST['hours'])) { if (isset($_POST['minutes'])) { $time = $_POST['hours'] * 100 + $_POST['minutes']; } else { $time = $_POST['hours'] * 100; } } if ($_FILES['drawing']['size'] > $maxFileSize) { $entryMessage .= LangValidateObservationMessage6; $_GET['indexAction'] = 'add_observation'; } elseif (!is_numeric($_POST['month']) || !is_numeric($_POST['day']) || !is_numeric($_POST['year']) || !checkdate($_POST['month'], $_POST['day'], $_POST['year']) || sprintf("%04d", $_POST['year']) . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day']) < '19500000' || sprintf("%04d", $_POST['year']) . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day']) > date('Ymd', strtotime('+1 day'))) { $entryMessage .= LangValidateObservationMessage2; $_GET['indexAction'] = 'add_observation'; } elseif (($date = $_POST['year'] . sprintf("%02d", $_POST['month']) . sprintf("%02d", $_POST['day'])) > date('Ymd')) { $entryMessage .= LangValidateObservationMessage3; $_GET['indexAction'] = 'add_observation'; } elseif ($time > -9999 && (!is_numeric($_POST['hours']) || !is_numeric($_POST['minutes']) || $_POST['hours'] < 0 || $_POST['hours'] > 23 || $_POST['minutes'] < 0 || $_POST['minutes'] > 59)) { $entryMessage .= LangValidateObservationMessage4; $_GET['indexAction'] = 'add_observation'; } else { if ($objUtil->checkPostKey('limit')) { if (preg_match('/([0-9]{1})[.,]{0,1}([0-9]{0,1})/', $_POST['limit'], $matches)) { // limiting magnitude like X.X or X,X with X a number between 0 and 9 $_POST['limit'] = $matches[1] . "." . ($matches[2] ? $matches[2] : "0"); } else { // clear current magnitude limit $_POST['limit'] = ""; } } if ($_POST['observationid']) { $current_observation = $_POST['observationid']; if (!$objUtil->checkAdminOrUserID($objObservation->getDsObservationProperty($current_observation, 'observerid'))) { $indexAction = ''; return; } else { $objObservation->setDsObservationProperty($current_observation, 'instrumentid', $_POST['instrument']); $objObservation->setDsObservationProperty($current_observation, 'locationid', $_POST['site']); $objObservation->setDsObservationProperty($current_observation, 'date', $date); $objObservation->setDsObservationProperty($current_observation, 'time', $time); $objObservation->setDsObservationProperty($current_observation, 'description', nl2br($_POST['description'])); $objObservation->setDsObservationProperty($current_observation, 'seeing', $_POST['seeing']); $objObservation->setDsObservationProperty($current_observation, 'limmag', $objUtil->checkPostKey('limit', 0)); $objObservation->setDsObservationProperty($current_observation, 'visibility', $objUtil->checkPostKey('visibility')); $objObservation->setDsObservationProperty($current_observation, 'language', $_POST['description_language']); } } else { $current_observation = $objObservation->addDSObservation($_POST['object'], $loggedUser, $_POST['instrument'], $_POST['site'], $date, $time, nl2br($_POST['description']), $_POST['seeing'], $_POST['limit'], $objUtil->checkPostKey('visibility'), $_POST['description_language']); } $_SESSION['addObs'] = ''; $_SESSION['Qobs'] = array(); $_SESSION['QobsParams'] = array(); if ($objUtil->checkPostKey('sqm')) { if (preg_match('/([0-9]{1})([0-9]{0,1})[.,]{0,1}([0-9]{0,1})/', $_POST['sqm'], $matches)) { // sqm value $_POST['sqm'] = $matches[1] . $matches[2] . "." . ($matches[3] ? $matches[3] : "0"); } else { $_POST['sqm'] = ""; } } // clear current magnitude limit if ($objUtil->checkPostKey('largeDiam')) { if (preg_match('/([0-9]+)[.,]{0,1}([0-9]{0,1})/', $_POST['largeDiam'], $matches)) { // large diameter $_POST['largeDiam'] = ($matches[1] ? $matches[1] : "0") . "." . ($matches[2] ? $matches[2] : "0"); } else { // clear current large diameter $_POST['largeDiam'] = ""; } } if ($objUtil->checkPostKey('smallDiam')) { if (preg('/([0-9]+)[.,]{0,1}([0-9]{0,1})/', $_POST['smallDiam'], $matches)) { // large diameter $_POST['smallDiam'] = ($matches[1] ? $matches[1] : "0") . "." . ($matches[2] ? $matches[2] : "0"); } else { // clear current large diameter $_POST['smallDiam'] = ""; } } if ($_POST['smallDiam'] > $_POST['largeDiam']) { $tmp = $_POST['largeDiam']; $_POST['largeDiam'] = $_POST['smallDiam']; $_POST['smallDiam'] = $tmp; } if ($objUtil->checkPostKey('size_units') == "min") { $_POST['smallDiam'] = $_POST['smallDiam'] * 60.0; $_POST['largeDiam'] = $_POST['largeDiam'] * 60.0; } if ($_POST['sqm']) { $objObservation->setDsObservationProperty($current_observation, 'SQM', preg_replace("/,/", ".", $objUtil->checkPostKey('sqm', -1))); } if ($_POST['smallDiam']) { $objObservation->setDsObservationProperty($current_observation, 'smallDiameter', $_POST['smallDiam']); } if ($_POST['largeDiam']) { $objObservation->setDsObservationProperty($current_observation, 'largeDiameter', $_POST['largeDiam']); } if (array_key_exists('stellarextended', $_POST) && $_POST['stellarextended'] == "stellar") { $objObservation->setDsObservationProperty($current_observation, 'stellar', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'stellar', -1); } if (array_key_exists('stellarextended', $_POST) && $_POST['stellarextended'] == "extended") { $objObservation->setDsObservationProperty($current_observation, 'extended', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'extended', -1); } if (array_key_exists('resolved', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'resolved', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'resolved', -1); } if (array_key_exists('mottled', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'mottled', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'mottled', -1); } if (array_key_exists('unusualShape', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'unusualShape', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'unusualShape', -1); } if (array_key_exists('partlyUnresolved', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'partlyUnresolved', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'partlyUnresolved', -1); } if (array_key_exists('colorContrasts', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'colorContrasts', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'colorContrasts', -1); } if (array_key_exists('equalBrightness', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'equalBrightness', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'equalBrightness', -1); } if (array_key_exists('niceField', $_POST)) { $objObservation->setDsObservationProperty($current_observation, 'niceField', 1); } else { $objObservation->setDsObservationProperty($current_observation, 'niceField', -1); } if ($_POST['filter']) { $objObservation->setDsObservationProperty($current_observation, 'filterid', $_POST['filter']); } if ($_POST['lens']) { $objObservation->setDsObservationProperty($current_observation, 'lensid', $_POST['lens']); } if ($_POST['eyepiece']) { $objObservation->setDsObservationProperty($current_observation, 'eyepieceid', $_POST['eyepiece']); } if ($_POST['magnification']) { $objObservation->setDsObservationProperty($current_observation, 'magnification', $_POST['magnification']); } if (!$objObserver->getObserverProperty($loggedUser, 'UT')) { $objObservation->setLocalDateAndTime($current_observation, $date, $time); } $objObservation->setDsObservationProperty($current_observation, 'clusterType', $objUtil->checkPostKey('clusterType')); $objObservation->setDsObservationProperty($current_observation, 'component1', $objUtil->checkPostKey('component1', -1)); $objObservation->setDsObservationProperty($current_observation, 'component2', $objUtil->checkPostKey('component2', -1)); if ($_FILES['drawing']['tmp_name'] != "") { $upload_dir = $instDir . 'deepsky/drawings'; $dir = opendir($upload_dir); $original_image = $_FILES['drawing']['tmp_name']; $destination_image = $upload_dir . "/" . $current_observation . "_resized.jpg"; require_once $instDir . "common/control/resize.php"; // resize code $new_image = image_createThumb($original_image, $destination_image, 490, 490, 100); move_uploaded_file($_FILES['drawing']['tmp_name'], $upload_dir . "/" . $current_observation . ".jpg"); $objObservation->setDsObservationProperty($current_observation, 'hasDrawing', 1); } // Add the observation to all the sessions $objSession->addObservationToSessions($current_observation); // Recalculate the accomplishments $objAccomplishments->recalculateDeepsky($loggedUser); $_SESSION['newObsYear'] = $_POST['year']; // save current details for faster submission of multiple observations $_SESSION['newObsMonth'] = $_POST['month']; $_SESSION['newObsDay'] = $_POST['day']; $_SESSION['newObsInstrument'] = $_POST['instrument']; $_SESSION['newObsLocation'] = $_POST['site']; $_SESSION['newObsLimit'] = $_POST['limit']; $_SESSION['newObsSqm'] = $_POST['sqm']; $_SESSION['newObsSQM'] = $_POST['sqm']; $_SESSION['newObsSeeing'] = $_POST['seeing']; $_SESSION['newObsLanguage'] = $_POST['description_language']; $_SESSION['newObsSavedata'] = "yes"; $_GET['indexAction'] = "detail_observation"; $_GET['dalm'] = 'D'; $_GET['observation'] = $current_observation; } } }
/** * takes values from preg_replace in _intparse and determines the replace string * * @access private * @return string replace values */ function doDebugParse() { $valid_tags = array('var', 'loop', 'if', 'elseif', 'else', 'unless', 'endloop', 'endif', 'endunless', 'include', 'phpinclude', 'comment', 'endcomment'); foreach ($this->_debugalltags as $v) { $lasttag = $this->_debugtags[count($this->_debugtags) - 1]; $tag = $v['tag']; $escape = $v['escape']; $format = $v['format']; $op = $v['op']; $value = $v['value']; $var = trim($v['name']); $openclose = $v['openclose']; $file = $v['file']; $line = $v['line']; $entire_tag = stripslashes($v['entire_tag']); // continue if it's a one=line comment if ($tag == 'comment' && !empty($var)) { continue; } // bad tag if (!in_array($tag, $valid_tags)) { array_push($this->_debugwarningmsgs, array('problem' => 'Warning: Invalid tag', 'detail' => "The following tag is not valid:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); continue; } // bad escape if (!empty($escape)) { if (!isset($this->ESCAPE_TAGS[$escape])) { array_push($this->_debugwarningmsgs, array('problem' => 'Warning: Invalid escape type', 'detail' => "The escape attribute of the following tag is not valid:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } } // bad format if (!empty($format)) { if (!isset($this->FORMAT_TAGS[$format])) { array_push($this->_debugwarningmsgs, array('problem' => 'Warning: Invalid format type', 'detail' => "The format attribute of the following tag is not valid:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } } // bad operator if (!empty($op)) { if (!in_array($op, $this->allowed_if_ops)) { array_push($this->_debugwarningmsgs, array('problem' => 'Warning: Invalid operator type', 'detail' => "The op attribute of the following tag is not supported:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } } if (preg_match("/^([a-z0-9_]+\\.)*([a-z0-9_]+[_a-z0-9]*)\$/i", $var, $matches) && !preg_match('/include|comment/', $tag)) { $var = $matches[2]; } // out of sequences if ($tag == 'else') { if (preg_match('/if|elseif|unless/', $lasttag[0])) { continue; } else { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_else out of sequence', 'detail' => "The following tag is out of sequence:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } } if ($tag == 'elseif') { if (preg('/if|elseif/', $lasttag[0])) { array_pop($this->_debugtags); } else { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_elseif out of sequence', 'detail' => "The following tag is out of sequence:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } } // bad syntax if (!preg_match("/^([a-z_]+[_a-z0-9\\.]*)\$/i", $var) && !preg_match('/include|comment/', $tag) && !empty($var)) { array_push($this->_debugwarningmsgs, array('problem' => 'Warning: Invalid variable name', 'detail' => "The variable name in the following tag does not comply with the correct php syntax:\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } // if it's a closing tag return if (preg_match("/^<\\/|{\\/|<!--\\/\$/s", $openclose) || preg_match("/endloop|endif|endunless|endcomment/", $tag)) { $closetag = 1; if ($tag == 'loop' || $tag == 'endloop') { $tag = 'loop'; } if ($tag == 'if' || $tag == 'endif') { $tag = 'if'; } if ($tag == 'unless' || $tag == 'endunless') { $tag = 'unless'; } if ($tag == 'comment' || $tag == 'endcomment') { $tag = 'comment'; } if ($tag == 'loop') { if ($lasttag[0] == 'unless') { array_push($this->_debugwarningmsgs, array('problem' => 'Notice: tmpl_endloop', 'detail' => "The following end loop tag was found as a closing tag to a tmpl_unless:" . $entire_tag . ", whilst this 'may' not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).", 'location' => 'Line: ' . $line . ', in file: ' . $file)); array_pop($this->_debugtags); } elseif ($lasttag[0] == 'if') { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_endloop', 'detail' => "The following end loop tag was found as a closing tag to a tmpl_if:" . $entire_tag . ", whilst this 'may' not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).", 'location' => 'Line: ' . $line . ', in file: ' . $file)); } elseif ($lasttag[0] != 'comment') { array_pop($this->_debugtags); } } elseif ($tag == 'if') { if ($lasttag[0] == 'unless') { array_push($this->_debugwarningmsgs, array('problem' => 'Notice: tmpl_endif', 'detail' => "The following end if tag was found as a closing tag to a tmpl_unless:" . $entire_tag . ", whilst this may not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).", 'location' => 'Line: ' . $line . ', in file: ' . $file)); array_pop($this->_debugtags); } elseif ($lasttag[0] == 'loop') { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_endif', 'detail' => "The following end if tag was found without it's opening tag (this maybe because of previous errors):\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } elseif ($lasttag[0] != 'comment') { array_pop($this->_debugtags); } } elseif ($tag == 'unless') { if ($lasttag[0] == 'if') { array_push($this->_debugwarningmsgs, array('problem' => 'Notice: tmpl_endunless', 'detail' => "The following end unless tag was found as a closing tag to a tmpl_if:" . $entire_tag . ", whilst this may not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).", 'location' => 'Line: ' . $line . ', in file: ' . $file)); array_pop($this->_debugtags); } elseif ($lasttag[0] == 'loop') { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_endunless', 'detail' => "The following end unless tag was found without it's opening tag (this maybe because of previous errors):\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } elseif ($lasttag[0] != 'comment') { array_pop($this->_debugtags); } } elseif ($tag == 'comment') { if ($lasttag[0] != 'comment') { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_' . $tag, 'detail' => "The following end comment tag was found without it's opening tag (this maybe because of previous errors):\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } else { array_pop($this->_debugtags); } } if (empty($lasttag[0])) { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_' . $tag, 'detail' => "The following end " . $tag . " tag was found without it's opening tag (this maybe because of previous errors):\n" . $entire_tag, 'location' => 'Line: ' . $line . ', in file: ' . $file)); } } if (preg_match('/if|unless|loop|elseif|comment/', $tag) && !$closetag) { array_push($this->_debugtags, array($tag, $file, $line, $entire_tag)); } unset($closetag); } // foreach // check for any unclosed tags foreach ($this->_debugtags as $v) { array_push($this->_debugwarningmsgs, array('problem' => 'Error: tmpl_' . $v[0], 'detail' => "The following tmpl_" . $v[0] . " tag was found without it's closing tag (this maybe because of previous errors):\n" . $v[3], 'location' => 'Line: ' . $v[2] . ', in file: ' . $v[1])); } }
function R301($URL = '?', $m = 1, $mtime = 1) { formatQS($URL); if (in_array(H, ['cli', 'cron'])) { return $URL; } if (!$_POST && !redirLoops($URL)) { return; } if (J9) { FB(debug_backtrace(), 301); } #$bt=end($bt); if (headers_sent()) { die("<META http-equiv='refresh' content='1;URL=" . $x . "'><script>location.href='{$x}#headersSent';</script>"); } if (!preg_match("~/sql2?/~", u) && strlen($URL) > 200 || preg_match("~image/png|base64,|data:~", u)) { return; } #db3("r301urldata:$URL"); if (e('nor301', 1) or $_POST['r301']) { return; } #no f*****g way !! static $nbessais, $lurl; $nbessais++; if ($_ENV['error']) { Db('error:' . $_ENV['error'] . ":" . $URL, 0, 'r301'); R302(); } #en cas erreur sql puis balancement d'une redirection 301 à ne pas enregistrer ! $URL = str_replace('*', 'http://', $URL); if (preg('xzxz', u)) { jx('mail'); return; } gt("R301,{$nbessais}"); if ($nbessais > 3) { db('r301 nbessais>3' . SU . ':activée:'); return; } $lurl = $URL; if ($_SESSION['lastredir']) { if (now - $_SESSION['lastredir'] < 4) { $_SESSION['nrdir']++; } } #if($_ENV['yt']['lastredir'])if(now-$_ENV['yt']['lastredir']<4)$_ENV['ipf']['nrdir']++; if ($_SESSION['nrdir'] > 4) { Db("nbredir" . SU . '=>' . $URL, 1, 'prio'); $_SESSION['nrdir'] = -2; R302('/'); } #if(j9)kill($_GET['N0301'].$_GET['N301']."$nc $lh $lr<>".SU."<>$URL<>$x");#['N0301'].$_GET['N301'].SU.' <> '.$URL if ($_GET['N0301'] . $_GET['N301'] or strpos(' ' . u, 'Tag.php') or preg('anciensin', h)) { return; } #|prechoix if (h == 'a74.fr' && preg('sxxx|#', $URL)) { sql5("delete from p.url where url=\"" . SU . "\""); } if ($m == 3) { R303($URL); } $URL = ltrim(str_replace('/http:/a', 'http://a', $URL), '/'); $URL = trim(Preg_replace("~%5C|%27~is", '', $URL), "'\"+%:,-=&#!¤*.† "); if (!strpos($URL, 'ttp:/')) { $URL = "http://" . H . "/" . $URL; } #if(j9)kill("ahah $r301 $URL"); if (SU == $URL) { $URL = "http://" . H . "/"; } #Vers la racine si redirige sur la même url :!! if (SU == $URL) { Db("selfurl:" . SU . " - " . $URL, 0, 'r301'); @unlink(CR301); return; } if (Preg_Match("~http://.{0,1}/~", $URL) or substr_count($URL, '/') < 2) { Db("redir malformée=>" . $URL, 0, 'r301'); } #ici r301.db #put some ?go=1 interoggation first in case of loops !!! while ($i < 5 && is_file(r3p($URL))) { $i++; $next = FGC(r3p($URL)); if ($next == SU) { unlink(r3p($URL)); } $URL = $next; GT("r3p{$i}"); } $i = 0; #if(j9)kill(SU.",$lurl,$URL"); if ($URL == SU) { #car cette fonction est couteuse en ressources while ($i < 3) { $i++; $x = h301($URL); G2("h301({$URL})=>{$x}", GT()); if ($x) { $URL = $x; } if ($URL == SU) { G2("\$URL==SU"); $URL = h301($URL . '?go=1'); if ($URL == SU) { Db('surl3' . SU); return; } } else { $i = 4; } } } if (!Preg('fotolia', $URL) and 0) { if (!Preg('200|401|302|402|403', $a)) { Db("selfurl4:{$a['1']}" . SU . "=>{$URL}"); R303('/'); } } #A ce moment, l'une d'entre elle redirige vers l'url de départ, ce qui n'est pas bon ! si double ou triple redirection .. changer toussa =) if (SU == $URL) { Db("selfurl2:" . SU, 0, 'r301'); @unlink(CR301); r303('/'); } if (!$URL) { av("emptyr301:{$URL}"); db('emptyr4' . SU); return; r303('/'); } elseif ($m == 1 && !$_POST && $URL != SU && $URL && isgoodurl(SU) && !strpos(u, '#')) { #if(u=='3eme-pilier.php'){DBM('debug r301 3P',SU.'=>'.$URL.pre($a).pre($_ENV));return;}#Annulé FAP(R . 'modif.db', SU, $URL); FPC(CR301, $URL); touch(CR301, $mtime); #write the file, then the file exists, no more trauma } $_GET['re'] = 301; R303($URL); #that's the final anyways ! #might be an old redirect with does boomrang somewhere }