本文整理汇总了PHP中CMain类的典型用法代码示例。如果您正苦于以下问题:PHP CMain类的具体用法?PHP CMain怎么用?PHP CMain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: AddNewUser
function AddNewUser($SITE_ID, $arFields, &$strError)
{
$ID_ADDED = 0;
$iDepartmentId = intval($arFields["DEPARTMENT_ID"]);
$bExtranet = $iDepartmentId <= 0;
$strEmail = trim($arFields["ADD_EMAIL"]);
$strName = trim($arFields["ADD_NAME"]);
$strLastName = trim($arFields["ADD_LAST_NAME"]);
$strPosition = trim($arFields["ADD_POSITION"]);
$strPassword = self::GeneratePassword($SITE_ID, $bExtranetUser);
self::setSendPassword($arFields["ADD_SEND_PASSWORD"] == "Y");
if (strlen($strEmail) <= 0) {
if (!isset($arFields["ADD_MAILBOX_ACTION"]) || !in_array($arFields["ADD_MAILBOX_ACTION"], array("create", "connect")) || strlen($arFields['ADD_MAILBOX_USER']) <= 0 || strlen($arFields['ADD_MAILBOX_DOMAIN']) <= 0) {
$strError = GetMessage("BX24_INVITE_DIALOG_ERROR_EMPTY_EMAIL");
} else {
// email from mailbox
$strEmail = $arFields['ADD_MAILBOX_USER'] . "@" . $arFields['ADD_MAILBOX_DOMAIN'];
}
}
if (!$strError) {
$arUser = array("LOGIN" => $strEmail, "NAME" => $strName, "LAST_NAME" => $strLastName, "EMAIL" => $strEmail, "PASSWORD" => $strPassword, "GROUP_ID" => CIntranetInviteDialog::getUserGroups($SITE_ID, $bExtranet), "WORK_POSITION" => $strPosition, "UF_DEPARTMENT" => $iDepartmentId > 0 ? array($iDepartmentId) : array(0));
if (!self::getSendPassword()) {
$arUser["CONFIRM_CODE"] = randString(8);
}
$obUser = new CUser();
$ID_ADDED = $obUser->Add($arUser);
if (!$ID_ADDED) {
if ($e = $GLOBALS["APPLICATION"]->GetException()) {
$strError = $e->GetString();
} else {
$strError = $obUser->LAST_ERROR;
}
} else {
if (self::getSendPassword()) {
$db_events = GetModuleEvents("main", "OnUserInitialize", true);
foreach ($db_events as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID_ADDED, $arUser));
}
}
$SiteIdToSend = $bExtranet && CModule::IncludeModule("extranet") ? CExtranet::GetExtranetSiteID() : CSite::GetDefSite();
$rsSites = CSite::GetByID($SiteIdToSend);
$arSite = $rsSites->Fetch();
$serverName = strlen($arSite["SERVER_NAME"]) > 0 ? $arSite["SERVER_NAME"] : (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
$event = new CEvent();
if (self::getSendPassword()) {
$url = (CMain::IsHTTPS() ? "https" : "http") . "://" . $serverName . $arSite["DIR"];
$event->SendImmediate("INTRANET_USER_ADD", $SITE_ID, array("EMAIL_TO" => $arUser["EMAIL"], "LINK" => $url, "PASSWORD" => $strPassword, "USER_TEXT" => GetMessage("BX24_INVITE_DIALOG_INVITE_MESSAGE_TEXT")));
} else {
$dbUser = CUser::GetByID($ID_ADDED);
$arUser = $dbUser->Fetch();
if (IsModuleInstalled("bitrix24")) {
$event->SendImmediate("BITRIX24_USER_INVITATION", $SITE_ID, array("EMAIL_FROM" => $GLOBALS["USER"]->GetEmail(), "EMAIL_TO" => $arUser["EMAIL"], "LINK" => CHTTP::URN2URI("/bitrix/tools/intranet_invite_dialog.php?user_id=" . $ID_ADDED . "&checkword=" . urlencode($arUser["CONFIRM_CODE"]), $serverName), "USER_TEXT" => GetMessage("BX24_INVITE_DIALOG_INVITE_MESSAGE_TEXT")));
} else {
$event->SendImmediate("INTRANET_USER_INVITATION", $SITE_ID, array("EMAIL_TO" => $arUser["EMAIL"], "LINK" => CHTTP::URN2URI("/bitrix/tools/intranet_invite_dialog.php?user_id=" . $ID_ADDED . "&checkword=" . urlencode($arUser["CONFIRM_CODE"]), $serverName), "USER_TEXT" => GetMessage("BX24_INVITE_DIALOG_INVITE_MESSAGE_TEXT")));
}
}
}
}
return $ID_ADDED;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:60,代码来源:invite_dialog.php
示例2: ToAbsoluteUrl
public static function ToAbsoluteUrl($url)
{
$url = trim(strval($url));
if ($url === '') {
return '';
} elseif (self::GetUrlScheme($url) !== '') {
return $url;
}
$scheme = CMain::IsHTTPS() ? 'https' : 'http';
$host = '';
if (defined('SITE_SERVER_NAME') && is_string(SITE_SERVER_NAME)) {
$host = SITE_SERVER_NAME;
}
if ($host === '') {
$host = COption::GetOptionString('main', 'server_name', '');
}
if ($host === '') {
$host = $_SERVER['SERVER_NAME'];
}
$port = intval($_SERVER['SERVER_PORT']);
if (preg_match('/^\\//', $url)) {
$url = substr($url, 1);
}
return $scheme . '://' . $host . ($port !== 80 && $port !== 443 ? ':' . $port : '') . '/' . $url;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:25,代码来源:crm_url_util.php
示例3: GetRedirectUrl
function GetRedirectUrl($identity, $return_to = false)
{
if (strlen($identity) <= 0) {
$GLOBALS['APPLICATION']->ThrowException(GetMessage('OPENID_CLIENT_EMPTY_IDENTITY'));
return false;
}
if (strlen($identity) > 1024) {
$identity = substr($identity, 0, 1024);
}
// may be 256 ????
if (strpos(strtolower($identity), 'http://') === false && strpos(strtolower($identity), 'https://') === false) {
$identity = 'http://' . $identity;
}
$_SESSION['BX_OPENID_IDENTITY'] = $identity;
if ($arOpenidServerTags = $this->GetOpenIDServerTags($identity)) {
if (!$this->CheckTrustProviders($arOpenidServerTags['server'])) {
$GLOBALS['APPLICATION']->ThrowException(GetMessage('OPENID_CLIENT_CHECK_TRUST_PRIVIDERS_FAULT'));
return false;
}
$protocol = CMain::IsHTTPS() ? "https" : "http";
$port = $_SERVER['SERVER_PORT'] > 0 && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 ? ':' . $_SERVER['SERVER_PORT'] : '';
$server_name = $protocol . '://' . $_SERVER['SERVER_NAME'] . $port;
if ($return_to === false) {
$return_to = $server_name . $GLOBALS['APPLICATION']->GetCurPageParam('', array('SEF_APPLICATION_CUR_PAGE_URL'), false);
}
if (strlen($arOpenidServerTags['delegate']) > 0) {
$identity = $arOpenidServerTags['delegate'];
}
$trust_root = $server_name . '/';
$url = $arOpenidServerTags['server'] . (strpos($arOpenidServerTags['server'], '?') !== false ? '&' : '?') . 'openid.mode=checkid_setup' . '&openid.return_to=' . urlencode($return_to) . '&openid.identity=' . urlencode($identity) . '&openid.trust_root=' . urlencode($trust_root) . '&openid.sreg.required=email,fullname' . '&openid.sreg.optional=gender,dob,postcode,country,timezone';
$_SESSION['BX_OPENID_RETURN_TO'] = $return_to;
return $url;
}
return false;
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:35,代码来源:openidclient.php
示例4: CSeoPageChecker
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 = (CMain::IsHTTPS() ? "https://" : "http://") . CBXPunycode::ToASCII($this->__server_name, $e = null) . $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;
}
开发者ID:Satariall,项目名称:izurit,代码行数:29,代码来源:seo_page_checker.php
示例5: end
/**
* Terminates controller and application.
* This method replaces "die()" or "exit()" and ensures life cycle of application.
* @return void
*/
protected function end()
{
$this->logDebugInfo();
/** @noinspection PhpUndefinedClassInspection */
\CMain::finalActions();
die;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:12,代码来源:controller.php
示例6: init
function init()
{
$this->username = CSalePaySystemAction::GetParamValue("USER");
$this->pwd = CSalePaySystemAction::GetParamValue("PWD");
$this->signature = CSalePaySystemAction::GetParamValue("SIGNATURE");
$this->currency = CSalePaySystemAction::GetParamValue("CURRENCY");
$this->testMode = CSalePaySystemAction::GetParamValue("TEST") == "Y";
if ($this->testMode) {
$this->domain = "sandbox.";
}
if (strlen($_REQUEST["token"]) > 0) {
$this->token = $_REQUEST["token"];
}
if (strlen($_REQUEST["PayerID"]) > 0) {
$this->payerId = $_REQUEST["PayerID"];
}
$this->version = "98.0";
$dbSite = CSite::GetByID(SITE_ID);
$arSite = $dbSite->Fetch();
$this->serverName = $arSite["SERVER_NAME"];
if (strLen($this->serverName) <= 0) {
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
$this->serverName = SITE_SERVER_NAME;
} else {
$this->serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
}
}
$this->serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $this->serverName;
if (strlen($this->username) <= 0 || strlen($this->username) <= 0 || strlen($this->username) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("CSalePaySystempaypal: init error", "CSalePaySystempaypal_init_error");
return false;
}
return true;
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:34,代码来源:pre_payment.php
示例7: InstallDB
function InstallDB()
{
global $DB, $APPLICATION;
$this->errors = false;
if(!$DB->Query("SELECT 'x' FROM b_pull_stack", true))
$this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/pull/install/db/".strtolower($DB->type)."/install.sql");
if($this->errors !== false)
{
$APPLICATION->ThrowException(implode("", $this->errors));
return false;
}
RegisterModule("pull");
RegisterModuleDependences("main", "OnProlog", "main", "", "", 3, "/modules/pull/ajax_hit.php");
RegisterModuleDependences("perfmon", "OnGetTableSchema", "pull", "CPullTableSchema", "OnGetTableSchema");
RegisterModuleDependences("main", "OnAfterRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
RegisterModuleDependences("main", "OnAfterUnRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
COption::SetOptionString("pull", "path_to_listener", (CMain::IsHTTPS() ? "https" : "http")."://#DOMAIN#".(CMain::IsHTTPS() ? ":8894" : ":8893").'/bitrix/sub/');
COption::SetOptionString("pull", "path_to_websocket", (CMain::IsHTTPS() ? "wss" : "ws")."://#DOMAIN#".(CMain::IsHTTPS() ? ":8894" : ":8893").'/bitrix/subws/');
COption::SetOptionString("pull", "path_to_publish", 'http://127.0.0.1:8895/bitrix/pub/');
COption::SetOptionString("pull", "websocket", 'N');
COption::SetOptionString("pull", "nginx", 'N');
COption::SetOptionString("pull", "push", 'N');
CAgent::AddAgent("CPullOptions::ClearAgent();", "pull", "N", 30, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+30, "FULL"));
return true;
}
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:31,代码来源:index.php
示例8: createSmartFilterSeoXML
function createSmartFilterSeoXML()
{
if (CModule::IncludeModule("iblock")) {
$resElDB = CIBlockElement::GetList(array("SORT" => "ASC"), array('IBLOCK_ID' => SEO_IBLOCK), false, false, array('PROPERTY_TARGET_ON', 'PROPERTY_INDEX', 'PROPERTY_FOLLOW', 'IBLOCK_ID', 'ID', 'NAME'));
$protocol = CMain::IsHTTPS() ? "https" : "http";
$host = $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 && $_SERVER['SERVER_PORT'] > 0 && strpos($_SERVER['HTTP_HOST'], ":") === false) {
$host .= ":" . $_SERVER['SERVER_PORT'];
}
$curDate = date("Y-m-d\\TH:i:s P");
$strBeginSmartFilter = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$index = 0;
while ($res = $resElDB->fetch()) {
$exp = explode('*', $res['PROPERTY_TARGET_ON_VALUE']['TEXT']);
$urlFilter = trim($exp[0]);
//clean url of smart filter
if ($index == 0) {
$strBeginSmartFilter .= "\t<url>\n\t\t";
$index++;
} else {
$strBeginSmartFilter .= "<url>\n\t\t";
}
$strBeginSmartFilter .= "<loc>" . $protocol . "://" . $host . $urlFilter . "</loc>\n\t\t";
$strBeginSmartFilter .= "<lastmod>" . $curDate . "</lastmod>\n\t";
$strBeginSmartFilter .= "</url>";
}
$strBeginSmartFilter .= "</urlset\n>";
$smartXmlFileName = 'sitemap_iblock_' . SEO_IBLOCK . '.xml';
$el = fopen($_SERVER['DOCUMENT_ROOT'] . '/' . $smartXmlFileName, "w");
fwrite($el, $strBeginSmartFilter);
fclose($el);
return "createSmartFilterSeoXML();";
}
}
开发者ID:VitaliiSestrenskyi,项目名称:sest,代码行数:34,代码来源:createSmartFilterSeoXML.php
示例9: url
/**
* get current url
*/
public static function url($full)
{
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
} else {
if (isset($_SERVER['argv'])) {
$uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
} elseif (isset($_SERVER['QUERY_STRING'])) {
$uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
} else {
$uri = $_SERVER['SCRIPT_NAME'];
}
}
// Prevent multiple slashes to avoid cross site requests via the FAPI.
$uri = '/' . ltrim($uri, '/');
$host = $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 && $_SERVER['SERVER_PORT'] > 0 && strpos($_SERVER['HTTP_HOST'], ":") === false) {
$host .= ":" . $_SERVER['SERVER_PORT'];
}
$protocol = CMain::IsHTTPS() ? "https" : "http";
if ($full) {
$uri = $protocol . "://" . $_SERVER['SERVER_NAME'] . $uri;
}
return $uri;
}
开发者ID:VitaliiSestrenskyi,项目名称:sest,代码行数:28,代码来源:sestrenskyiClass.php
示例10: OnEndBufferContent
/**
*
* @param string &$content
* @return void
*
*/
public function OnEndBufferContent(&$content)
{
if (isset($_GET["nocdn"])) {
return;
}
self::$proto = CMain::IsHTTPS() ? "https" : "http";
self::$config = CBitrixCloudCDNConfig::getInstance()->loadFromOptions();
if (self::$config->isExpired()) {
if (self::$config->lock()) {
try {
try {
$delayExpiration = true;
self::$config = CBitrixCloudCDNConfig::getInstance()->loadRemoteXML();
self::$config->saveToOptions();
self::$config->unlock();
} catch (CBitrixCloudException $e) {
//In case of documented XML error we'll disable CDN
if ($e->getErrorCode() !== "") {
self::SetActive(false);
$delayExpiration = false;
}
throw $e;
}
} catch (exception $e) {
if ($delayExpiration) {
self::$config->setExpired(time() + 1800);
}
CAdminNotify::Add(array("MESSAGE" => GetMessage("BCL_CDN_NOTIFY", array("#HREF#" => "/bitrix/admin/bitrixcloud_cdn.php?lang=" . LANGUAGE_ID)), "TAG" => "bitrixcloud_off", "MODULE_ID" => "bitrixcloud", "ENABLE_CLOSE" => "Y"));
self::$config->unlock();
return;
}
}
}
if (!self::$config->isActive()) {
return false;
}
$sites = self::$config->getSites();
if (defined("ADMIN_SECTION")) {
if (!isset($sites["admin"])) {
return;
}
} elseif (defined("SITE_ID")) {
if (!isset($sites[SITE_ID])) {
return;
}
} else {
return;
}
self::$ajax = preg_match("/<head>/i", substr($content, 0, 512)) === 0;
$arPrefixes = array_map(array("CBitrixCloudCDN", "_preg_quote"), self::$config->getLocationsPrefixes());
$arExtensions = array_map(array("CBitrixCloudCDN", "_preg_quote"), self::$config->getLocationsExtensions());
if (!empty($arPrefixes) && !empty($arExtensions)) {
$prefix_regex = "(?:" . implode("|", $arPrefixes) . ")";
$extension_regex = "(?:" . implode("|", $arExtensions) . ")";
$regex = "/\n\t\t\t\t((?i:\n\t\t\t\t\thref=\n\t\t\t\t\t|src=\n\t\t\t\t\t|BX\\.loadCSS\\(\n\t\t\t\t\t|BX\\.loadScript\\(\n\t\t\t\t\t|jsUtils\\.loadJSFile\\(\n\t\t\t\t\t|background\\s*:\\s*url\\(\n\t\t\t\t)) #attribute\n\t\t\t\t(\"|') #open_quote\n\t\t\t\t(" . $prefix_regex . ") #prefix\n\t\t\t\t([^?'\"]+\\.) #href body\n\t\t\t\t(" . $extension_regex . ") #extension\n\t\t\t\t(|\\?\\d+|\\?v=\\d+) #params\n\t\t\t\t(\\2) #close_quote\n\t\t\t/x";
$content = preg_replace_callback($regex, array("CBitrixCloudCDN", "_filter"), $content);
}
}
开发者ID:,项目名称:,代码行数:64,代码来源:
示例11: unRegisterModule
public static function unRegisterModule($moduleName)
{
$con = Application::getInstance()->getConnection();
$con->queryExecute("DELETE FROM b_agent WHERE MODULE_ID='" . $con->getSqlHelper()->forSql($moduleName) . "'");
\CMain::DelGroupRight($moduleName);
static::delete($moduleName);
$event = new Event("main", "OnAfterUnRegisterModule", array($moduleName));
$event->send();
}
开发者ID:ASDAFF,项目名称:open_bx,代码行数:9,代码来源:modulemanager.php
示例12: end
protected function end($terminate = true)
{
Diag::getInstance()->logDebugInfo($this->getName());
if ($terminate) {
/** @noinspection PhpUndefinedClassInspection */
\CMain::finalActions();
die;
}
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:9,代码来源:basecomponent.php
示例13: ExecuteEvents
function ExecuteEvents()
{
$err_mess = "<br>Class: CEvent<br>File: ".__FILE__."<br>Function: CheckEvents<br>Line: ";
global $DB, $CACHE_MANAGER;
if(defined("FX_FORK_AGENTS_AND_EVENTS_FUNCTION"))
{
if(CMain::ForkActions(array("CEvent", "ExecuteEvents")))
return "";
}
}
开发者ID:ASDAFF,项目名称:open_bx,代码行数:11,代码来源:event.php
示例14: SaveConfig
function SaveConfig($arServerList)
{
self::$arList = false;
$isOnline = false;
$content = '<' . '?
define("BX_MEMCACHE_CLUSTER", "' . EscapePHPString(CMain::GetServerUniqID()) . '");
$arList = array(
';
$defGroup = 1;
$arGroups = array();
$rsGroups = CClusterGroup::GetList(array("ID" => "DESC"));
while ($arGroup = $rsGroups->Fetch()) {
$defGroup = $arGroups[$arGroup["ID"]] = intval($arGroup["ID"]);
}
foreach ($arServerList as $i => $arServer) {
$isOnline |= $arServer["STATUS"] == "ONLINE";
$GROUP_ID = intval($arServer["GROUP_ID"]);
if (!array_key_exists($arServer["GROUP_ID"], $arGroups)) {
$GROUP_ID = $defGroup;
}
$content .= "\t" . intval($i) . " => array(\n";
$content .= "\t\t'ID' => \"" . EscapePHPString($arServer["ID"]) . "\",\n";
$content .= "\t\t'GROUP_ID' => " . $GROUP_ID . ",\n";
$content .= "\t\t'HOST' => \"" . EscapePHPString($arServer["HOST"]) . "\",\n";
$content .= "\t\t'PORT' => " . intval($arServer["PORT"]) . ",\n";
$content .= "\t\t'WEIGHT' => " . intval($arServer["WEIGHT"]) . ",\n";
if ($arServer["STATUS"] == "ONLINE") {
$content .= "\t\t'STATUS' => \"ONLINE\",\n";
} elseif ($arServer["STATUS"] == "OFFLINE") {
$content .= "\t\t'STATUS' => \"OFFLINE\",\n";
} else {
$content .= "\t\t'STATUS' => \"READY\",\n";
}
$content .= "\t),\n";
}
$content .= ');
?' . '>';
file_put_contents($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/cluster/memcache.php", $content);
bx_accelerator_reset();
self::$systemConfigurationUpdate = null;
$cache = \Bitrix\Main\Config\Configuration::getValue('cache');
if ($isOnline) {
if (!is_array($cache) || !isset($cache['type']) || !is_array($cache['type']) || !isset($cache['type']['class_name']) || !$cache['type']['class_name'] === 'CPHPCacheMemcacheCluster') {
\Bitrix\Main\Config\Configuration::setValue('cache', array('type' => array('class_name' => 'CPHPCacheMemcacheCluster', 'extension' => 'memcache', 'required_file' => 'modules/cluster/classes/general/memcache_cache.php')));
self::$systemConfigurationUpdate = true;
}
} else {
if (is_array($cache) && isset($cache['type']) && is_array($cache['type']) && isset($cache['type']['class_name']) && $cache['type']['class_name'] === 'CPHPCacheMemcacheCluster') {
\Bitrix\Main\Config\Configuration::setValue('cache', null);
self::$systemConfigurationUpdate = false;
}
}
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:53,代码来源:memcache.php
示例15: SaveGroupRight
private function SaveGroupRight()
{
CMain::DelGroupRight($this->module_id);
$GROUP = $_REQUEST['GROUPS'];
$RIGHT = $_REQUEST['RIGHTS'];
foreach ($GROUP as $k => $v) {
if ($k == 0) {
COption::SetOptionString($this->module_id, 'GROUP_DEFAULT_RIGHT', $RIGHT[0], 'Right for groups by default');
} else {
CMain::SetGroupRight($this->module_id, $GROUP[$k], $RIGHT[$k]);
}
}
}
开发者ID:Black-Core-Sec,项目名称:sd,代码行数:13,代码来源:CModuleOptions.php
示例16: ExecuteEvents
function ExecuteEvents()
{
$err_mess = "<br>Class: CEvent<br>File: " . __FILE__ . "<br>Function: CheckEvents<br>Line: ";
global $DB, $CACHE_MANAGER;
if (defined("BX_FORK_AGENTS_AND_EVENTS_FUNCTION")) {
if (CMain::ForkActions(array("CEvent", "ExecuteEvents"))) {
return "";
}
}
$uniq = COption::GetOptionString("main", "server_uniq_id", "");
if (strlen($uniq) <= 0) {
$uniq = md5(uniqid(rand(), true));
COption::SetOptionString("main", "server_uniq_id", $uniq);
}
$bulk = intval(COption::GetOptionString("main", "mail_event_bulk", 5));
if ($bulk <= 0) {
$bulk = 5;
}
$strSql = "SELECT 'x' " . "FROM b_event " . "WHERE SUCCESS_EXEC='N' " . "LIMIT 1";
$db_result_event = $DB->Query($strSql);
if ($db_result_event->Fetch()) {
$db_lock = $DB->Query("SELECT GET_LOCK('" . $uniq . "_event', 0) as L");
$ar_lock = $db_lock->Fetch();
if ($ar_lock["L"] == "0") {
return "";
}
} else {
if (CACHED_b_event !== false) {
$CACHE_MANAGER->Set("events", true);
}
return "";
}
$strSql = "\n\t\t\tSELECT ID, C_FIELDS, EVENT_NAME, MESSAGE_ID, LID, DATE_FORMAT(DATE_INSERT, '%d.%m.%Y %H:%i:%s') as DATE_INSERT, DUPLICATE\n\t\t\tFROM b_event\n\t\t\tWHERE SUCCESS_EXEC='N'\n\t\t\tORDER BY ID\n\t\t\tLIMIT " . $bulk;
$rsMails = $DB->Query($strSql);
while ($arMail = $rsMails->Fetch()) {
$flag = CEvent::HandleEvent($arMail);
/*
'0' - нет шаблонов (не нужно было ничего отправл¤ть)
'Y' - все отправлены
'F' - все не смогли быть отправлены
'P' - частично отправлены
*/
$strSql = "\n\t\t\t\tUPDATE b_event SET\n\t\t\t\t\tDATE_EXEC = now(),\n\t\t\t\t\tSUCCESS_EXEC = '{$flag}'\n\t\t\t\tWHERE\n\t\t\t\t\tID = " . $arMail["ID"];
$DB->Query($strSql, false, $err_mess . __LINE__);
}
$DB->Query("SELECT RELEASE_LOCK('" . $uniq . "_event')");
}
开发者ID:spas-viktor,项目名称:books,代码行数:47,代码来源:event.php
示例17: GetCurTemplate
function GetCurTemplate()
{
/** @noinspection PhpUnusedLocalVariableInspection */
global $DB, $APPLICATION, $USER;
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\t" . CMain::__GetConditionFName() . ",\n\t\t\t\t\tTEMPLATE\n\t\t\t\tFROM\n\t\t\t\t\tb_site_template\n\t\t\t\tWHERE\n\t\t\t\t\tSITE_ID = '" . SITE_ID . "'\n\t\t\t\tORDER BY\n\t\t\t\t\tif(length(" . CMain::__GetConditionFName() . ")>0, 1, 2), SORT\n\t\t\t\t";
$dbr = $DB->Query($strSql);
while ($ar = $dbr->Fetch()) {
$strCondition = trim($ar["CONDITION"]);
if (strlen($strCondition) > 0 && !@eval("return " . $strCondition . ";")) {
continue;
}
if (($path = getLocalPath("templates/" . $ar["TEMPLATE"], FX_PERSONAL_ROOT)) !== false && is_dir($_SERVER["DOCUMENT_ROOT"] . $path)) {
return $ar["TEMPLATE"];
}
}
return ".default";
}
开发者ID:ASDAFF,项目名称:open_bx,代码行数:17,代码来源:main.php
示例18: onBeforeAdd
public static function onBeforeAdd(Entity\Event $event)
{
$result = new Entity\EventResult();
$data = $event->getParameter("fields");
if (isset($data["USER_ID"]) && isset($data['PASSWORD'])) {
$salt = md5(\CMain::GetServerUniqID() . uniqid());
$password = $salt . md5($salt . $data['PASSWORD']);
$modified = array('PASSWORD' => $password);
$user = Main\UserTable::getRowById($data["USER_ID"]);
if ($user !== null) {
$realm = defined('BX_HTTP_AUTH_REALM') ? BX_HTTP_AUTH_REALM : "Bitrix Site Manager";
$digest = md5($user["LOGIN"] . ':' . $realm . ':' . $data['PASSWORD']);
$modified['DIGEST_PASSWORD'] = $digest;
}
$result->modifyFields($modified);
}
return $result;
}
开发者ID:rasuldev,项目名称:torino,代码行数:18,代码来源:applicationpassword.php
示例19: SaveConfig
public static function SaveConfig($arServerList)
{
self::$arList = false;
$content = '<'.'?
// define("BX_MEMCACHE_CLUSTER", "'.EscapePHPString(CMain::GetServerUniqID()).'");
$arList = array(
';
$defGroup = 1;
$arGroups = array();
$rsGroups = CClusterGroup::GetList(array("ID" => "DESC"));
while($arGroup = $rsGroups->Fetch())
$defGroup = $arGroups[$arGroup["ID"]] = intval($arGroup["ID"]);
foreach($arServerList as $i => $arServer)
{
$GROUP_ID = intval($arServer["GROUP_ID"]);
if(!array_key_exists($arServer["GROUP_ID"], $arGroups))
$GROUP_ID = $defGroup;
$content .= "\t".intval($i)." => array(\n";
$content .= "\t\t'ID' => \"".EscapePHPString($arServer["ID"])."\",\n";
$content .= "\t\t'GROUP_ID' => ".$GROUP_ID.",\n";
$content .= "\t\t'HOST' => \"".EscapePHPString($arServer["HOST"])."\",\n";
$content .= "\t\t'PORT' => ".intval($arServer["PORT"]).",\n";
$content .= "\t\t'WEIGHT' => ".intval($arServer["WEIGHT"]).",\n";
if($arServer["STATUS"] == "ONLINE")
$content .= "\t\t'STATUS' => \"ONLINE\",\n";
elseif($arServer["STATUS"] == "OFFLINE")
$content .= "\t\t'STATUS' => \"OFFLINE\",\n";
else
$content .= "\t\t'STATUS' => \"READY\",\n";
$content .= "\t),\n";
}
$content .= ');
?'.'>';
file_put_contents(
$_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/cluster/memcache.php"
,$content
);
}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:41,代码来源:memcache.php
示例20: ExecuteAgents
public static function ExecuteAgents($str_crontab)
{
global $DB, $CACHE_MANAGER, $pPERIOD;
if (defined("BX_FORK_AGENTS_AND_EVENTS_FUNCTION")) {
if (CMain::ForkActions(array("CAgent", "ExecuteAgents"), array($str_crontab))) {
return "";
}
}
$saved_time = 0;
$cache_id = "agents" . $str_crontab;
if (CACHED_b_agent !== false && $CACHE_MANAGER->Read(CACHED_b_agent, $cache_id, "agents")) {
$saved_time = $CACHE_MANAGER->Get($cache_id);
if (time() < $saved_time) {
return "";
}
}
$uniq = CMain::GetServerUniqID();
$strSql = "\n\t\t\tSELECT 'x'\n\t\t\tFROM b_agent\n\t\t\tWHERE\n\t\t\t\tACTIVE = 'Y'\n\t\t\t\tAND NEXT_EXEC <= now()\n\t\t\t\tAND (DATE_CHECK IS NULL OR DATE_CHECK <= now())\n\t\t\t\t" . $str_crontab . "\n\t\t\tLIMIT 1\n\t\t";
$db_result_agents = $DB->Query($strSql);
if ($db_result_agents->Fetch()) {
$db_lock = $DB->Query("SELECT GET_LOCK('" . $uniq . "_agent', 0) as L");
$ar_lock = $db_lock->Fetch();
if ($ar_lock["L"] == "0") {
return "";
}
} else {
if (CACHED_b_agent !== false) {
$rs = $DB->Query("SELECT UNIX_TIMESTAMP(MIN(NEXT_EXEC))-UNIX_TIMESTAMP(NOW()) DATE_DIFF FROM b_agent WHERE ACTIVE='Y' " . $str_crontab . "");
$ar = $rs->Fetch();
if (!$ar || $ar["DATE_DIFF"] < 0) {
$date_diff = 0;
} elseif ($ar["DATE_DIFF"] > CACHED_b_agent) {
$date_diff = CACHED_b_agent;
} else {
$date_diff = $ar["DATE_DIFF"];
}
if ($saved_time > 0) {
$CACHE_MANAGER->Clean($cache_id, "agents");
$CACHE_MANAGER->Read(CACHED_b_agent, $cache_id, "agents");
}
$CACHE_MANAGER->Set($cache_id, intval(time() + $date_diff));
}
return "";
}
$strSql = "SELECT ID, NAME, AGENT_INTERVAL, IS_PERIOD, MODULE_ID " . "FROM b_agent " . "WHERE ACTIVE='Y' " . "\tAND NEXT_EXEC<=now() " . "\tAND (DATE_CHECK IS NULL OR DATE_CHECK<=now()) " . $str_crontab . " ORDER BY RUNNING ASC, SORT desc";
$db_result_agents = $DB->Query($strSql);
$ids = '';
$agents_array = array();
while ($db_result_agents_array = $db_result_agents->Fetch()) {
$agents_array[] = $db_result_agents_array;
$ids .= ($ids != '' ? ', ' : '') . $db_result_agents_array["ID"];
}
if ($ids != '') {
$strSql = "UPDATE b_agent SET DATE_CHECK=DATE_ADD(IF(DATE_CHECK IS NULL, now(), DATE_CHECK), INTERVAL 600 SECOND) WHERE ID IN (" . $ids . ")";
$DB->Query($strSql);
}
$DB->Query("SELECT RELEASE_LOCK('" . $uniq . "_agent')");
$logFunction = defined("BX_AGENTS_LOG_FUNCTION") && function_exists(BX_AGENTS_LOG_FUNCTION) ? BX_AGENTS_LOG_FUNCTION : false;
for ($i = 0, $n = count($agents_array); $i < $n; $i++) {
$arAgent = $agents_array[$i];
if ($logFunction) {
$logFunction($arAgent, "start");
}
@set_time_limit(0);
ignore_user_abort(true);
if (strlen($arAgent["MODULE_ID"]) > 0 && $arAgent["MODULE_ID"] != "main") {
if (!CModule::IncludeModule($arAgent["MODULE_ID"])) {
continue;
}
}
//update the agent to the running state - if it fails it'll go to the end of the list on the next try
$DB->Query("UPDATE b_agent SET RUNNING='Y' WHERE ID=" . $arAgent["ID"]);
//these vars can be assigned within agent code
$pPERIOD = $arAgent["AGENT_INTERVAL"];
CTimeZone::Disable();
global $USER;
unset($USER);
$eval_result = "";
$e = eval("\$eval_result=" . $arAgent["NAME"]);
unset($USER);
CTimeZone::Enable();
if ($logFunction) {
$logFunction($arAgent, "finish", $eval_result, $e);
}
if ($e === false) {
continue;
} elseif (strlen($eval_result) <= 0) {
$strSql = "DELETE FROM b_agent WHERE ID=" . $arAgent["ID"];
} else {
$strSql = "\n\t\t\t\t\tUPDATE b_agent SET\n\t\t\t\t\t\tNAME='" . $DB->ForSQL($eval_result, 2000) . "',\n\t\t\t\t\t\tLAST_EXEC=now(),\n\t\t\t\t\t\tNEXT_EXEC=DATE_ADD(" . ($arAgent["IS_PERIOD"] == "Y" ? "NEXT_EXEC" : "now()") . ", INTERVAL " . $pPERIOD . " SECOND),\n\t\t\t\t\t\tDATE_CHECK=NULL,\n\t\t\t\t\t\tRUNNING='N'\n\t\t\t\t\tWHERE ID=" . $arAgent["ID"];
}
$DB->Query($strSql);
}
return null;
}
开发者ID:rasuldev,项目名称:torino,代码行数:95,代码来源:agent.php
注:本文中的CMain类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论