Ejemplo n.º 1
0
 public function get($typeSID)
 {
     // ƒл¤ показа баннера одного типа только 1 раз на странице
     if (!empty($this->_typeSids[$typeSID])) {
         return false;
     }
     if (!empty($_SESSION['SESS_SHOW_INCLUDE_TIME_EXEC'])) {
         $debugKey = $_SESSION['SESS_SHOW_INCLUDE_TIME_EXEC'];
         $_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] = 'N';
     }
     $cacheBlock = new CPHPCache();
     $url = CAdvBanner::GetCurUri();
     if (($pos = strpos(CAdvBanner::GetCurUri(), '?')) !== false) {
         $url = substr($url, 0, $pos);
     }
     $cacheId = $typeSID . '-' . $url;
     if ($cacheBlock->StartDataCache($this->_cacheTime, $cacheId, $this->_cacheDir)) {
         $result = CAdvBanner::Show($typeSID, '', '');
         $cacheBlock->EndDataCache(array('VARS' => $result));
     } else {
         $vars = $cacheBlock->GetVars();
         $result = $vars['VARS'];
     }
     if (!empty($_SESSION['SESS_SHOW_INCLUDE_TIME_EXEC'])) {
         $_SESSION['SESS_SHOW_INCLUDE_TIME_EXEC'] = $debugKey;
     }
     /*ѕодсчЄт показов*/
     if (empty($this->_typeSids[$typeSID])) {
         $this->_typeSids[$typeSID] = 1;
     } else {
         $this->_typeSids[$typeSID] = $this->_typeSids[$typeSID] + 1;
     }
     /**/
     return $result;
 }
Ejemplo n.º 2
0
 public static function GetPageWeights_RS()
 {
     $err_mess = CAdvBanner::err_mess() . "<br>Function: GetPageWeights_RS<br>Line: ";
     global $APPLICATION, $DB, $USER;
     $stat_adv_id = intval($_SESSION["SESS_LAST_ADV_ID"]);
     $stat_country_id = trim($_SESSION["SESS_COUNTRY_ID"]);
     $stat_city_id = intval($_SESSION["SESS_CITY_ID"]);
     if ($stat_city_id > 0 && CModule::IncludeModule('statistic')) {
         $rsCity = CCity::GetList(array(), array("=CITY_ID" => $stat_city_id));
         if ($arCity = $rsCity->Fetch()) {
             $stat_region = $arCity["REGION_NAME"];
         }
     }
     $new_guest = $_SESSION["SESS_GUEST_NEW"] == "N" ? "N" : "Y";
     $url = CAdvBanner::GetCurUri();
     $arrTime = getdate();
     $weekday = strtoupper($arrTime["weekday"]);
     $hour = intval($arrTime["hours"]);
     $strUserGroups = $USER->GetUserGroupString();
     $DONT_USE_CONTRACT = COption::GetOptionString("advertising", "DONT_USE_CONTRACT", "N");
     if ($DONT_USE_CONTRACT == "N") {
         $strSql = "\n\t\t\t\tSELECT DISTINCT\n\t\t\t\t\tB.TYPE_SID,\n\t\t\t\t\tB.ID\t\t\t\t\tBANNER_ID,\n\t\t\t\t\tB.WEIGHT\t\t\t\tBANNER_WEIGHT,\n\t\t\t\t\tB.SHOWS_FOR_VISITOR,\n\t\t\t\t\tB.FIX_CLICK,\n\t\t\t\t\tB.FIX_SHOW,\n\t\t\t\t\tB.KEYWORDS\t\t\t\tBANNER_KEYWORDS,\n\t\t\t\t\t" . $DB->DateToCharFunction("B.DATE_SHOW_FIRST") . "\t\tDATE_SHOW_FIRST,\n\t\t\t\t\t" . $DB->DateToCharFunction("B.DATE_SHOW_FROM") . "\t\t\tDATE_SHOW_FROM,\n\t\t\t\t\t" . $DB->DateToCharFunction("B.DATE_SHOW_TO") . "\t\t\tDATE_SHOW_TO,\n\t\t\t\t\tB.FLYUNIFORM\t\t\tFLYUNIFORM,\n\t\t\t\t\tB.MAX_SHOW_COUNT\t\tMAX_SHOW_COUNT,\n\t\t\t\t\tB.SHOW_COUNT\t\t\tSHOW_COUNT,\n\t\t\t\t\tC.ID\t\t\t\t\tCONTRACT_ID,\n\t\t\t\t\tC.WEIGHT\t\t\t\tCONTRACT_WEIGHT,\n\t\t\t\t\tC.KEYWORDS\t\t\t\tCONTRACT_KEYWORDS\n\t\t\t\tFROM\n\t\t\t\t\tb_adv_type T\n\n\t\t\t\tINNER JOIN b_adv_banner B ON (\n\t\t\t\t\t\tB.ACTIVE='Y'\n\t\t\t\t\tand\tB.TYPE_SID = T.SID\n\t\t\t\t\tand\tB.STATUS_SID = 'PUBLISHED'\n\t\t\t\t\tand (B.FOR_NEW_GUEST is null or B.FOR_NEW_GUEST='{$new_guest}')\n\t\t\t\t\tand\t(ifnull(B.MAX_SHOW_COUNT,0)>ifnull(B.SHOW_COUNT,0) or ifnull(B.MAX_SHOW_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_CLICK_COUNT,0)>ifnull(B.CLICK_COUNT,0) or ifnull(B.MAX_CLICK_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_VISITOR_COUNT,0)>ifnull(B.VISITOR_COUNT,0) or ifnull(B.MAX_VISITOR_COUNT,0)=0)\n\t\t\t\t\tand (B.DATE_SHOW_FROM<=now() or B.DATE_SHOW_FROM is null or length(B.DATE_SHOW_FROM)<=0)\n\t\t\t\t\tand (B.DATE_SHOW_TO>=now() or B.DATE_SHOW_TO is null or length(B.DATE_SHOW_TO)<=0))\n\n\t\t\t\tINNER JOIN b_adv_banner_2_site BS ON (\n\t\t\t\t\t\tBS.BANNER_ID = B.ID\n\t\t\t\t\tand BS.SITE_ID = '" . SITE_ID . "')\n\n\t\t\t\tINNER JOIN b_adv_contract C ON (\n\t\t\t\t\t\tC.ID = B.CONTRACT_ID\n\t\t\t\t\tand C.ACTIVE='Y'\n\t\t\t\t\tand\t(ifnull(C.MAX_SHOW_COUNT,0)>ifnull(C.SHOW_COUNT,0) or ifnull(C.MAX_SHOW_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(C.MAX_CLICK_COUNT,0)>ifnull(C.CLICK_COUNT,0) or ifnull(C.MAX_CLICK_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(C.MAX_VISITOR_COUNT,0)>ifnull(C.VISITOR_COUNT,0) or ifnull(C.MAX_VISITOR_COUNT,0)=0)\n\t\t\t\t\tand (C.DATE_SHOW_FROM<=now() or C.DATE_SHOW_FROM is null or length(C.DATE_SHOW_FROM)<=0)\n\t\t\t\t\tand (C.DATE_SHOW_TO>=now() or C.DATE_SHOW_TO is null or length(C.DATE_SHOW_TO)<=0))\n\n\t\t\t\tINNER JOIN b_adv_contract_2_site CS ON (\n\t\t\t\t\t\tCS.CONTRACT_ID = B.CONTRACT_ID\n\t\t\t\t\tand CS.SITE_ID = '" . SITE_ID . "')\n\n\t\t\t\tINNER JOIN b_adv_contract_2_type CT ON (\n\t\t\t\t\t\tCT.CONTRACT_ID = C.ID\n\t\t\t\t\tand (CT.TYPE_SID = 'ALL' or CT.TYPE_SID = T.SID))\n\n\t\t\t\tINNER JOIN b_adv_banner_2_weekday BW ON (\n\t\t\t\t\t\tBW.BANNER_ID = B.ID\n\t\t\t\t\tand BW.C_WEEKDAY='" . $DB->ForSql($weekday, 10) . "'\n\t\t\t\t\tand BW.C_HOUR = '{$hour}')\n\n\t\t\t\tINNER JOIN b_adv_contract_2_weekday CW ON (\n\t\t\t\t\t\tCW.CONTRACT_ID = C.ID\n\t\t\t\t\tand CW.C_WEEKDAY='" . $DB->ForSql($weekday, 10) . "'\n\t\t\t\t\tand CW.C_HOUR = '{$hour}')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_group UG1 ON (\n\t\t\t\t\t(UG1.BANNER_ID = B.ID\n\t\t\t\t\tand UG1.GROUP_ID in (" . $strUserGroups . ") and UG1.GROUP_ID<>2)\n\t\t\t\t)\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP1 ON (\n\t\t\t\t\t\tBP1.BANNER_ID = B.ID\n\t\t\t\t\tand BP1.SHOW_ON_PAGE='Y')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP2 ON (\n\t\t\t\t\t\tBP2.BANNER_ID = B.ID\n\t\t\t\t\tand BP2.SHOW_ON_PAGE='N'\n\t\t\t\t\tand '" . $DB->ForSQL($url) . "' like concat(BP2.PAGE, '%'))\n\n\t\t\t\tLEFT JOIN b_adv_contract_2_page\tCP1 ON (\n\t\t\t\t\t\tCP1.CONTRACT_ID = C.ID\n\t\t\t\t\tand CP1.SHOW_ON_PAGE='Y')\n\n\t\t\t\tLEFT JOIN b_adv_contract_2_page CP2 ON (\n\t\t\t\t\t\tCP2.CONTRACT_ID = C.ID\n\t\t\t\t\tand CP2.SHOW_ON_PAGE='N'\n\t\t\t\t\tand '" . $DB->ForSQL($url) . "' like concat(CP2.PAGE, '%'))\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_stat_adv\tBA\tON BA.BANNER_ID = B.ID\n\t\t\t\tLEFT JOIN b_adv_banner_2_country BC ON BC.BANNER_ID = B.ID AND (\n\t\t\t\t\t(\n\t\t\t\t\t\t(B.STAT_TYPE is null OR length(B.STAT_TYPE)=0 OR B.STAT_TYPE='COUNTRY')\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='REGION'\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t\tAND BC.REGION='" . $DB->ForSql($stat_region) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='CITY'\n\t\t\t\t\t\tAND BC.CITY_ID='" . intval($stat_city_id) . "'\n\t\t\t\t\t)\n\t\t\t\t)\n\n\t\t\t\tWHERE\n\t\t\t\t\tT.ACTIVE = 'Y'\n\n\t\t\t\tand (\n\t\t\t\t\tB.STAT_COUNT is null\n\t\t\t\t\tor B.STAT_COUNT = 0\n\t\t\t\t\tor BC.BANNER_ID is not null\n\t\t\t\t)\n\t\t\t\tand BP2.ID is null\n\t\t\t\tand CP2.ID is null\n\t\t\t\tand (BP1.ID is null or '" . $DB->ForSQL($url) . "' like concat(BP1.PAGE, '%'))\n\t\t\t\tand (CP1.ID is null or '" . $DB->ForSQL($url) . "' like concat(CP1.PAGE, '%'))\n\t\t\t\tand (BA.STAT_ADV_ID is null or BA.STAT_ADV_ID='" . $stat_adv_id . "')\n\t\t\t\tand (BC.COUNTRY_ID is null or BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "')\n\n\t\t\t\tand\n\t\t\t\t(\n\t\t\t\t\t(B.SHOW_USER_GROUP = 'Y' and UG1.GROUP_ID is not null)\n\t\t\t\t\tor\n\t\t\t\t\t(B.SHOW_USER_GROUP <> 'Y' and UG1.GROUP_ID is null)\n\t\t\t\t)\n\n\t\t\t\tORDER BY B.TYPE_SID desc, C.ID desc\n\t\t\t\t";
     } else {
         $strSql = "\n\t\t\t\tSELECT DISTINCT\n\t\t\t\t\tB.TYPE_SID,\n\t\t\t\t\tB.ID\t\t\t\t\tBANNER_ID,\n\t\t\t\t\tB.WEIGHT\t\t\t\tBANNER_WEIGHT,\n\t\t\t\t\tB.SHOWS_FOR_VISITOR,\n\t\t\t\t\tB.FIX_CLICK,\n\t\t\t\t\tB.FIX_SHOW,\n\t\t\t\t\tB.KEYWORDS\t\t\t\tBANNER_KEYWORDS\n\t\t\t\tFROM\n\t\t\t\t\tb_adv_type T\n\n\t\t\t\tINNER JOIN b_adv_banner B ON (\n\t\t\t\t\t\tB.ACTIVE='Y'\n\t\t\t\t\tand\tB.TYPE_SID = T.SID\n\t\t\t\t\tand\tB.STATUS_SID = 'PUBLISHED'\n\t\t\t\t\tand (B.FOR_NEW_GUEST is null or B.FOR_NEW_GUEST='{$new_guest}')\n\t\t\t\t\tand\t(ifnull(B.MAX_SHOW_COUNT,0)>ifnull(B.SHOW_COUNT,0) or ifnull(B.MAX_SHOW_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_CLICK_COUNT,0)>ifnull(B.CLICK_COUNT,0) or ifnull(B.MAX_CLICK_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_VISITOR_COUNT,0)>ifnull(B.VISITOR_COUNT,0) or ifnull(B.MAX_VISITOR_COUNT,0)=0)\n\t\t\t\t\tand (B.DATE_SHOW_FROM<=now() or B.DATE_SHOW_FROM is null or length(B.DATE_SHOW_FROM)<=0)\n\t\t\t\t\tand (B.DATE_SHOW_TO>=now() or B.DATE_SHOW_TO is null or length(B.DATE_SHOW_TO)<=0))\n\n\t\t\t\tINNER JOIN b_adv_banner_2_site BS ON (\n\t\t\t\t\t\tBS.BANNER_ID = B.ID\n\t\t\t\t\tand BS.SITE_ID = '" . SITE_ID . "')\n\n\t\t\t\tINNER JOIN b_adv_banner_2_weekday BW ON (\n\t\t\t\t\t\tBW.BANNER_ID = B.ID\n\t\t\t\t\tand BW.C_WEEKDAY='" . $DB->ForSql($weekday, 10) . "'\n\t\t\t\t\tand BW.C_HOUR = '{$hour}')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_group UG1 ON (\n\t\t\t\t\t(UG1.BANNER_ID = B.ID\n\t\t\t\t\tand UG1.GROUP_ID in (" . $strUserGroups . ") and UG1.GROUP_ID<>2)\n\t\t\t\t)\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP1 ON (\n\t\t\t\t\t\tBP1.BANNER_ID = B.ID\n\t\t\t\t\tand BP1.SHOW_ON_PAGE='Y')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP2 ON (\n\t\t\t\t\t\tBP2.BANNER_ID = B.ID\n\t\t\t\t\tand BP2.SHOW_ON_PAGE='N'\n\t\t\t\t\tand '" . $DB->ForSQL($url) . "' like concat(BP2.PAGE, '%'))\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_stat_adv\tBA\tON BA.BANNER_ID = B.ID\n\t\t\t\tLEFT JOIN b_adv_banner_2_country BC ON BC.BANNER_ID = B.ID AND (\n\t\t\t\t\t(\n\t\t\t\t\t\t(B.STAT_TYPE is null OR length(B.STAT_TYPE)=0 OR B.STAT_TYPE='COUNTRY')\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='REGION'\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t\tAND BC.REGION='" . $DB->ForSql($stat_region) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='CITY'\n\t\t\t\t\t\tAND BC.CITY_ID='" . intval($stat_city_id) . "'\n\t\t\t\t\t)\n\t\t\t\t)\n\n\t\t\t\tWHERE\n\t\t\t\t\tT.ACTIVE = 'Y'\n\n\t\t\t\tand (\n\t\t\t\t\tB.STAT_COUNT is null\n\t\t\t\t\tor B.STAT_COUNT = 0\n\t\t\t\t\tor BC.BANNER_ID is not null\n\t\t\t\t)\n\t\t\t\tand BP2.ID is null\n\t\t\t\tand (BP1.ID is null or '" . $DB->ForSQL($url) . "' like concat(BP1.PAGE, '%'))\n\t\t\t\tand (BA.STAT_ADV_ID is null or BA.STAT_ADV_ID='" . $stat_adv_id . "')\n\t\t\t\tand (BC.COUNTRY_ID is null or BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "')\n\t\t\t\tand\n\t\t\t\t(\n\t\t\t\t\t(B.SHOW_USER_GROUP = 'Y' and UG1.GROUP_ID is not null)\n\t\t\t\t\tor\n\t\t\t\t\t(B.SHOW_USER_GROUP <> 'Y' and UG1.GROUP_ID is null)\n\t\t\t\t)\n\t\t\t\tORDER BY B.TYPE_SID desc";
     }
     $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $rs;
 }