本文整理汇总了PHP中CUser::Login方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::Login方法的具体用法?PHP CUser::Login怎么用?PHP CUser::Login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::Login方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckAuthorization
function CheckAuthorization($user, $password)
{
$UserAuthTry = new CUser();
$authTry = $UserAuthTry->Login($user, $password);
if ($authTry === true) {
$unode = $UserAuthTry->GetByLogin($user);
$uinfo = $unode->Fetch();
return $uinfo;
}
return new CSOAPFault('Server Error', 'Unable to authorize user.');
}
示例2: AuthtorizeAfterAds
/**
* функция после добавлением элемента в инфоблока
* @param $arFields поля элемента ифоблока
* для страницы Объявления
* eсли VIP объявление то добавляет корзину
* привязывает по ID созданное объявления к товару в корзине
* редирект на необходимы url
*/
function AuthtorizeAfterAds(&$arFields){
unset($_SESSION['user777999authorize']);
if($arFields['PROPERTY_VALUES']['114']){
foreach($arFields['PROPERTY_VALUES']['114'] as $key114 => $item114){
if($item114['VALUE']){
foreach($arFields['PROPERTY_VALUES']['113'] as $key113 => $item113){
if($item113['VALUE']){
$arFields['PROPERTY_VALUES']['113'][$key113]=ConvertDateTime($item114['VALUE'], "YYYY-MM-DD HH:MI:SS");
}else{
$arFields['PROPERTY_VALUES']['113'][n0]=ConvertDateTime($item114['VALUE'], "YYYY-MM-DD HH:MI:SS");
}
}
}
}
}
if(($arFields["IBLOCK_ID"] == 16)&&(!CUser::IsAuthorized())){
global $USER;
$rsUser = CUser::GetByID($_SESSION['NEW_USER_ID']);
$arUser = $rsUser->Fetch();
$_SESSION['$arUser']=$arUser;
$USER = new CUser;
$arAuthResult = $USER->Login($arUser['LOGIN'], $arUser['PASSWORD'], "Y","N");
}
//$_SESSION['user777authorize']=$arFields;
if(($arFields["IBLOCK_ID"] == 16)&&(CModule::IncludeModule("catalog"))&&(CModule::IncludeModule("sale"))){
$price_product=floatval($arFields["PROPERTY_VALUES"][86]);
$quantity_product=floatval($arFields["PROPERTY_VALUES"][87]);
if($price_product){
$PRODUCT_ID = $arFields['ID'];
$PRICE_TYPE_ID = 1;
$arFieldsprice = Array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
"PRICE" =>$price_product,
"CURRENCY" => "RUB",
"QUANTITY_FROM" => 1,
);
$res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID
)
);
if ($arr = $res->Fetch())
{
CPrice::Update($arr["ID"], $arFieldsprice);
}
else
{
CPrice::Add($arFieldsprice,true);
}
}
}
if (
(
(($arFields["IBLOCK_ID"] == 2)&& (is_numeric($arFields["PROPERTY_VALUES"][73])))
||
(($arFields["IBLOCK_ID"] == 15)&& (is_numeric($arFields["PROPERTY_VALUES"][76])))
||
(($arFields["IBLOCK_ID"] == 14)&& (is_numeric($arFields["PROPERTY_VALUES"][78])))
)
&&
CModule::IncludeModule("catalog")
&&
CModule::IncludeModule("sale")
&&
((strstr($_SERVER['REQUEST_URI'],'/personal/moy-magazin/'))||(strstr($_SERVER['REQUEST_URI'],'/obyavleniya/add-ads/')))
)
{
switch($arFields["IBLOCK_ID"]){
case 2:
$price_product=floatval($arFields["PROPERTY_VALUES"][73]);
$quantity_product=floatval($arFields["PROPERTY_VALUES"][75]);
break;
case 14:
$price_product=floatval($arFields["PROPERTY_VALUES"][78]);
$quantity_product=floatval($arFields["PROPERTY_VALUES"][79]);
//.........这里部分代码省略.........
示例3: DoCreate
/**
* Perform a creation of a user as callback on a submitted form.
*
* @param CForm $form the current form.
* @param CUser $user the user object.
*/
public function DoCreate($form, $user)
{
if ($form['password1']['value'] != $form['password1']['value'] || empty($form['password1']['value']) || empty($form['password2']['value']) || empty($form['acronym']['value']) || empty($form['name']['value']) || empty($form['email']['value'])) {
return false;
}
if ($user->Create($form['acronym']['value'], $form['password1']['value'], $form['name']['value'], $form['email']['value'])) {
return $user->Login($form['acronym']['value'], $form['password1']['value']);
}
return false;
}
示例4: switch
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
use Bitrix\Security\Mfa;
$req = $_REQUEST;
if ($req['AUTH_FORM'] && $req['AUTH_FORM'] == 'Y' && $req['TYPE']) {
$curPage = CMain::GetCurPage();
switch ($req['TYPE']) {
case 'AUTH':
$arLogin = CUser::Login($req['USER_LOGIN'], $req['USER_PASSWORD'], 'Y', 'Y');
if ($arLogin === true) {
header('Location: ' . $curPage, true);
} else {
$arResult['ERROR'][] = $arLogin;
}
case 'REGISTER':
}
}
if (!$USER->IsAuthorized()) {
$arResult["FORM_TYPE"] = "login";
} else {
$arResult["FORM_TYPE"] = "logout";
$arResult["AUTH_URL"] = $currentUrl;
$arResult["PROFILE_URL"] = $arParams["PROFILE_URL"] . (strpos($arParams["PROFILE_URL"], "?") !== false ? "&" : "?") . "backurl=" . urlencode($currentUrl);
$arRes = array();
foreach ($arResult as $key => $value) {
$arRes[$key] = htmlspecialcharsbx($value);
$arRes['~' . $key] = $value;
}
示例5: CDatabase
*
*/
// Include the essential config-file which also creates the $anax variable with its defaults.
include __DIR__ . '/config.php';
$hera['stylesheets'][] = 'css/forms.css';
// Connect to a MySQL database using PHP PDO
$db = new CDatabase($hera['database']);
$user = new CUser($db);
if ($user->IsAuthenticated()) {
$output = "Du är inloggad som: {$user->GetAcronym()} ({$user->GetName()}) / <a href='logout.php'>Logga ut?</a>";
} else {
$output = "Du är INTE inloggad.";
}
// Check if user and password is okey
if (isset($_POST['Login'])) {
$user->Login($_POST['acronym'], $_POST['password']);
header('Location: login.php');
}
// Do it and store it all in variables in the Hera container.
$hera['title'] = "Login";
$hera['main'] = <<<EOD
<h1>{$hera['title']}</h1>
<form method=post>
<fieldset>
<legend>Logga in</legend>
<p><em>Du kan logga in med emsf14:emsf14 för att logga in som vanlig användare eller admin:admin för att logga in som administratör.</em></p>
<div class='box'>Inte medlem än? Klicka <a href='register.php'>här</a> för att registrera dig.</div>
<p><label>Användare:<br><input type=text name='acronym' value=''></label></p>
<p><label>Lösenord:<br><input type=password name='password' value=''></label></p>
<p><input type='submit' value='Logga in' name='Login'></p>
<p>{$output}</p>
示例6: CUser
<?php
define('STOP_STATISTICS', true);
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
$GLOBALS['APPLICATION']->RestartBuffer();
//include lang file
CComponentUtil::__IncludeLang(dirname($_SERVER["SCRIPT_NAME"]), "/ajax.php");
global $USER;
if (!is_object($USER)) {
$USER = new CUser();
}
$result = array();
if (strlen($_POST['ajax_key']) && $_POST['ajax_key'] == md5('ajax_' . LICENSE_KEY) && htmlspecialcharsbx($_POST["TYPE"]) == "AUTH" && check_bitrix_sessid()) {
$login = htmlspecialcharsbx($_POST["USER_PASSWORD"]);
$password = htmlspecialcharsbx($_POST["USER_LOGIN"]);
$arAuthResult = $USER->Login($login, $password, "Y");
if (!$USER->IsAuthorized()) {
$result['status'] = 'error';
$result['errors'] = array();
} else {
$result['status'] = 'ok';
}
}
exit(json_encode($result));
示例7: trim
* Created by JetBrains PhpStorm.
* User: oleg
* Date: 22.09.12
* Time: 17:26
* To change this template use File | Settings | File Templates.
*/
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$email = trim($_POST["email"]);
$reg = intval($_POST["reg"]);
$password = trim($_POST["password"]);
if ($email == "" || $password == "") {
die(json_encode(array("status" => "errors", "message" => "Пустой логин или пароль", "input" => array("email", "password"))));
}
global $USER;
$user = new CUser();
$arAuthResult = $user->Login($email, $password, "Y");
if ($arAuthResult['TYPE'] != "ERROR") {
die(json_encode(array("status" => "ok")));
} elseif ($reg == 1) {
if (CUser::GetByLogin($email)->Fetch() == NULL) {
$arFields = array("EMAIL" => $email, "LOGIN" => $email, "ACTIVE" => "Y", "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password);
$ID = $user->Add($arFields);
if (intval($ID) > 0) {
if ($user->Authorize($ID)) {
die(json_encode(array("status" => "ok")));
} else {
die(json_encode(array("status" => "ok", "message" => "Не получилось авторизировать")));
}
} else {
die(json_encode(array("status" => "errors", "message" => $user->LAST_ERROR)));
}
示例8: CUser
Header('X-CRM-Version: 11.5.0');
// just to check version. we can manually enlarge it in further updates
Header('Content-Type: application/json; charset=utf-8');
// check data
$arData = $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET;
$arData = $APPLICATION->ConvertCharsetArray($arData, 'UTF-8', LANG_CHARSET);
if (empty($arData)) {
$APPLICATION->RestartBuffer();
echo CUtil::PhpToJSObject(array('error' => 400, 'error_message' => $APPLICATION->ConvertCharset(GetMessage('CRM_REST_ERROR_BAD_REQUEST'), LANG_CHARSET, 'UTF-8')));
exit;
}
$bCheckPerms = true;
// authorize
if (isset($arData['LOGIN']) && isset($arData['PASSWORD'])) {
$CCrmUser = new CUser();
if (($error = $CCrmUser->Login($arData['LOGIN'], $arData['PASSWORD'], 'N', 'Y')) !== true) {
$APPLICATION->RestartBuffer();
echo CUtil::PhpToJSObject(array('error' => 403, 'error_message' => $error === false ? "OTP required" : $APPLICATION->ConvertCharset(strip_tags(nl2br($error['MESSAGE'])), LANG_CHARSET, 'UTF-8')));
exit;
}
CCRMLeadRest::CreateAuthHash($arData);
} elseif ($arData['AUTH']) {
if (!CCRMLeadRest::CheckAuthHash($arData)) {
$APPLICATION->RestartBuffer();
echo CUtil::PhpToJSObject(array('error' => 403, 'error_message' => $APPLICATION->ConvertCharset(GetMessage('CRM_PERMISSION_DENIED'), LANG_CHARSET, 'UTF-8')));
exit;
}
} else {
$APPLICATION->RestartBuffer();
echo CUtil::PhpToJSObject(array('error' => 403, 'error_message' => $APPLICATION->ConvertCharset(GetMessage('CRM_REST_ERROR_BAD_AUTH'), LANG_CHARSET, 'UTF-8')));
exit;