dbh) die("FATAL ERROR: Unable to connect to the database at $MYSQL_HOST"); # what to do when with MySQL errors if ($SHOW_MYSQL_ERRORS=='off') $db->hide_errors(); # for debug MySQL errors use after query: ## # if ($db->captured_errors) # $db->vardump($db->captured_errors); ## # or $SHOW_MYSQL_ERRORS='on' in vars.inc.php $LinkID = &$db->dbh; if ((float)mysql_get_server_info($LinkID) >= 4.1) { if (!$MYSQL_CHARSET) $MYSQL_CHARSET = 'cp1251'; $db->query("SET NAMES '$MYSQL_CHARSET'"); $db->query("SET sql_mode=''"); } ?>get_var("SELECT ".($sysTbl?"User":"Message")."_ID FROM ".($sysTbl?"User":"Message$classID")." WHERE Keyword='$keyword'".(!$sysTbl?" AND Sub_Class_ID=$cc":"")); if ($db->num_rows) { $msgID = $res; return ($msgID); } else { return false; } } /** * Получить всю информацию о сайте по его hostname * * @param string $host * @return array */ function GetCatalogueByHostName($host) { global $db; $host = $db->escape($host); $res = $db->get_row("(SELECT * FROM Catalogue WHERE Domain = '$host' OR (CONCAT('|', REPLACE(Mirrors, '\\n', '|')) LIKE '%|$host%') LIMIT 1) UNION (SELECT * FROM Catalogue ORDER BY Checked=1, Priority, Catalogue_ID LIMIT 1) LIMIT 1", ARRAY_A); return $res; } // function GetCatalogueID ($host) { global $db, $DOMAIN_NAME; $res = $db->get_var("SELECT Catalogue_ID FROM Catalogue WHERE IF(LOCATE('.',Domain),Domain,IF(Domain<>'',CONCAT(Domain,'.".$DOMAIN_NAME."'),'".$DOMAIN_NAME."'))='".$host."'"); if ($db->num_rows) { $CatalogueID = $res; return ($CatalogueID); } else { $res = $db->get_results("SELECT Catalogue_ID,Mirrors FROM Catalogue ORDER BY Catalogue_ID",ARRAY_N); foreach ($res as $row) { list($CatalogueID,$Mirrors) =$row; $DomainArray = explode("\n",$Mirrors); for ($i=0;$iget_row("SELECT * FROM Subdivision WHERE Subdivision_ID='$sub'",ARRAY_A); } return $_cache["sub"][$sub]; } function GetSubdivisionID ($catalogue, $path) { global $db, $_cache; // $sub = $db->get_var("SELECT Subdivision_ID FROM Subdivision WHERE Catalogue_ID='".$catalogue."' AND Hidden_URL='".$path."'"); // return $sub; $row = $db->get_row("SELECT * FROM Subdivision WHERE Catalogue_ID='$catalogue' AND Hidden_URL='$path'", ARRAY_A); $_cache["sub"][$row["Subdivision_ID"]] = $row; return $row["Subdivision_ID"]; } function AttemptToRedirect ($url) { global $db, $REDIRECT_STATUS, $PHP_TYPE; $res = $db->get_row("SELECT REPLACE(NewURL,'*','\\\'),REPLACE(OldURL,'*','([[:alnum:]]+)') FROM Redirect WHERE '".$url."' LIKE CONCAT('http://',REPLACE(REPLACE(OldURL,'_','\\\_'),'*','%')) OR '".$url."' LIKE CONCAT('http://www.',REPLACE(REPLACE(OldURL,'_','\\\_'),'*','%')) ORDER BY LENGTH(OldURL) DESC LIMIT 1", ARRAY_N); if (!$db->num_rows) return 0; list($new_url,$old_url) = $res; if (strchr($new_url,"\\")) $result_url = ereg_replace($old_url, $new_url, $url); else $result_url = "http://".$new_url; if ($REDIRECT_STATUS=="on") { if ($AUTHORIZATION_TYPE=='session') { if (substr($result_url,-1)!='l' && substr($result_url,-1)!='/') {$result_url .= ("&".session_name()."=".session_id()); } else { $result_url .= ("?".session_name()."=".session_id()); } } if ($PHP_TYPE=='cgi') { header('Status: 301 Moved Permanently'); } header("Location: $result_url"); } else { if ($PHP_TYPE=='cgi') { header('Status: 200 OK'); } echo ""; } exit; } ?>