public static function GetModuleConnection($module_id, $bModuleInclude = false) { $node_id = COption::GetOptionString($module_id, "dbnode_id", "N"); if (is_numeric($node_id)) { if ($bModuleInclude) { $status = COption::GetOptionString($module_id, "dbnode_status", "ok"); if ($status === "move") { return false; } } $moduleDB = CDatabase::GetDBNodeConnection($node_id, $bModuleInclude); if (is_object($moduleDB)) { $moduleDB->bModuleConnection = true; return $moduleDB; } //There was an connection error if ($bModuleInclude && CModule::IncludeModule('cluster')) { CClusterDBNode::SetOffline($node_id); } //TODO: unclear what to return when node went offline //in the middle of the hit. return false; } else { return $GLOBALS["DB"]; } }
function CSeoPageChecker($site, $url, $get = true, $check_errors = true) { global $APPLICATION; if (CModule::IncludeModule('search')) { $this->bSearch = true; } else { $APPLICATION->ThrowException(GetMessage('SEO_ERROR_NO_SEARCH')); } // don't return false or set bError! $this->__bCheckErrors = $check_errors; $this->__site = $site; $dbRes = CSite::GetByID($this->__site); if ($arRes = $dbRes->Fetch()) { $this->__lang = $arRes['LANGUAGE_ID']; $this->__server_name = $arRes['SERVER_NAME']; if (strlen($this->__server_name) <= 0) { $this->__server_name = COption::GetOptionString('main', 'server_name', ''); } if (strlen($this->__server_name) > 0) { $this->__url = 'http://' . $this->__server_name . $url; return $get ? $this->GetHTTPData() : true; } else { $this->bError = true; $APPLICATION->ThrowException(str_replace('#SITE_ID#', $this->__site, GetMessage('SEO_ERROR_NO_SERVER_NAME'))); return false; } } return false; }
public static function GetPHPFilesMark() { $res = array(); $file_name = $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "/upload/") . "/perfmon#i#.php"; $content = "<?\$s='" . str_repeat("x", 1024) . "';?><?/*" . str_repeat("y", 1024) . "*/?><?\$r='" . str_repeat("z", 1024) . "';?>"; for ($j = 0; $j < 4; $j++) { $s1 = getmicrotime(); for ($i = 0; $i < 100; $i++) { $fn = str_replace("#i#", $i, $file_name); } $e1 = getmicrotime(); $N1 = $e1 - $s1; $s2 = getmicrotime(); for ($i = 0; $i < 100; $i++) { //This is one op $fn = str_replace("#i#", $i, $file_name); $fh = fopen($fn, "wb"); fwrite($fh, $content); fclose($fh); include $fn; unlink($fn); } $e2 = getmicrotime(); $N2 = $e2 - $s2; if ($N2 > $N1) { $res[] = 100 / ($N2 - $N1); } } if (count($res)) { return array_sum($res) / doubleval(count($res)); } else { return 0; } }
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 function Authorize() { global $APPLICATION; $APPLICATION->RestartBuffer(); if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) { $redirect_uri = CSocServUtil::ServerName() . '/bitrix/tools/oauth/bitrix24.php'; $userId = intval($_REQUEST['uid']); $appID = trim(COption::GetOptionString("socialservices", "bitrix24_gadget_appid", '')); $appSecret = trim(COption::GetOptionString("socialservices", "bitrix24_gadget_appsecret", '')); $portalURI = $_REQUEST['domain']; if (strpos($portalURI, "http://") === false && strpos($portalURI, "https://") === false) { $portalURI = "https://" . $portalURI; } $gAuth = new CBitrixOAuthInterface($appID, $appSecret, $portalURI, $_REQUEST["code"]); $this->entityOAuth = $gAuth; $gAuth->addScope(explode(',', $_REQUEST["scope"])); if ($gAuth->GetAccessToken($redirect_uri) !== false) { $gAuth->saveDataDB(); } } $url = CSocServUtil::ServerName() . BX_ROOT; $mode = 'opener'; $url = CUtil::JSEscape($url); $location = $mode == "opener" ? 'if(window.opener) window.opener.location = \'' . $url . '\'; window.close();' : ' window.location = \'' . $url . '\';'; $JSScript = ' <script type="text/javascript"> ' . $location . ' </script> '; echo $JSScript; die; }
public function __construct($docRoot) { foreach ($this->arParams as $key => $value) { $paramValue = \COption::GetOptionString(self::$MODULE_NAME, $key); if (!$paramValue) { $this->errors .= \Helper::boldColorText("Not value for {$key}", "red"); } elseif ($value == "dir") { $this->arParams[$key] = $docRoot . $paramValue; if ($key != 'LOG_FILE') { if (!is_dir($this->arParams[$key])) { if (!mkdir($this->arParams[$key])) { $this->errors .= \Helper::boldColorText("Dir {$this->arParams[$key]} is absent", "red"); } } } } else { $this->arParams[$key] = $paramValue; } } if (!empty($this->errors)) { $logFile = $this->arParams['LOG_FILE']; if ($logFile == 'dir') { $logFile = $docRoot . '/local/logs/lot_info'; } file_put_contents($this->errors, $logFile, FILE_APPEND); throw new \Exception($this->errors); } }
public static function AddBlogPost($arFields) { if (!is_array($_POST)) { $_POST = array(); } $_POST = array_merge($_POST, array("apply" => "Y", "decode" => "N"), $arFields); $strPathToPost = COption::GetOptionString("socialnetwork", "userblogpost_page", false, SITE_ID); $strPathToSmile = COption::GetOptionString("socialnetwork", "smile_page", false, SITE_ID); $BlogGroupID = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, SITE_ID); $arBlogComponentParams = array("IS_REST" => "Y", "ID" => "new", "PATH_TO_POST" => $strPathToPost, "PATH_TO_SMILE" => $strPathToSmile, "GROUP_ID" => $BlogGroupID, "USER_ID" => $GLOBALS["USER"]->GetID(), "USE_SOCNET" => "Y", "MICROBLOG" => "Y"); ob_start(); $result = $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:socialnetwork.blog.post.edit", "", $arBlogComponentParams, false, array("HIDE_ICONS" => "Y")); ob_end_clean(); if (!$result) { throw new Exception('Error'); } else { if (isset($arFields["FILES"]) && \Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk') && ($storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($GLOBALS["USER"]->GetID())) && ($folder = $storage->getFolderForUploadedFiles($GLOBALS["USER"]->GetID()))) { // upload to storage $arResultFile = array(); foreach ($arFields["FILES"] as $tmp) { $arFile = CRestUtil::saveFile($tmp); if (is_array($arFile)) { $file = $folder->uploadFile($arFile, array('NAME' => $arFile["name"], 'CREATED_BY' => $GLOBALS["USER"]->GetID()), array(), true); if ($file) { $arResultFile[] = \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX . $file->getId(); } } } if (!empty($arResultFile)) { CBlogPost::Update($result, array("HAS_PROPS" => "Y", "UF_BLOG_POST_FILE" => $arResultFile)); } } return $result; } }
function checkAccountNumberValue($templateType, $number_data, $number_prefix) { $res = true; switch ($templateType) { case 'NUMBER': if (strlen($number_data) <= 0 || strlen($number_data) > 7 || !ctype_digit($number_data) || intval($number_data) < intval(COption::GetOptionString("sale", "account_number_data", "")) ) $res = false; break; case 'PREFIX': if (strlen($number_prefix) <= 0 || strlen($number_prefix) > 7 || preg_match('/[^a-zA-Z0-9_-]/', $number_prefix) ) $res = false; break; } return $res; }
function CWebDavVirtual($arStructure, $base_url, $arParams = array()) { $arParams = is_array($arParams) ? $arParams : array(); $this->CWebDavBase($base_url); $this->arStructure = $arStructure; $this->permission = $this->permission_real; if ($this->permission_real >= "W") { $this->check_creator = false; } $this->USER["GROUPS"] = $GLOBALS["USER"]->GetUserGroupArray(); $this->workflow = false; if (!isset($arParams["CACHE_TIME"])) { $arParams["CACHE_TIME"] = 3600; } if ($arParams["CACHE_TYPE"] == "Y" || $arParams["CACHE_TYPE"] == "A" && COption::GetOptionString("main", "component_cache_on", "Y") == "Y") { $arParams["CACHE_TIME"] = intval($arParams["CACHE_TIME"]); } else { $arParams["CACHE_TIME"] = 0; } $this->CACHE_TIME = $arParams["CACHE_TIME"] = 0; $cache_hash = md5(serialize($arStructure)); $this->CACHE_PATH = str_replace(array("///", "//"), "/", "/" . SITE_ID . "/webdav/" . $cache_hash . "/"); $this->CACHE_OBJ = false; if ($this->CACHE_TIME > 0) { $this->CACHE_OBJ = new CPHPCache(); } if (!$this->SetRootSection($arParams["ROOT_SECTION_ID"])) { $this->arError[] = array("id" => "root_section_is_not_found", "text" => GetMessage("WD_ROOT_SECTION_NOT_FOUND")); } }
public function DoUninstall() { COption::RemoveOption('imageimport'); DeleteDirFiles($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/imageimport/install/admin', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin'); UnRegisterModule('imageimport'); return true; }
public static function GetAbsoluteRoot() { if(defined('FX_TEMPORARY_FILES_DIRECTORY')) return FX_TEMPORARY_FILES_DIRECTORY; else return $_SERVER["DOCUMENT_ROOT"]."/".(COption::GetOptionString("main", "upload_dir", "upload"))."/tmp"; }
function InstallDB($install_wizard = true) { global $DB, $DBType, $APPLICATION; $arCurPhpVer = Explode(".", PhpVersion()); if (IntVal($arCurPhpVer[0]) < 5) { return true; } $errors = null; if (!$DB->Query("SELECT 'x' FROM b_bp_workflow_instance", true)) { $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/bizproc/install/db/" . $DBType . "/install.sql"); } if (!empty($errors)) { $APPLICATION->ThrowException(implode("", $errors)); return false; } RegisterModule("bizproc"); RegisterModuleDependences("iblock", "OnAfterIBlockElementDelete", "bizproc", "CBPVirtualDocument", "OnAfterIBlockElementDelete"); RegisterModuleDependences("main", "OnAdminInformerInsertItems", "bizproc", "CBPAllTaskService", "OnAdminInformerInsertItems"); RegisterModuleDependences('rest', 'OnRestServiceBuildDescription', 'bizproc', '\\Bitrix\\Bizproc\\RestService', 'onRestServiceBuildDescription'); RegisterModuleDependences('rest', 'OnRestAppDelete', 'bizproc', '\\Bitrix\\Bizproc\\RestService', 'onRestAppDelete'); RegisterModuleDependences('rest', 'OnRestAppUpdate', 'bizproc', '\\Bitrix\\Bizproc\\RestService', 'onRestAppUpdate'); RegisterModuleDependences('timeman', 'OnAfterTMDayStart', 'bizproc', 'CBPDocument', 'onAfterTMDayStart'); COption::SetOptionString("bizproc", "SkipNonPublicCustomTypes", "Y"); return true; }
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; }
function OnModuleInstalledEvent($id, $installed, $Module) { foreach (GetModuleEvents("main", "OnModuleInstalled", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($id, $installed)); } $cModules = COption::GetOptionString("main", "mp_modules_date", ""); $arModules = array(); if (strlen($cModules) > 0) { $arModules = unserialize($cModules); } if ($installed == "Y") { $arModules[] = array("ID" => $id, "NAME" => htmlspecialcharsbx($Module->MODULE_NAME), "TMS" => time()); if (count($arModules) > 3) { $arModules = array_slice($arModules, -3); } COption::SetOptionString("main", "mp_modules_date", serialize($arModules)); } else { foreach ($arModules as $arid => $val) { if ($val["ID"] == $id) { unset($arModules[$arid]); } } if (count($arModules) > 0) { COption::SetOptionString("main", "mp_modules_date", serialize($arModules)); } else { COption::RemoveOption("main", "mp_modules_date"); } $_SESSION["MP_MOD_DELETED"] = array("ID" => $id, "NAME" => $Module->MODULE_NAME); } }
function UnInstallDB($arParams = array()) { global $DB, $DBType, $APPLICATION; $this->errors = false; UnRegisterModuleDependences("main", "OnPageStart", "security", "CSecurityIPRule", "OnPageStart"); UnRegisterModuleDependences("main", "OnBeforeProlog", "security", "CSecurityFilter", "OnBeforeProlog"); UnRegisterModuleDependences("main", "OnEndBufferContent", "security", "CSecurityXSSDetect", "OnEndBufferContent"); UnRegisterModuleDependences("main", "OnBeforeUserLogin", "security", "CSecurityUser", "OnBeforeUserLogin"); UnRegisterModuleDependences("main", "OnUserDelete", "security", "CSecurityUser", "OnUserDelete"); UnRegisterModuleDependences("main", "OnEventLogGetAuditTypes", "security", "CSecurityFilter", "GetAuditTypes"); UnRegisterModuleDependences("main", "OnEventLogGetAuditTypes", "security", "CSecurityAntiVirus", "GetAuditTypes"); UnRegisterModuleDependences("main", "OnBeforeLocalRedirect", "security", "CSecurityRedirect", "BeforeLocalRedirect"); UnRegisterModuleDependences("main", "OnEndBufferContent", "security", "CSecurityRedirect", "EndBufferContent"); UnRegisterModuleDependences("main", "OnAdminInformerInsertItems", "security", "CSecurityFilter", "OnAdminInformerInsertItems"); UnRegisterModuleDependences("main", "OnAdminInformerInsertItems", "security", "CSecuritySiteChecker", "OnAdminInformerInsertItems"); COption::SetOptionString("main", "session_id_ttl", "60"); COption::SetOptionString("main", "use_session_id_ttl", "N"); COption::SetOptionInt("main", "session_id_ttl", 60); COption::SetOptionString("security", "session", "N"); if (!array_key_exists("save_tables", $arParams) || $arParams["save_tables"] != "Y") { $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/security/install/db/" . strtolower($DB->type) . "/uninstall.sql"); $this->UnInstallTasks(); } UnRegisterModule("security"); if ($this->errors !== false) { $APPLICATION->ThrowException(implode("<br>", $this->errors)); return false; } return true; }
public function onPrepareComponentParams($params) { $this->arIBlock = CIBlock::GetArrayByID($params["IBLOCK_ID"]); $this->arResult["IBLOCK"] = htmlspecialcharsex($this->arIBlock); $this->arResult["IBLOCK_ID"] = $this->arIBlock["ID"]; $this->arResult["GRID_ID"] = "lists_list_elements_" . $this->arResult["IBLOCK_ID"]; $this->arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0; $this->arResult["SECTIONS"] = array(); $this->arResult["SECTION_ID"] = false; $this->arResult["LIST_SECTIONS"] = array(); if (isset($_GET["list_section_id"])) { $sectionId = intval($_GET["list_section_id"]); } else { $sectionId = intval($params["SECTION_ID"]); } $rsSections = CIBlockSection::GetList(array("left_margin" => "asc"), array("IBLOCK_ID" => $this->arIBlock["ID"], "GLOBAL_ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y")); while ($arSection = $rsSections->GetNext()) { $this->arResult["SECTIONS"][$arSection["ID"]] = array("ID" => $arSection["ID"], "NAME" => $arSection["NAME"]); if ($arSection["ID"] == $sectionId) { $this->arResult["SECTION"] = $arSection; $this->arResult["SECTION_ID"] = $arSection["ID"]; } $this->arResult["LIST_SECTIONS"][$arSection["ID"]] = str_repeat(" . ", $arSection["DEPTH_LEVEL"]) . $arSection["NAME"]; } $this->arResult["IS_SOCNET_GROUP_CLOSED"] = false; if (intval($params["~SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork")) { $arSonetGroup = CSocNetGroup::GetByID(intval($params["~SOCNET_GROUP_ID"])); if (is_array($arSonetGroup) && $arSonetGroup["CLOSED"] == "Y" && !CSocNetUser::IsCurrentUserModuleAdmin() && ($arSonetGroup["OWNER_ID"] != $GLOBALS["USER"]->GetID() || COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y")) { $this->arResult["IS_SOCNET_GROUP_CLOSED"] = true; } } return $params; }
function InitializeTemplate($arParams, $arResult) { $this->WEB_FORM_ID = $arParams["WEB_FORM_ID"]; $this->RESULT_ID = $arParams["RESULT_ID"]; $this->arParams = $arParams; $this->arForm = $arResult["arForm"]; $this->arQuestions = $arResult["arQuestions"]; $this->arAnswers = $arResult["arAnswers"]; $this->arDropDown = $arResult["arDropDown"]; $this->arMultiSelect = $arResult["arMultiSelect"]; $this->arrVALUES = $arResult["arrVALUES"]; $this->F_RIGHT = $arResult["F_RIGHT"]; if ($this->RESULT_ID) { if ($this->isAccessFormResult($arResult['arResultData'])) { $this->arrRESULT_PERMISSION = CFormResult::GetPermissions($this->RESULT_ID, $v); $this->arResult = $arResult['arResultData']; } } $this->strFormNote = $arResult["FORM_NOTE"]; $this->__form_validate_errors = $arResult["FORM_ERRORS"]; $this->bIsFormValidateErrors = $arResult['isFormErrors'] == 'Y'; $this->bSimple = COption::GetOptionString("form", "SIMPLE", "Y") == "Y" ? true : false; $this->WEB_FORM_NAME = $arResult["arForm"]["SID"]; if ($this->arForm["USE_CAPTCHA"] == "Y") { $this->CAPTCHACode = $arResult["CAPTCHACode"]; } }
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; }
function GetList($category = false) { static $arMeasurementsTable; if (!is_array($arMeasurementsTable)) { $tablePath = COption::GetOptionString('sale', 'measurement_path', '/bitrix/modules/sale/measurements.php'); $fullPath = $_SERVER["DOCUMENT_ROOT"] . $tablePath; if (strlen($tablePath) > 0 && file_exists($fullPath) && !is_dir($fullPath)) { require_once $fullPath; if (!is_array($arMeasurementsTable)) { return false; } } else { return false; } } if (!$category) { return $arMeasurementsTable; } else { $arList = array(); foreach ($arMeasurementsTable as $key => $arM) { if ($arM["CATEGORY"] == $category) { $arList[$key] = $arM; } } return $arList; } }
public static function FormatEvent($arFields, $arParams, $bMail = false) { global $APPLICATION, $CACHE_MANAGER; $arResult = array("EVENT" => $arFields); if (defined("BX_COMP_MANAGED_CACHE")) { $CACHE_MANAGER->RegisterTag("CALENDAR_EVENT_" . intval($arFields["SOURCE_ID"])); $CACHE_MANAGER->RegisterTag("CALENDAR_EVENT_LIST"); } $eventViewResult = $APPLICATION->IncludeComponent('bitrix:calendar.livefeed.view', '', array("EVENT_ID" => $arFields["SOURCE_ID"], "USER_ID" => $arFields["USER_ID"], "PATH_TO_USER" => $arParams["PATH_TO_USER"], "MOBILE" => $arParams["MOBILE"]), null, array('HIDE_ICONS' => 'Y')); $arResult["EVENT_FORMATTED"] = array("TITLE" => GetMessage("EC_EDEV_EVENT"), "TITLE_24" => GetMessage("EC_EDEV_EVENT"), "URL" => "javascript:BX.StartSlider(" . $arFields["USER_ID"] . "," . $arFields["SOURCE_ID"] . ");", "MESSAGE" => $eventViewResult['MESSAGE'], "FOOTER_MESSAGE" => $eventViewResult['FOOTER_MESSAGE'], "IS_IMPORTANT" => false, "STYLE" => "calendar-confirm"); $eventId = $arFields["SOURCE_ID"]; if (!$eventId) { $eventId = 0; } $editUrl = CCalendar::GetPath('user', $arFields["USER_ID"]); $editUrl = $editUrl . (strpos($editUrl, "?") === false ? '?' : '&') . 'EVENT_ID=EDIT' . $eventId; $arRights = array(); $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"])); while ($arRight = $dbRight->Fetch()) { $arRights[] = $arRight["GROUP_CODE"]; } $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"]))); if (isset($eventViewResult['CACHED_JS_PATH'])) { $arResult['CACHED_JS_PATH'] = $eventViewResult['CACHED_JS_PATH']; } $arResult['ENTITY']['FORMATTED']["NAME"] = "ENTITY FORMATTED NAME"; $arResult['ENTITY']['FORMATTED']["URL"] = COption::GetOptionString("timeman", "WORK_REPORT_PATH", "/company/work_report.php"); $arResult['AVATAR_SRC'] = CSocNetLog::FormatEvent_CreateAvatar($arFields, $arParams, 'CREATED_BY'); $arFieldsTooltip = array('ID' => $arFields['USER_ID'], 'NAME' => $arFields['~CREATED_BY_NAME'], 'LAST_NAME' => $arFields['~CREATED_BY_LAST_NAME'], 'SECOND_NAME' => $arFields['~CREATED_BY_SECOND_NAME'], 'LOGIN' => $arFields['~CREATED_BY_LOGIN']); $arResult['CREATED_BY']['TOOLTIP_FIELDS'] = CSocNetLog::FormatEvent_FillTooltip($arFieldsTooltip, $arParams); return $arResult; }
public function SaveKeys($arKeys) { $privKey = $arKeys["PRIV"]; unset($arKeys["PRIV"]); COption::SetOptionString("main", "~rsa_keys_openssl", serialize($arKeys)); COption::SetOptionString("main", "~rsa_key_pem", $privKey); }
function TerminateSubscribe($arFields) { $saved_s = unserialize(COption::GetOptionString("echogroup.smsru", "SUBS")); if (in_array($arFields["ID"], $saved_s)) { global $USER; $uid = $USER->GetID(); if ($arFields["USER_ID"]) { $uid = $arFields["USER_ID"]; } if ($arFields["UID"]) { $uid = $arFields["UID"]; } if ($uid > 2) { $res = $USER->GetByID($uid); $arUser = $res->Fetch(); if (!$arUser["PERSONAL_PHONE"]) { $arUser["PERSONAL_PHONE"] = $arFields["TO"]; } foreach ($arFields as $k => $v) { $arForm["MESSAGE"] = str_replace("#" . $k . "#", $v, $arForm["MESSAGE"]); } CEchogroupSmsru::Send($arUser["PERSONAL_PHONE"], $arForm["MESSAGE"]); return false; } } }
function InstallDB() { global $DB, $APPLICATION; $this->errors = false; if (!$DB->Query("SELECT 'x' FROM b_seo_keywords", true)) { $this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/seo/install/db/" . strtolower($DB->type) . "/install.sql"); } if ($this->errors !== false) { $APPLICATION->ThrowException(implode("", $this->errors)); return false; } RegisterModule("seo"); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/seo/install/tasks/install.php"; RegisterModuleDependences('main', 'OnPanelCreate', 'seo', 'CSeoEventHandlers', 'SeoOnPanelCreate'); if (COption::GetOptionString('seo', 'searchers_list', '') == '' && CModule::IncludeModule('statistic')) { $arFilter = array('ACTIVE' => 'Y', 'NAME' => 'Google|MSN|Bing', 'NAME_EXACT_MATCH' => 'Y'); if (COption::GetOptionString('main', 'vendor') == '1c_bitrix') { $arFilter['NAME'] .= '|Yandex'; } $strSearchers = ''; $dbRes = CSearcher::GetList($by = 's_id', $order = 'asc', $arFilter, $is_filtered); while ($arRes = $dbRes->Fetch()) { $strSearchers .= ($strSearchers == '' ? '' : ',') . $arRes['ID']; } COption::SetOptionString('seo', 'searchers_list', $strSearchers); } return true; }
function CheckFields() { global $arrFILES, $bAdmin, $bSupportTeam; $arMsg = array(); if ($bSupportTeam != "Y" && $bAdmin != "Y") { $max_size = COption::GetOptionString("support", "SUPPORT_MAX_FILESIZE"); $max_size = intval($max_size) * 1024; } if ($max_size > 0 && is_array($arrFILES) && count($arrFILES) > 0) { $i = 0; while (list($key, $arFILE) = each($arrFILES)) { $i++; if (intval($arFILE["size"]) > $max_size) { $arMsg[] = array("id" => "FILE_" . $i, "text" => str_replace("#FILE_NAME#", $arFILE["name"], GetMessage("SUP_MAX_FILE_SIZE_EXCEEDING"))); //$str .= str_replace("#FILE_NAME#", $arFILE["name"], GetMessage("SUP_MAX_FILE_SIZE_EXCEEDING"))."<br>"; } } } if (!empty($arMsg)) { $e = new CAdminException($arMsg); $GLOBALS["APPLICATION"]->ThrowException($e); return false; } return true; }
function UnInstallDB() { COption::RemoveOption("translate"); UnRegisterModuleDependences('main', 'OnPanelCreate', 'translate'); UnRegisterModule("translate"); return true; }
protected function processActionInstallProcesses() { $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id"); $this->checkPermission(); $this->checkRequiredPostParams(array('processes')); if ($this->errorCollection->hasErrors()) { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_CPAC_NOT_SELECTED_PROCESSES')))); $this->sendJsonErrorResponse(); } $siteId = SITE_ID; if ($this->request->getPost('siteId')) { $siteId = $this->request->getPost('siteId'); } try { $processes = $this->request->getPost('processes'); if (is_array($processes)) { foreach ($processes as $filePath) { \Bitrix\Lists\Importer::installProcess($filePath, $siteId); } } else { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_CPAC_INCORRECT_DATA')))); } } catch (Exception $e) { $this->errorCollection->add(array(new Error($e->getMessage()))); } if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('LISTS_CPAC_MESSAGE_SUCCESS'))); }
function DelayedStemIndex() { $DB = CDatabase::GetModuleConnection('search'); $etime = time() + intval(COption::GetOptionString("search", "agent_duration")); do { $stemQueue = $DB->Query($DB->TopSql("\n\t\t\t\tSELECT SEARCH_CONTENT_ID ID\n\t\t\t\tFROM b_search_content_stem\n\t\t\t\tWHERE SEARCH_CONTENT_ID < 0\n\t\t\t", 1)); if ($stemTask = $stemQueue->Fetch()) { $ID = -$stemTask["ID"]; $sites = array(); $rsSite = $DB->Query("\n\t\t\t\t\tSELECT SITE_ID, URL\n\t\t\t\t\tFROM b_search_content_site\n\t\t\t\t\tWHERE SEARCH_CONTENT_ID = " . $ID . "\n\t\t\t\t"); while ($arSite = $rsSite->Fetch()) { $sites[$arSite["SITE_ID"]] = $arSite["URL"]; } if (BX_SEARCH_VERSION > 1) { $sql = "SELECT SEARCHABLE_CONTENT from b_search_content_text WHERE SEARCH_CONTENT_ID = {$ID}"; } else { $sql = "SELECT SEARCHABLE_CONTENT from b_search_content WHERE ID = {$ID}"; } $rsContent = $DB->Query($sql); if ($arContent = $rsContent->Fetch()) { $DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = " . $ID); CSearch::StemIndex($sites, $ID, $arContent["SEARCHABLE_CONTENT"]); } $DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = " . $stemTask["ID"]); } else { //Cancel the agent return ""; } } while ($etime >= time()); return "CSearchStemTable::DelayedStemIndex();"; }
/** * <p>Метод удаляет файл из таблицы зарегистрированных файлов (b_file) и с диска. Статичный метод.</p> * * * @param int $id Цифровой идентификатор файла. * * @return mixed * * <h4>Example</h4> * <pre> * <? * // удаляем изображение формы * $arFilter = array("ID" => 1, "ID_EXACT_MATCH" => "Y"); * $rsForm = CForm::GetList($by, $order, $arFilter, $is_filtered); * if ($arForm = $rsForm->Fetch()) * { * if (intval($arForm["IMAGE_ID"])>0) <b>CFile::Delete</b>($arForm["IMAGE_ID"]); * } * ?> * </pre> * * * <h4>See Also</h4> * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfiles.php">DeleteDirFiles</a> </li> * <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfilesex.php">DeleteDirFilesEx</a> </li> * </ul><a name="examples"></a> * * * @static * @link http://dev.1c-bitrix.ru/api_help/main/reference/cfile/delete.php * @author Bitrix */ public static function Delete($ID) { global $DB; $io = CBXVirtualIo::GetInstance(); $ID = intval($ID); if ($ID <= 0) { return; } $res = CFile::GetByID($ID); if ($res = $res->Fetch()) { $delete_size = 0; $upload_dir = COption::GetOptionString("main", "upload_dir", "upload"); $dname = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/" . $res["SUBDIR"]; $fname = $dname . "/" . $res["FILE_NAME"]; $file = $io->GetFile($fname); if ($file->isExists() && $file->unlink()) { $delete_size += $res["FILE_SIZE"]; } $delete_size += CFile::ResizeImageDelete($res); $DB->Query("DELETE FROM b_file WHERE ID = " . $ID); $directory = $io->GetDirectory($dname); if ($directory->isExists() && $directory->isEmpty()) { $directory->rmdir(); } CFile::CleanCache($ID); foreach (GetModuleEvents("main", "OnFileDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($res)); } /****************************** QUOTA ******************************/ if ($delete_size > 0 && COption::GetOptionInt("main", "disk_space") > 0) { CDiskQuota::updateDiskQuota("file", $delete_size, "delete"); } /****************************** QUOTA ******************************/ } }
function BXCreateSection(&$fileContent, &$sectionFileContent, &$absoluteFilePath, &$sectionPath) { //Check quota $quota = new CDiskQuota(); if (!$quota->CheckDiskQuota(array("FILE_SIZE" => strlen($fileContent) + strlen($sectionFileContent)))) { $GLOBALS["APPLICATION"]->ThrowException($quota->LAST_ERROR, "BAD_QUOTA"); return false; } $io = CBXVirtualIo::GetInstance(); //Create dir if (!$io->CreateDirectory($absoluteFilePath)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("PAGE_NEW_FOLDER_CREATE_ERROR") . "<br /> (" . htmlspecialcharsbx($absoluteFilePath) . ")", "DIR_NOT_CREATE"); return false; } //Create .section.php $f = $io->GetFile($absoluteFilePath . "/.section.php"); if (!$GLOBALS["APPLICATION"]->SaveFileContent($absoluteFilePath . "/.section.php", $sectionFileContent)) { return false; } //Create index.php if (!$GLOBALS["APPLICATION"]->SaveFileContent($absoluteFilePath . "/index.php", $fileContent)) { return false; } else { if (COption::GetOptionString($module_id, "log_page", "Y") == "Y") { $res_log['path'] = $sectionPath . "/index.php"; CEventLog::Log("content", "PAGE_ADD", "main", "", serialize($res_log)); } } return true; }
public function __construct($arDBRecord = false) { parent::__construct($arDBRecord); $DB = CDatabase::GetModuleConnection('statistic'); if (!$arDBRecord) { $country_recs = COption::GetOptionString("statistic", "COUNTRY_INDEX_LOADED", "N"); if ($country_recs !== "Y") { $rs = $DB->Query(CStatistics::DBTopSql("SELECT /*TOP*/ * FROM b_stat_country", 1)); if ($rs->Fetch()) { $country_recs = "Y"; COption::SetOptionString("statistic", "COUNTRY_INDEX_LOADED", "Y"); } } $this->country_avail = $country_recs === "Y"; if ($this->country_avail) { $city_recs = COption::GetOptionString("statistic", "CITY_INDEX_LOADED", "N"); if ($city_recs !== "Y") { $rs = $DB->Query(CStatistics::DBTopSql("SELECT /*TOP*/ * FROM b_stat_city_ip", 1)); if ($rs->Fetch()) { COption::SetOptionString("statistic", "CITY_INDEX_LOADED", "Y"); } } $this->city_avail = COption::GetOptionString("statistic", "CITY_INDEX_LOADED", "N") === "Y"; } $this->is_installed = $this->country_avail; } }