当前位置: 首页>>代码示例>>PHP>>正文


PHP CTimeZone::Enabled方法代码示例

本文整理汇总了PHP中CTimeZone::Enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP CTimeZone::Enabled方法的具体用法?PHP CTimeZone::Enabled怎么用?PHP CTimeZone::Enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTimeZone的用法示例。


在下文中一共展示了CTimeZone::Enabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetRealParameterValue

 private function GetRealParameterValue($objectName, $fieldName, &$result)
 {
     $return = false;
     if ($objectName == "Document") {
         $rootActivity = $this->GetRootActivity();
         $documentId = $rootActivity->GetDocumentId();
         $documentService = $this->workflow->GetService("DocumentService");
         $document = $documentService->GetDocument($documentId);
         if (array_key_exists($fieldName, $document)) {
             $result = $document[$fieldName];
             if (is_array($result) && strtoupper(substr($fieldName, -strlen('_PRINTABLE'))) == '_PRINTABLE') {
                 $result = implode(", ", $result);
             }
             $return = true;
         } else {
             $result = '';
             $return = true;
         }
     } elseif ($objectName == "Template") {
         $rootActivity = $this->GetRootActivity();
         if (substr($fieldName, -strlen("_printable")) == "_printable") {
             $fieldNameTmp = substr($fieldName, 0, strlen($fieldName) - strlen("_printable"));
             $result = $rootActivity->{$fieldNameTmp};
             $rootActivity = $this->GetRootActivity();
             $documentId = $rootActivity->GetDocumentId();
             $documentService = $this->workflow->GetService("DocumentService");
             $result = $documentService->GetFieldValuePrintable($documentId, $fieldNameTmp, $rootActivity->arPropertiesTypes[$fieldNameTmp]["Type"], $result, $rootActivity->arPropertiesTypes[$fieldNameTmp]);
             if (is_array($result)) {
                 $result = implode(", ", $result);
             }
         } else {
             $result = $rootActivity->{$fieldName};
         }
         $return = true;
     } elseif ($objectName == "Variable" || $objectName == 'Constant') {
         $rootActivity = $this->GetRootActivity();
         if (substr($fieldName, -strlen("_printable")) == "_printable") {
             $fieldNameTmp = substr($fieldName, 0, strlen($fieldName) - strlen("_printable"));
             $result = $objectName == "Variable" ? $rootActivity->GetVariable($fieldNameTmp) : $rootActivity->GetConstant($fieldNameTmp);
             $fieldType = $objectName == "Variable" ? $rootActivity->arVariablesTypes[$fieldNameTmp] : $rootActivity->GetConstantType($fieldNameTmp);
             $rootActivity = $this->GetRootActivity();
             $documentId = $rootActivity->GetDocumentId();
             $documentService = $this->workflow->GetService("DocumentService");
             $result = $documentService->GetFieldValuePrintable($documentId, $fieldNameTmp, $fieldType["Type"], $result, $fieldType);
             if (is_array($result)) {
                 $result = implode(", ", $result);
             }
         } else {
             $result = $objectName == "Variable" ? $rootActivity->GetVariable($fieldName) : $rootActivity->GetConstant($fieldName);
         }
         $return = true;
     } elseif ($objectName == "Workflow") {
         $result = $this->GetWorkflowInstanceId();
         $return = true;
     } elseif ($objectName == "User") {
         $result = 0;
         if ($GLOBALS["USER"]->IsAuthorized()) {
             $result = "user_" . $GLOBALS["USER"]->GetID();
         }
         $return = true;
     } elseif ($objectName == "System") {
         global $DB;
         $result = null;
         if ($fieldName == "Now") {
             $result = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
         } elseif ($fieldName == "NowLocal") {
             $result = time();
             if (CTimeZone::Enabled()) {
                 $result += CTimeZone::GetOffset();
             }
             $result = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $result);
         } elseif ($fieldName == "Date") {
             $result = date($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")));
         }
         if ($result !== null) {
             $return = true;
         }
     } elseif ($objectName) {
         $activity = $this->workflow->GetActivityByName($objectName);
         if ($activity) {
             // _printable is not supported because mapping between activity property types
             // and document property types is not supported
             $result = $activity->{$fieldName};
             $return = true;
         }
     }
     return $return;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:88,代码来源:activity.php

示例2: htmlspecialcharsbx

{
	$arResult["USER_PROPERTIES"]["SHOW"] = "Y";
	$arResult["bVarsFromForm"] = (count($arResult['ERRORS']) <= 0) ? false : true;
}
// ******************** /User properties ***************************************************

// initialize captcha
if ($arResult["USE_CAPTCHA"] == "Y")
	$arResult["CAPTCHA_CODE"] = htmlspecialcharsbx($APPLICATION->CaptchaGetCode());

// set title
if ($arParams["SET_TITLE"] == "Y") 
	$APPLICATION->SetTitle(GetMessage("REGISTER_DEFAULT_TITLE"));

//time zones
$arResult["TIME_ZONE_ENABLED"] = CTimeZone::Enabled();
if($arResult["TIME_ZONE_ENABLED"])
	$arResult["TIME_ZONE_LIST"] = CTimeZone::GetZones();

$arResult["SECURE_AUTH"] = false;
if(!CMain::IsHTTPS() && COption::GetOptionString('main', 'use_encrypted_auth', 'N') == 'Y')
{
	$sec = new CRsaSecurity();
	if(($arKeys = $sec->LoadKeys()))
	{
		$sec->SetKeys($arKeys);
		$sec->AddToForm('regform', array('REGISTER[PASSWORD]', 'REGISTER[CONFIRM_PASSWORD]'));
		$arResult["SECURE_AUTH"] = true;
	}
}
开发者ID:ASDAFF,项目名称:open_bx,代码行数:30,代码来源:component.php

示例3: getDatetimeExpressionTemplate

 /**
  * @return string
  */
 public static function getDatetimeExpressionTemplate()
 {
     if (self::$datetimeTemplate === null) {
         $helper = Application::getConnection()->getSqlHelper();
         $format = Context::getCurrent()->getCulture()->getDateTimeFormat();
         $datetimeFieldName = '#FIELD#';
         $datetimeField = $datetimeFieldName;
         if (\CTimeZone::Enabled()) {
             $diff = \CTimeZone::GetOffset();
             if ($diff != 0) {
                 $datetimeField = $helper->addSecondsToDateTime($diff, $datetimeField);
             }
             unset($diff);
         }
         self::$datetimeTemplate = str_replace(array('%', $datetimeFieldName), array('%%', '%1$s'), $helper->formatDate($format, $datetimeField));
         unset($datetimeField, $datetimeFieldName, $format, $helper);
     }
     return self::$datetimeTemplate;
 }
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:22,代码来源:currencymanager.php

示例4: PrologActions

 function PrologActions()
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $USER;
     if (defined("BX_CHECK_SHORT_URI") && BX_CHECK_SHORT_URI) {
         if ($arUri = CBXShortUri::GetUri($_SERVER["REQUEST_URI"])) {
             CBXShortUri::SetLastUsed($arUri["ID"]);
             if (CModule::IncludeModule("statistic")) {
                 CStatEvent::AddCurrent("short_uri_redirect", "", "", "", "", $arUri["URI"], "N", SITE_ID);
             }
             LocalRedirect($arUri["URI"], true, CBXShortUri::GetHttpStatusCodeText($arUri["STATUS"]));
             die;
         }
     }
     //session expander
     if (COption::GetOptionString("main", "session_expand", "Y") != "N" && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND == false)) {
         $arPolicy = $USER->GetSecurityPolicy();
         $phpSessTimeout = ini_get("session.gc_maxlifetime");
         if ($arPolicy["SESSION_TIMEOUT"] > 0) {
             $sessTimeout = min($arPolicy["SESSION_TIMEOUT"] * 60, $phpSessTimeout);
         } else {
             $sessTimeout = $phpSessTimeout;
         }
         $cookie_prefix = COption::GetOptionString('main', 'cookie_name', 'BITRIX_SM');
         $salt = $_COOKIE[$cookie_prefix . '_UIDH'] . "|" . $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . LICENSE_KEY . "|" . CMain::GetServerUniqID();
         $key = md5(bitrix_sessid() . $salt);
         $bShowMess = $USER->IsAuthorized() && COption::GetOptionString("main", "session_show_message", "Y") != "N";
         $ext = array('ajax');
         if ($bShowMess) {
             $ext[] = "fx";
         }
         CUtil::InitJSCore($ext);
         $jsMsg = '<script type="text/javascript">' . "\n" . ($bShowMess ? 'bxSession.mess.messSessExpired = \'' . CUtil::JSEscape(GetMessage("MAIN_SESS_MESS", array("#TIMEOUT#" => round($sessTimeout / 60)))) . '\';' . "\n" : '') . 'bxSession.Expand(' . $sessTimeout . ', \'' . bitrix_sessid() . '\', ' . ($bShowMess ? 'true' : 'false') . ', \'' . $key . '\');' . "\n" . '</script>';
         if ($APPLICATION->IsJSOptimized()) {
             $APPLICATION->AddHeadScript('/bitrix/js/main/session.js');
             $APPLICATION->AddAdditionalJS($jsMsg);
         } else {
             $APPLICATION->AddHeadString('<script type="text/javascript" src="' . CUtil::GetAdditionalFileURL('/bitrix/js/main/session.js') . '"></script>' . "\n" . $jsMsg, true);
         }
         $_SESSION["BX_SESSION_COUNTER"] = intval($_SESSION["BX_SESSION_COUNTER"]) + 1;
         if (!defined("BX_SKIP_SESSION_TERMINATE_TIME")) {
             $_SESSION["BX_SESSION_TERMINATE_TIME"] = time() + $sessTimeout;
         }
     }
     //user auto time zone via js cookies
     if (CTimeZone::Enabled()) {
         CTimeZone::SetAutoCookie();
     }
     // check user options set via cookie
     if ($USER->IsAuthorized()) {
         $cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS";
         if (!empty($_COOKIE[$cookieName])) {
             CUserOptions::SetCookieOptions($cookieName);
         }
     }
     if (COption::GetOptionString("main", "buffer_content", "Y") == "Y" && (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)) {
         ob_start(array(&$APPLICATION, "EndBufferContent"));
         $APPLICATION->buffered = true;
         define("BX_BUFFER_USED", true);
         register_shutdown_function(create_function('', 'while(@ob_end_flush());'));
     }
     foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent);
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:65,代码来源:main.php

示例5: GetOffset

 public static function GetOffset($userId = false)
 {
     $offset = 0;
     if ($userId > 0) {
         if (!isset(self::$arTimezoneOffsets[$userId])) {
             if (!CTimeZone::Enabled()) {
                 CTimeZone::Enable();
                 $offset = CTimeZone::GetOffset($userId);
                 CTimeZone::Disable();
             } else {
                 $offset = CTimeZone::GetOffset($userId);
             }
             self::$arTimezoneOffsets[$userId] = $offset;
         } else {
             $offset = self::$arTimezoneOffsets[$userId];
         }
     } else {
         if (!isset(self::$offset)) {
             if (!CTimeZone::Enabled()) {
                 CTimeZone::Enable();
                 $offset = CTimeZone::GetOffset();
                 CTimeZone::Disable();
             } else {
                 $offset = CTimeZone::GetOffset();
             }
             self::$offset = $offset;
         } else {
             $offset = self::$offset;
         }
     }
     return $offset;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:32,代码来源:calendar.php

示例6: createFromUserTime

 /**
  * Creates DateTime object from local user time using global timezone settings and default culture
  *
  * @param string $timeString
  * @return DateTime
  */
 public static function createFromUserTime($timeString)
 {
     /** @var DateTime $time */
     try {
         //try full datetime format
         $time = new static($timeString);
     } catch (Main\ObjectException $e) {
         //try short date format
         $time = new static($timeString, Date::getFormat());
         $time->setTime(0, 0, 0);
     }
     if (\CTimeZone::Enabled()) {
         static $diff = null;
         if ($diff === null) {
             $diff = \CTimeZone::GetOffset();
         }
         if ($diff != 0) {
             $time->add(($diff > 0 ? "-" : "") . "PT" . abs($diff) . "S");
         }
     }
     return $time;
 }
开发者ID:ASDAFF,项目名称:open_bx,代码行数:28,代码来源:datetime.php

示例7: array

<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$arFormFields = array("NAME" => 1, "SECOND_NAME" => 1, "LAST_NAME" => 1, "AUTO_TIME_ZONE" => 1, "PERSONAL_PROFESSION" => 1, "PERSONAL_WWW" => 1, "PERSONAL_ICQ" => 1, "PERSONAL_GENDER" => 1, "PERSONAL_BIRTHDAY" => 1, "PERSONAL_PHOTO" => 1, "PERSONAL_PHONE" => 1, "PERSONAL_FAX" => 1, "PERSONAL_MOBILE" => 1, "PERSONAL_PAGER" => 1, "PERSONAL_STREET" => 1, "PERSONAL_MAILBOX" => 1, "PERSONAL_CITY" => 1, "PERSONAL_STATE" => 1, "PERSONAL_ZIP" => 1, "PERSONAL_COUNTRY" => 1, "PERSONAL_NOTES" => 1, "WORK_COMPANY" => 1, "WORK_DEPARTMENT" => 1, "WORK_POSITION" => 1, "WORK_WWW" => 1, "WORK_PHONE" => 1, "WORK_FAX" => 1, "WORK_PAGER" => 1, "WORK_STREET" => 1, "WORK_MAILBOX" => 1, "WORK_CITY" => 1, "WORK_STATE" => 1, "WORK_ZIP" => 1, "WORK_COUNTRY" => 1, "WORK_PROFILE" => 1, "WORK_LOGO" => 1, "WORK_NOTES" => 1);
if (!CTimeZone::Enabled()) {
    unset($arFormFields["AUTO_TIME_ZONE"]);
}
$arUserFields = array();
foreach ($arFormFields as $value => $dummy) {
    $arUserFields[$value] = "[" . $value . "] " . GetMessage("REGISTER_FIELD_" . $value);
}
$arRes = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER", 0, LANGUAGE_ID);
$userProp = array();
if (!empty($arRes)) {
    foreach ($arRes as $key => $val) {
        $userProp[$val["FIELD_NAME"]] = strLen($val["EDIT_FORM_LABEL"]) > 0 ? $val["EDIT_FORM_LABEL"] : $val["FIELD_NAME"];
    }
}
$arComponentParameters = array("PARAMETERS" => array("SHOW_FIELDS" => array("NAME" => GetMessage("REGISTER_SHOW_FIELDS"), "TYPE" => "LIST", "MULTIPLE" => "Y", "ADDITIONAL_VALUES" => "N", "VALUES" => $arUserFields, "PARENT" => "BASE"), "REQUIRED_FIELDS" => array("NAME" => GetMessage("REGISTER_REQUIRED_FIELDS"), "TYPE" => "LIST", "MULTIPLE" => "Y", "ADDITIONAL_VALUES" => "N", "VALUES" => $arUserFields, "PARENT" => "BASE"), "AUTH" => array("NAME" => GetMessage("REGISTER_AUTOMATED_AUTH"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "PARENT" => "ADDITIONAL_SETTINGS"), "USE_BACKURL" => array("NAME" => GetMessage("REGISTER_USE_BACKURL"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "PARENT" => "ADDITIONAL_SETTINGS"), "SUCCESS_PAGE" => array("NAME" => GetMessage("REGISTER_SUCCESS_PAGE"), "TYPE" => "STRING", "DEFAULT" => "", "PARENT" => "ADDITIONAL_SETTINGS"), "SET_TITLE" => array(), "USER_PROPERTY" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("USER_PROPERTY"), "TYPE" => "LIST", "VALUES" => $userProp, "MULTIPLE" => "Y", "DEFAULT" => array())));
开发者ID:spas-viktor,项目名称:books,代码行数:21,代码来源:.parameters.php

示例8: GetRealParameterValue

 private function GetRealParameterValue($objectName, $fieldName, &$result, array $modifiers = null)
 {
     $return = true;
     $property = null;
     if ($objectName == "Document") {
         $rootActivity = $this->GetRootActivity();
         $documentId = $rootActivity->GetDocumentId();
         /** @var CBPDocumentService $documentService */
         $documentService = $this->workflow->GetService("DocumentService");
         $document = $documentService->GetDocument($documentId);
         $result = '';
         if (isset($document[$fieldName])) {
             $result = $document[$fieldName];
             if (is_array($result) && strtoupper(substr($fieldName, -strlen('_PRINTABLE'))) == '_PRINTABLE') {
                 $result = implode(", ", $result);
             }
             if (!empty($modifiers)) {
                 $documentType = $this->GetDocumentType();
                 $fields = $documentService->GetDocumentFields($documentType);
                 $property = isset($fields[$fieldName]) ? $fields[$fieldName] : null;
             }
         }
     } elseif ($objectName == 'Template' || $objectName == 'Variable' || $objectName == 'Constant') {
         $rootActivity = $this->GetRootActivity();
         if (substr($fieldName, -strlen("_printable")) == "_printable") {
             $fieldName = substr($fieldName, 0, strlen($fieldName) - strlen("_printable"));
             $modifiers = array('printable');
         }
         switch ($objectName) {
             case 'Variable':
                 $result = $rootActivity->GetVariable($fieldName);
                 $property = $rootActivity->arVariablesTypes[$fieldName];
                 break;
             case 'Constant':
                 $result = $rootActivity->GetConstant($fieldName);
                 $property = $rootActivity->GetConstantType($fieldName);
                 break;
             default:
                 $result = $rootActivity->{$fieldName};
                 $property = $rootActivity->arPropertiesTypes[$fieldName];
         }
     } elseif ($objectName == "Workflow") {
         $result = $this->GetWorkflowInstanceId();
         $property = array('Type' => 'string');
     } elseif ($objectName == "User") {
         $result = 0;
         if (isset($GLOBALS["USER"]) && is_object($GLOBALS["USER"]) && $GLOBALS["USER"]->isAuthorized()) {
             $result = "user_" . $GLOBALS["USER"]->GetID();
         }
         $property = array('Type' => 'user');
     } elseif ($objectName == "System") {
         global $DB;
         $result = null;
         $property = array('Type' => 'datetime');
         if ($fieldName == "Now") {
             $result = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")));
         } elseif ($fieldName == "NowLocal") {
             $result = time();
             if (CTimeZone::Enabled()) {
                 $result += CTimeZone::GetOffset();
             }
             $result = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $result);
         } elseif ($fieldName == "Date") {
             $result = date($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")));
             $property = array('Type' => 'date');
         }
         if ($result === null) {
             $return = false;
         }
     } elseif ($objectName) {
         $activity = $this->workflow->GetActivityByName($objectName);
         if ($activity) {
             $result = $activity->{$fieldName};
             //if mapping is set, we can apply modifiers (type converting & formating like `printable`, `bool` etc.)
             if (isset($activity->arPropertiesTypes[$fieldName])) {
                 $property = $activity->arPropertiesTypes[$fieldName];
             }
         } else {
             $return = false;
         }
     } else {
         $return = false;
     }
     if ($return) {
         $result = $this->applyPropertyValueModifiers($fieldName, $property, $result, $modifiers);
     }
     return $return;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:88,代码来源:activity.php

示例9: Authorize

 /**
  * Performs the user authorization:
  *    fills session parameters;
  *    remembers auth;
  *    spreads auth through sites
  */
 function Authorize($id, $bSave = false, $bUpdate = true, $applicationId = null)
 {
     /** @global CMain $APPLICATION */
     global $DB, $APPLICATION;
     unset($_SESSION["SESS_OPERATIONS"]);
     unset($_SESSION["MODULE_PERMISSIONS"]);
     $_SESSION["BX_LOGIN_NEED_CAPTCHA"] = false;
     $strSql = "SELECT U.* " . "FROM b_user U  " . "WHERE U.ID='" . intval($id) . "' ";
     $result = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     if ($arUser = $result->Fetch()) {
         $this->justAuthorized = true;
         $_SESSION["SESS_AUTH"]["AUTHORIZED"] = "Y";
         $_SESSION["SESS_AUTH"]["USER_ID"] = $arUser["ID"];
         $_SESSION["SESS_AUTH"]["LOGIN"] = $arUser["LOGIN"];
         $_SESSION["SESS_AUTH"]["LOGIN_COOKIES"] = $arUser["LOGIN"];
         $_SESSION["SESS_AUTH"]["EMAIL"] = $arUser["EMAIL"];
         $_SESSION["SESS_AUTH"]["PASSWORD_HASH"] = $arUser["PASSWORD"];
         $_SESSION["SESS_AUTH"]["TITLE"] = $arUser["TITLE"];
         $_SESSION["SESS_AUTH"]["NAME"] = $arUser["NAME"] . ($arUser["NAME"] == '' || $arUser["LAST_NAME"] == '' ? "" : " ") . $arUser["LAST_NAME"];
         $_SESSION["SESS_AUTH"]["FIRST_NAME"] = $arUser["NAME"];
         $_SESSION["SESS_AUTH"]["SECOND_NAME"] = $arUser["SECOND_NAME"];
         $_SESSION["SESS_AUTH"]["LAST_NAME"] = $arUser["LAST_NAME"];
         $_SESSION["SESS_AUTH"]["PERSONAL_PHOTO"] = $arUser["PERSONAL_PHOTO"];
         $_SESSION["SESS_AUTH"]["PERSONAL_GENDER"] = $arUser["PERSONAL_GENDER"];
         $_SESSION["SESS_AUTH"]["ADMIN"] = false;
         $_SESSION["SESS_AUTH"]["CONTROLLER_ADMIN"] = false;
         $_SESSION["SESS_AUTH"]["POLICY"] = CUser::GetGroupPolicy($arUser["ID"]);
         $_SESSION["SESS_AUTH"]["AUTO_TIME_ZONE"] = trim($arUser["AUTO_TIME_ZONE"]);
         $_SESSION["SESS_AUTH"]["TIME_ZONE"] = $arUser["TIME_ZONE"];
         $_SESSION["SESS_AUTH"]["APPLICATION_ID"] = $applicationId;
         $_SESSION["SESS_AUTH"]["BX_USER_ID"] = $arUser["BX_USER_ID"];
         // groups
         $_SESSION["SESS_AUTH"]["GROUPS"] = Main\UserTable::getUserGroupIds($arUser["ID"]);
         foreach ($_SESSION["SESS_AUTH"]["GROUPS"] as $groupId) {
             if ($groupId == 1) {
                 $_SESSION["SESS_AUTH"]["ADMIN"] = true;
                 break;
             }
         }
         //sometimes we don't need to update db (REST)
         if ($bUpdate) {
             $tz = '';
             if (CTimeZone::Enabled()) {
                 if (!CTimeZone::IsAutoTimeZone(trim($arUser["AUTO_TIME_ZONE"])) || CTimeZone::GetCookieValue() !== null) {
                     $tz = ', TIME_ZONE_OFFSET = ' . CTimeZone::GetOffset();
                 }
             }
             $bxUid = '';
             if (!empty($_COOKIE['BX_USER_ID']) && preg_match('/^[0-9a-f]{32}$/', $_COOKIE['BX_USER_ID'])) {
                 if ($_COOKIE['BX_USER_ID'] != $arUser['BX_USER_ID']) {
                     // save new bxuid value
                     $bxUid = ", BX_USER_ID = '" . $_COOKIE['BX_USER_ID'] . "'";
                     $arUser['BX_USER_ID'] = $_COOKIE['BX_USER_ID'];
                     $_SESSION["SESS_AUTH"]["BX_USER_ID"] = $_COOKIE['BX_USER_ID'];
                 }
             }
             $DB->Query("\n\t\t\t\t\tUPDATE b_user SET\n\t\t\t\t\t\tSTORED_HASH = NULL,\n\t\t\t\t\t\tLAST_LOGIN = " . $DB->GetNowFunction() . ",\n\t\t\t\t\t\tTIMESTAMP_X = TIMESTAMP_X,\n\t\t\t\t\t\tLOGIN_ATTEMPTS = 0\n\t\t\t\t\t\t" . $tz . "\n\t\t\t\t\t\t" . $bxUid . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tID=" . $arUser["ID"]);
             if ($applicationId === null && ($bSave || COption::GetOptionString("main", "auth_multisite", "N") == "Y")) {
                 $hash = $this->GetSessionHash();
                 $secure = COption::GetOptionString("main", "use_secure_password_cookies", "N") == "Y" && CMain::IsHTTPS();
                 if ($bSave) {
                     $period = time() + 60 * 60 * 24 * 30 * 60;
                     $spread = BX_SPREAD_SITES | BX_SPREAD_DOMAIN;
                 } else {
                     $period = 0;
                     $spread = BX_SPREAD_SITES;
                 }
                 $APPLICATION->set_cookie("UIDH", $hash, $period, '/', false, $secure, $spread, false, true);
                 $APPLICATION->set_cookie("UIDL", $arUser["LOGIN"], $period, '/', false, $secure, $spread, false, true);
                 $stored_id = CUser::CheckStoredHash($arUser["ID"], $hash);
                 if ($stored_id) {
                     $DB->Query("UPDATE b_user_stored_auth SET\n\t\t\t\t\t\t\t\tLAST_AUTH=" . $DB->CurrentTimeFunction() . ",\n\t\t\t\t\t\t\t\t" . ($this->bLoginByHash ? "" : "TEMP_HASH='" . ($bSave ? "N" : "Y") . "', ") . "\n\t\t\t\t\t\t\t\tIP_ADDR='" . sprintf("%u", ip2long($_SERVER["REMOTE_ADDR"])) . "'\n\t\t\t\t\t\t\tWHERE ID=" . $stored_id);
                 } else {
                     $arFields = array('USER_ID' => $arUser["ID"], '~DATE_REG' => $DB->CurrentTimeFunction(), '~LAST_AUTH' => $DB->CurrentTimeFunction(), 'TEMP_HASH' => $bSave ? "N" : "Y", '~IP_ADDR' => sprintf("%u", ip2long($_SERVER["REMOTE_ADDR"])), 'STORED_HASH' => $hash);
                     $stored_id = CDatabase::Add("b_user_stored_auth", $arFields);
                 }
                 $_SESSION["SESS_AUTH"]["STORED_AUTH_ID"] = $stored_id;
             }
         }
         $this->admin = null;
         $arParams = array("user_fields" => $arUser, "save" => $bSave, "update" => $bUpdate, "applicationId" => $applicationId);
         foreach (GetModuleEvents("main", "OnAfterUserAuthorize", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($arParams));
         }
         foreach (GetModuleEvents("main", "OnUserLogin", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($_SESSION["SESS_AUTH"]["USER_ID"]));
         }
         if (COption::GetOptionString("main", "event_log_login_success", "N") === "Y") {
             CEventLog::Log("SECURITY", "USER_AUTHORIZE", "main", $arUser["ID"], $applicationId);
         }
         CHTMLPagesCache::OnUserLogin();
         return true;
     }
     return false;
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:user.php

示例10: array

echo CSite::SelectBox("LID", $str_LID, "", "", "style=\"width:220px\"" . $dis);
?>
</td>
	</tr>
<?
	$tabControl->EndCustomField("LID", '<input type="hidden" name="LID" value="'.$str_LID.'">');

	$params = array('id="bx_user_info_event"');
	if(!$canSelfEdit || $str_EXTERNAL_AUTH_ID <> '')
	{
		$params[] = "disabled";
	}
	$tabControl->AddCheckBoxField("user_info_event", GetMessage('INFO_FOR_USER'), false, "Y", ($_REQUEST["user_info_event"]=="Y"), $params);
endif;

if(CTimeZone::Enabled())
{
	$tabControl->AddSection("USER_TIME_ZONE", GetMessage("user_edit_time_zones"));
	$tabControl->AddDropDownField("AUTO_TIME_ZONE", GetMessage("user_edit_time_zones_auto"), false, array(""=>GetMessage("user_edit_time_zones_auto_def"), "Y"=>GetMessage("user_edit_time_zones_auto_yes"), "N"=>GetMessage("user_edit_time_zones_auto_no")), $str_AUTO_TIME_ZONE, array('onchange="this.form.TIME_ZONE.disabled=(this.value != \'N\')"'));
	$tabControl->AddDropDownField("TIME_ZONE", GetMessage("user_edit_time_zones_zones"), false, CTimeZone::GetZones(), $str_TIME_ZONE, ($str_AUTO_TIME_ZONE<>"N"? array('disabled') : array()));
}
?>
<?
if($showGroupTabs):
	$tabControl->BeginNextFormTab();
	$tabControl->BeginCustomField("GROUP_ID", GetMessage("user_edit_form_groups"));
?>
	<tr>
		<td colspan="2" align="center">
			<table border="0" cellpadding="0" cellspacing="0" class="internal" style="width:80%;">
			<tr class="heading">
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:31,代码来源:user_edit.php

示例11: PrologActions

 public static function PrologActions()
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $USER;
     if (COption::GetOptionString("main", "buffer_content", "Y") == "Y" && (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)) {
         ob_start(array(&$APPLICATION, "EndBufferContent"));
         $APPLICATION->buffered = true;
         // define("BX_BUFFER_USED", true);
         register_shutdown_function(function () {
             // define("BX_BUFFER_SHUTDOWN", true);
             for ($i = 0, $n = ob_get_level(); $i < $n; $i++) {
                 ob_end_flush();
             }
         });
     }
     //session expander
     if (COption::GetOptionString("main", "session_expand", "Y") != "N" && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND === false)) {
         //only for authorized
         if (COption::GetOptionString("main", "session_auth_only", "Y") != "Y" || $USER->IsAuthorized()) {
             $arPolicy = $USER->GetSecurityPolicy();
             $phpSessTimeout = ini_get("session.gc_maxlifetime");
             if ($arPolicy["SESSION_TIMEOUT"] > 0) {
                 $sessTimeout = min($arPolicy["SESSION_TIMEOUT"] * 60, $phpSessTimeout);
             } else {
                 $sessTimeout = $phpSessTimeout;
             }
             $cookie_prefix = COption::GetOptionString('main', 'cookie_name', 'BITRIX_SM');
             $salt = $_COOKIE[$cookie_prefix . '_UIDH'] . "|" . $USER->GetID() . "|" . $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . LICENSE_KEY . "|" . CMain::GetServerUniqID();
             $key = md5(bitrix_sessid() . $salt);
             $bShowMess = $USER->IsAuthorized() && COption::GetOptionString("main", "session_show_message", "Y") != "N";
             CUtil::InitJSCore(array('ajax', 'ls'));
             $jsMsg = '<script type="text/javascript">' . "\n" . ($bShowMess ? 'bxSession.mess.messSessExpired = \'' . CUtil::JSEscape(GetMessage("MAIN_SESS_MESS", array("#TIMEOUT#" => round($sessTimeout / 60)))) . '\';' . "\n" : '') . 'bxSession.Expand(' . $sessTimeout . ', \'' . bitrix_sessid() . '\', ' . ($bShowMess ? 'true' : 'false') . ', \'' . $key . '\');' . "\n" . '</script>';
             $APPLICATION->AddHeadScript('/bitrix/js/main/session.js');
             $APPLICATION->AddAdditionalJS($jsMsg);
             $_SESSION["BX_SESSION_COUNTER"] = intval($_SESSION["BX_SESSION_COUNTER"]) + 1;
             if (!defined("BX_SKIP_SESSION_TERMINATE_TIME")) {
                 $_SESSION["BX_SESSION_TERMINATE_TIME"] = time() + $sessTimeout;
             }
         }
     }
     //user auto time zone via js cookies
     if (CTimeZone::Enabled() && (!defined("BX_SKIP_TIMEZONE_COOKIE") || BX_SKIP_TIMEZONE_COOKIE === false)) {
         CTimeZone::SetAutoCookie();
     }
     // check user options set via cookie
     if ($USER->IsAuthorized()) {
         $cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS";
         if (!empty($_COOKIE[$cookieName])) {
             CUserOptions::SetCookieOptions($cookieName);
         }
     }
     foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent);
     }
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:55,代码来源:main.php

示例12: disableTimeZone

 private static function disableTimeZone()
 {
     static::$timeZoneEnabled = \CTimeZone::Enabled();
     \CTimeZone::Disable();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:5,代码来源:datetime.php

示例13: ConvertFromDB

 public static function ConvertFromDB($arProperty, $value, $format = '')
 {
     static $offsetEnabled = null;
     static $timeOffset = false;
     if (!isset($offsetEnabled) || $offsetEnabled !== CTimeZone::Enabled()) {
         $offsetEnabled = CTimeZone::Enabled();
         $timeOffset = CTimeZone::GetOffset();
     }
     if (strlen($value["VALUE"]) > 0) {
         $timestamp = MakeTimeStamp($value["VALUE"], 'YYYY-MM-DD HH:MI:SS');
         $timestamp += $timeOffset;
         $value["VALUE"] = ConvertTimeStamp($timestamp, $format ? $format : "FULL");
         $value["VALUE"] = str_replace(" 00:00:00", "", $value["VALUE"]);
     }
     return $value;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:16,代码来源:prop_datetime.php

示例14: GetUserOffset

 public static function GetUserOffset($params)
 {
     $userOffset = 0;
     $localOffset = 0;
     if (!CTimeZone::Enabled()) {
         return 0;
     }
     try {
         $localTime = new DateTime();
         $localOffset = $localTime->getOffset();
         $autoTimeZone = trim($params["AUTO_TIME_ZONE"]);
         $userZone = $params["TIME_ZONE"];
         $factOffset = $params["TIME_ZONE_OFFSET"];
         if ($autoTimeZone == "N") {
             $userTime = $userZone != "" ? new DateTime(null, new DateTimeZone($userZone)) : $localTime;
             $userOffset = $userTime->getOffset();
         } else {
             if (CTimeZone::IsAutoTimeZone($autoTimeZone)) {
                 return intval($factOffset);
             } else {
                 $serverZone = COption::GetOptionString("main", "default_time_zone", "");
                 $serverTime = $serverZone != "" ? new DateTime(null, new DateTimeZone($serverZone)) : $localTime;
                 $userOffset = $serverTime->getOffset();
             }
         }
     } catch (Exception $e) {
         return 0;
     }
     return intval($userOffset) - intval($localOffset);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:30,代码来源:im_mail.php

示例15: Authorize

 /**
  * Performs the user authorization:
  *    fills session parameters;
  *    remembers auth;
  *    spreads auth through sites
  */
 function Authorize($id, $bSave = false)
 {
     /** @global CMain $APPLICATION */
     global $DB, $APPLICATION;
     unset($_SESSION["SESS_OPERATIONS"]);
     $_SESSION["BX_LOGIN_NEED_CAPTCHA"] = false;
     $strSql = "SELECT U.* " . "FROM b_user U  " . "WHERE U.ID='" . intval($id) . "' ";
     $result = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     if ($arUser = $result->Fetch()) {
         $_SESSION["SESS_AUTH"]["AUTHORIZED"] = "Y";
         $_SESSION["SESS_AUTH"]["USER_ID"] = $arUser["ID"];
         $_SESSION["SESS_AUTH"]["LOGIN"] = $arUser["LOGIN"];
         $_SESSION["SESS_AUTH"]["LOGIN_COOKIES"] = $arUser["LOGIN"];
         $_SESSION["SESS_AUTH"]["EMAIL"] = $arUser["EMAIL"];
         $_SESSION["SESS_AUTH"]["PASSWORD_HASH"] = $arUser["PASSWORD"];
         $_SESSION["SESS_AUTH"]["NAME"] = $arUser["NAME"] . ($arUser["NAME"] == '' || $arUser["LAST_NAME"] == '' ? "" : " ") . $arUser["LAST_NAME"];
         $_SESSION["SESS_AUTH"]["FIRST_NAME"] = $arUser["NAME"];
         $_SESSION["SESS_AUTH"]["SECOND_NAME"] = $arUser["SECOND_NAME"];
         $_SESSION["SESS_AUTH"]["LAST_NAME"] = $arUser["LAST_NAME"];
         $_SESSION["SESS_AUTH"]["ADMIN"] = false;
         $_SESSION["SESS_AUTH"]["CONTROLLER_ADMIN"] = false;
         $_SESSION["SESS_AUTH"]["POLICY"] = CUser::GetGroupPolicy($arUser["ID"]);
         $_SESSION["SESS_AUTH"]["AUTO_TIME_ZONE"] = trim($arUser["AUTO_TIME_ZONE"]);
         $_SESSION["SESS_AUTH"]["TIME_ZONE"] = $arUser["TIME_ZONE"];
         $arGroups = array();
         $strSql = "SELECT G.ID " . "FROM b_group G  " . "WHERE G.ANONYMOUS='Y' " . "\tAND G.ACTIVE='Y' ";
         $result = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         while ($ar = $result->Fetch()) {
             $arGroups[] = $ar["ID"];
         }
         if (!in_array(2, $arGroups)) {
             $arGroups[] = 2;
         }
         $strSql = "SELECT G.ID " . "FROM b_user_group UG, b_group G  " . "WHERE UG.USER_ID = " . $arUser["ID"] . " " . "\tAND G.ID=UG.GROUP_ID  " . "\tAND G.ACTIVE='Y' " . "\tAND ((UG.DATE_ACTIVE_FROM IS NULL) OR (UG.DATE_ACTIVE_FROM <= " . $DB->CurrentTimeFunction() . ")) " . "\tAND ((UG.DATE_ACTIVE_TO IS NULL) OR (UG.DATE_ACTIVE_TO >= " . $DB->CurrentTimeFunction() . ")) " . "\tAND (G.ANONYMOUS<>'Y' OR G.ANONYMOUS IS NULL) ";
         $result = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         while ($ar = $result->Fetch()) {
             $arGroups[] = $ar["ID"];
             if ($ar["ID"] == 1) {
                 $_SESSION["SESS_AUTH"]["ADMIN"] = true;
             }
         }
         sort($arGroups);
         $_SESSION["SESS_AUTH"]["GROUPS"] = $arGroups;
         $tz = '';
         if (CTimeZone::Enabled()) {
             if (!CTimeZone::IsAutoTimeZone(trim($arUser["AUTO_TIME_ZONE"])) || CTimeZone::GetCookieValue() !== null) {
                 $tz = ', TIME_ZONE_OFFSET = ' . CTimeZone::GetOffset();
             }
         }
         $DB->Query("\n\t\t\t\tUPDATE b_user SET\n\t\t\t\t\tSTORED_HASH = NULL,\n\t\t\t\t\tLAST_LOGIN = " . $DB->GetNowFunction() . ",\n\t\t\t\t\tTIMESTAMP_X = TIMESTAMP_X,\n\t\t\t\t\tLOGIN_ATTEMPTS = 0\n\t\t\t\t\t" . $tz . "\n\t\t\t\tWHERE\n\t\t\t\t\tID=" . $arUser["ID"]);
         $APPLICATION->set_cookie("LOGIN", $_SESSION["SESS_AUTH"]["LOGIN_COOKIES"], time() + 60 * 60 * 24 * 30 * 60, '/', false, false, COption::GetOptionString("main", "auth_multisite", "N") == "Y");
         if ($bSave || COption::GetOptionString("main", "auth_multisite", "N") == "Y") {
             $hash = $this->GetSessionHash();
             $secure = COption::GetOptionString("main", "use_secure_password_cookies", "N") == "Y" && CMain::IsHTTPS();
             if ($bSave) {
                 $APPLICATION->set_cookie("UIDH", $hash, time() + 60 * 60 * 24 * 30 * 60, '/', false, $secure, BX_SPREAD_SITES | BX_SPREAD_DOMAIN);
             } else {
                 $APPLICATION->set_cookie("UIDH", $hash, 0, '/', false, $secure, BX_SPREAD_SITES);
             }
             $stored_id = CUser::CheckStoredHash($arUser["ID"], $hash);
             if ($stored_id) {
                 $DB->Query("UPDATE b_user_stored_auth SET\n\t\t\t\t\t\t\tLAST_AUTH=" . $DB->CurrentTimeFunction() . ",\n\t\t\t\t\t\t\t" . ($this->bLoginByHash ? "" : "TEMP_HASH='" . ($bSave ? "N" : "Y") . "', ") . "\n\t\t\t\t\t\t\tIP_ADDR='" . sprintf("%u", ip2long($_SERVER["REMOTE_ADDR"])) . "'\n\t\t\t\t\t\tWHERE ID=" . $stored_id);
             } else {
                 $arFields = array('USER_ID' => $arUser["ID"], '~DATE_REG' => $DB->CurrentTimeFunction(), '~LAST_AUTH' => $DB->CurrentTimeFunction(), 'TEMP_HASH' => $bSave ? "N" : "Y", '~IP_ADDR' => sprintf("%u", ip2long($_SERVER["REMOTE_ADDR"])), 'STORED_HASH' => $hash);
                 $stored_id = CDatabase::Add("b_user_stored_auth", $arFields);
             }
             $_SESSION["SESS_AUTH"]["STORED_AUTH_ID"] = $stored_id;
         }
         $this->admin = null;
         $arParams = array("user_fields" => $arUser, "save" => $bSave);
         foreach (GetModuleEvents("main", "OnAfterUserAuthorize", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array(&$arParams));
         }
         foreach (GetModuleEvents("main", "OnUserLogin", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($_SESSION["SESS_AUTH"]["USER_ID"]));
         }
         if (COption::GetOptionString("main", "event_log_login_success", "N") === "Y") {
             CEventLog::Log("SECURITY", "USER_AUTHORIZE", "main", $arUser["ID"]);
         }
         return true;
     }
     return false;
 }
开发者ID:nProfessor,项目名称:Mytb,代码行数:89,代码来源:user.php


注:本文中的CTimeZone::Enabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。