// date_default_timezone_set('Europe/Moscow');
/* show_page.php */
//$pg_commtitle = "";
$pg_title = "";
$pg_tp_title = "НОВОСТИ";
$pg_description = "";
$pg_keywords = "";
//$pg_pragma = "";
//$tm_expires = "";
//$ss_logon = "";
//$us_login = "";
$pg_left_col = false;
$pg_cent_col = "";
$pg_righ_col_exist = true;
$pg_righ_col = false;
$pg_dont_show = false;
$pg_nav_line = "Новости >> ";
$pg_months = array("Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь");
$pg_countrys = array("rus" => "Россия", "ukr" => "Украина", "tur" => "Турция", "mol" => "Молдавия");
$db_query = "";
$db_date_cond = "";
$db_path_cond = "";
$CURRENT_TIMESTAMP=date("YmdHis",mktime());
$pg_redtram_banner_1 = $pg_redtram_banner_1_stencil;
$pg_redtram_banner_2 = $pg_redtram_banner_2_stencil;
//if (preg_match("{^/news/([:/0-9]+)(\?[-._&=a-z0-9]+)?$}i", $pg_path, $matches) && $matches[1] != "") {
if (preg_match("|^/news/(\d{4}(/\d{2}(/\d{2}(/\d{2}(:\d{2}(:\d{2})?)?)?)?)?)?/?$|i", $pg_path, $matches) && $matches[1] != "") {
//echo $matches[1]; // только для тестирования
$db_date = preg_replace("{[:/]}", "", $matches[1]);
$db_date = substr($db_date, 0, 14);
$db_date_4sql = str_replace("/","-",$matches[1]);
if (substr($db_date_4sql,10,1) == "-")
$db_date_4sql =
substr($db_date_4sql,0,10)." ".substr($db_date_4sql,11);
//debug echo "===".$db_date."===
"; echo "===".$db_date_4sql."===
";
if (strlen($db_date)==14) {
//+ sq added 05-Jan-2011. The precise date may be 3-hours or 4-hours shifted from real
// To make some 'shifted' links valid this code checks not only precise date,
// but date_pub+3 hours and date_pub+4 hours. Of course, overlaps are possible!
// it's only workaround!
$sq_y = substr($db_date,0,4);
$sq_m = substr($db_date,4,2);
$sq_d = substr($db_date,6,2);
$sq_h = substr($db_date,8,2);
$sq_i = substr($db_date,10,2);
$sq_s = substr($db_date,12,2);
$sq_idate3 = mktime($sq_h,$sq_i,$sq_s,$sq_m,$sq_d,$sq_y) - 3*60*60;
$sq_idate4 = mktime($sq_h,$sq_i,$sq_s,$sq_m,$sq_d,$sq_y) - 4*60*60;
$sq_date3 = date('YmdHis', $sq_idate3);
$sq_date3_4sql = date('Y-m-d H:i:s', $sq_idate3);
$sq_date4 = date('YmdHis', $sq_idate4);
$sq_date4_4sql = date('Y-m-d H:i:s', $sq_idate4);
//debug to see result of timeshifting (upper lines before all page!)
// echo "===".$db_date."==="; echo "===".$db_date_4sql."===
";
// echo "===".$sq_date3."==="; echo "===".$sq_date3_4sql."===
";
// echo "===".$sq_date4."==="; echo "===".$sq_date4_4sql."===
";
$db_date_cond = " AND (`r3_text`.`date_pub`='".$db_date_4sql."' OR `r3_text`.`date_pub`='".$sq_date3_4sql."' OR `r3_text`.`date_pub`='".$sq_date4_4sql."')";
//was: $db_date_cond = " AND `r3_text`.`date_pub`='".$db_date_4sql."'";
//- sq added
}
else
$db_date_cond = " AND `r3_text`.`date_pub` LIKE '".$db_date_4sql."%'";
//debug echo "===".$db_date_cond."===
";
} elseif (preg_match("{^/news/([a-f0-9]+)$}i", $pg_path, $matches)) {
$db_path_cond = " AND `r3_text`.`text_name` = '".$matches[1]."'";
} elseif (preg_match("{^/news(/[-._a-z0-9]+)+$}i", $pg_path)) {
$db_path_cond = " AND CONCAT(`r3_topic`.`path_lat`, `r3_topic`.`topic_name`, '/', `r3_text`.`text_name`) LIKE '".$pg_path."%'";
}
//----- changed by L,120930
// $cut_future_date = " AND `r3_text`.`date_pub` < CURRENT_TIMESTAMP";
$cut_future_date = "";
if (isset($_GET["start"])) $db_start = intval($_GET["start"]);
elseif (preg_match("{^/news/?$}i", $pg_path)) $db_start = 0;
else
if(strpos($pg_path,"/start=")>0) $db_start = intval(substr($pg_path,12,strlen($pg_path)));
else $db_start = 0;
if (isset($_GET["offset"])) $db_offset = intval($_GET["offset"]);
else $db_offset = 10;
$db_query = "SELECT `r3_text`.`text_id`, `r3_text`.`date_pub`, `r3_text`.`title`, `r3_text`.`text`, `r3_text`.`pict2_ext`, `r3_text`.`pict_alt`,"
." `r3_topic`.`topic_name`, `r3_topic`.`title`, `r3_topic`.`kword`, `r3_topic`.`descr` FROM `r3_text`"
." LEFT JOIN `r3_topic` ON `r3_text`.`topic_id` = `r3_topic`.`topic_id`"
." WHERE `r3_text`.`type` = '1'"
." AND `r3_text`.`usr_active` = '1'"
.$cut_future_date
.$db_date_cond
.$db_path_cond
." ORDER BY `r3_text`.`date_ord` DESC"
." LIMIT ".$db_start.", ".$db_offset;
$db_query_cnt = "SELECT `r3_text`.`text_id` FROM `r3_text`"
." WHERE `r3_text`.`type` = '1'"
." AND `r3_text`.`usr_active` = '1'"
.$cut_future_date
.$db_date_cond
.$db_path_cond;
$db_results_cnt = mysql_query_ext($db_query_cnt);
$db_cnt=@mysql_num_rows($db_results_cnt);
$db_result = @mysql_query_ext($db_query);
if (!$db_result) {echo "
Ошибка доступа к базе: " . mysql_error()."
\n"; echo "