= $minTime) || ($day == "Sat" && $time <= $maxTime)) { header ("Location: index2.php?id=$offPage&lang=$lang"); exit; } // check off days $today = date("Y-m-d"); $tomorrow = date("Y-m-d", strtotime("+1 day")); $sql = "select * from offDays where offDay = '$today' or offDay = '$tomorrow'"; $result = commonDoQuery($sql); if (mysql_num_rows($result) != 0) { while ($row = mysql_fetch_array($result)) { if (($row['offDay'] == $today && $time <= $maxTime) || ($row['offDay'] == $tomorrow && $time >= $minTime)) { header ("Location: index2.php?id=$offPage&lang=$lang"); exit; } } } } // ---------------------------------------------------------------------------------------------------------------------------------- if ($emailid) { $sql = "select clubEmails.*, clubMailingLists.membersOnly as memOnly from clubEmails left join clubMailingLists on clubEmails.mailingListId = clubMailingLists.id where clubEmails.id = '$emailid'"; $result = commonDoQuery($sql); if (mysql_num_rows($result) == 0) { header("HTTP/1.0 404 Not Found"); exit; } $pageRow = mysql_fetch_array($result); $pageRow['membersOnly'] = false; $pageRow['type'] = ''; $pageRow['winTitle'] = ''; $pageRow['isReady'] = 1; if ($pageRow['memOnly'] == 1) { $sql = "select count(*) from clubMembers, clubMailingListsMembers where verifyCode = '$verifyCode' and clubMailingListsMembers.mailingListId in ($pageRow[mailingListId]) and clubMailingListsMembers.memberId = clubMembers.id"; $result = commonDoQuery($sql); $row = mysql_fetch_array($result); if (!$verifyCode || $row[0] == 0) { // Unauthorized to view this email on site header("HTTP/1.1 301 Moved Permanently"); header("Location:http://$_SERVER[HTTP_HOST]"); exit; } } } else { $sql = "select * from globalParms"; $result = commonDoQuery($sql); $row = mysql_fetch_array($result); $hasMobileVersion = $row['hasMobileVersion']; $countViewsPolicy = $row['countViewsPolicy']; $langs = explode(",",$row['langs']); $mainLang = $langs[0]; if ($id == "") $id = 1; if ($lang == "") { $lang = mysql_real_escape_string($_COOKIE['cookie_lang']); if ($lang == "" || strpos($row['langs'],$lang) === false) { $showChooseLangWindow = true; // get first language as default $lang = $langs[0]; } } $lang = strtoupper($lang); // save site language setcookie ("cookie_lang", $lang); $langToInclude = $lang; if (($lang == "HEB" || $lang == "HB2") && $isUTF8) $langToInclude .= "8"; include "langFiles/$langToInclude.php"; // ------------------------------------------------------------------------------------------------------------------------------ $sql = "select * from pages, pages_byLang where pages.id = pages_byLang.pageId and pages_byLang.language = '$lang' and id=$id"; $result = commonDoQuery($sql); $pageRow = mysql_fetch_array($result); } // ---------------------------------------------------------------------------------------------------------------------------------- if (!$pageRow) // page does not exist { $sql = "select notReadyPageId from globalParms"; $result = commonDoQuery($sql); $parmsRow = mysql_fetch_array($result); header("HTTP/1.0 404 Not Found"); if ($parmsRow['notReadyPageId'] != 0) { $id= $parmsRow['notReadyPageId']; $sql = "select * from pages, pages_byLang where pages.id = pages_byLang.pageId and pages_byLang.language = '$lang' and id=$id"; $result = commonDoQuery($sql); $pageRow = mysql_fetch_array($result); } else exit; } // ---------------------------------------------------------------------------------------------------------------------------------- if ($id < 0 && (strtotime($pageRow['updated']) + 60*5) < strtotime("now")) // show preview page only for 5 minutes { header("HTTP/1.1 301 Moved Permanently"); header("Location: index2.php?id=".(-$id)."&lang=$lang"); exit; } if ($pageRow['isReady'] == 0 && $id > 0) // page exists but not ready yet { $sql = "select notReadyPageId from globalParms"; $result = commonDoQuery($sql); $parmsRow = mysql_fetch_array($result); if ($parmsRow['notReadyPageId'] != 0) { header ("Location: index2.php?id=$parmsRow[notReadyPageId]&lang=$lang"); } else { echo "Page is not ready yet"; } exit; } $isMobile = false; $layoutLang = $lang; $membersOnlyField = "membersOnly"; if ($hasMobileVersion && commonIsMobile ()) { $isMobile = true; $membersOnlyField = "mobileMembersOnly"; $layoutLang .= "m"; } // check if members only if ($pageRow[$membersOnlyField] == "1") { $memberRow = commonGetClubMemberRow(); $sql = "select * from clubConfig"; $result = commonDoQuery($sql); $clubRow = mysql_fetch_array($result); // check if member is login if ($memberRow == null || ($clubRow['passwordChangeDays'] != 0 && $memberRow['passwordExpireTime'] != "0000-00-00" && strtotime($memberRow['passwordExpireTime']) < strtotime(date("Y-m-d")))) { // find member login page if ($memberRow == null) $goId = $clubRow['memberLoginPageId']; else $goId = $clubRow['updatePasswordPageId']; header ("Location: index2.php?id=$goId&returnTo=$id&catId=$catId"); exit; } } if (!$emailid && $countViewsPolicy != -1) { // count views // ------------------------------------------------------------------------------------------------------------------------------ $countViews = $_COOKIE['cookie_countViews']; $countViewsArray = explode("#",trim($countViews,"#")); if ((!in_array("$id", $countViewsArray) || $countViewsPolicy == "1") && commonCheckUserAgent()) { // update count views for this page $sql = "update pages set countViews = countViews + 1 where id = $id"; commonDoQuery($sql); // add id to cookie $countViews .= $id . "#"; setcookie ("cookie_countViews", $countViews, 0); } // save page referer // ------------------------------------------------------------------------------------------------------------------------------ if ($_COOKIE['cookie_referer'] == "") { setcookie ("cookie_referer", $_SERVER['HTTP_REFERER'], 0); setcookie ("cookie_landAt", $_SERVER['REQUEST_URI'], 0); } } if ($isStatic == 1 && !$isMobile) { $staticSql = "select UNCOMPRESS(htmlCode) from staticPagesCache where queryString = '$_SERVER[REQUEST_URI]'"; $staticRes = commonDoQuery($staticSql); $staticRow = mysql_fetch_array($staticRes); if ($staticRow) { echo $staticRow[0]; exit; } } $sql = "select * from layouts left join layouts_byLang on layouts.id = layouts_byLang.layoutId and layouts_byLang.language = '$layoutLang' where id=".$pageRow['layoutId']." and active=1"; $result = commonDoQuery($sql); $layoutRow = mysql_fetch_array($result); $ids = explode(",",$id); $webpagetxt = $layoutRow['text']; // layouts switches // ---------------------------------------------------------------------------------------------------------------------------------- // get all layout switches $sql = "select * from layoutSwitches_byLang where language = '$layoutLang' order by id"; $switches = commonDoQuery($sql); $allSwitchs = array(); while ($switchRow = mysql_fetch_array($switches)) { $allSwitchs[$switchRow['name']] = $switchRow['text']; } while (preg_match("/@([a-zA-Z_0-9]+)@/",$webpagetxt,$regs)) { if (array_key_exists($regs[1], $allSwitchs)) $webpagetxt = str_replace("@$regs[1]@", $allSwitchs[$regs[1]], $webpagetxt); else $webpagetxt = str_replace("@$regs[1]@", "", $webpagetxt); } // ------------------------------------------------------------------------------------------------------------------------------ if (function_exists("commonPreParser")) { $webpagetxt = commonPreParser($webpagetxt); } // find page cat id (by type) only if catId is empty // ---------------------------------------------------------------------------------------------------------------------------------- if ($catId == "" && !$emailid) { // find cat id $sql = "select categoryId from categoriesItems where itemId = $id and type = '$pageRow[type]'"; $result = commonDoQuery($sql); if (mysql_num_rows($result) != 0) { $row = mysql_fetch_array($result); $catId = $row[0]; } } if ($catId != "") { // replace #catId# $webpagetxt = str_replace("#thisCatId#", $catId, $webpagetxt); } /* * TBD: we will do that query if we see the special box of language selection * we will first check if lenght($langs) > 1 and then we will query * select language from pages_byLang where pageId=$id1 and language <> '$lang' and isReady=1 * $sql = "select language from pages_byLang where pageId=$articleId and language <> '$lang' and txt <> ''"; $result = commonDoQuery($sql); $other_langs = array(); while ($row = mysql_fetch_array($result)) array_push($other_langs,$row[0]); */ // replace all queryText (from search on site form) $webpagetxt = str_replace("#queryText#", $queryText, $webpagetxt); $webpagetxt = str_replace("#queryTextEncoded#", urlencode($queryText), $webpagetxt); if ($emailid) { // change email content $emailContentHtml = "#emailContent#"; $emailContentStart = strpos($webpagetxt, $emailContentHtml, 0); if ($emailContentStart != false) { $webpagetxt = substr_replace($webpagetxt, $pageRow['htmlCode'], $emailContentStart, strlen($emailContentHtml)); } $webpageind = 0; while ($matchpoint = strpos($webpagetxt, "#emailSubject#", $webpageind)) { $webpageind += 14; $webpagetxt = substr_replace($webpagetxt, $pageRow['subject'], $matchpoint, 14); } // replace #firstname# $webpagetxt = str_replace("#firstname#", $firstname, $webpagetxt); // [Amir 16/3/09] for Hotmail we make our css files as inline if (strpos($webpagetxt, "common.css") === false) { $contents = ''; $handle = fopen("common.css", "rb"); while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); $handle = fopen("css/layouts.css", "rb"); while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); $addcss = ""; $matchpoint = strpos($webpagetxt, "", 0); $webpagetxt = substr_replace($webpagetxt, "$addcss\n", $matchpoint, 7); } } // change window title $winTitle = str_replace("'","’",$pageRow['winTitle']); $webpagetxt = str_replace("#winTitle#", $winTitle, $webpagetxt); /* $winTitleHtml = "#winTitle#"; $winTitleStart = strpos($webpagetxt, $winTitleHtml, 0); if ($winTitleStart != false) { $webpagetxt = substr_replace($webpagetxt, stripslashes($winTitle), $winTitleStart, strlen($winTitleHtml)); }*/ // change bottom text (copy rigths) $bottomTextHtml = "#bottomText#"; $bottomTextStart = strpos($webpagetxt, $bottomTextHtml, 0); if ($bottomTextStart != false) { // search if we have bottomText on db $sql = "select bottomText from globalParms_byLang where language = '$lang'"; $result = commonDoQuery($sql); $parmsRow = mysql_fetch_array($result); if (strpos(strtolower($parmsRow['bottomText']), " "עברית", "ENG" => "English", "ESP" => "Español", "FRN" => "Français", "RUS" => "Русский", "ARB" => "عربي"); // declares all isReady variables for all site languages for ($l=0; $l$queryText",$htmlPageRow['title']); $htmlPageRow['txt'] = str_replace($queryText,"$queryText",$htmlPageRow['txt']); } $matchpoint = strpos($webpagetxt, "#title#", $webpageind); $matchnextpoint = strpos($webpagetxt, "divType=", $webpageind); if ($matchpoint != false && ($matchpoint < $matchnextpoint || $matchnextpoint == false)) { $webpagetxt = substr_replace($webpagetxt, $thisPageRow['title'], $matchpoint, 7); $webpageind = $matchpoint + strlen($thisPageRow['title']); } $htmlCode = $htmlPageRow['txt']; $matchpoint = strpos($webpagetxt, "#pageHtml#", $webpageind); $matchnextpoint = strpos($webpagetxt, "divType=", $webpageind); if ($matchpoint != false && ($matchpoint < $matchnextpoint || $matchnextpoint == false)) { $webpagetxt = substr_replace($webpagetxt, $htmlCode, $matchpoint, 10); $webpageind = $matchpoint + strlen($htmlCode); } break; case "gallery": if (!function_exists("gallery_build")) include "index2_gallery.php"; gallery_build (); break; case "album": if (!function_exists("album_build")) include "index2_album.php"; album_build (); break; case "forum": if (!function_exists("forum_build")) include "index2_forum.php"; forum_build (); break; case "discussion": if (!function_exists("discussion_build")) include "index2_discussions.php"; discussion_build (); break; case "essay": if (!function_exists("essay_build")) include "index2_essay.php"; essay_build ($linkTarget); break; case "blog" : if (!function_exists("blog_build")) include "index2_blog.php"; blog_build (); break; case "questionnaire" : if (!function_exists("questionnaire_build")) include "index2_questionnaire.php"; questionnaire_build (); break; case "event": if (!function_exists("event_build")) include "index2_events.php"; event_build (); break; case "hug": if (!function_exists("hug_build")) include "index2_hugs.php"; hug_build (); break; case "specific": $matchpoint = strpos($webpagetxt, "#title#", $webpageind); $matchnextpoint = strpos($webpagetxt, "divType=", $webpageind); if ($matchpoint != false && ($matchpoint < $matchnextpoint || $matchnextpoint == false)) { $webpagetxt = substr_replace($webpagetxt, $pageRow['title'], $matchpoint, 7); $webpageind = $matchpoint + strlen($pageRow['title']); } break; } break; case "popupMenu" : if (!function_exists("popupMenus_build")) include "index2_popupMenus.php"; popupMenu_build (); break; case "cascadeMenu" : if (!function_exists("cascadeMenu_build")) include "index2_popupMenus.php"; cascadeMenu_build (); break; case "discussion" : if (!function_exists("discussion_build")) include "index2_discussions.php"; discussion_build (); break; case "essay" : if (!function_exists("essay_build")) include "index2_essay.php"; essay_build (); break; case "galleryImages": if (!function_exists("galleryImages_build")) include "index2_gallery.php"; galleryImages_build (); break; case "album": if (!function_exists("album_build")) include "index2_album.php"; album_build (); break; case "albumImages": if (!function_exists("albumImages_build")) include "index2_album.php"; albumImages_build (); break; case "event" : if (!function_exists("event_build")) include "index2_events.php"; event_build (); break; case "blog" : if (!function_exists("blog_build")) include "index2_blog.php"; blog_build (); break; case "forum": if (!function_exists("forumById_build")) include "index2_forum.php"; forumById_build (); break; case "subMenu" : if (!function_exists("subMenu_build")) include "index2_menus.php"; subMenu_build (); break; case "galleryPreview": if (!function_exists("galleryPreview_build")) include "index2_gallery.php"; galleryPreview_build (); break; case "albumPreview": if (!function_exists("albumPreview_build")) include "index2_album.php"; albumPreview_build (); break; case "special" : // first - do include to essays (for bulid essay) if (!function_exists("essay_build")) include "index2_essay.php"; if (!function_exists("special_build")) include "index2_special.php"; special_build (); break; case "php": $webpageind = $matchnextpoint + 1; $matchpoint = strpos($webpagetxt, "phpSource=\"", $webpageind); $webpageind = $matchpoint + 11; $matchnextpoint = strpos($webpagetxt, "\"", $webpageind); $phpSource = substr($webpagetxt, $webpageind, $matchnextpoint - $webpageind); $phpSourceSplit = explode("#", $phpSource); $phpSourceName = $phpSourceSplit[0]; $parms = ""; if (count($phpSourceSplit) == 2) $parms = $phpSourceSplit[1]; if (!function_exists($phpSourceName . "_getHtml")) include $phpSourceName . ".php"; eval ("\$phpSource = $phpSourceName" . "_getHtml($parms);"); $matchpoint = strpos($webpagetxt, "#phpHtml#", $webpageind); $webpagetxt = substr_replace($webpagetxt, $phpSource, $matchpoint, 9); $webpageind = $matchpoint + strlen($phpSource); break; case "verification": $webpageind = $matchnextpoint + 1; $matchpoint = strpos($webpagetxt, "parms=\"", $webpageind); $webpageind = $matchpoint + 7; $matchnextpoint = strpos($webpagetxt, "\"", $webpageind); $parms = substr($webpagetxt, $webpageind, $matchnextpoint - $webpageind); eval ("\$verificationHtml = commonVefiticationHtml($parms);"); $matchpoint = strpos($webpagetxt, "#verificationHtml#", $webpageind); $webpagetxt = substr_replace($webpagetxt, $verificationHtml, $matchpoint, strlen("#verificationHtml#")); $webpageind = $matchpoint + strlen($verificationHtml); break; case "forumLastMsgs" : if (!function_exists("forumLastMsgs_build")) include "index2_forum.php"; forumLastMsgs_build (); break; case "forumPreview" : if (!function_exists("forumPreview_build")) include "index2_forum.php"; forumPreview_build (); break; case "discussionPreview" : if (!function_exists("discussionPreview_build")) include "index2_discussions.php"; discussionPreview_build (); break; case "essayPreview" : if (!function_exists("essayPreview_build")) include "index2_essay.php"; essayPreview_build (); break; case "mostTalkbacksEssays" : if (!function_exists("mostTalkbacksEssays_build")) include "index2_essay.php"; mostTalkbacksEssays_build (); break; case "latestEssay" : if (!function_exists("latestEssay_build")) include "index2_essay.php"; latestEssay_build (); break; case "sitemap" : if (!function_exists("sitemap_build")) include "index2_sitemap.php"; sitemap_build (); break; case "talkbacks" : if (!function_exists("talkbacks_build")) include "index2_talkbacks.php"; talkbacks_build (); break; case "urls" : if (!function_exists("urls_build")) include "index2_urls.php"; urls_build (); break; case "survey" : if (!function_exists("survey_build")) include "index2_survey.php"; survey_build (); break; case "surveyPreview" : if (!function_exists("surveyPreview_build")) include "index2_survey.php"; surveyPreview_build (); break; case "faq" : if (!function_exists("faq_build")) include "index2_faq.php"; faq_build (); break; case "nadlan" : if (!function_exists("nadlan_build")) include "index2_nadlan.php"; nadlan_build (); break; case "nadlanItem" : if (!function_exists("nadlanItem_build")) include "index2_nadlan.php"; nadlanItem_build (); break; case "carsTablet" : if (!function_exists("carsTablet_build")) include "index2_carsTablet.php"; carsTablet_build (); break; case "tablet" : if (!function_exists("tablet_build")) include "index2_tablet.php"; tablet_build (); break; case "tabletPreview" : if (!function_exists("tabletPreview_build")) include "index2_tablet.php"; tabletPreview_build (); break; case "phonesbook" : if (!function_exists("phonesbook_build")) include "index2_phonesbook.php"; phonesbook_build (); break; case "phonesbookQuery": if (!function_exists("phonesbookQuery_build")) include "index2_phonesbook.php"; phonesbookQuery_build (); break; case "events" : if (!function_exists("events_build")) include "index2_events.php"; events_build (); break; case "eventsCalendar" : if (!function_exists("eventsCalendar_build")) include "index2_events.php"; eventsCalendar_build (); break; case "hugs" : if (!function_exists("hugs_build")) include "index2_hugs.php"; hugs_build (); break; case "news" : if (!function_exists("news_build")) include "index2_news.php"; news_build (); break; case "searchResults" : if (!function_exists("searchResults_build")) include "index2_search.php"; searchResults_build(); $resetQueryTextCookie = false; break; case "categories" : if (!function_exists("categories_build")) { include "index2_categories.php"; } categories_build (); break; case "subCategories" : if (!function_exists("subCategories_build")) { include "index2_categories.php"; } subCategories_build (); break; case "category" : if (!function_exists("category_build")) { include "index2_categories.php"; } category_build (); break; case "categoryItems" : if (!function_exists("categoryItems_build")) { include "index2_categories.php"; } categoryItems_build (); break; case "categoryProducts" : if (!function_exists("categoryProducts_build")) { include "index2_shop.php"; } categoryProducts_build (); break; case "products" : if (!function_exists("products_build")) include "index2_shop.php"; products_build (); break; case "enums" : if (!function_exists("enums_build")) include "index2_enums.php"; enums_build (); break; case "product" : if (!function_exists("product_build")) include "index2_shop.php"; product_build (); break; case "productPath" : if (!function_exists("productPath_build")) include "index2_shop.php"; productPath_build (); break; case "attachProducts" : if (!function_exists("attachProducts_build")) include "index2_shop.php"; attachProducts_build (); break; case "productFeedbacks" : if (!function_exists("productFeedbacks_build")) include "index2_shop.php"; productFeedbacks_build (); break; case "prodcutsByProduct" : if (!function_exists("prodcutsByProduct_build")) include "index2_shop.php"; prodcutsByProduct_build (); break; case "producers" : if (!function_exists("prodcutsByProduct_build")) include "index2_shop.php"; producers_build (); break; case "cart" : if (!function_exists("cart_build")) include "index2_shop.php"; cart_build (); break; case "checkOrder" : if (!function_exists("checkOrder_build")) include "index2_shop.php"; checkOrder_build (); break; case "blogArchive" : if (!function_exists("blogArchive_build")) include "index2_blog.php"; blogArchive_build (); break; case "otherBlogs" : if (!function_exists("otherBlogs_build")) include "index2_blog.php"; otherBlogs_build (); break; case "blogPosts" : if (!function_exists("blogPosts_build")) include "index2_blog.php"; blogPosts_build (); break; case "postComments" : if (!function_exists("postComments_build")) include "index2_blog.php"; postComments_build (); break; case "lastBlog" : if (!function_exists("lastBlog_build")) include "index2_blog.php"; lastBlog_build (); break; case "latestBlogPost" : if (!function_exists("latestBlogPost_build")) include "index2_blog.php"; latestBlogPost_build (); break; case "blogPreview" : if (!function_exists("blogPreview_build")) include "index2_blog.php"; blogPreview_build (); break; case "newsletterPreview" : if (!function_exists("newsletterPreview_build")) { include "index2_newsletters.php"; } newsletterPreview_build (); break; case "box": $webpageind = $matchnextpoint + 1; $matchpoint = strpos($webpagetxt, "boxName=\"", $webpageind); $webpageind = $matchpoint + 9; $matchnextpoint = strpos($webpagetxt, "\"", $webpageind); $webpageName = substr($webpagetxt, $webpageind, $matchnextpoint - $webpageind); $strip = false; if (strpos($webpageName, "#strip") !== false) { $strip = true; $webpageName = str_replace("#strip", "", $webpageName); } // Remove non-standard attribures for XHTML compliance // ------------------------------------------------------------------------------------------------------------------ $webpagetxt = substr_replace($webpagetxt, "", $matchpoint, $matchnextpoint - $matchpoint + 1); $webpageind -= 9; $sql = "select boxes.*, boxes_byLang.* from boxes left join boxes_byLang on boxes.id = boxes_byLang.boxId and boxes_byLang.language = '$lang' where boxName='$webpageName'"; $result = commonDoQuery($sql); $boxRow = mysql_fetch_array($result); switch ($boxRow['type']) { case "links": if (!function_exists("menu_build")) include "index2_menus.php"; menu_build (); break; case "html": $matchpoint = strpos($webpagetxt, "#title#", $webpageind); $matchnextpoint = strpos($webpagetxt, "divType", $webpageind); if ($matchpoint != false && ($matchpoint < $matchnextpoint || $matchnextpoint == false)) { $webpagetxt = substr_replace($webpagetxt, $boxRow['title'], $matchpoint, 7); } $matchnextpoint = strpos($webpagetxt, "#boxHtml#", $webpageind); $boxContent = $boxRow['content']; if ($strip) $boxContent = strip_tags($boxContent); if ($boxRow['isScroll'] == "1") { $boxContent = "$boxContent"; } $webpagetxt = substr_replace($webpagetxt, $boxContent, $matchnextpoint, 9); $webpageind = $matchnextpoint + strlen($boxRow['content']); break; } break; case "boxTitle": $webpageind = $matchnextpoint + 1; $matchpoint = strpos($webpagetxt, "boxName=\"", $webpageind); $webpageind = $matchpoint + 9; $matchnextpoint = strpos($webpagetxt, "\"", $webpageind); $webpageName = substr($webpagetxt, $webpageind, $matchnextpoint - $webpageind); // Remove non-standard attribures for XHTML compliance // ------------------------------------------------------------------------------------------------------------------ $webpagetxt = substr_replace($webpagetxt, "", $matchpoint, $matchnextpoint - $matchpoint + 1); $webpageind -= 9; $sql = "select boxes.*, boxes_byLang.* from boxes left join boxes_byLang on boxes.id = boxes_byLang.boxId and boxes_byLang.language = '$lang' where boxName='$webpageName'"; $result = commonDoQuery($sql); $boxRow = mysql_fetch_array($result); $matchpoint = strpos($webpagetxt, "#title#", $webpageind); $matchnextpoint = strpos($webpagetxt, "divType", $webpageind); if ($matchpoint != false && ($matchpoint < $matchnextpoint || $matchnextpoint == false)) { $webpagetxt = substr_replace($webpagetxt, $boxRow['title'], $matchpoint, 7); $webpageind = $matchpoint + strlen($boxRow['title']); } break; case "navPath": $matchpoint = strpos($webpagetxt, "!START", $webpageind); $matchnextpoint = strpos($webpagetxt, "!END", $webpageind); $repeatBlock = substr($webpagetxt, $matchpoint+6, $matchnextpoint-$matchpoint-6); $repeatBlockSplit = explode("!SELECTED",$repeatBlock); // remove start-end block $webpagetxt = substr_replace($webpagetxt, "", $matchpoint, $matchnextpoint+4-$matchpoint); $beginpoint = $matchpoint; $navRow = $pageRow; $navPages = array(); $isFirst = true; $more = 1; while ($more != 0) { //echo ">>> id = $navRow[id] parent=$navRow[navParentId]
"; // in order to prevent infinite loop if (in_array($navRow['id'],$navPages)) break; array_push ($navPages, $navRow['id']); $navtitle = $navRow['navTitle']; if ($navtitle == "") $navtitle = $navRow['title']; if ($isFirst) { if (count($repeatBlockSplit) == 2) { $workingBlock = $repeatBlockSplit[1]; } $isFirst = false; } else { $workingBlock = $repeatBlockSplit[0]; $more--; } $serverName = $_SERVER['SERVER_NAME'] . str_replace("/index.php", "", str_replace("/index2.php", "", strtolower($_SERVER['SCRIPT_NAME']))); if ($navRow['id'] == 1 && $serverName != $_SERVER['SERVER_ADDR']) { $navUrl = "http://$serverName"; } else { if ($navRow['rewriteName'] != "") { $navUrl = $navRow['rewriteName']; } else { $getParams = ""; reset ($_GET); while (list($key, $val) = each($_GET)) { if ($key == "id" || $key == "lang" || $val == "") continue; if (strpos($navRow['urlExtraParams'], $key) === false) $getParams .= "&$key=$val"; } $navUrl = "index2.php?id=$navRow[id]$navRow[urlExtraParams]$getParams&lang=$lang"; if ($serverName != $_SERVER['SERVER_ADDR']) $navUrl = "http://$serverName/$navUrl"; } } $workingBlock = str_replace("#url#", "$navUrl", $workingBlock); $matchpoint = strpos($workingBlock, "#title#"); if ($matchpoint != false) $workingBlock = substr_replace($workingBlock, stripslashes($navtitle), $matchpoint, 7); if ($navtitle != "") // add this path only if not empty $webpagetxt = substr_replace($webpagetxt, $workingBlock, $beginpoint, 0); if ($navRow[navParentId] != 0) { // get next page $sql = "select id, navParentId, navTitle, title, urlExtraParams, rewriteName from pages, pages_byLang where pages.id = pages_byLang.pageId and language = '$lang' and id = $navRow[navParentId]"; $result = commonDoQuery($sql); $navRow = mysql_fetch_array($result); } if ($navRow['navParentId'] != 0) { $more++; } } break; case "bannerPreview" : bannerPreview_build(); break; case "bannersGallery" : bannersGallery_build(); break; } } } if ($resetQueryTextCookie) { $expire = time() - 3600; setcookie("queryText", "", $expire); } // replace get parameters (second replace) // ----------------------------------------------------------------------------------------------------------------- reset($_GET); while (list($key, $val) = each($_GET)) { if ($key == "id") continue; $webpagetxt = str_replace("#GET-$key#", stripslashes($val), $webpagetxt); } if (strpos($webpagetxt, "#GET-lang#") != false) { $webpagetxt = str_replace("#GET-lang#", $lang, $webpagetxt); } // add locallang support $webpagetxt = str_replace("#id#", $id, $webpagetxt); $webpagetxt = str_replace("#selectedHEB#", (("HEB"==$lang)?"selected":""), $webpagetxt); $webpagetxt = str_replace("#selectedHB2#", (("HB2"==$lang)?"selected":""), $webpagetxt); // replace #id1# with first id $webpagetxt = str_replace("#id1#", $ids[0], $webpagetxt); // replace all makehomepage $homepageKeyword = "#makehomepage#"; $homepageCode = "onclick=\"this.style.behavior='url(#default#homepage)'; this.setHomePage('http://".$_SERVER['SERVER_NAME']."/');\""; $webpageind = 0; while ($homepageStart = strpos($webpagetxt, $homepageKeyword, $webpageind)) { $webpageind = $homepageStart + strlen($homepageKeyword); $webpagetxt = substr_replace($webpagetxt, $homepageCode, $homepageStart, strlen($homepageKeyword)); } // replace all addToFavorite $addtofavoriteKeyword = "#addtofavorite#"; $addtofavoriteCode = "onclick=\"if (window.external) window.external.AddFavorite( 'http://".$_SERVER['SERVER_NAME'].str_replace("&","&",$_SERVER['REQUEST_URI']). "', document.title);\""; $webpageind = 0; while ($addtofavoriteStart = strpos($webpagetxt, $addtofavoriteKeyword, $webpageind)) { $webpageind = $addtofavoriteStart + strlen($addtofavoriteKeyword); $webpagetxt = substr_replace($webpagetxt, $addtofavoriteCode, $addtofavoriteStart, strlen($addtofavoriteKeyword)); } // add bg music (if exist) // ----------------------------------------------------------------------------------------------------------------- $musicHtml = ""; if (strpos($webpagetxt, "#music#", 0) !== false) { $pageMusicFile = $pageRow['musicBgFile']; if ($pageMusicFile != "") { $musicHtml = "
Get Adobe Flash Player.
"; } $webpagetxt = str_replace("#music#", $musicHtml, $webpagetxt); } // support print page links // ----------------------------------------------------------------------------------------------------------------- $webpageind = 0; $matchpoint = strpos($webpagetxt, "#print=", $webpageind); $addFunc = false; while ($matchpoint != false) { $webpageind = $matchpoint + 7; $matchnextpoint = strpos($webpagetxt, "#", $webpageind); $printContentName = substr($webpagetxt, $webpageind, $matchnextpoint - $webpageind); $webpagetxt = substr_replace($webpagetxt, "goPrint('$printContentName')", $matchpoint, 7+strlen($printContentName)+1); if (!$addFunc) { $addFunc = true; $dir = "ltr"; $align = "left"; if ($lang == "HEB" || $lang == "HB2" || $lang == "ARB") { $dir = "rtl"; $align = "right"; } $addMeta = ""; if ($isUTF8) $addMeta = ""; $printLogo = ""; if (file_exists("loadedFiles/printLogo.png")) { $printLogo = ""; } $js = ""; $matchpoint = strpos($webpagetxt, "", 0); $webpagetxt = substr_replace($webpagetxt, "$js\n", $matchpoint, 7); } $matchpoint = strpos($webpagetxt, "#print=", $webpageind); } // alert error messages after page loading // ----------------------------------------------------------------------------------------------------------------- $matchpoint = strpos($webpagetxt, "#handleLoginError#", 0); if ($matchpoint !== false) { $alertError = ""; if ($_GET['loginError'] != "") $alertError .= ""; $webpagetxt = substr_replace($webpagetxt, $alertError, $matchpoint, 18); } // replace again get parameters // ----------------------------------------------------------------------------------------------------------------- $getParams = ""; reset ($_GET); while (list($key, $val) = each($_GET)) { $webpagetxt = str_replace("#GET-$key#", stripslashes($val), $webpagetxt); if ($key != "id" && $key != "lang" && $key != "new" && $val != "") $getParams .= "&$key=$val"; } $webpagetxt = str_replace("#getParams#", $getParams, $webpagetxt); // add banners again // ------------------------------------------------------------------------------------------------------------------------------ banners_build (); // add keywords meta and description meta // ------------------------------------------------------------------------------------------------------------------------------ $keywords = stripslashes($pageRow['keywords']); $description = stripslashes($pageRow['description']); if ($keywords == "" || $description == "") { $sql = "select * from globalParms_byLang where language='$lang'"; $result = commonDoQuery($sql); $row = mysql_fetch_array($result); if ($keywords == "") $keywords = stripslashes($row['keywords']); if ($description == "") $description = stripslashes($row['description']); } if ($id != 1 && $description == "") $description = $pageRow['winTitle']; $keywordsMeta = ""; $descriptionMeta = ""; $robotsMeta = stripslashes($pageRow['robots']); if ($robotsMeta != "") { $robotsMeta = ""; } $matchpoint = strpos($webpagetxt, "", 0); $matchEndPoint = strpos($webpagetxt, "", 0); $searchRobotsMeta = strpos($webpagetxt, ' $matchEndPoint)) $webpagetxt = substr_replace($webpagetxt, "\n$robotsMeta\n", $matchpoint, 8); $searchKeywordsMeta = strpos($webpagetxt, ' $matchEndPoint) $webpagetxt = substr_replace($webpagetxt, "\n$keywordsMeta\n", $matchpoint, 8); $searchDescriptionMeta = strpos($webpagetxt, ' $matchEndPoint) $webpagetxt = substr_replace($webpagetxt, "\n$descriptionMeta\n", $matchpoint, 8); if ($layoutRow['type'] != 'newsletter') { //include lang js // ------------------------------------------------------------------------------------------------------------------------------ $langJS = ""; $langJS = "\n"; $matchpoint = strpos($webpagetxt, "", 0); if (($laterMatchpoint = strpos($webpagetxt, "base href", 0)) !== false) { $matchpoint = strpos($webpagetxt, "\n", $laterMatchpoint); $webpagetxt = substr_replace($webpagetxt, "\n$langJS", $matchpoint, 1); } else if (($laterMatchpoint = strpos($webpagetxt, "meta name='description'", 0)) !== false) { $matchpoint = strpos($webpagetxt, ">", $laterMatchpoint); $webpagetxt = substr_replace($webpagetxt, ">\n$langJS", $matchpoint, 1); } else $webpagetxt = substr_replace($webpagetxt, "\n$langJS", $matchpoint, 6); } // ------------------------------------------------------------------------------------------------------------------------------ if (strpos($webpagetxt, "divType=\"searchResults\"") !== false) { // add nofollow meta tag $nofollowMeta = ""; $matchpoint = strpos($webpagetxt, "", 0); $webpagetxt = substr_replace($webpagetxt, "$nofollowMeta\n", $matchpoint, 7); } // ------------------------------------------------------------------------------------------------------------------------------ if (!$emailid) { if ($showChooseLangWindow) { $sql = "select * from popWindows where type = 'chooseLang' and (showOnPageId = $id or showOnPageId = 0) and popPageId != $id and status = 'active'"; $result = commonDoQuery($sql); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); $webpagetxt = createPopWindow ($webpagetxt, $row); } else { $showChooseLangWindow = false; } } if (!$showChooseLangWindow) { // pop windows // ------------------------------------------------------------------------------------------------------------------------------ $sql = "select * from popWindows where (showOnPageId = $id or showOnPageId = 0) and popPageId != $id and status = 'active' and type != 'chooseLang'"; $result = commonDoQuery($sql); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); $webpagetxt = createPopWindow ($webpagetxt, $row); } } } // date & time // ------------------------------------------------------------------------------------------------------------------------------ $today = strtotime("now"); # day $matchpoint = strpos($webpagetxt, "#day#"); if ($matchpoint != false) { $day = commonGetDay (date("w"), $lang); $webpagetxt = str_replace("#day#", $day, $webpagetxt); } # month $matchpoint = strpos($webpagetxt, "#month#"); if ($matchpoint != false) { $month = commonGetMonth (date("m")); $webpagetxt = str_replace("#month#", $month, $webpagetxt); } # date_ while (($matchpoint = strpos($webpagetxt, "#date_")) != false) { $matchnextpoint = strpos($webpagetxt, "#", $matchpoint+6); $format = substr($webpagetxt, $matchpoint+6, $matchnextpoint-$matchpoint-6); $dateFormat = date($format); $webpagetxt = str_replace("#date_$format#", $dateFormat, $webpagetxt); } # time $matchpoint = strpos($webpagetxt, "#time#"); if ($matchpoint != false) { $time = date("H:i", $today); $webpagetxt = str_replace("#time#", $time, $webpagetxt); } while (($matchpoint = strpos($webpagetxt, "#jewishDate#")) != false) { $today = strtotime("now"); $lectureDate = date("d.m.Y",$today); $gregorianMonth = date("n", $today); $gregorianDay = date("j", $today); $gregorianYear = date("Y", $today); $jdDate = gregoriantojd($gregorianMonth,$gregorianDay,$gregorianYear); $jdDate = jdtojewish($jdDate, true); $jdDate = str_replace(" '", "' ", $jdDate); if ($isUTF8) $jdDate = iconv("windows-1255","utf-8", $jdDate); $webpagetxt = str_replace("#jewishDate#", $jdDate, $webpagetxt); } // memberName // ------------------------------------------------------------------------------------------------------------------------------ $matchpoint = strpos($webpagetxt, "#memberName#"); if ($matchpoint != false) { $memberRow = commonGetClubMemberRow(); $memberName = ""; if ($memberRow == null) { switch ($lang) { case "HEB" : $memberName = "אורח"; } } else { $memberName = "$memberRow[firstname] $memberRow[lastname]"; } $webpagetxt = str_replace("#memberName#", $memberName, $webpagetxt); } // online member // ------------------------------------------------------------------------------------------------------------------------------ $matchpoint = strpos($webpagetxt, "#onlineMemberJS#"); if ($matchpoint != false) { $js = ""; $memberRow = commonGetClubMemberRow(); if ($memberRow != null) { $sql = "select withSessions, keepAliveInterval from clubConfig"; $result = commonDoQuery($sql); $row = mysql_fetch_array($result); $onlineMemberInterval = 1000 * $row['keepAliveInterval']; // in miliseconds if ($row['withSessions'] == "1") { global $sessionCode; $code = $sessionCode; } else { $code = $memberRow['verifyCode']; } if (strpos($webpagetxt, "xmlObj.js") == false) $js = " "; $js .= " "; } $webpagetxt = substr_replace($webpagetxt, $js, $matchpoint, strlen("#onlineMemberJS#")); } // ------------------------------------------------------------------------------------------------------------------------------ // remove hataf-patach which added by xStrandard $webpagetxt = str_replace(chr(194), "", $webpagetxt); // check if there are more switches // ------------------------------------------------------------------------------------------------------------------------------ while (preg_match("/@([a-zA-Z_0-9]+)@/",$webpagetxt,$regs)) { if (array_key_exists($regs[1], $allSwitchs)) $webpagetxt = str_replace("@$regs[1]@", $allSwitchs[$regs[1]], $webpagetxt); else $webpagetxt = str_replace("@$regs[1]@", "", $webpagetxt); } // ------------------------------------------------------------------------------------------------------------------------------ if (function_exists("commonPostParser")) { $webpagetxt = commonPostParser($webpagetxt); } // add banners again after post // ------------------------------------------------------------------------------------------------------------------------------ banners_build (); // replace again get parameters (if exists) // ----------------------------------------------------------------------------------------------------------------- reset ($_GET); while (list($key, $val) = each($_GET)) { $webpagetxt = str_replace("#GET-$key#", $val, $webpagetxt); } // replace #browser# // ------------------------------------------------------------------------------------------------------------------------------ if (strpos($webpagetxt, "#browser#", 0) != false) { if (preg_match( '/MSIE ([0-9]{1,2}.[0-9]{1,2})/',$_SERVER["HTTP_USER_AGENT"],$log_version)) { $browser = "ie"; } else if (strpos($_SERVER["HTTP_USER_AGENT"], "Chrome") !== false) { $browser = "chrome"; } else if (strpos($_SERVER["HTTP_USER_AGENT"], "Safari") !== false) { $browser = "safari"; } else { $browser = "firefox"; } $webpagetxt = str_replace("#browser#", $browser, $webpagetxt); } // replace #ie6# // ------------------------------------------------------------------------------------------------------------------------------ $ie6 = ""; if (strpos($webpagetxt, "#ie6#", 0) != false) { $matchpoint = strpos($_SERVER["HTTP_USER_AGENT"], "MSIE"); if ($matchpoint != false) { $version = substr($_SERVER["HTTP_USER_AGENT"], $matchpoint+5, 1); if ($version == "6") { $ie6 = "ie6"; } } $webpagetxt = str_replace("#ie6#", $ie6, $webpagetxt); } #browserVersion# // ------------------------------------------------------------------------------------------------------------------------------ $version = ""; $matchpoint = strpos($_SERVER["HTTP_USER_AGENT"], "MSIE"); if ($matchpoint != false) { $matchpoint2 = strpos($_SERVER["HTTP_USER_AGENT"], ".", $matchpoint+1); $version = substr($_SERVER["HTTP_USER_AGENT"], $matchpoint+5, $matchpoint2-$matchpoint-5); } $matchpoint = strpos($_SERVER["HTTP_USER_AGENT"], "Chrome"); if ($matchpoint != false) { $matchpoint2 = strpos($_SERVER["HTTP_USER_AGENT"], ".", $matchpoint+1); $version = substr($_SERVER["HTTP_USER_AGENT"], $matchpoint+7, $matchpoint2-$matchpoint-7); } $matchpoint = strpos($_SERVER["HTTP_USER_AGENT"], "Firefox"); if ($matchpoint != false) { $matchpoint2 = strpos($_SERVER["HTTP_USER_AGENT"], ".", $matchpoint+1); $version = substr($_SERVER["HTTP_USER_AGENT"], $matchpoint+8, $matchpoint2-$matchpoint-8); } $webpagetxt = str_replace("#browserVersion#", $version, $webpagetxt); if ($layoutRow['type'] != 'newsletter') { // add common.js (if not exists already) // ------------------------------------------------------------------------------------------------------------------------------ if (strpos($webpagetxt, "common.js") == false) { $js = ""; $matchpoint = strpos($webpagetxt, "", 0); $webpagetxt = substr_replace($webpagetxt, "\n$js", $matchpoint, 6); } } // replace all links to home page of the main lang to domain name only with set cookie first: // http://www.domain.co.il?index2.php?id=1&lang=XXX => http://www.domain.co.il with set cookie lang=XXX // ------------------------------------------------------------------------------------------------------------------------------ $serverName = "http://$_SERVER[SERVER_NAME]"; $webpagetxt = str_replace("index2.php?id=1&lang=$mainLang\"", "$serverName\" onclick='commonSetCookie(\"lang\", \"$mainLang\")'", $webpagetxt); $webpagetxt = str_replace("index2.php?id=1&lang=$mainLang'", "$serverName' onclick='commonSetCookie(\"lang\", \"$mainLang\")'", $webpagetxt); // Remove non-standard attribures for XHTML compliance // ------------------------------------------------------------------------------------------------------------------ array_push ($ibosTags, "boxName", "divType", "divDone", "phpSource", "limit", "category", "page", "parms", "orderBy", "sepType", "params", "startPos"); foreach ($ibosTags as $ibosTag) { while ($matchpoint = strpos($webpagetxt, "${ibosTag}=\"", 0)) { $webpageind = $matchpoint + strlen($ibosTag) + 2; $matchnextpoint = strpos($webpagetxt, "\"", $webpageind); $webpagetxt = substr_replace($webpagetxt, "", $matchpoint, $matchnextpoint - $matchpoint + 1); } } ///////////////////////////////////// if ($isStatic == 1 && !$isMobile) { $staticSql = "insert into staticPagesCache (queryString, htmlCode, since) values('$_SERVER[REQUEST_URI]', COMPRESS('".mysql_real_escape_string($webpagetxt)."'), now())"; commonDoQuery($staticSql); } ///////////////////////////////////// echo $webpagetxt; if ($isDebug) { $totalShowPageTime = microtime(time)-$startPageTime; if ($totalShowPageTime >= 5) // don't report below 5 seconds { krsort($queriesLog); // report an error $msg = " Site: $_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]
Total time: $totalShowPageTime
Referer: $_SERVER[HTTP_REFERER]
Agent: $_SERVER[HTTP_USER_AGENT]
Queries:
".print_r($queriesLog, true)." "; commonSendHtmlEmail ("Interuse", "info@interuse.co.il", "amir@interuse.co.il", "$privateFtpName Queries Log", $msg); } } /* --------------------------------------------------------------------------------------------------------------------------- */ /* createPopWindow */ /* --------------------------------------------------------------------------------------------------------------------------- */ function createPopWindow ($webpagetxt, $row) { global $id, $lang; $popType = $row['type']; // popunderLoad | popunderUnload | popupLoad | popupUnload | popupMsg | chooseLang if ($popType == "popupOnClose" && $id != $row[popPageId]) { $siteUrl = "http://$_SERVER[SERVER_NAME]$_SERVER[PHP_SELF]"; $onClose = " onbeforeunload=' if (event.clientY < 0 && event.clientX > 500) { window.open (\"$siteUrl?id=$row[popPageId]&lang=$lang\",\"popup$row[id]\", \"width=$row[popWidth]px,height=$row[popHeight]px,left=$row[popLeft]px,top=$row[popTop]px\") }'"; $webpagetxt = str_replace(" 0) $counterBefore--; } else if ($counterBefore > 0) { $counterBefore--; } setcookie("counterBefore_popup$row[id]", $counterBefore); // handle beenHere cookie $beenHere = $_COOKIE['beenHere_popup' . $row['id']]; } if (($beenHere == "" || $beenHere == "0") && $visitNum <= $row['counter'] && $counterBefore == 0) { setcookie("beenHere_popup$row[id]", "1", 0); $row['popWidth'] == "0" ? $row['popWidth'] = "400" : $row['popWidth']; $row['popHeight'] == "0" ? $row['popHeight'] = "400" : $row['popHeight']; if ($popType == "popunderUnload" || $popType == "popupUnload") { $attachEvent1 = "unload"; $attachEvent2 = "onunload"; } else { $attachEvent1 = "load"; $attachEvent2 = "onload"; } if ($popType == "popupMsg" || $popType == "chooseLang") { $event = "var popupMsgDiv = document.getElementById('popupMsg'); popupMsgDiv.style.zIndex = 1000; popupMsgDiv.style.display = 'block';"; } else { $event = "win = window.open ('index2.php?id=$row[popPageId]&lang=$lang', 'popup$row[id]', 'width=$row[popWidth]px,height=$row[popHeight]px,left=$row[popLeft]px,top=$row[popTop]px');"; if ($popType == "popunderLoad" || $popType == "popunderUnload") $event .= "\nwin.blur (); \nwindow.focus();"; else $event .= "\nwin.focus();"; } $js = ""; $js .= ""; $matchpoint = strpos($webpagetxt, "", 0); $webpagetxt = substr_replace($webpagetxt, "\n$js", $matchpoint, 6); if ($popType == "popupMsg" || $popType == "chooseLang") { $popupDiv = ""; $matchpoint = strpos($webpagetxt, "", 0); $webpagetxt = substr_replace($webpagetxt, "\n$popupDiv", $matchpoint, 7); } } } return $webpagetxt; } ?>