本文整理汇总了PHP中COption类的典型用法代码示例。如果您正苦于以下问题:PHP COption类的具体用法?PHP COption怎么用?PHP COption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了COption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetModuleConnection
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"];
}
}
示例2: 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 = '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;
}
示例3: GetPHPFilesMark
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;
}
}
示例4: Show
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();
}
}
}
}
}
示例5: Authorize
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;
}
示例6: __construct
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);
}
}
示例7: AddBlogPost
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;
}
}
示例8: checkAccountNumberValue
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;
}
示例9: CWebDavVirtual
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"));
}
}
示例10: DoUninstall
public function DoUninstall()
{
COption::RemoveOption('imageimport');
DeleteDirFiles($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/imageimport/install/admin', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin');
UnRegisterModule('imageimport');
return true;
}
示例11: GetAbsoluteRoot
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";
}
示例12: InstallDB
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;
}
示例13: CalcUserBonus
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;
}
示例14: OnModuleInstalledEvent
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);
}
}
示例15: UnInstallDB
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;
}