Advertisement
Axxxxxx

phone_1

Aug 2nd, 2017
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <div style="color:white">
  2. <?
  3.  
  4. $start = microtime(true);
  5.  
  6. $cookieCity = trim(htmlspecialchars($_COOKIE['gorod']));
  7.  
  8. $basePhone = "+7 (800) 200-36-90 ";
  9.  
  10.  
  11. //echo '____'.$cookieCity;
  12. $cache_id = md5($cookieCity);
  13. $cacheTime = 3600;
  14. $cachePath = 'city_'.$cache_id;
  15. $obCache = new CPHPCache();
  16.  
  17. if ($obCache->InitCache($cacheTime, $cacheId, $cachePath))
  18. {
  19. $arResult = $obCache->GetVars();
  20. $obCache->Output();
  21. }
  22. else
  23. {
  24. $obCache->StartDataCache();
  25. $arSelect = Array("ID","PROPERTY_TELEFON","PROPERTY_GOROD");
  26. $arFilter = Array("IBLOCK_ID"=>3, "NAME"=>$cookieCity, "ACTIVE"=>"Y");
  27. $arFilter = Array("IBLOCK_ID"=>3, "PROPERTY_GOROD"=>$cookieCity, "ACTIVE"=>"Y");
  28. $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nTopCount"=>50), $arSelect);
  29.  
  30. while($ob = $res->GetNextElement())
  31. {
  32. $arFields = $ob->GetFields();
  33. /* myprint_r($arFields['PROPERTY_TELEFON_VALUE'],2);
  34. myprint_r($arFields['PROPERTY_GOROD_VALUE'],2);*/
  35. $phones = $arFields['PROPERTY_TELEFON_VALUE'];
  36.  
  37. }
  38. $phones = explode(',', $phones);
  39. //print_r($phones);
  40. ?>
  41.  
  42. <? if ( $cookieCity!=='Минск' and $cookieCity!=='Москва'){ // не показываем телефон 8800 для москвы и минска?>
  43. <div class="phone-container"><a class="phone" href="tel:<?= $basePhone ?>"><?= $basePhone; ?></a></div>
  44. <?}?>
  45. <div class="phone-container"><a class="phone" href="tel:<?= $phones[0]?>"><?= $phones[0] ?></a></div>
  46. <? if ( $cookieCity=='Минск'){?>
  47. <div class="phone-container"><a class="phone" href="tel:<?= $phones[1]?>"><?= $phones[1] ?></a></div>
  48. <?}?>
  49. <?
  50. $obCache->EndDataCache(array("myDBResult"=>$arMyResult));
  51. }
  52.  
  53. $time = microtime(true) - $start;
  54. printf('Скрипт выполнялся %.4F сек.', $time);
  55. ?>
  56. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement