本文整理汇总了PHP中CMain类的典型用法代码示例。如果您正苦于以下问题:PHP CMain类的具体用法?PHP CMain怎么用?PHP CMain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();";
}
}
示例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;
}
示例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);
}
}
示例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();
}
示例12: end
protected function end($terminate = true)
{
Diag::getInstance()->logDebugInfo($this->getName());
if ($terminate) {
/** @noinspection PhpUndefinedClassInspection */
\CMain::finalActions();
die;
}
}
示例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 "";
}
}
示例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;
}
}
}
示例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]);
}
}
}