2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-10 16:59:19 +00:00
* e107 website system
*
2016-12-05 00:36:10 +00:00
* Copyright ( C ) 2008 - 2016 e107 Inc ( e107 . org )
2008-12-10 16:59:19 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Administration Area Authorization
*
* $Source : / cvs_backup / e107_0 . 8 / e107_admin / auth . php , v $
2010-02-10 18:18:01 +00:00
* $Revision $
* $Date $
* $Author $
2009-11-22 14:10:09 +00:00
*/
2006-12-02 04:36:16 +00:00
2009-11-22 14:10:09 +00:00
if ( ! defined ( 'e107_INIT' ))
{
exit ;
}
2013-09-16 14:12:04 -07:00
2017-01-21 10:49:04 -08:00
e107 :: getDb () -> db_Mark_Time ( '(Start auth.php)' );
2013-09-16 14:12:04 -07:00
define ( 'e_CAPTCHA_FONTCOLOR' , '#F9A533' );
2012-12-07 15:16:42 -08:00
// Required for a clean v1.x -> v2 upgrade.
$core = e107 :: getConfig ( 'core' );
2015-09-03 16:19:39 -07:00
if ( $core -> get ( 'admintheme' ) != 'bootstrap3' )
2012-12-07 15:16:42 -08:00
{
2015-07-17 18:22:56 -07:00
$core -> update ( 'admintheme' , 'bootstrap3' );
2012-12-07 15:16:42 -08:00
$core -> update ( 'adminstyle' , 'infopanel' );
2013-03-16 14:30:53 -07:00
$core -> update ( 'admincss' , 'admin_dark.css' );
2012-12-07 15:16:42 -08:00
$core -> set ( 'e_jslib_core' , array ( 'prototype' => 'none' , 'jquery' => 'auto' ));
$core -> save ();
e107 :: getRedirect () -> redirect ( e_SELF );
}
2006-12-02 04:36:16 +00:00
2013-10-28 12:57:27 -07:00
// Check Admin-Perms for current language and redirect if necessary.
2015-09-03 16:19:39 -07:00
if ( USER && ! getperms ( '0' ) && vartrue ( $pref [ 'multilanguage' ]) && ! getperms ( e_LANGUAGE ) && empty ( $_E107 [ 'no_language_perm_check' ]))
2013-10-28 12:57:27 -07:00
{
2015-06-06 02:33:23 -07:00
$lng = e107 :: getLanguage ();
2013-10-28 12:57:27 -07:00
$tmp = explode ( " . " , ADMINPERMS );
foreach ( $tmp as $ln )
{
if ( $lng -> isValid ( $ln ))
{
2015-06-06 02:33:23 -07:00
$redirect = deftrue ( " MULTILANG_SUBDOMAIN " ) ? $lng -> subdomainUrl ( $ln ) : e_SELF . " ?elan= " . $ln ;
// echo "redirect to: ".$redirect;
e107 :: getRedirect () -> go ( $redirect );
// break;
2013-10-28 12:57:27 -07:00
}
}
}
2009-07-18 10:17:56 +00:00
/* done in class2
2009-11-22 14:10:09 +00:00
@ include_once ( e_LANGUAGEDIR . e_LANGUAGE . " /admin/lan_admin.php " );
@ include_once ( e_LANGUAGEDIR . " English/admin/lan_admin.php " );
*/
2006-12-02 04:36:16 +00:00
if ( ADMIN )
{
2009-10-19 20:09:15 +00:00
define ( 'ADMIN_PAGE' , true );
2008-12-10 16:59:19 +00:00
//don't include it if it'a an AJAX call or not wanted
2009-11-22 14:10:09 +00:00
if ( ! e_AJAX_REQUEST && ! defset ( 'e_NOHEADER' ))
2009-08-19 14:39:57 +00:00
{
2010-05-14 18:45:51 +00:00
// XXX LOGIN AS Temporary solution, we need something smarter, e.g. reserved message stack 'admin' which will be always printed
// inside admin area
if ( e107 :: getUser () -> getSessionDataAs ())
2016-12-05 01:18:15 +00:00
{
2010-05-14 18:45:51 +00:00
$asuser = e107 :: getSystemUser ( e107 :: getUser () -> getSessionDataAs (), false );
2016-12-05 00:36:10 +00:00
$lanVars = array ( 'x' => ( $asuser -> getId () ? $asuser -> getName () . ' (' . $asuser -> getValue ( 'email' ) . ')' : 'unknown' )) ;
2016-12-05 01:18:15 +00:00
e107 :: getMessage () -> addInfo ( $tp -> lanVars ( ADLAN_164 , $lanVars ) . ' <a href="' . e_ADMIN_ABS . 'users.php?mode=main&action=logoutas">[' . LAN_LOGOUT . ']</a>' );
2016-12-05 00:36:10 +00:00
2010-05-14 18:45:51 +00:00
}
2012-11-28 09:35:06 +02:00
// NEW, legacy 3rd party code fix, header called inside the footer o.O
2012-11-29 10:47:26 +02:00
if ( deftrue ( 'e_ADMIN_UI' ))
{
// boot.php already loaded
require_once ( e_ADMIN . " header.php " );
}
else
{
// boot.php is included in admin dispatcher constructor, so do it only for legacy code
require_once ( e_ADMIN . 'boot.php' );
}
2009-08-19 14:39:57 +00:00
}
2010-05-14 18:45:51 +00:00
2009-01-07 15:40:06 +00:00
/*
* FIXME - missing $style for tablerender
* The Solution : parse_admin () without sending it to the browser if it ' s an ajax call
* The Problem : doubled render time for the ajax called page !!!
*/
2006-12-02 04:36:16 +00:00
}
else
{
2008-12-10 16:59:19 +00:00
//login via AJAX call is not allowed
2009-11-22 14:10:09 +00:00
if ( e_AJAX_REQUEST )
2008-12-10 16:59:19 +00:00
{
2009-11-22 14:10:09 +00:00
require_once ( e_HANDLER . 'js_helper.php' );
2008-12-10 16:59:19 +00:00
e_jshelper :: sendAjaxError ( 403 , ADLAN_86 , ADLAN_87 , true );
}
2012-06-18 09:06:20 +00:00
2012-11-29 10:47:26 +02:00
require_once ( e_ADMIN . 'boot.php' );
2012-06-18 09:06:20 +00:00
$sec_img = e107 :: getSecureImg ();
2010-05-14 18:45:51 +00:00
2013-03-21 23:06:46 -07:00
$use_imagecode = ( vartrue ( $pref [ 'admincode' ]) && extension_loaded ( " gd " ));
2010-05-14 18:45:51 +00:00
2006-12-02 04:36:16 +00:00
if ( $_POST [ 'authsubmit' ])
{
$obj = new auth ;
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
if ( $use_imagecode )
2012-06-13 04:58:43 +00:00
{
2012-06-18 09:06:20 +00:00
if ( $sec_img -> invalidCode ( $_POST [ 'rand_num' ], $_POST [ 'code_verify' ]))
2006-12-02 04:36:16 +00:00
{
2012-06-13 04:58:43 +00:00
e107 :: getRedirect () -> redirect ( 'admin.php?failed' );
2006-12-02 04:36:16 +00:00
exit ;
2012-06-13 04:58:43 +00:00
// echo "<script type='text/javascript'>document.location.href='../index.php'</script>\n";
// header("location: ../index.php");
// exit;
2006-12-02 04:36:16 +00:00
}
}
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
// require_once (e_HANDLER.'user_handler.php');
$row = $authresult = $obj -> authcheck ( $_POST [ 'authname' ], $_POST [ 'authpass' ], varset ( $_POST [ 'hashchallenge' ], '' ));
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
if ( $row [ 0 ] == " authfail " )
{
$admin_log -> e_log_event ( 4 , __FILE__ . " | " . __FUNCTION__ . " @ " . __LINE__ , " LOGIN " , LAN_ROLL_LOG_11 , " U: " . $tp -> toDB ( $_POST [ 'authname' ]), FALSE , LOG_TO_ROLLING );
2006-12-02 04:36:16 +00:00
echo " <script type='text/javascript'>document.location.href='../index.php'</script> \n " ;
2015-09-05 20:02:51 -07:00
2012-05-24 15:54:25 +00:00
e107 :: getRedirect () -> redirect ( 'admin.php?failed' );
2006-12-02 04:36:16 +00:00
exit ;
2008-06-13 20:20:23 +00:00
}
2009-11-22 14:10:09 +00:00
else
{
$cookieval = $row [ 'user_id' ] . " . " . md5 ( $row [ 'user_password' ]);
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
// $sql->db_Select("user", "*", "user_name='".$tp -> toDB($_POST['authname'])."'");
// list($user_id, $user_name, $userpass) = $sql->db_Fetch();
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
// Calculate class membership - needed for a couple of things
// Problem is that USERCLASS_LIST just contains 'guest' and 'everyone' at this point
$class_list = explode ( ',' , $row [ 'user_class' ]);
if ( $row [ 'user_admin' ] && strlen ( $row [ 'user_perms' ]))
{
$class_list [] = e_UC_ADMIN ;
if ( strpos ( $row [ 'user_perms' ], '0' ) === 0 )
{
$class_list [] = e_UC_MAINADMIN ;
}
2006-12-02 04:36:16 +00:00
}
2009-11-22 14:10:09 +00:00
$class_list [] = e_UC_MEMBER ;
$class_list [] = e_UC_PUBLIC ;
2010-05-14 18:45:51 +00:00
2016-06-06 15:42:42 -07:00
if ( in_array ( varset ( $pref [ 'user_audit_class' ], '' ), $class_list ))
{
e107 :: getAdminLog () -> user_audit ( USER_AUDIT_LOGIN , 'Login via admin page' , $row [ 'user_id' ], $row [ 'user_name' ]);
2009-11-22 14:10:09 +00:00
}
2010-05-14 18:45:51 +00:00
2010-06-06 04:29:54 +00:00
$edata_li = array ( " user_id " => $row [ 'user_id' ], " user_name " => $row [ 'user_name' ], 'class_list' => implode ( ',' , $class_list ), 'user_admin' => $row [ 'user_admin' ]);
2010-10-26 07:41:20 +00:00
// Fix - set cookie before login trigger
2009-11-22 14:10:09 +00:00
session_set ( e_COOKIE , $cookieval , ( time () + 3600 * 24 * 30 ));
2010-10-26 07:41:20 +00:00
2012-12-07 15:16:42 -08:00
2012-12-07 03:38:21 -08:00
// ---
2010-10-26 07:41:20 +00:00
e107 :: getEvent () -> trigger ( " login " , $edata_li );
e107 :: getRedirect () -> redirect ( e_ADMIN_ABS . 'admin.php' );
//echo "<script type='text/javascript'>document.location.href='admin.php'</script>\n";
2006-12-02 04:36:16 +00:00
}
}
2010-05-14 18:45:51 +00:00
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'logout' ;
2012-06-06 23:30:57 +00:00
if ( ADMIN == FALSE )
{
define ( " e_IFRAME " , TRUE );
}
2009-11-22 14:10:09 +00:00
if ( ! defset ( 'NO_HEADER' ))
require_once ( e_ADMIN . " header.php " );
2010-05-14 18:45:51 +00:00
2008-12-10 16:59:19 +00:00
if ( ADMIN == FALSE )
2008-06-13 20:20:23 +00:00
{
2012-06-06 23:30:57 +00:00
// Needs help from Deso, Vesko and Stoev! :-)
e107 :: css ( 'inline' , "
2013-03-18 05:38:08 -07:00
body { text - align : left ; font - size : 15 px ; line - height : 1.5 em ; font - weight : normal ;
font - family : Arial , Helvetica , sans - serif ; background - attachment : scroll ;
background - color : rgb ( 47 , 47 , 47 ); color : rgb ( 198 , 198 , 198 );
2013-03-19 21:27:28 -07:00
2013-03-18 05:38:08 -07:00
background - repeat : no - repeat ; background - size : auto auto
}
2012-06-06 23:30:57 +00:00
a { color : #F6931E; text-decoration:none; }
a : hover { color : silver ; text - decoration : none ; }
. bold { font - weight : bold ; }
. field { text - align : center ; padding : 5 px }
. field input { padding : 5 px ;
2013-03-18 05:38:08 -07:00
2012-06-06 23:30:57 +00:00
}
. field input : focus {
2013-03-18 05:38:08 -07:00
2012-06-06 23:30:57 +00:00
}
. field input : hover {
2013-03-18 05:38:08 -07:00
2012-06-06 23:30:57 +00:00
}
2015-02-14 17:38:41 -08:00
#logo {
height : 140 px ;
max - width : 310 px ;
2013-03-19 21:27:28 -07:00
padding - right : 5 px ;
margin - left : auto ;
margin - right : auto ;
margin - top : 2 % ;
2015-02-14 17:38:41 -08:00
width : 95 % ;
2013-03-19 21:27:28 -07:00
}
2012-11-28 13:25:41 -08:00
2012-06-06 23:30:57 +00:00
#login-admin {
margin - left : auto ;
margin - right : auto ;
2013-03-19 21:27:28 -07:00
margin - top : 2 % ;
2015-02-14 17:38:41 -08:00
min - width : 250 px ;
width : 30 % ;
padding : 0 px ;
max - width : 100 % ;
2013-03-18 05:38:08 -07:00
2012-12-07 15:16:42 -08:00
/*
2012-11-28 13:25:41 -08:00
*/
2012-06-06 23:30:57 +00:00
}
2015-08-20 16:30:28 -07:00
#login-admin div.panel { padding: 0 }
2012-06-06 23:30:57 +00:00
#login-admin label { display: none; text-align: right }
2015-08-20 16:30:28 -07:00
. admin - submit { text - align : center ; padding - top : 20 px ; }
2012-06-06 23:30:57 +00:00
2012-06-06 23:37:40 +00:00
. submit { }
2015-02-14 17:38:41 -08:00
2012-06-06 23:30:57 +00:00
2013-09-17 10:07:59 -07:00
. placeholder { color : #646667; font-style:italic }
2012-06-06 23:30:57 +00:00
2012-06-07 00:33:10 +00:00
::- webkit - input - placeholder { font - style : italic ; color : #bbb; }
2012-06-06 23:30:57 +00:00
2012-06-07 00:33:10 +00:00
:- moz - placeholder { font - style : italic ; color : #bbb; }
2012-06-06 23:30:57 +00:00
2012-07-11 05:14:09 +00:00
h2 { text - align : center ; color : #FAAD3D; }
2012-06-06 23:30:57 +00:00
2015-02-14 17:38:41 -08:00
#username {background: url(".e_IMAGE."admin_images/admins_16.png) no-repeat scroll 7px 9px; padding:7px; padding-left:30px; width:80%; max-width:218px; }
#userpass {background: url(".e_IMAGE."admin_images/lock_16.png) no-repeat scroll 7px 9px; padding:7px;padding-left:30px; width:80%; max-width:218px; }
2015-08-20 16:30:28 -07:00
#code-verify { width: 220px; padding: 7px; margin-left: auto; margin-right: auto; }
2015-02-14 17:38:41 -08:00
2015-08-20 16:30:28 -07:00
input [ disabled ] { color : silver ; }
2012-06-13 04:58:43 +00:00
button [ disabled ] span { color : silver ; }
2012-12-07 15:16:42 -08:00
. title_clean { display : none ; }
2015-02-14 17:38:41 -08:00
2012-06-06 23:30:57 +00:00
" );
2006-12-02 04:36:16 +00:00
$obj = new auth ;
$obj -> authform ();
2009-11-22 14:10:09 +00:00
if ( ! defset ( 'NO_HEADER' ))
require_once ( e_ADMIN . " footer.php " );
2006-12-02 04:36:16 +00:00
exit ;
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
class auth
{
2009-11-22 14:10:09 +00:00
/**
* Admin auth login
* @ return null
*/
2012-06-06 23:30:57 +00:00
public function authform () // NOTE: this should NOT be a template of the admin-template, however themes may style it using css.
2010-05-14 18:45:51 +00:00
{
2013-06-09 20:53:44 +01:00
global $use_imagecode , $sec_img ;
2010-05-14 18:45:51 +00:00
2013-06-09 20:53:44 +01:00
$pref = e107 :: getPref ();
2009-11-22 14:10:09 +00:00
$frm = e107 :: getForm ();
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
$incChap = ( vartrue ( $pref [ 'password_CHAP' ], 0 )) ? " onsubmit='hashLoginPassword(this)' " : " " ;
2012-06-06 23:30:57 +00:00
// Start Clean
// NOTE: this should NOT be a template of the admin-template, however themes may style it using css.
$class = ( e_QUERY == 'failed' ) ? " class='e-shake' " : " " ;
2015-09-05 20:02:51 -07:00
2012-06-06 23:30:57 +00:00
$text = " <form id='admin-login' method='post' action=' " . e_SELF . " ' { $incChap } >
2016-12-04 19:41:14 +00:00
< div id = 'logo' >< img src = '".e_IMAGE."logo_template_large.png' alt = '".LAN_LOGIN."' /></ div >
2015-08-20 16:30:28 -07:00
< div id = 'login-admin' class = 'center' >
2015-09-05 20:02:51 -07:00
< div > " ;
if ( e_QUERY == 'failed' )
{
e107 :: lan ( 'core' , 'login' );
$text .= " <div class='alert alert-danger'> " . LAN_LOGIN_21 . " </div> " ;
$text .= " <script type='text/javascript'>
window . setTimeout ( function () {
$ ( '.alert' ) . fadeTo ( 500 , 0 ) . slideUp ( 500 , function (){
$ ( this ) . remove ();
});
}, 5000 );
</ script > " ;
}
$text .= "
2015-08-20 16:30:28 -07:00
< div class = 'panel well panel-primary' >
< div class = 'panel-heading' >< h3 class = 'panel-title' > " .LAN_HEADER_04. " </ h3 ></ div >
< div class = 'panel-body' >
2012-06-06 23:30:57 +00:00
< div class = 'field' >
< label for = 'username' > " .ADLAN_89. " </ label >
2013-03-19 19:05:12 -07:00
< input class = 'tbox e-tip' type = 'text' autofocus required = 'required' name = 'authname' placeholder = '".ADLAN_89."' id = 'username' size = '30' value = '' maxlength = '".varset($pref[' loginname_maxlength '], 30)."' />
2016-02-26 11:54:57 -08:00
< div class = 'field-help' data - placement = 'right' > " .LAN_ENTER_USRNAME_EMAIL. " </ div >
2012-06-06 23:30:57 +00:00
</ div >
< div class = 'field' >
< label for = 'userpass' > " .ADLAN_90. " </ label >
2016-02-26 11:54:57 -08:00
< input class = 'tbox e-tip' type = 'password' required = 'required' name = 'authpass' placeholder = '".ADLAN_90."' id = 'userpass' size = '30' value = '' maxlength = '30' />
< div class = 'field-help' data - placement = 'right' > " .LAN_PWD_REQUIRED. " </ div >
2012-06-06 23:30:57 +00:00
</ div > " ;
if ( $use_imagecode )
{
$text .= "
< div class = 'field' >
2015-08-20 16:30:28 -07:00
< label for = 'code-verify' > " .LAN_ENTER_CODE. " </ label > "
2012-06-18 09:06:20 +00:00
. $sec_img -> renderImage () .
$sec_img -> renderInput () . "
2012-06-06 23:30:57 +00:00
</ div > " ;
}
$text .= " <div class='admin-submit'> "
2012-11-26 21:53:56 -08:00
. $frm -> admin_button ( 'authsubmit' , ADLAN_91 , 'login' );
2012-06-06 23:30:57 +00:00
if ( e107 :: getSession () -> is ( 'challenge' ) && varset ( $pref [ 'password_CHAP' ], 0 ))
{
$text .= " <input type='hidden' name='hashchallenge' id='hashchallenge' value=' " . e107 :: getSession () -> get ( 'challenge' ) . " ' /> \n \n " ;
}
2015-02-14 17:38:41 -08:00
$text .= " </div></div>
2012-06-06 23:30:57 +00:00
</ div >
</ div >
2015-08-20 16:30:28 -07:00
</ div >
2012-06-06 23:30:57 +00:00
</ form > " ;
2012-11-26 21:50:08 -08:00
e107 :: getRender () -> tablerender ( " " , $text , 'admin-login' );
2015-02-14 17:38:41 -08:00
echo " <div class='row-fluid'>
2016-12-04 19:41:14 +00:00
< div class = 'center' style = 'margin-top:25%; color:silver' >< span style = 'padding:0 40px 0 0px;' >< a href = 'http://e107.org' > " .ADLAN_165. " </ a ></ span > < a href = '".e_BASE."index.php' > " .ADLAN_166. " </ a ></ div >
2015-02-14 17:38:41 -08:00
</ div > " ;
2006-12-02 04:36:16 +00:00
}
2009-11-22 14:10:09 +00:00
/**
* Admin auth check
* @ param string $authname , entered name
* @ param string $authpass , entered pass
* @ param object $authresponse [ optional ]
* @ return boolean if fail , else result array
*/
public function authcheck ( $authname , $authpass , $authresponse = '' )
2006-12-02 04:36:16 +00:00
{
2013-06-09 20:53:44 +01:00
$pref = e107 :: getPref ();
2009-11-22 14:10:09 +00:00
$tp = e107 :: getParser ();
$sql_auth = e107 :: getDb ( 'sql_auth' );
2010-10-26 07:41:20 +00:00
$user_info = e107 :: getUserSession ();
2013-06-09 20:53:44 +01:00
$reason = '' ;
2010-05-14 18:45:51 +00:00
2009-11-22 14:10:09 +00:00
$authname = $tp -> toDB ( preg_replace ( " / \ sOR \ s| \ =| \ #/ " , " " , trim ( $authname )));
2008-06-13 20:20:23 +00:00
$authpass = trim ( $authpass );
2010-05-14 18:45:51 +00:00
2013-06-09 20:53:44 +01:00
if ((( $authpass == '' ) && ( $authresponse == '' )) || ( $authname == '' ))
2009-11-22 14:10:09 +00:00
$reason = 'np' ;
if ( strlen ( $authname ) > varset ( $pref [ 'loginname_maxlength' ], 30 ))
$reason = 'lu' ;
2010-05-14 18:45:51 +00:00
2008-06-13 20:20:23 +00:00
if ( ! $reason )
{
2009-11-22 14:10:09 +00:00
if ( $sql_auth -> db_Select ( " user " , " * " , " user_loginname=' { $authname } ' AND user_admin='1' " ))
2006-12-02 04:36:16 +00:00
{
2009-11-22 14:10:09 +00:00
$row = $sql_auth -> db_Fetch ();
2006-12-02 04:36:16 +00:00
}
2009-11-22 14:10:09 +00:00
elseif ( $sql_auth -> db_Select ( " user " , " * " , " user_name=' { $authname } ' AND user_admin='1' " ))
{
$row = $sql_auth -> db_Fetch ();
$authname = $row [ 'user_loginname' ];
}
else
2006-12-02 04:36:16 +00:00
{
2009-11-22 14:10:09 +00:00
$reason = 'iu' ;
2006-12-02 04:36:16 +00:00
}
}
2013-06-09 20:53:44 +01:00
2009-11-22 14:10:09 +00:00
if ( ! $reason && ( $row [ 'user_id' ])) // Can validate password
2010-05-14 18:45:51 +00:00
{
2010-10-26 07:41:20 +00:00
$session = e107 :: getSession ();
2013-06-09 20:53:44 +01:00
if (( $authresponse && $session -> is ( 'prevchallenge' )) && ( $authresponse != $session -> get ( 'prevchallenge' )))
2009-11-22 14:10:09 +00:00
{ // Verify using CHAP (can't handle login by email address - only loginname - although with this code it does still work if the password is stored unsalted)
2013-06-09 20:53:44 +01:00
/*
$title = 'Login via admin' ;
$extra_text = 'C: ' . $session -> get ( 'challenge' ) . ' PC: ' . $session -> get ( 'prevchallenge' ) . ' PPC: ' . $session -> get ( 'prevprevchallenge' ) . ' R:' . $authresponse . ' P:' . $row [ 'user_password' ];
$text = 'CHAP: ' . $username . ' (' . $extra_text . ')' ;
$title = e107 :: getParser () -> toDB ( $title );
$text = e107 :: getParser () -> toDB ( $text );
e107 :: getAdminLog () -> e_log_event ( 4 , __FILE__ . " | " . __FUNCTION__ . " @ " . __LINE__ , " LOGIN " , $title , $text , FALSE , LOG_TO_ROLLING );
$logfp = fopen ( e_LOG . 'authlog.txt' , 'a+' ); fwrite ( $logfp , $title . ': ' . $text . " \n " ); fclose ( $logfp );
*/
if (( $pass_result = $user_info -> CheckCHAP ( $session -> get ( 'prevchallenge' ), $authresponse , $authname , $row [ 'user_password' ])) !== PASSWORD_INVALID )
2009-11-22 14:10:09 +00:00
{
2013-06-09 20:53:44 +01:00
return $row ;
2009-11-22 14:10:09 +00:00
}
}
else
{ // Plaintext password
2013-06-09 20:53:44 +01:00
/*
$title = 'Login via admin' ;
$extra_text = 'C: ' . $session -> get ( 'challenge' ) . ' PC: ' . $session -> get ( 'prevchallenge' ) . ' PPC: ' . $session -> get ( 'prevprevchallenge' ) . ' R:' . $authresponse . ' P:' . $row [ 'user_password' ];
$text = 'STD: ' . $username . ' (' . $extra_text . ')' ;
$title = e107 :: getParser () -> toDB ( $title );
$text = e107 :: getParser () -> toDB ( $text );
e107 :: getAdminLog () -> e_log_event ( 4 , __FILE__ . " | " . __FUNCTION__ . " @ " . __LINE__ , " LOGIN " , $title , $text , FALSE , LOG_TO_ROLLING );
// $logfp = fopen(e_LOG.'authlog.txt', 'a+'); fwrite($logfp, $title.': '.$text."\n"); fclose($logfp);
*/
2009-11-22 14:10:09 +00:00
if (( $pass_result = $user_info -> CheckPassword ( $authpass , $authname , $row [ 'user_password' ])) !== PASSWORD_INVALID )
{
return $row ;
}
2015-09-05 20:02:51 -07:00
2009-11-22 14:10:09 +00:00
}
2008-06-13 20:20:23 +00:00
}
2009-11-22 14:10:09 +00:00
return array ( " authfail " , " reason " => $reason );
2006-12-02 04:36:16 +00:00
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
2009-11-22 14:10:09 +00:00
?>