HooLIGUN 9 09/19/2017 04:47 PM Здравствуйте. Подскажите пожалуйста актуальный скрипт дня авторизации на стороннем php файле для форума версии 3.4.9 , Поиском пользовался, но думаю, там устарелые версии Share this post Link to post Share on other sites
newbie 1,721 09/20/2017 08:50 AM Поиском пользовался, но думаю, там устарелые версии Покажите,что нашли? Share this post Link to post Share on other sites
HooLIGUN 9 09/20/2017 09:14 AM php class<?php /** * IBResource, LTD; Ritsuka, UnLTD * IP.Board * Member authorization API file * * @author GiV, Ritsuka * @copyright (c) 2010 IBResource, LTD. * @link http://www.ibresource.ru * @version 1.0.0 * */ if ( ! class_exists( 'apiCore' ) ) { require_once( FORUM_PATH . 'admin/api/api_core.php' ); } class apiMemberLogin extends apiCore { private $_handler = NULL; public $path_to_ipb = FORUM_PATH; public function childInit() { require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' ); require_once( IPS_ROOT_PATH . 'sources/handlers/han_login.php' ); $this->_handler = new han_login( $this->registry ); $this->_handler->init(); } public function login( $username, $password, $remember = TRUE ) { $this->request['username'] = $username; $this->request['password'] = $password; $this->request['rememberMe'] = $remember; return $this->_handler->verifyLogin(); } public function logout() { IPSCookie::set( "member_id" , "0" ); IPSCookie::set( "pass_hash" , "0" ); IPSCookie::set( "anonlogin" , "-1" ); if( is_array( $_COOKIE ) ) { foreach( $_COOKIE as $cookie => $value) { if ( stripos( $cookie, $this->settings['cookie_id'] . 'ipbforumpass' ) !== false ) { IPSCookie::set( $cookie, '-', -1 ); } } } $this->registry->member()->sessionClass()->convertMemberToGuest(); return true; } public function getMember() { return $this->registry->member()->fetchMemberData(); } } Код<?php //header('Content-type: text/html; charset=utf-8'); define( 'FORUM_PATH', $_SERVER['DOCUMENT_ROOT'].'/forum31/'); require_once( FORUM_PATH . 'admin/api/member/api_member_login.php' ); $apiMember = new apiMemberLogin(); $apiMember->init(); /* Авторизация */ if( $_POST['login'] && $_POST['password'] ) { $login = $_POST['login']; $password = $_POST['password']; $ret = $apiMember->login( $login, $password ); if( $ret[2] ) { if( $ret[2] == 'wrong_auth' ) { echo 'Неверный логин или пароль<br>'; } else { echo 'Ошибка авторизации: {$ret[2]}<br>'; } } else { echo '<html><head><meta http-equiv="refresh" content="2;url=index.php"></head><body>Вы вошли в систему!</body><html>'; exit; } } /* Выход */ if( $_GET['do'] == 'logout' ) { $apiMember->logout(); echo '<html><head><meta http-equiv="refresh" content="2;url=index.php"></head><body>Выход из системы</body><html>'; exit; } $member = $apiMember->getMember(); if($member['member_id']) { //print_r( $member ); echo 'Вы залогены как '.$member['name'].' <a href="index.php?do=logout">Выход</a><br />'; } else { echo 'Вы не авторизированы<br /> <form name="form_login" action="index.php?do=login" method="post"> <input name="login" type="text"><br /> <input name="password" type="password"><br /> <input type="submit" value="Отправить"> </form> '; } unset($apiMember); ?> Вроде как это под 3.0.* Share this post Link to post Share on other sites
newbie 1,721 09/20/2017 10:04 AM В теме, где нашли, есть же обсуждение моментов для 3.4.Например, http://ipbskins.ru/forum/topic6401.html/page__view__findpost__p__81548 Share this post Link to post Share on other sites
HooLIGUN 9 09/20/2017 10:28 AM Только в этом отличие,и всё? Share this post Link to post Share on other sites
newbie 1,721 09/21/2017 04:57 AM Всегда можно протестировать работу скрипта. И, если что-то не работает, исправить. Share this post Link to post Share on other sites
HooLIGUN 9 09/24/2017 05:13 PM (edited) Как сделать, чтобы данные выводились сразу после отправки формы, минуя обновления страницы с сообщением "Вы вошли в систему!"то есть Вместо этого echo '<html><head><meta http-equiv="refresh" content="0;url=result.php?do=success"></head><body>Вы вошли в систему!</body><html>'; exit; сразу были данные юзера. Ввел данные - нажал отправить - страница с данными (без всяких переадресаций) Edited September 24, 2017 by HooLIGUN Share this post Link to post Share on other sites
newbie 1,721 09/25/2017 08:47 AM ipsRegistry::instance()->output->silentRedirect( "ссылка" ); 1 Share this post Link to post Share on other sites
HooLIGUN 9 06/04/2018 12:05 PM Обнаружил багПри использовании логина с спец символами, авторизация не проходитПо крайней мере со знаком "!" авторизация не удается ("wrong_auth"). Возможно исправить? /* Авторизация */ if( $_POST['login'] && $_POST['password'] ) { $login = $_POST['login']; $password = $_POST['password']; $ret = $apiMember->login( $login, $password ); if( $ret[2] ) { if( $ret[2] == 'wrong_auth' ) { //Неверные данные } } else { //Авторизация успешна } } Share this post Link to post Share on other sites
newbie 1,721 06/05/2018 05:33 AM По крайней мере со знаком "!" авторизация не удается ("wrong_auth"). Возможно исправить?Замените $login = $_POST['login'];на $login = ipsRegistry::$request['login']; 1 Share this post Link to post Share on other sites