function CurrencyFormatNumber($price, $currency) { $arCurFormat = CCurrencyLang::GetCurrencyFormat($currency); if (!isset($arCurFormat["DECIMALS"])) { $arCurFormat["DECIMALS"] = 2; } $arCurFormat["DECIMALS"] = IntVal($arCurFormat["DECIMALS"]); if (!isset($arCurFormat["DEC_POINT"])) { $arCurFormat["DEC_POINT"] = "."; } if (!empty($arCurFormat["THOUSANDS_VARIANT"])) { if ($arCurFormat["THOUSANDS_VARIANT"] == "N") { $arCurFormat["THOUSANDS_SEP"] = ""; } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "D") { $arCurFormat["THOUSANDS_SEP"] = "."; } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "C") { $arCurFormat["THOUSANDS_SEP"] = ","; } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "S") { $arCurFormat["THOUSANDS_SEP"] = chr(32); } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "B") { $arCurFormat["THOUSANDS_SEP"] = chr(32); } } if (!isset($arCurFormat["FORMAT_STRING"])) { $arCurFormat["FORMAT_STRING"] = "#"; } $price = number_format($price, $arCurFormat["DECIMALS"], $arCurFormat["DEC_POINT"], $arCurFormat["THOUSANDS_SEP"]); if ($arCurFormat["THOUSANDS_VARIANT"] == "B") { $num = str_replace(" ", " ", $num); } $price = str_replace(',', '.', $price); return $price; }
public static function Show() { IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/interface/prolog_main_admin.php'); $supportFinishDate = COption::GetOptionString('main', '~support_finish_date', ''); if ($supportFinishDate != '' && is_array($aSupportFinishDate = ParseDate($supportFinishDate, 'ymd'))) { $aGlobalOpt = CUserOptions::GetOption("global", "settings", array()); if ($aGlobalOpt['messages']['support'] != 'N') { $supportFinishStamp = mktime(0, 0, 0, $aSupportFinishDate[1], $aSupportFinishDate[0], $aSupportFinishDate[2]); $supportDateDiff = ceil(($supportFinishStamp - time()) / 86400); $sSupportMess = ''; $sSupWIT = " (<span onclick=\"BX.toggle(BX('supdescr'))\" style='border-bottom: 1px dashed #1c91e7; color: #1c91e7; cursor: pointer;'>" . GetMessage("prolog_main_support_wit") . "</span>)"; if ($supportDateDiff >= 0 && $supportDateDiff <= 30) { $sSupportMess = GetMessage("prolog_main_support11", array('#FINISH_DATE#' => GetTime($supportFinishStamp), '#DAYS_AGO#' => $supportDateDiff == 0 ? GetMessage("prolog_main_today") : GetMessage('prolog_main_support_days', array('#N_DAYS_AGO#' => $supportDateDiff)), '#LICENSE_KEY#' => md5(LICENSE_KEY), '#WHAT_IS_IT#' => $sSupWIT, '#SUP_FINISH_DATE#' => GetTime(mktime(0, 0, 0, $aSupportFinishDate[1] + 1, $aSupportFinishDate[0], $aSupportFinishDate[2])))); } elseif ($supportDateDiff < 0 && $supportDateDiff >= -30) { $sSupportMess = GetMessage("prolog_main_support21", array('#FINISH_DATE#' => GetTime($supportFinishStamp), '#DAYS_AGO#' => -$supportDateDiff, '#LICENSE_KEY#' => md5(LICENSE_KEY), '#WHAT_IS_IT#' => $sSupWIT, '#SUP_FINISH_DATE#' => GetTime(mktime(0, 0, 0, $aSupportFinishDate[1] + 1, $aSupportFinishDate[0], $aSupportFinishDate[2])))); } elseif ($supportDateDiff < -30) { $sSupportMess = GetMessage("prolog_main_support31", array('#FINISH_DATE#' => GetTime($supportFinishStamp), '#LICENSE_KEY#' => md5(LICENSE_KEY), '#WHAT_IS_IT#' => $sSupWIT)); } if ($sSupportMess != '') { $sSupportMess .= GetMessage('ACRIT_EXPORTPRO_BUY_LICENCE'); $userOption = CUserOptions::GetOption("main", "admSupInf"); if (mktime() > $userOption["showInformerDate"]) { $prolongUrl = "/bitrix/admin/buy_support.php?lang=" . LANGUAGE_ID; if (!in_array(LANGUAGE_ID, array("ru", "ua")) || IntVal(COption::GetOptionString("main", "~PARAM_PARTNER_ID")) <= 0) { require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/update_client.php"; $prolongUrl = "http://www.acrit-studio.ru/shop/list/lupd/"; } echo BeginNote('style="position: relative; top: -15px;"'); ?> <div style="float: right; padding-left: 50px; margin-top: -5px; text-align: center;"> <a href="<?php echo $prolongUrl; ?> " target="_blank" class="adm-btn adm-btn-save" style="margin-bottom: 4px;"><?php echo GetMessage("prolog_main_support_button_prolong"); ?> </a><br /> <a href="http://www.acrit-studio.ru/market/" target="_blank"><?php echo GetMessage("prolog_main_support_button_prolong_modules"); ?> </a> </div> <?php echo $sSupportMess; ?> <div id="supdescr" style="display: none;"><br /><br /><b><?php echo GetMessage("prolog_main_support_wit_descr1"); ?> </b><hr><?php echo GetMessage("prolog_main_support_wit_descr2"); ?> </div> <?php echo EndNote(); } } } } }
public static function Set($userID, $code, $value = false) { global $DB; if (!CSocNetGroup::__ValidateID($userID)) { return false; } $userID = IntVal($userID); $code = trim($code); if ($userID <= 0 || strlen($code) <= 0) { return false; } $value = $value == "Y" ? "Y" : "N"; $rsSubscription = CSocNetSubscription::GetList(array(), array("USER_ID" => $userID, "CODE" => $code)); if ($arSubscription = $rsSubscription->Fetch()) { if ($value != "Y") { CSocNetSubscription::Delete($arSubscription["ID"]); } } else { if ($value == "Y") { CSocNetSubscription::Add(array("USER_ID" => $userID, "CODE" => $code)); } } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_subscription_" . $code); } return true; }
public function CheckPrivileges($testPrivileges, $principal, $calendarId) { if (is_object($principal) && $principal instanceof CDavPrincipal) { $principal = $principal->Id(); } if (!is_numeric($principal)) { return false; } $principal = IntVal($principal); $calendarIdNorm = implode("-", $calendarId); static $arCalendarPrivilegesCache = array(); if (!isset($arCalendarPrivilegesCache[$calendarIdNorm][$principal])) { $arPriv = array(); // $arPrivOrig = array('bAccess' => true/false, 'bReadOnly' => true/false, 'privateStatus' => 'time'/'title'); $arPrivOrig = CCalendar::GetUserPermissionsForCalendar($calendarId, $principal); if ($arPrivOrig['bAccess']) { $arPriv[] = 'urn:ietf:params:xml:ns:caldav:read-free-busy'; if (!isset($arPrivOrig['privateStatus']) || $arPrivOrig['privateStatus'] != 'time') { $arPriv[] = 'DAV::read'; } if (!$arPrivOrig['bReadOnly']) { $arPriv[] = 'DAV:write'; $arPriv[] = 'DAV:bind'; $arPriv[] = 'DAV:unbind'; $arPriv[] = 'DAV:write-properties'; $arPriv[] = 'DAV:write-content'; } } $arCalendarPrivilegesCache[$calendarIdNorm][$principal] = CDav::PackPrivileges($arPriv); } $testPrivilegesBits = CDav::PackPrivileges($testPrivileges); return ($arCalendarPrivilegesCache[$calendarIdNorm][$principal] & $testPrivilegesBits) > 0; }
function OnSearchGetURL($arFields) { global $DB, $BX_NEWS_DETAIL_URL, $BX_NEWS_SECTION_URL; static $arIBlockCache = array(); if ($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=") { return $arFields["URL"]; } if (!CModule::IncludeModule('iblock')) { return ""; } $IBLOCK_ID = IntVal($arFields["PARAM2"]); if (!array_key_exists($IBLOCK_ID, $arIBlockCache)) { $res = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tDETAIL_PAGE_URL,\n\t\t\t\t\tSECTION_PAGE_URL,\n\t\t\t\t\tCODE as IBLOCK_CODE,\n\t\t\t\t\tXML_ID as IBLOCK_EXTERNAL_ID,\n\t\t\t\t\tIBLOCK_TYPE_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock\n\t\t\t\tWHERE ID = " . $IBLOCK_ID . "\n\t\t\t"); $arIBlockCache[$IBLOCK_ID] = $res->Fetch(); } if (!is_array($arIBlockCache[$IBLOCK_ID])) { return ""; } $arFields["URL"] = LTrim($arFields["URL"], " ="); parse_str($arFields["URL"], $arr); $arr = $arIBlockCache[$IBLOCK_ID] + $arr; $arr["LANG_DIR"] = $arFields["DIR"]; if (substr($arFields["ITEM_ID"], 0, 1) !== 'S') { return CIBlock::ReplaceDetailUrl($BX_NEWS_DETAIL_URL, $arr, true, "E"); } else { return CIBlock::ReplaceDetailUrl($BX_NEWS_SECTION_URL, $arr, true, "S"); } }
function Get_Fancy_Images($orderby = 'ID', $order = 'ASC', $limit = -1) { global $wpdb; // Check Parameters if (!$orderby) { $orderby = 'ID'; } if (!In_Array($order, array('ASC', 'DESC', 'RAND'))) { $order = 'ASC'; } $limit = IntVal($limit); // Build Statement $stmt = ' SELECT attachment.*, gallery.ID gallery_id FROM ' . $wpdb->posts . ' attachment, ' . $wpdb->posts . ' gallery WHERE attachment.post_type = "attachment" AND attachment.post_mime_type LIKE "image/%" AND gallery.post_type = "' . $this->fancy_gallery->gallery_post_type . '" AND attachment.post_parent = gallery.ID GROUP BY attachment.ID '; if ($order == 'RAND') { $stmt .= 'ORDER BY RAND() '; } else { $stmt .= 'ORDER BY attachment.' . $orderby . ' ' . $order . ' '; } if ($limit > 0) { $stmt .= 'LIMIT ' . $limit; } return $wpdb->Get_Results($stmt); }
public function parse($fraktion_id, $wahlperiode_id) { $fraktion_id = IntVal($fraktion_id); $wahlperiode_id = IntVal($wahlperiode_id); if (SITE_CALL_MODE != "cron") { echo "- Fraktion {$fraktion_id}\n"; } $html_details = RISTools::load_file("http://www.ris-muenchen.de/RII/RII/ris_fraktionen_detail.jsp?risid={$fraktion_id}&periodeid={$wahlperiode_id}"); $daten = new Fraktion(); $daten->id = $fraktion_id; if (preg_match("/introheadline\">(.*)<\\/h3/siU", $html_details, $matches)) { var_dump($matches); $daten->name = trim(str_replace(" ", " ", $matches[1])); } $aenderungen = ""; /** @var Fraktion $alter_eintrag */ $alter_eintrag = Fraktion::model()->findByPk($fraktion_id); $changed = true; if ($alter_eintrag) { $changed = false; if ($alter_eintrag->name != $daten->name) { $aenderungen .= "Name: " . $alter_eintrag->name . " => " . $daten->name . "\n"; } if ($aenderungen != "") { $changed = true; } } if ($changed) { if ($aenderungen == "") { $aenderungen = "Neu angelegt\n"; } } if ($alter_eintrag) { $alter_eintrag->setAttributes($daten->getAttributes(), false); if (!$alter_eintrag->save()) { echo "Fraktion 1\n"; var_dump($alter_eintrag->getErrors()); die("Fehler"); } $daten = $alter_eintrag; } else { if (!$daten->save()) { echo "Fraktion 2\n"; var_dump($daten->getErrors()); die("Fehler"); } } if ($aenderungen != "") { echo "Fraktion {$fraktion_id}: Verändert: " . $aenderungen . "\n"; } if ($aenderungen != "") { $aend = new RISAenderung(); $aend->ris_id = $daten->id; $aend->ba_nr = null; $aend->typ = RISAenderung::$TYP_STADTRAT_FRAKTION; $aend->datum = new CDbExpression("NOW()"); $aend->aenderungen = $aenderungen; $aend->save(); } }
function SelectServerSettingsByService($ServiceID) { #------------------------------------------------------------------------------- $Service = DB_Select('Services', array('ID', 'Code', 'Name'), array('UNIQ', 'ID' => IntVal($ServiceID))); switch (ValueOf($Service)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return new gException('SERVICE_NOT_FOUND', SPrintF('Сервис (%s) не существует', $ServiceID)); case 'array': break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $ServersGroup = DB_Select('ServersGroups', '*', array('UNIQ', 'Where' => SPrintF('`ServiceID` = %u', $ServiceID), 'Limits' => array(0, 1), 'SortOn' => 'SortID')); #------------------------------------------------------------------------------- switch (ValueOf($ServersGroup)) { case 'error': return ERROR | @Trigger_Error('[Server->SelectServerByService]: не удалось выбрать группу серверов'); case 'exception': return new gException('SERVICE_ServersGroups_NOT_FOUND', 'Для данного сервиса нет групп серверов'); case 'array': #------------------------------------------------------------------------------- return SelectServerSettings($ServersGroup['ID']); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- }
function QueryMinecraft($IP, $Port = 25565, $Timeout = 2) { $Socket = Socket_Create(AF_INET, SOCK_STREAM, SOL_TCP); Socket_Set_Option($Socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => (int) $Timeout, 'usec' => 0)); Socket_Set_Option($Socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => (int) $Timeout, 'usec' => 0)); if ($Socket === FALSE || @Socket_Connect($Socket, $IP, (int) $Port) === FALSE) { return FALSE; } Socket_Send($Socket, "þ", 2, 0); $Len = Socket_Recv($Socket, $Data, 512, 0); Socket_Close($Socket); if ($Len < 4 || $Data[0] !== "ÿ") { return FALSE; } $Data = SubStr($Data, 3); // Strip packet header (kick message packet and short length) $Data = iconv('UTF-16BE', 'UTF-8', $Data); // Are we dealing with Minecraft 1.4+ server? if ($Data[1] === "§" && $Data[2] === "1") { $Data = Explode("", $Data); return array('HostName' => $Data[3], 'Players' => IntVal($Data[4]), 'MaxPlayers' => IntVal($Data[5]), 'Protocol' => IntVal($Data[1]), 'Version' => $Data[2]); } $Data = Explode("§", $Data); return array('HostName' => SubStr($Data[0], 0, -1), 'Players' => isset($Data[1]) ? IntVal($Data[1]) : 0, 'MaxPlayers' => isset($Data[2]) ? IntVal($Data[2]) : 0, 'Protocol' => 0, 'Version' => '1.3'); }
/** * @param string $filename * @return array */ public static function document_pdf_metadata($filename) { $result = []; exec(PATH_PDFINFO . " '" . addslashes($filename) . "'", $result); $seiten = 0; $datum = ""; if (preg_match("/Pages:\\s*([0-9]+)/siu", implode("\n", $result), $matches_page)) { $seiten = IntVal($matches_page[1]); } if (preg_match("/CreationDate:\\s*([a-z0-9 :]+)\n/siu", implode("\n", $result), $matches_date)) { $datum = date_parse($matches_date[1]); if ($datum && isset($datum["year"]) && $datum["year"] > 1990) { $datum = $datum["year"] . "-" . $datum["month"] . "-" . $datum["day"] . " " . $datum["hour"] . ":" . $datum["minute"] . ":" . $datum["second"]; } else { $datum = "0000-00-00 00:00:00"; } } if ($seiten > 0) { return ["seiten" => $seiten, "datum" => $datum]; } $result = []; exec(PATH_IDENTIFY . " {$filename}", $result); $anzahl = 0; foreach ($result as $res) { if (strpos($res, "DirectClass")) { $anzahl++; } } return ["seiten" => $anzahl, "datum" => $datum]; }
public function run($args) { if (count($args) == 0) { die("./yii recalc_ort2ba [Orts-ID|alle]\n"); } if ($args[0] == "alle") { /** @var OrtGeo[] $orte */ $orte = OrtGeo::model()->findAll(["order" => "id"]); } else { /** @var OrtGeo[] $orte */ $orte = OrtGeo::model()->findAll(["condition" => "id = " . IntVal($args[0])]); } /** @var Bezirksausschuss[] $bas */ $bas = Bezirksausschuss::model()->findAll(); foreach ($orte as $ort) { $found_ba = null; foreach ($bas as $ba) { if ($ba->pointInBA($ort->lon, $ort->lat)) { echo $ort->id . " - " . $ort->ort . ": " . $ba->ba_nr . "\n"; $found_ba = $ba->ba_nr; } } if ($found_ba) { $ort->ba_nr = $found_ba; $ort->save(); } } }
function ForumNumberRusEnding($num) { if (LANGUAGE_ID == "ru") { if (strlen($num)>1 && substr($num, strlen($num)-2, 1)=="1") { return GetMessage("F_ENDING_OV"); } else { $c = IntVal(substr($num, strlen($num)-1, 1)); if ($c==0 || ($c>=5 && $c<=9)) return GetMessage("F_ENDING_OV"); elseif ($c==1) return ""; else return GetMessage("F_ENDING_A"); } } else { if (IntVal($num)>1) return "s"; return ""; } }
protected function process(ViewBag $viewbag) { $movie = $this->movie; $list = $this->list; $im = imagecreate($this->W, $this->H); $background_color = imagecolorallocate($im, 0xc0, 0xc0, 0xc0); imagefilledrectangle($im, 0, 0, $this->W - 1, $this->H - 1, $background_color); $black = imagecolorallocate($im, 0, 0, 0); imagerectangle($im, 0, 0, $this->W - 1, $this->H - 1, $black); $red = imagecolorallocate($im, 0xc0, 0, 0); $max = $movie->getMaxSeek(); $scale = DoubleVal($this->W) / DoubleVal($max); foreach ($list->getCutRegions() as $v) { $left = $v[0]; $right = $v[1]; if ($right == -1) { $right = $max; } $x1 = IntVal($left * $scale); $x2 = min($this->W - 1, IntVal($right * $scale)); imagefilledrectangle($im, $x1, 1, $x2, $this->H - 2, $red); } header("Content-Type: image/png"); header("Cache-Control: must-revalidate"); imagepng($im); exit; }
public function run($args) { define("VERYFAST", true); if (count($args) == 0) { die("./yii recalc_documents [Dokument-ID|alle]\n"); } if ($args[0] == "alle") { $sql = Yii::app()->db->createCommand(); $sql->select("id")->from("dokumente")->where("id >= 579866")->order("id"); $data = $sql->queryColumn(["id"]); } else { $data = [IntVal($args[0])]; } $anz = count($data); foreach ($data as $nr => $dok_id) { echo "{$nr} / {$anz} => {$dok_id}\n"; /** @var Dokument $dokument */ $dokument = Dokument::model()->findByPk($dok_id); if (!$dokument) { continue; } $dokument->download_if_necessary(); $dokument->geo_extract(); $absolute_filename = $dokument->getLocalPath(); $metadata = RISPDF2Text::document_pdf_metadata($absolute_filename); $dokument->seiten_anzahl = $metadata["seiten"]; $dokument->datum_dokument = $metadata["datum"]; $dokument->save(); echo $dokument->id . " => " . $dokument->seiten_anzahl . " / " . $dokument->datum_dokument . "\n"; } }
public static function Update($ID, $arFields) { global $DB; $ID = IntVal($ID); if ($ID <= 0) { return False; } $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CSaleAffiliateTransact::CheckFields("UPDATE", $arFields, $ID)) { return false; } $strUpdate = $DB->PrepareUpdate("b_sale_affiliate_transact", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strUpdate .= $key . "=" . $value . " "; } $strSql = "UPDATE b_sale_affiliate_transact SET " . $strUpdate . " WHERE ID = " . $ID . " "; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); return $ID; }
public static function OnGetRatingContentOwner($arParams) { if ($arParams['ENTITY_TYPE_ID'] == 'USER') { return IntVal($arParams['ENTITY_ID']); } return false; }
public static function AddByChannel($channelId, $arParams = array()) { global $DB; if (!is_array($channelId)) { $channelId = array($channelId); } $result = false; if (strlen($arParams['module_id']) > 0 || strlen($arParams['command']) > 0) { $arData = array('module_id' => $arParams['module_id'], 'command' => $arParams['command'], 'params' => is_array($arParams['params']) ? $arParams['params'] : array()); if (CPullOptions::GetQueueServerStatus()) { $command = array('SERVER_TIME_WEB' => time(), 'SERVER_NAME' => COption::GetOptionString('main', 'server_name', $_SERVER['SERVER_NAME']), 'MESSAGE' => array($arData), 'ERROR' => ''); if (!is_array($channelId) && CPullOptions::GetQueueServerVersion() == 1) { $command['CHANNEL_ID'] = $channelId; } $message = CUtil::PhpToJsObject($command); if (!defined('BX_UTF') || !BX_UTF) { $message = $GLOBALS['APPLICATION']->ConvertCharset($message, SITE_CHARSET, 'utf-8'); } $options = isset($arParams['expiry']) ? array('expiry' => intval($arParams['expiry'])) : array(); $res = CPullChannel::Send($channelId, str_replace("\n", " ", $message), $options); $result = $res ? true : false; } else { foreach ($channelId as $channel) { $arParams = array('CHANNEL_ID' => $channel, 'MESSAGE' => str_replace("\n", " ", serialize($arData)), '~DATE_CREATE' => $DB->CurrentTimeFunction()); $res = IntVal($DB->Add("b_pull_stack", $arParams, array("MESSAGE"))); $result = $res ? true : false; } } return $result; } return false; }
public function run($args) { if (!isset($args[0])) { die("./yiic reindexsolr_documents [id]|stadtrat_beschluss|ba_beschluss|alle [offset]\n"); } if ($args[0] > 0) { $data = [$args[0]]; } elseif ($args[0] == "alle") { $sql = Yii::app()->db->createCommand(); $sql->select("id")->from("dokumente")->where("id >= 0")->order("id"); $data = $sql->queryColumn(["id"]); } elseif (isset(Dokument::$TYPEN_ALLE[$args[0]])) { $sql = Yii::app()->db->createCommand(); $sql->select("id")->from("dokumente")->where("typ = '" . addslashes($args[0]) . "'")->order("id"); $data = $sql->queryColumn(["id"]); } else { die("./yiic reindexsolr_documents [id]|stadtrat_beschluss|ba_beschluss|rathausumschau|alle\n"); } $offset = isset($args[1]) && $args[1] > 0 ? IntVal($args[1]) : 0; $anz = count($data); for ($i = $offset; $i < $anz; $i++) { $dok_id = $data[$i]; echo "{$i} / {$anz} => {$dok_id}\n"; /** @var Dokument $dokument */ $dokument = Dokument::model()->findByPk($dok_id); $dokument->solrIndex(); } }
public static function GetByID($ID) { global $DB; $ID = IntVal($ID); if (isset($GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_".$ID]) && is_array($GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_".$ID]) && is_set($GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_".$ID], "ID")) { return $GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_".$ID]; } else { $strSql = "SELECT P.ID, P.SITE_ID, P.PATH, P.TYPE ". "FROM b_blog_site_path P ". "WHERE P.ID = ".$ID.""; $dbResult = $DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__); if ($arResult = $dbResult->Fetch()) { $GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH_CACHE_".$ID] = $arResult; $GLOBALS["BLOG_SITE_PATH"]["BLOG_SITE_PATH1_CACHE_".$arResult["SITE_ID"]] = $arResult; return $arResult; } } return False; }
function BasketNumberWordEndings($num, $lang = false, $arEnds = false) { if ($lang === false) { $lang = LANGUAGE_ID; } if ($arEnds === false) { $arEnds = array(GetMessage("TSB1_WORD_OBNOVL_END1"), GetMessage("TSB1_WORD_OBNOVL_END2"), GetMessage("TSB1_WORD_OBNOVL_END3"), GetMessage("TSB1_WORD_OBNOVL_END4")); } if ($lang == "ru") { if (strlen($num) > 1 && substr($num, strlen($num) - 2, 1) == "1") { return $arEnds[0]; } else { $c = IntVal(substr($num, strlen($num) - 1, 1)); if ($c == 0 || $c >= 5 && $c <= 9) { return $arEnds[1]; } elseif ($c == 1) { return $arEnds[2]; } else { return $arEnds[3]; } } } elseif ($lang == "en") { if (IntVal($num) > 1) { return "s"; } return ""; } else { return ""; } }
function NavQuery($arNavParams, $arQuerySelect, $strTableName, $strQueryWhere, $arQueryOrder) { global $DB; if (IntVal($arNavParams["nTopCount"]) <= 0) { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tcount(1) C\n\t\t\t\tFROM\n\t\t\t\t\t" . $strTableName . " t\n\t\t\t"; if ($strQueryWhere) { $strSql .= "\n\t\t\t\t\tWHERE\n\t\t\t\t\t" . $strQueryWhere . "\n\t\t\t\t"; } $res_cnt = $DB->Query($strSql); $res_cnt = $res_cnt->Fetch(); $cnt = $res_cnt["C"]; $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t" . implode(", ", $arQuerySelect) . "\n\t\t\t\tFROM\n\t\t\t\t\t" . $strTableName . " t\n\t\t\t"; if ($strQueryWhere) { $strSql .= "\n\t\t\t\t\tWHERE\n\t\t\t\t\t" . $strQueryWhere . "\n\t\t\t\t"; } if (count($arQueryOrder) > 0) { $strSql .= "\n\t\t\t\t\tORDER BY\n\t\t\t\t\t" . implode(", ", $arQueryOrder) . "\n\t\t\t\t"; } $res = new CDBResult(); $res->NavQuery($strSql, $cnt, $arNavParams); return $res; } else { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t" . implode(", ", $arQuerySelect) . "\n\t\t\t\tFROM\n\t\t\t\t\t" . $strTableName . " t\n\t\t\t"; if ($strQueryWhere) { $strSql .= "\n\t\t\t\t\tWHERE\n\t\t\t\t\t" . $strQueryWhere . "\n\t\t\t\t"; } if (count($arQueryOrder) > 0) { $strSql .= "\n\t\t\t\t\tORDER BY\n\t\t\t\t\t" . implode(", ", $arQueryOrder) . "\n\t\t\t\t"; } return $DB->Query($DB->TopSql($strSql, intval($arNavParams["nTopCount"]))); } }
function GetCity($arFields) { $iPPID = IntVal($arFields["PP_ID"]) ? IntVal($arFields["PP_ID"]) : 0; $iID = 0; $iBXCityID = 0; $sCode = strlen($arFields["CODE"]) ? $arFields["CODE"] : ""; $iPrice = 0; $sActive = "N"; if ($iPPID) { $obPPCity = CPickpoint::SelectCityByPPID($iPPID); if ($arPPCity = $obPPCity->Fetch()) { $iBXID = $arPPCity["BX_ID"]; if ($arPPCity["ACTIVE"] == "Y") { $sActive = "Y"; } $arBXCity = CPickpoint::SelectCityByID($iBXID); $iPrice = FloatVal($arPPCity["PRICE"]); $sCode = $arBXCity["CITY_NAME"]; } else { $arCity = CPickpoint::SelectCityByCode($sCode); $iBXID = $arCity["ID"]; } } else { $arCity = CPickpoint::SelectCityByCode($sCode); $iBXID = $arCity["ID"]; $iPPID = 0; } #ID# #CODE (BX or PP ? exists)# #PP_ID# #BX_ID# #PRICE# return array("ID" => $iID, "CODE" => $sCode, "PP_ID" => $iPPID, "BX_ID" => $iBXID, "PRICE" => $iPrice, "ACTIVE" => $sActive); }
function ConvertCurrency($valSum, $curFrom, $curTo, $valDate = "") { global $DB; if (strlen($valDate) <= 0) { $valDate = date("Y-m-d"); } list($dpYear, $dpMonth, $dpDay) = split("-", $valDate, 3); $dpDay += 1; $valDate = date("Y-m-d", mktime(0, 0, 0, $dpMonth, $dpDay, $dpYear)); $curFromRate = 0; $curFromRateCnt = 0; $strSql = "SELECT C.AMOUNT, C.AMOUNT_CNT, CR.RATE, CR.RATE_CNT " . "FROM b_catalog_currency C " . "\tLEFT JOIN b_catalog_currency_rate CR " . "\t\tON (C.CURRENCY = CR.CURRENCY AND CR.DATE_RATE < '" . $valDate . "') " . "WHERE C.CURRENCY = '" . $DB->ForSql($curFrom) . "' " . "ORDER BY DATE_RATE DESC"; $db_res = $DB->Query($strSql); if ($res = $db_res->Fetch()) { $curFromRate = DoubleVal($res["RATE"]); $curFromRateCnt = IntVal($res["RATE_CNT"]); if ($curFromRate <= 0) { $curFromRate = DoubleVal($res["AMOUNT"]); $curFromRateCnt = IntVal($res["AMOUNT_CNT"]); } } $curToRate = 0; $curToRateCnt = 0; $strSql = "SELECT C.AMOUNT, C.AMOUNT_CNT, CR.RATE, CR.RATE_CNT " . "FROM b_catalog_currency C " . "\tLEFT JOIN b_catalog_currency_rate CR " . "\t\tON (C.CURRENCY = CR.CURRENCY AND CR.DATE_RATE < '" . $valDate . "') " . "WHERE C.CURRENCY = '" . $DB->ForSql($curTo) . "' " . "ORDER BY DATE_RATE DESC"; $db_res = $DB->Query($strSql); if ($res = $db_res->Fetch()) { $curToRate = DoubleVal($res["RATE"]); $curToRateCnt = DoubleVal($res["RATE_CNT"]); if ($curToRate <= 0) { $curToRate = DoubleVal($res["AMOUNT"]); $curToRateCnt = IntVal($res["AMOUNT_CNT"]); } } return DoubleVal(DoubleVal($valSum) * $curFromRate * $curToRateCnt / $curToRate / $curFromRateCnt); }
function formatImageLink($imageName, $linkTarget, $altText) { if (preg_match('/^(http|ftp)/', $imageName)) { $imageUrl = $imageName; $sizeAttrs = ""; } else { $imageTitle = Title::makeTitleSafe(NS_IMAGE, $imageName); if (is_null($imageTitle)) { return "(invalid image name)"; } $image = wfFindFile($imageTitle); if (is_null($image)) { return "(invalid image)"; } $imageUrl = $image->getViewURL(); $sizeAttrs = 'width="' . IntVal($image->getWidth()) . '" height="' . IntVal($image->getHeight()) . '"'; } if (preg_match('/^(http|ftp)/', $linkTarget)) { $linkUrl = $linkTarget; } else { $linkTitle = Title::newFromText($linkTarget); if (is_null($linkTitle)) { return "(invalid link target)"; } $linkUrl = $linkTitle->getLocalUrl(); } return '<a href="' . htmlspecialchars($linkUrl) . '"><img src="' . htmlspecialchars($imageUrl) . '" ' . $sizeAttrs . ' alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '" /></a>'; }
public static function Add($userId) { global $DB, $APPLICATION; $channelId = md5(uniqid().$_SERVER["REMOTE_ADDR"].$_SERVER["SERVER_NAME"].(is_object($APPLICATION)? $APPLICATION->GetServerUniqID(): '')); $arParams = Array( 'USER_ID' => intval($userId), 'CHANNEL_ID' => $channelId, 'LAST_ID' => 0, '~DATE_CREATE' => $DB->CurrentTimeFunction(), ); $result = IntVal($DB->Add("b_pull_channel", $arParams, Array())); if (CPullOptions::GetNginxStatus()) { $result = false; $arData = Array( 'module_id' => 'pull', 'command' => 'open', 'params' => Array(), ); $CHTTP = new CHTTP(); $CHTTP->http_timeout = 10; if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), CUtil::PhpToJsObject(Array('MESSAGE' => Array($arData), 'ERROR' => '')))) $result = $CHTTP->result; } return ($result? $channelId: false); }
function CalcUserBonus($arConfigs) { global $DB; $err_mess = (CRatings::err_mess())."<br>Function: CalcUserBonus<br>Line: "; $communityLastVisit = COption::GetOptionString("main", "rating_community_last_visit", '90'); CRatings::AddComponentResults($arConfigs); $strSql = "DELETE FROM b_rating_component_results WHERE RATING_ID = '".IntVal($arConfigs['RATING_ID'])."' AND COMPLEX_NAME = '".$DB->ForSql($arConfigs['COMPLEX_NAME'])."'"; $res = $DB->Query($strSql, false, $err_mess.__LINE__); $strSql = "INSERT INTO b_rating_component_results (RATING_ID, MODULE_ID, RATING_TYPE, NAME, COMPLEX_NAME, ENTITY_ID, ENTITY_TYPE_ID, CURRENT_VALUE) SELECT '".IntVal($arConfigs['RATING_ID'])."' RATING_ID, '".$DB->ForSql($arConfigs['MODULE_ID'])."' MODULE_ID, '".$DB->ForSql($arConfigs['RATING_TYPE'])."' RATING_TYPE, '".$DB->ForSql($arConfigs['NAME'])."' NAME, '".$DB->ForSql($arConfigs['COMPLEX_NAME'])."' COMPLEX_NAME, RB.ENTITY_ID as ENTITY_ID, '".$DB->ForSql($arConfigs['ENTITY_ID'])."' ENTITY_TYPE_ID, RB.BONUS*".floatval($arConfigs['CONFIG']['COEFFICIENT'])." CURRENT_VALUE FROM b_rating_user RB LEFT JOIN b_user U ON U.ID = RB.ENTITY_ID AND U.ACTIVE = 'Y' AND U.LAST_LOGIN > DATE_SUB(NOW(), INTERVAL ".intval($communityLastVisit)." DAY) WHERE RB.RATING_ID = ".IntVal($arConfigs['RATING_ID'])." AND U.ID IS NOT NULL "; $res = $DB->Query($strSql, false, $err_mess.__LINE__); return true; }
public static function AddByChannel($channelId, $arParams = array()) { global $DB; if (!is_array($channelId)) { $channelId = array($channelId); } if (strlen($arParams['module_id']) > 0 || strlen($arParams['command']) > 0) { $arData = array('module_id' => $arParams['module_id'], 'command' => $arParams['command'], 'params' => is_array($arParams['params']) ? $arParams['params'] : array()); if (CPullOptions::GetQueueServerStatus()) { $command = array('MESSAGE' => array($arData), 'ERROR' => ''); if (!is_array($channelId) && CPullOptions::GetQueueServerVersion() == 1) { $command['CHANNEL_ID'] = $channelId; } $message = CUtil::PhpToJsObject($command); if (!defined('BX_UTF') || !BX_UTF) { $message = $GLOBALS['APPLICATION']->ConvertCharset($message, SITE_CHARSET, 'utf-8'); } $res = CPullChannel::Send($channelId, str_replace("\n", " ", $message)); $result = $res ? true : false; } else { foreach ($channelId as $channel) { $arParams = array('CHANNEL_ID' => $channel, 'MESSAGE' => str_replace("\n", " ", serialize($arData)), '~DATE_CREATE' => $DB->CurrentTimeFunction()); $res = IntVal($DB->Add("b_pull_stack", $arParams, array("MESSAGE"))); $result = $res ? true : false; } } if (isset($arParams['push_text']) && strlen($arParams['push_text']) > 0 && isset($arParams['push_user']) && intval($arParams['push_user']) > 0) { $CPushManager = new CPushManager(); $CPushManager->AddQueue(array('USER_ID' => $arParams['push_user'], 'MESSAGE' => str_replace("\n", " ", $arParams['push_text']), 'PARAMS' => $arParams['push_params'], 'BADGE' => isset($arParams['push_badge']) ? intval($arParams['push_badge']) : '', 'TAG' => isset($arParams['push_tag']) ? $arParams['push_tag'] : '', 'SUB_TAG' => isset($arParams['push_sub_tag']) ? $arParams['push_sub_tag'] : '', 'APP_ID' => isset($arParams['push_app_id']) ? $arParams['push_app_id'] : '')); } return $result; } return false; }
/** * Returns information from a single calendar object, based on it's object * uri. * * The returned array must have the same keys as getCalendarObjects. The * 'calendardata' object is required here though, while it's not required * for getCalendarObjects. * * @param string $calendarId * @param string $objectUri * @throws Sabre_DAV_Exception_FileNotFound * @return array */ function getCalendarObject($calendarId, $objectUri) { $a = get_app(); $user_id = $a->user["uid"]; $obj = FriendicaVirtualCalSourceBackend::getItemsByUri($user_id, $objectUri); return array("id" => IntVal($obj["data_uri"]), "calendardata" => $obj["ical"], "uri" => $obj["data_uri"], "lastmodified" => $obj["date"], "calendarid" => $calendarId, "etag" => $obj["ical_etag"], "size" => IntVal($obj["ical_size"])); }
public static function DeleteByOrder($OrderID) { global $DB; $OrderID = IntVal($OrderID); $DB->Query("Update b_sale_user_transact SET NOTES='ORDER " . $OrderID . "' WHERE ORDER_ID = " . $OrderID . " ", true); return $DB->Query("Update b_sale_user_transact SET ORDER_ID = NULL WHERE ORDER_ID = " . $OrderID . " ", true); }
function DeleteByOrder($orderID) { global $DB; $orderID = IntVal($orderID); $strSql = "DELETE FROM b_sale_order_props_value WHERE ORDER_ID = " . $orderID . " "; return $DB->Query($strSql, True); }