"; print_r($_SESSION['cart']); print ""; */ getChapter($chapter); if($_GET["submit_filter"]) { set_vars_from_request($FORM_NAMES, $_GET); } if($_POST["submit"]) //==================================================================================================================== { $id_inserted = 0; $MESSAGE_success = 0; include("admin/_engine/library/set_array_for_form.php"); set_vars_name_to_array($chapter, $FORM_NAMES, $table_name); // Установка имен переменных и свойств в массив $FORM_NAMES set_vars_from_request($FORM_NAMES, $_REQUEST); // Запись в массив $FORM_NAMES всех значений из $_REQUEST /* print "
";
print_r($FORM_NAMES);
print "
"; */ if(!analyse_form_vars($FORM_NAMES, $TYPES, $error)) // Анализ на корректность ВСЕХ полей ввода. Проход в цикле по всем полям { // print $table_name; if(analyse_for_uploads($FORM_NAMES, $FILES_array, $error)) // Проверка нужно ли что-то загружать? UPLOAD файлов { if(mysql_get_name_for_file(TABLE_NAME, $FILES_array, $FORM_NAMES, $index, $error)) // Делаем в базе новую запись "*" - считываем новый ID - формируем имя файла { if(!upload_all_files_to_server($FORM_NAMES, $FILES_array, $type_files, $error, $message, "")) //Загрузка всех файлов на сервер { $mas[0] = $index; delete_record_from_database($FORM_NAMES, TABLE_NAME, $FORM_NAMES["properties"]["index"], $mas, $error); // Если при закачке файла произошел сбой - удаляем запись в базе, созданную для хранения имени этого файла } } } if(!$error[0]) // Запись в базу данных... { if(($id_inserted = update_or_insert_record_in_database($table_name, $FORM_NAMES["properties"]["index"], $FORM_NAMES, $FILES_array, $index, $error))) { $MESSAGE_success = 1; $FOR_MAIL["value"] = $FORM_NAMES["value"]; /* print "
";
	print_r($FORM_NAMES["value"]);
	print "
"; */ } } } else { $ERROR_str = $ERRORS[$_SESSION["lang"]][$error[0]]; } } if((!$error[0] && $_REQUEST["submit"]) || $_REQUEST["clear"]) // ОЧИЩЕНИЕ ПОЛЕЙ (после успешной загрузки) ================================================================================================= { clear_form_vars($FORM_NAMES, $_REQUEST); } // Установка ключа : повторная отправка данных с формы ====================================================================================== // set_key_for_form($key); //------------------------------------------------------------------------------------------------------------------------------------------- // print phpinfo(); getChapterType($chapter_arr, $chapter); // print_r($chapter_arr); // print $chapter_type; if(getTemplate($chapter, $template)) { if($chapter_arr["type"] == "_STATIC_PAGE") { set_vars_for_CHPU($chapter, $CHPU, $URIelements, $iL); if(notURI_Exeption($URIelements[0 + $iL], $URI_Exeption) && !isset($_GET["logout"])) { count_uri_elem_404($URIelements, 1 + $iL); } getStaticPage($chapter, $chapter_arr["title"], $template_static_page); } // Запрос к таблицам - получение нужных меток getResultFromChapter($chapter, $result); // printResult($result); getStaticContent($chapter, $result_static); // printResult($result_static); print getPage($result, $result_static, $template, $chapter_arr, $template_static_page, $FORM_NAMES, $MARKERS, $ERROR_str, $MESSAGE_success, $FOR_MAIL); } /* else { print "

Не указан главный шаблон GRID (сетка)
и хотя бы один из PLACE'ов !

"; } */ //SPEED END //$exec_time = microtime(true) - $start_time; //print "
Script-time:".$exec_time."
"; //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- function getPage($result, $result_static, $template, $title_of_page, $template_static_page, $FORM_NAMES, $MARKERS, $ERROR_str, $MESSAGE_success, $FOR_MAIL) { /* print "
";
	print_r($title_of_page);
	print "
"; */ global $chapter; $keys = get_array_keys($result); if($keys[0]){$N = count($result[$keys[0]]);} $unique_places = array(); $unique_places_dop = array(); for($i = 0; $i < $N; $i++) { $block_temp = ""; $block_path = PATH_FOR_BLOCK."/".$result["file_block"][$i]; $SQL_request["query"] = ""; // Очищаем переменную от полных запросов, помещенных в одну переменную switch($result["type"][$i]) { case "_STATIC_CHAPTER": { $block_temp = $template_static_page; break; } case "_STATIC": { $SQL_request["issPRINT"] = TRUE; sql_logic($result["block"][$i], $SQL_request, $array_parent); if(is_array($result_static["id_block"]) && $SQL_request["issPRINT"] !== FALSE) { $ind = array_search($result["block_id"][$i], $result_static["id_block"]); if($ind !== FALSE) { if($result["file_block"][$i]) { $block_temp = implode('', file($block_path)); $keys = get_array_keys($result_static); foreach($keys as $val) { if($val != "id_block") { $block_temp = str_replace("%".$val."%", $result_static[$val][$ind], $block_temp); $pos = strpos($block_temp, MARKER_IMG); if($pos !== false) { $block_temp = replaceLableToImg($block_temp, MARKER_IMG, "id_static_blocks", $result_static["static_blocks_id"][$ind], "id_order", IMG_PATH."/".IMG_STATIC_BLOCKS_PATH, "", CMS_PREFIX."_static_blocks_img"); } $pos = strpos($block_temp, MARKER_DOC); if($pos !== false) { $block_temp = replaceLableToDoc($block_temp, MARKER_DOC, "id_static_blocks", $result_static["static_blocks_id"][$ind], "id_order", DOC_PATH."/".DOC_STATIC_BLOCKS_PATH, "", CMS_PREFIX."_static_blocks_doc"); } } } } else { // print "ТУТ!!"; $block_temp = $result_static["title"][$ind]." ".$result_static["content"][$ind]; $pos = strpos($block_temp, MARKER_IMG); if($pos !== false) { $block_temp = replaceLableToImg($block_temp, MARKER_IMG, "id_static_blocks", $result_static["static_blocks_id"][$ind], "id_order", IMG_PATH."/".IMG_STATIC_BLOCKS_PATH, "", CMS_PREFIX."_static_blocks_img"); } $pos = strpos($block_temp, MARKER_DOC); if($pos !== false) { $block_temp = replaceLableToDoc($block_temp, MARKER_DOC, "id_static_blocks", $result_static["static_blocks_id"][$ind], "id_order", DOC_PATH."/".DOC_STATIC_BLOCKS_PATH, "", CMS_PREFIX."_static_blocks_doc"); } } } } // $template = str_replace("%".$result["block"][$i]."%", $block_temp[$result["block_id"][$i]], $template); break; } case "_COMPLEX": { // print "
==".$result["block"][$i]; if(sql_logic($result["block"][$i], $SQL_request, $array_parent)) { //print "
==".$result["block"][$i]; // print_r($array_parent); $block_temp = print_template($SQL_request, $result["type"][$i], $result["block"][$i], $result["print_by_php"][$i], $block_path, $array_parent, "", $title_of_page, $MARKERS); $array_parent[0][0] = ""; $array_parent = ""; //$SQL_request["query"] = ""; } else { // return FALSE; } if(!$block_temp && $SQL_request["if_empty"]) { $block_temp = add_search_message($SQL_request["if_empty"]); } break; } case "_FORM": { /* print "
";
							print_r($FORM_NAMES);
							print "
"; */ set_vars_for_CHPU($chapter, $CHPU, $URIelements, $iL); global $chapter_arr; if($chapter_arr["type"] == "_FORM") { count_uri_elem_404($URIelements, 1 + $iL); } $block_temp = print_form_template($chapter, $block_path, $FOR_MAIL["macroses"], $FORM_NAMES, $ERROR_str, $MESSAGE_success); //$block_temp = print_template($SQL_request, $result["type"][$i], $block_path, $array_parent, "", $title_of_page, $MARKERS); if($MESSAGE_success) { // include("settings/web-print/send_email.php"); // include("admin/_engine/library/send_emails_functions.php"); send_email($result["block"][$i], $FOR_MAIL, $MESSAGE_success); // Отправка письма на email } break; } case "_FORM_FILTER": { include("settings/web-print/filter_form.php"); if(filter_form_ok($result["block"][$i])) { $block_temp = print_form_FILTER_template($block_path, $FOR_MAIL["macroses"], $FORM_NAMES, $ERROR_str, $MESSAGE_success); } //$block_temp = print_template($SQL_request, $result["type"][$i], $block_path, $array_parent, "", $title_of_page, $MARKERS); break; } case "_SEARCH_RESULT": { if($_GET["search"]) //POST { include("settings/web-print/sql_search_results.php"); sql_search_results($result["block"][$i], $SQL_request, $_GET["search"]); // $_POST["search_field"] $block_temp = print_template($SQL_request, $result["type"][$i], $result["block"][$i], $result["print_by_php"][$i], $block_path, $array_parent, "", $title_of_page, $MARKERS); } if($block_temp == "") { $block_temp = add_search_message(PATH_FOR_SEARCH_MESSAGE_TEMPLATE); } break; } case "_NAVIGATION": { $SQL_request["fields_name"] = "cms_sitemap.title_chapter, cms_sitemap.description, cms_sitemap.img_chapter, cms_sitemap.style_chapter, cms_sitemap.title_page, cms_sitemap.meta_description, cms_sitemap.meta_keywords, cms_navigation.chapter, cms_navigation.img_navigation, cms_navigation.style_navigation "; $SQL_request["tablenames_and_conditions"] = "cms_sitemap LEFT JOIN cms_navigation ON(cms_navigation.navigation_id = cms_sitemap.id_navigation) LEFT JOIN cms_navigation_in_block ON(cms_navigation_in_block.id_navigation = cms_navigation.navigation_id) LEFT JOIN cms_block ON(cms_block.block_id = cms_navigation_in_block.id_block) "; $SQL_request["where"] = "WHERE cms_sitemap.id_lang = ".$_SESSION['id_lang'] ." AND cms_block.block_id = '".$result["block_id"][$i]."'"; $SQL_request["id_order"] = "id_order"; // Поле по которому делается сортировка $SQL_request["order_by"] = "ORDER BY cms_sitemap.".$SQL_request["id_order"]; $SQL_request["sort_type"] = "ASC"; $block_temp = print_template($SQL_request, $result["type"][$i], $result["block"][$i], $result["print_by_php"][$i], $block_path, "", "", $title_of_page, $MARKERS); //print "
=".$title_of_page["title"]."=".$title_of_page["description"]."=".$title_of_page["keywords"]; break; } case "_LANG": { $SQL_request["fields_name"] = "title_lang, lang, default_lang "; $SQL_request["tablenames_and_conditions"] = "cms_lang"; $SQL_request["where"] = "WHERE not_active != '1' AND (not_printed != '1' OR id != '".$_SESSION['id_lang']."')"; // $SQL_request["id_order"] = "id_order"; // Поле по которому делается сортировка $SQL_request["order_by"] = "ORDER BY cms_lang.".$SQL_request["id_order"]; $SQL_request["sort_type"] = "ASC"; $block_temp = print_template($SQL_request, $result["type"][$i], $result["block"][$i], $result["print_by_php"][$i], $block_path, "", "", $title_of_page, $MARKERS); break; } } if($result["file_place"][$i]) { if(array_search($result["place"][$i], $unique_places_dop) === FALSE) { $place_path = PATH_FOR_PLACE."/".$result["file_place"][$i]; $unique_places[$result["place"][$i]] = implode('', file($place_path)); $k = count($unique_places_dop); $unique_places_dop[$k] = $result["place"][$i]; } $unique_places[$result["place"][$i]] = str_replace("%".$result["block"][$i]."%", $block_temp, $unique_places[$result["place"][$i]]); } else { $unique_places[$result["place"][$i]] .= $block_temp; } if($block_temp) { $places_ok[$result["place"][$i]] = 1; } } $keys = get_array_keys($unique_places); foreach($keys as $val) { if($places_ok[$val] == 1) { $template = str_replace("%".$val."%", $unique_places[$val], $template); } } //--------------------------------------------------------------------------------- if(!myMysqlConnection($link)) return false; // Подключение к базе $res = mysql_query("SELECT block FROM cms_block", $link); while($record = mysql_fetch_array($res)) { $keys = get_array_keys($record); foreach($keys as $val) { if(!is_integer($val)) { $template = str_replace("%".$record[$val]."%", "", $template); } } } $res = mysql_query("SELECT place FROM cms_place", $link); // printResult_from_Query($result); // Парсинг лишних PLACE'ов while($record = mysql_fetch_array($res)) { $keys = get_array_keys($record); foreach($keys as $val) { if(!is_integer($val)) { $template = str_replace("%".$record[$val]."%", "", $template); } } } //--------------------------------------------------------------------------------- /* if($chapter_arr["title"] != "") { $title_of_page["title"] = $chapter_arr["title"]; } */ // set_title_of_page($title_of_page, $template); replace_specials_add($template); set_title_of_page($title_of_page, $template); return $template; } //------------------------------------------------------------------------------------------------------- function replace_specials_add(&$template) // замена специальных макросов { set_vars_for_CHPU($chapter, $CHPU, $URIelements, $iL); while($marker_properties = get_marker_new($template, "{%URL_PARAM:")) { $tpl_repalced = $URIelements[(int)$marker_properties["field_name"]+$iL]; $template = str_replace($marker_properties["real_value"], $tpl_repalced, $template); } } //------------------------------------------------------------------------------------------------------- function getStaticPage($chapter, $title_of_page, &$block_temp) { $SQL_request["fields_name"] = "cms_static_chapters.static_chapters_id, cms_static_chapters.title, cms_static_chapters.content, cms_block.file_block, cms_block.block "; $SQL_request["tablenames_and_conditions"] = "cms_static_chapters LEFT JOIN cms_block ON(cms_static_chapters.id_block = cms_block.block_id) LEFT JOIN cms_navigation ON (cms_navigation.navigation_id = cms_static_chapters.id_navigation) "; $SQL_request["where"] = "WHERE cms_static_chapters.id_lang = ".$_SESSION['id_lang'] ." AND cms_navigation.chapter = '".$chapter."'"; $SQL_request["id_order"] = ""; // Поле по которому делается сортировка $SQL_request["order_by"] = ""; $SQL_request["sort_type"] = ""; if(!myMysqlConnection($link)) return false; // Подключение к базе $result = mysql_query("SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"], $link); print mysql_error(); if(mysql_num_rows($result)) { $record = mysql_fetch_array($result); if($record["file_block"]) { $block_temp = ""; $block_path = PATH_FOR_BLOCK."/".$record["file_block"]; $block_temp = implode('', file($block_path)); if($record["title"]) { $block_temp = str_replace("%title%", $record["title"], $block_temp); } else { $block_temp = str_replace("%title%", $title_of_page, $block_temp); } $block_temp = str_replace("%content%", stripslashes($record["content"]), $block_temp); $pos = strpos($block_temp, MARKER_IMG); if($pos !== false) { $block_temp = replaceLableToImg($block_temp, MARKER_IMG, "id_static_chapters", $record["static_chapters_id"], "id_order", IMG_PATH."/".IMG_STATIC_CHAPTERS_PATH, "", CMS_PREFIX."_static_chapters_img"); } $pos = strpos($block_temp, MARKER_DOC); if($pos !== false) { $block_temp = replaceLableToDoc($block_temp, MARKER_DOC, "id_static_chapters", $record["static_chapters_id"], "id_order", DOC_PATH."/".DOC_STATIC_CHAPTERS_PATH, "", CMS_PREFIX."_static_chapters_doc"); } $pos = strpos($block_temp, MARKER_GALLERY); if($pos !== false) { global $GALLERY_auto_for; if(($keeey = array_search($chapter, $GALLERY_auto_for)) !== FALSE) { if(!myMysqlConnection($link)) return false; // Подключение к базе $result = mysql_query("SELECT navigation_id from cms_navigation WHERE chapter = '".$chapter."'", $link); print mysql_error(); $record = mysql_fetch_array($result); $result2 = mysql_query("SELECT static_chapters_id from cms_static_chapters WHERE id_navigation = '".$record["navigation_id"]."' AND id_lang = '".$_SESSION['id_lang']."'", $link); print mysql_error(); $record2 = mysql_fetch_array($result2); $dir_gallery = $chapter."-".$record2["static_chapters_id"]; // print $dir_gallery; // $temp = $static_array[$marker_properties["field_name"]]; $block_temp = replaceToGallery($block_temp, 0, 0, 0, $dir_gallery, CMS_PREFIX."_gallery_files"); // $block_temp = replaceLableToDoc($block_temp, MARKER_DOC, "id_static_blocks", $result_static["static_blocks_id"][$ind], "id_order", DOC_PATH."/".DOC_STATIC_BLOCKS_PATH, "", CMS_PREFIX."_static_blocks_doc"); } } } else { $block_temp = $result_static["title"][$ind]." ".$result_static["content"][$ind]; $pos = strpos($block_temp, MARKER_IMG); if($pos !== false) { $block_temp = replaceLableToImg($block_temp, MARKER_IMG, "id_static_chapters", $record["static_chapters_id"], "id_order", IMG_PATH."/".IMG_STATIC_CHAPTERS_PATH, "", CMS_PREFIX."_static_chapters_img"); } $pos = strpos($block_temp, MARKER_DOC); if($pos !== false) { $block_temp = replaceLableToDoc($block_temp, MARKER_DOC, "id_static_chapters", $record["static_chapters_id"], "id_order", DOC_PATH."/".DOC_STATIC_CHAPTERS_PATH, "", CMS_PREFIX."_static_chapters_doc"); } } } } //------------------------------------------------------------------------------------------------------- function set_title_of_page($title_of_page, &$template) // Установка title и meta для страницы { global $SITE_title; /* из PHP-вывода */ global $meta_title; global $meta_description; global $meta_keywords; // Перекрывание заголовков if($title_of_page["meta_title"]) { $template = str_replace("%TITLE_OF_PAGE%", strip_tags($title_of_page["meta_title"]), $template); } else if($meta_title) { $template = str_replace("%TITLE_OF_PAGE%", strip_tags($meta_title), $template); } //------------------------------------------------------------------------------------------------------- if($title_of_page["meta_keywords"]) { $template = str_replace("%KEYWORDS_OF_PAGE%", str_replace('"', "", strip_tags($title_of_page["meta_keywords"])), $template); } else if($meta_keywords) { $template = str_replace("%KEYWORDS_OF_PAGE%", str_replace('"', "", strip_tags($meta_keywords)), $template); } //------------------------------------------------------------------------------------------------------- if($title_of_page["meta_description"]) { $template = str_replace("%DESCRIPTION_OF_PAGE%", str_replace('"', "", strip_tags($title_of_page["meta_description"])), $template); } else if($meta_description) { $template = str_replace("%DESCRIPTION_OF_PAGE%", str_replace('"', "", strip_tags($meta_description)), $template); } $title_page = $title_of_page["title"]; if($title_of_page["title_dop"]) { $title_page = $title_of_page["title_dop"]." | ".$title_of_page["title"]; if($title_of_page["title_page"]) { $title_page = $title_of_page["title_dop"]." :: ".$title_of_page["title_page"]; } else if($SITE_title[$_SESSION["lang"]]) { $title_page .= " :: ".$SITE_title[$_SESSION["lang"]]; } } else if($title_of_page["title_page"]) { $title_page = $title_of_page["title_page"]; } else if($SITE_title[$_SESSION["lang"]]) { $title_page .= " :: ".$SITE_title[$_SESSION["lang"]]; } $template = str_replace("%TITLE_OF_PAGE%", strip_tags($title_page), $template); /* if($title_of_page["title_page"]) { $template = str_replace("%TITLE_OF_SITE%", $title_of_page["title_page"], $template); } else { $template = str_replace("%TITLE_OF_SITE%", $SITE_title[$_SESSION["lang"]], $template); } */ $template = str_replace("%CHAPTER%", $_GET["chapter"], $template); // Поиск/замена CHAPTER $template = str_replace("%TITLE_OF_CHAPTER%", strip_tags($title_of_page["title"]), $template); $template = str_replace("%DESCRIPTION_OF_PAGE%", $title_of_page["description"], $template); $template = str_replace("%KEYWORDS_OF_PAGE%", $title_of_page["keywords"], $template); // $template = substr_replace_ALL_markers($template, "", "%", "%"); // Очистка темплейта от неиспользованных макросов } //------------------------------------------------------------------------------------------------------- function getChapter(&$chapter) { $chapter = $_GET["chapter"]; if(!$_GET["chapter"]){ $chapter = "index";} // print $chapter; // проверяем какого типа URL - ЧПУ или нет? $URI = $_SERVER['REQUEST_URI']; check_chapter_in_URI($URI, $chapter, $URIelements); redirect_to_chpu($URIelements); // редирект старых // print $chapter; $_SESSION["chapter"] = $chapter; define("CHAPTER", $chapter); } //------------------------------------------------------------------------------------------------------- function getChapterType(&$chapter_arr, $chapter) // Получить тип раздела - _STATIC или _COMPLEX { $SQL_request["fields_name"] = "cms_dir_chaptertypes.chapter_type, cms_sitemap.title_chapter, cms_sitemap.title_page, cms_sitemap.meta_description, cms_sitemap.meta_keywords "; $SQL_request["tablenames_and_conditions"] = "cms_navigation LEFT JOIN cms_dir_chaptertypes ON(cms_navigation.id_dir_chaptertypes = cms_dir_chaptertypes.id) LEFT JOIN cms_sitemap ON(cms_sitemap.id_navigation = cms_navigation.navigation_id) "; $SQL_request["where"] = "WHERE"." "."cms_navigation.chapter"." = '".$chapter."'". " AND cms_sitemap.id_lang = '".$_SESSION['id_lang']."'"; $SQL_request["id_order"] = ""; // Поле по которому делается сортировка if($SQL_request["id_order"]) { $SQL_request["order_by"] = ""; $SQL_request["sort_type"] = ""; } if(!myMysqlConnection($link)) return false; // Подключение к базе $result = mysql_query("SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"], $link); print mysql_error(); if(mysql_num_rows($result)) { $record = mysql_fetch_array($result); $chapter_arr["type"] = $record["chapter_type"]; $chapter_arr["title"] = $record["title_chapter"]; $chapter_arr["title_page"] = $record["title_page"]; $chapter_arr["keywords"] = $record["meta_keywords"]; $chapter_arr["description"] = $record["meta_description"]; return true; } return false; } //------------------------------------------------------------------------------------------------------- function getTemplate(&$chapter, &$template) { $SQL_request["fields_name"] = "cms_grid.file_name_grid, cms_sitemap.title_chapter "; $SQL_request["tablenames_and_conditions"] = "cms_navigation LEFT JOIN cms_grid ON(cms_navigation.id_grid = cms_grid.id) LEFT JOIN cms_sitemap ON(cms_navigation.navigation_id = cms_sitemap.id_navigation) "; $SQL_request["where"] = "WHERE"." "."cms_navigation.chapter"." = '".$chapter."'"." AND cms_sitemap.id_lang = ".$_SESSION['id_lang']; $SQL_request["id_order"] = ""; // Поле по которому делается сортировка if($SQL_request["id_order"]) { $SQL_request["order_by"] = "ORDER BY"." ".$table_main.".".$SQL_request["id_order"]; $SQL_request["sort_type"] = "ASC"; } if(!myMysqlConnection($link)) return false; // Подключение к базе $result = mysql_query("SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"], $link); print mysql_error(); // printResult_from_Query($result); if(!mysql_num_rows($result)) { $chapter = "index"; $field_name = "chapter"; $links_url_params = explode("&", $_SERVER["QUERY_STRING"]); $links_url_params = clear_url_from_wrong_params($links_url_params); $url = $links_url_params; $str_link = $field_name."=".$chapter; if(search_value_in_url_array($url, $field_name, "=", $j)) { $url[$j] = $str_link; $url_str = implode("&", $url); } else { $url_str = implode("&", $url); (strlen($url_str)) ? $url_str = $str_link."&".$url_str : $url_str = $str_link; } // $url_for_redirect = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]."?".$url_str; // $url_for_redirect = "http://".$_SERVER["HTTP_HOST"]."/"."?".$url_str; // print gotoPage($url_for_redirect, PATH_REDIRECT."/"."redirect.php"); header('HTTP/1.0 404 Not Found'); readfile('404.html'); exit(); // echo "

404 Not Found

"; // echo "The page that you have requested could not be found."; // Перенаправление return FALSE; } $record = mysql_fetch_array($result); if($record["file_name_grid"]) // Если есть тэмплейт { //Загрузка нужного тэмплейта $grid = PATH_FOR_GRID."/".$record["file_name_grid"]; //$title_of_page = $record["title_chapter"]; // print $title_of_page; // print $chapter; $template = implode('', file($grid)); $template = str_replace("{%-print-LANG-%}", "tpl_".$_SESSION["lang"], $template); return TRUE; } return FALSE; } //------------------------------------------------------------------------------------------------------- function gotoPage($url, $path) { $template = implode('', file($path)); return str_replace("%URL_FOR_REDIRECT%", $url, $template); } //------------------------------------------------------------------------------------------------------- function getResultFromChapter($chapter, &$result) { // $start_time = microtime(true); /* $SQL_request["fields_name"] = "DISTINCT cms_block.id_order, cms_block.block, cms_block.print_by_php, cms_block.file_block, cms_block.id_dir_blocktypes, cms_block.block_id, cms_block.common, cms_block.id_place, cms_place.place, cms_place.file_place, cms_dir_blocktypes.type "; $SQL_request["tablenames_and_conditions"] = // LEFT JOIN cms_place ON(cms_place.id = cms_place_block.id_place) // LEFT JOIN cms_block ON(cms_block.block_id = cms_place_block.id_block) " cms_navigation, cms_place, cms_block_in_navigation_new, cms_block LEFT JOIN cms_dir_blocktypes ON(cms_dir_blocktypes.id = cms_block.id_dir_blocktypes) "; $SQL_request["where"] = " WHERE (cms_navigation.chapter = '".$chapter."'" ." AND cms_place.id = cms_block_in_navigation_new.id_place" ." AND cms_block.block_id = cms_block_in_navigation_new.id_block" ." AND cms_navigation.navigation_id = cms_block_in_navigation_new.id_navigation" ." AND (cms_block_in_navigation_new.id_lang = ".$_SESSION["id_lang"]." OR cms_block_in_navigation_new.id_lang = 0))" ." OR (cms_block.common = 1 AND cms_place.id = cms_block.id_place)" ." " //OR cms_block.common = 1 // ; // */ $test_query = " SELECT DISTINCT cms_block.id_order, cms_block.block, cms_block.print_by_php, cms_block.file_block, cms_block.id_dir_blocktypes, cms_block.block_id, cms_block.common, cms_block.id_place, cms_place.place, cms_place.file_place, cms_dir_blocktypes.type FROM cms_block LEFT JOIN cms_block_in_navigation_new ON(cms_block.block_id = cms_block_in_navigation_new.id_block) LEFT JOIN cms_dir_blocktypes ON(cms_dir_blocktypes.id = cms_block.id_dir_blocktypes) LEFT JOIN cms_place ON(cms_place.id = cms_block_in_navigation_new.id_place) LEFT JOIN cms_navigation ON(cms_navigation.navigation_id = cms_block_in_navigation_new.id_navigation) WHERE cms_navigation.chapter = '".$chapter."' AND (cms_block_in_navigation_new.id_lang = '".$_SESSION["id_lang"]."' OR cms_block_in_navigation_new.id_lang = '0') UNION ALL SELECT DISTINCT cms_block.id_order, cms_block.block, cms_block.print_by_php, cms_block.file_block, cms_block.id_dir_blocktypes, cms_block.block_id, cms_block.common, cms_block.id_place, cms_place.place, cms_place.file_place, cms_dir_blocktypes.type FROM cms_place, cms_block LEFT JOIN cms_dir_blocktypes ON(cms_dir_blocktypes.id = cms_block.id_dir_blocktypes) WHERE cms_block.common = '1' AND cms_place.id = cms_block.id_place ORDER BY id_order ASC "; $SQL_request["id_order"] = "id_order"; // Поле по которому делается сортировка if($SQL_request["id_order"]) { $SQL_request["order_by"] = "ORDER BY cms_block.".$SQL_request["id_order"]; $SQL_request["sort_type"] = "ASC"; } if(!myMysqlConnection($link)) return false; // Подключение к базе $res = mysql_query($test_query, $link); // print "ERROR:".mysql_error(); // printResult_from_Query($res); // print "SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"]; // $res = mysql_query("SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"], $link); // print "ERROR:".mysql_error(); // printResult_from_Query($res); getArrayResult($res, $result); // $exec_time = microtime(true) - $start_time; // print "Время выполнения 1:".$exec_time; } //------------------------------------------------------------------------------------------------------- function getStaticContent($chapter, &$result_static) { // print "


!!!!!!!!!!!!!!!".$_SESSION['id_lang']; /* $SQL_request["fields_name"] = "DISTINCT cms_static_blocks.title, cms_static_blocks.content, cms_static_blocks.static_blocks_id, cms_static_blocks.id_block, cms_block.common "; $SQL_request["tablenames_and_conditions"] = " cms_navigation, cms_block_in_navigation_new, cms_static_blocks LEFT JOIN cms_block ON(cms_block.block_id = cms_static_blocks.id_block) "; $SQL_request["where"] = "WHERE ((cms_navigation.chapter = '".$chapter."'" ." AND cms_block.block_id = cms_block_in_navigation_new.id_block" ." AND cms_block_in_navigation_new.id_navigation = cms_navigation.navigation_id)" ." OR cms_block.common = 1)" ." AND cms_static_blocks.id_lang = ".$_SESSION['id_lang']; $SQL_request["id_order"] = "id_block"; // Поле по которому делается сортировка if($SQL_request["id_order"]) { $SQL_request["order_by"] = "ORDER BY cms_static_blocks.".$SQL_request["id_order"]; $SQL_request["sort_type"] = "ASC"; } */ $test_query = " SELECT DISTINCT cms_static_blocks.title, cms_static_blocks.content, cms_static_blocks.static_blocks_id, cms_static_blocks.id_block, cms_block.common FROM cms_block LEFT JOIN cms_static_blocks ON(cms_block.block_id = cms_static_blocks.id_block) LEFT JOIN cms_block_in_navigation_new ON(cms_block.block_id = cms_block_in_navigation_new.id_block) LEFT JOIN cms_navigation ON(cms_navigation.navigation_id = cms_block_in_navigation_new.id_navigation) WHERE ( cms_navigation.chapter = '".$chapter."' OR cms_block.common = '1' ) AND cms_static_blocks.id_lang = '".$_SESSION["id_lang"]."' "; if(!myMysqlConnection($link)) return false; // Подключение к базе $result = mysql_query($test_query, $link); print mysql_error(); // printResult_from_Query($res); // $exec_time = microtime(true) - $start_time; // print "Время выполнения!!!:".$exec_time; // print "SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"]; // $result = mysql_query("SELECT ".$SQL_request["fields_name"]." FROM ".$SQL_request["tablenames_and_conditions"]." ".$SQL_request["where"]." ".$SQL_request["order_by"]." ".$SQL_request["sort_type"], $link); // print mysql_error(); // printResult_from_Query($result); getArrayResult($result, $result_static); //Формируем массив результата } ?>