Esempio n. 1
0
<?php

define("START_EXEC_PROLOG_BEFORE_1", microtime());
$GLOBALS["BX_STATE"] = "PB";
if (isset($_REQUEST["BX_STATE"])) {
    unset($_REQUEST["BX_STATE"]);
}
if (isset($_GET["BX_STATE"])) {
    unset($_GET["BX_STATE"]);
}
if (isset($_POST["BX_STATE"])) {
    unset($_POST["BX_STATE"]);
}
if (isset($_COOKIE["BX_STATE"])) {
    unset($_COOKIE["BX_STATE"]);
}
if (isset($_FILES["BX_STATE"])) {
    unset($_FILES["BX_STATE"]);
}
if (!isset($USER)) {
    global $USER;
}
if (!isset($APPLICATION)) {
    global $APPLICATION;
}
if (!isset($DB)) {
    global $DB;
}
require_once dirname(__FILE__) . "/../include.php";
CMain::PrologActions();
Esempio n. 2
0
 function AuthForm($mess, $show_prolog = true, $show_epilog = true, $not_show_links = "N", $do_die = true)
 {
     //сдалаем все глобальные переменные видимыми здесь
     $excl = array("excl" => 1, "key" => 1, "GLOBALS" => 1, "mess" => 1, "show_epilog" => 1, "show_epilog" => 1, "not_show_links" => 1, "do_die" => 1);
     foreach ($GLOBALS as $key => $value) {
         if (!array_key_exists($key, $excl)) {
             global ${$key};
         }
     }
     if (substr($this->GetCurDir(), 0, strlen(BX_ROOT . "/admin/")) == BX_ROOT . "/admin/" || defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
         $isAdmin = "_admin";
     } else {
         $isAdmin = "";
     }
     if (isset($this->arAuthResult) && $this->arAuthResult !== true && (is_array($this->arAuthResult) || strlen($this->arAuthResult) > 0)) {
         $arAuthResult = $this->arAuthResult;
     } else {
         $arAuthResult = $mess;
     }
     //заголовок страницы
     $APPLICATION->SetTitle(GetMessage("AUTH_TITLE"));
     //вытащим из cookies последнее удачное имя входа
     $last_login = ${COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LOGIN"};
     $inc_file = "";
     $comp_name = "";
     if ($forgot_password == "yes") {
         //форма высылки пароля
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_SEND_PASSWORD"));
         $comp_name = "system.auth.forgotpasswd";
         $inc_file = "forgot_password";
     } elseif ($change_password == "yes") {
         //форма изменения пароля
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CHANGE_PASSWORD"));
         $comp_name = "system.auth.changepasswd";
         $inc_file = "change_password";
     } elseif ($register == "yes" && $isAdmin == "" && COption::GetOptionString("main", "new_user_registration", "N") == "Y") {
         //форма регистрации
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_REGISTER"));
         $comp_name = "system.auth.registration";
         $inc_file = "registration";
     } elseif ($confirm_registration === "yes" && $isAdmin === "" && COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y") {
         //confirm registartion
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CONFIRM"));
         $comp_name = "system.auth.confirmation";
         $inc_file = "confirmation";
     } elseif ($authorize_registration == "yes" && $isAdmin == "") {
         //форма авторизации и регистрации
         $inc_file = "authorize_registration";
     } else {
         //форма авторизации
         $comp_name = "system.auth.authorize";
         $inc_file = "authorize";
     }
     if ($show_prolog) {
         CMain::PrologActions();
         define("BX_AUTH_FORM", true);
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog" . $isAdmin . "_after.php";
     }
     if ($isAdmin == "") {
         // если пользуем вторые компоненты и есть что подключать - подключаем
         if (COption::GetOptionString("main", "auth_comp2", "N") == "Y" && $comp_name != "") {
             $this->IncludeComponent("bitrix:" . $comp_name, "", array("AUTH_RESULT" => $arAuthResult, "NOT_SHOW_LINKS" => $not_show_links));
         } else {
             $this->IncludeFile("main/auth/" . $inc_file . ".php", array("last_login" => $last_login, "arAuthResult" => $arAuthResult, "not_show_links" => $not_show_links));
         }
     } else {
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/auth/wrapper.php";
     }
     if ($show_epilog) {
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog" . $isAdmin . ".php";
     }
     if ($do_die) {
         die;
     }
 }
Esempio n. 3
0
 function AuthForm($mess, $show_prolog = true, $show_epilog = true, $not_show_links = "N", $do_die = true)
 {
     $excl = array("excl" => 1, "key" => 1, "GLOBALS" => 1, "mess" => 1, "show_epilog" => 1, "not_show_links" => 1, "do_die" => 1);
     foreach ($GLOBALS as $key => $value) {
         if (!array_key_exists($key, $excl)) {
             global ${$key};
         }
     }
     if (substr($this->GetCurDir(), 0, strlen(BX_ROOT . "/admin/")) == BX_ROOT . "/admin/" || defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
         $isAdmin = "_admin";
     } else {
         $isAdmin = "";
     }
     if (isset($this->arAuthResult) && $this->arAuthResult !== true && (is_array($this->arAuthResult) || strlen($this->arAuthResult) > 0)) {
         $arAuthResult = $this->arAuthResult;
     } else {
         $arAuthResult = $mess;
     }
     /** @global CMain $APPLICATION */
     global $APPLICATION, $forgot_password, $change_password, $register, $confirm_registration, $authorize_registration;
     //page title
     $APPLICATION->SetTitle(GetMessage("AUTH_TITLE"));
     //last login from cookie
     $last_login = ${COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LOGIN"};
     $comp_name = "";
     if ($forgot_password == "yes") {
         //pass request form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_SEND_PASSWORD"));
         $comp_name = "system.auth.forgotpasswd";
         $inc_file = "forgot_password";
     } elseif ($change_password == "yes") {
         //pass change form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CHANGE_PASSWORD"));
         $comp_name = "system.auth.changepasswd";
         $inc_file = "change_password";
     } elseif ($register == "yes" && $isAdmin == "" && COption::GetOptionString("main", "new_user_registration", "N") == "Y") {
         //registration form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_REGISTER"));
         $comp_name = "system.auth.registration";
         $inc_file = "registration";
     } elseif ($confirm_registration === "yes" && $isAdmin === "" && COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y") {
         //confirm registartion
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CONFIRM"));
         $comp_name = "system.auth.confirmation";
         $inc_file = "confirmation";
     } elseif ($authorize_registration == "yes" && $isAdmin == "") {
         //combined auth and reg form
         $inc_file = "authorize_registration";
     } else {
         //auth form
         $comp_name = "system.auth.authorize";
         $inc_file = "authorize";
     }
     if ($show_prolog) {
         CMain::PrologActions();
         define("BX_AUTH_FORM", true);
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog" . $isAdmin . "_after.php";
     }
     if ($isAdmin == "") {
         // form by Components 2.0
         if (COption::GetOptionString("main", "auth_comp2", "N") == "Y" && $comp_name != "") {
             $this->IncludeComponent("bitrix:" . $comp_name, "", array("AUTH_RESULT" => $arAuthResult, "NOT_SHOW_LINKS" => $not_show_links));
         } else {
             $this->IncludeFile("main/auth/" . $inc_file . ".php", array("last_login" => $last_login, "arAuthResult" => $arAuthResult, "not_show_links" => $not_show_links));
         }
     } else {
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/auth/wrapper.php";
     }
     if ($show_epilog) {
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog" . $isAdmin . ".php";
     }
     if ($do_die) {
         die;
     }
 }
Esempio n. 4
0
 /**
  * <p>Метод подключает ряд компонентов в зависимости от параметров пришедших на страницу: </p> <table class="tnormal" width="100%"><tbody> <tr> <th width="25%">Параметр</th> <th width="25%">Значение</th> <th width="50%">Название компонента</th> </tr> <tr> <td>forgot_password</td> <td>yes</td> <td>Форма отправки контрольного слова для смены пароля (<b>system.auth.forgotpasswd</b>)</td> </tr> <tr> <td>change_password</td> <td>yes</td> <td>(Форма смены забытого пароля (<b>system.auth.changepasswd</b>)</td> </tr> <tr> <td>register</td> <td>yes</td> <td>Форма регистрации (<b>system.auth.registration</b>)</td> </tr> <tr> <td>authorize_registration</td> <td>yes</td> <td>Форма авторизации (<b>system.auth.authorize</b>)</td> </tr> </tbody></table> <p>Если не указан ни один из параметров, то по умолчанию метод подключит компонент "Форма авторизации".</p> <p class="note"><b>Примечание</b>. После вывода соответствующего компонента метод завершает выполнение страницы.</p> <p>Динамичный метод.</p>
  *
  *
  * @param mixed $mess  yes
  *
  * @param bool $show_prolog = true yes
  *
  * @param bool $show_epilog = true yes
  *
  * @param string $not_show_links = "N" yes
  *
  * @param bool $do_die = true 
  *
  * @return mixed 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * // определим право чтения на файл "/download/document.doc" у текущего пользователя
  * $FILE_PERM = $APPLICATION-&gt;GetFileAccessPermission("/download/document.doc");
  * $FILE_PERM = (strlen($FILE_PERM)&gt;0 ? $FILE_PERM : "D");
  * // если право чтения нет, то выводем форму авторизации
  * if($FILE_PERM &lt; "R") <b>$APPLICATION-&gt;AuthForm</b>("У вас нет права доступа к данному файлу.");
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li><a href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;CHAPTER_ID=04565"
  * >Компоненты</a></li> <li> <a
  * href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;LESSON_ID=2819" >Права доступа</a>
  * </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/other/showmessage.php">ShowMessage</a> </li> </ul>
  * <a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cmain/authform.php
  * @author Bitrix
  */
 public function AuthForm($mess, $show_prolog = true, $show_epilog = true, $not_show_links = "N", $do_die = true)
 {
     $excl = array("excl" => 1, "key" => 1, "GLOBALS" => 1, "mess" => 1, "show_prolog" => 1, "show_epilog" => 1, "not_show_links" => 1, "do_die" => 1);
     foreach ($GLOBALS as $key => $value) {
         if (!array_key_exists($key, $excl)) {
             global ${$key};
         }
     }
     if (substr($this->GetCurDir(), 0, strlen(BX_ROOT . "/admin/")) == BX_ROOT . "/admin/" || defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
         $isAdmin = "_admin";
     } else {
         $isAdmin = "";
     }
     if (isset($this->arAuthResult) && $this->arAuthResult !== true && (is_array($this->arAuthResult) || strlen($this->arAuthResult) > 0)) {
         $arAuthResult = $this->arAuthResult;
     } else {
         $arAuthResult = $mess;
     }
     /** @global CMain $APPLICATION */
     global $APPLICATION, $forgot_password, $change_password, $register, $confirm_registration;
     //page title
     $APPLICATION->SetTitle(GetMessage("AUTH_TITLE"));
     $inc_file = "";
     if ($forgot_password == "yes") {
         //pass request form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_SEND_PASSWORD"));
         $comp_name = "system.auth.forgotpasswd";
         $inc_file = "forgot_password";
     } elseif ($change_password == "yes") {
         //pass change form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CHANGE_PASSWORD"));
         $comp_name = "system.auth.changepasswd";
         $inc_file = "change_password";
     } elseif ($register == "yes" && $isAdmin == "" && COption::GetOptionString("main", "new_user_registration", "N") == "Y") {
         //registration form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_REGISTER"));
         $comp_name = "system.auth.registration";
     } elseif ($confirm_registration === "yes" && $isAdmin === "" && COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y") {
         //confirm registartion
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CONFIRM"));
         $comp_name = "system.auth.confirmation";
     } elseif (CModule::IncludeModule("security") && \Bitrix\Security\Mfa\Otp::isOtpRequired() && $_REQUEST["login_form"] != "yes") {
         //otp form
         $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_OTP"));
         $comp_name = "system.auth.otp";
         $inc_file = "otp";
     } else {
         header('X-Bitrix-Ajax-Status: Authorize');
         //auth form
         $comp_name = "system.auth.authorize";
         $inc_file = "authorize";
     }
     if ($show_prolog) {
         CMain::PrologActions();
         // define("BX_AUTH_FORM", true);
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog" . $isAdmin . "_after.php";
     }
     if ($isAdmin == "") {
         // form by Components 2.0
         $this->IncludeComponent("bitrix:" . $comp_name, COption::GetOptionString("main", "auth_components_template", ""), array("AUTH_RESULT" => $arAuthResult, "NOT_SHOW_LINKS" => $not_show_links));
     } else {
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/auth/wrapper.php";
     }
     if ($show_epilog) {
         include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog" . $isAdmin . ".php";
     }
     if ($do_die) {
         die;
     }
 }