在網路上下載了個thinkphp5.3的源碼學習,因為沒有安裝文件,只能透過資料庫匯入的方式安裝,資料庫匯入和配置好資料庫連接檔後,在phpmydmin裡面的admin表裡找到
admin:admin
password:12eefdf664f0e07e65a2c35e01e98d29
我把password解密後得到明文密碼:o8889t
#在登入原始碼後台的時候一直提示密碼或帳號錯誤,然後我把admin表裡面的password改成e10adc3949ba59abbe56e057f20f883e 明文是:123456
再次登入還是發現提示帳號或密碼錯誤,我想知道這個後台的密碼是什麼加密方式。或者要怎麼樣後台才能登入成功。列出了三個文件,請大佬賜教,感激不盡。
後台登入AdminController.class.php程式碼如下:
---------------------------- -------------------------------------------------- ----
<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller
{
public function index()
{
layout(false);
$this->#display();##display();##display();##display();##display();##display();##display();##display();##display();
## } //登入 public function loginin() {ofalse);# if(I('post.adminuser') and I('post.adminpwd'))
{
$adminuser=I('post.adminuser');
# $adminpwd=I('post.adminpwd');
//記住帳號
# $remember=I('post.remember' );
if(!empty($remember))
{
cookie('remember',$remember,3600*24*30);
cookie('loginname',$adminuser,3600*24*30);
cookie('loginpwd',$adminpwd,3600*24*30);
# }else {
cookie('remember',null);
cookie('loginname',null);
cookie('loginpwd',null);
## }
$auth=I('post.auth');
$verify = new \Think\Verify();
$res =$verify->check($auth, '');
if($res==false)
{
# $this->assign(' error','驗證碼不正確! ');
$this->display('index');
exit();
}
$admin=new \Admin \Model\AdminModel();
$res=$admin->where("adminname='$adminuser'")->find();
if($res)
{
$status=$res['status'];
if($status==0)
{
$this->assign('error','該管理員已被停用!');
$this->display('index');
exit ();
}else {
$password=$res['password'];
//MD5加密
$pwd=$admin ->encrypt($adminpwd);
## if($password!=$pwd) {# $this->assign('error','用戶名稱或密碼錯誤!'); $this->display('index'); $this->display('index'); exit(); }else { //判斷管理員群組是否已停用 $group_id=$res['group_id']; $AdminGroup=new \Admin\Model\AdminGroupModel(); $res_g=$AdminGroup->where("id=$group_id")->field('status')->find(); if($res_g['status'] =='1') { //更新登入狀態 $ip=getIP(); $login_num=$res[' login_num'] 1; $data=array( 'last_login_time'=>date('Y-m-d H:i:s'), 'last_login_ip' >$ip, 'login_num'=>$login_num ); $res2=$admin->where("adminname='$adminuser' ")->save($data); if($res2) { //儲存使用者SESSION $_SESSION[' admin_id']=$res['uid']; $_SESSION['a_group_id']=$res['group_id'];# //跳轉頁 $this->redirect('System/index'); }else { $this->assign('error','登入失敗! '); $this->display('index'); } }else { $this->assign( 'error','您所在的管理員群組已停用!'); $this->display('index'); exit(); } } } }else { $this->assign('error',』該管理員不存在! '); $this->display('index'); } }else { $this->assign( 'error','帳號、密碼不能為空!'); $this->display('index'); }# }//退出登入 public function loginout() { $_SESSION['admin_id']=null;### $_SESSION['admin_id']=null;###
$_SESSION['a_group_id']=null;
# //跳頁
$this->redirect('Index/index');
# }
//產生驗證碼
public function verify()
## {# ob_end_cle{
# ob_end_clean();
an();## $config = array(
'expire' => 1800, // 驗證碼過期時使用背景圖片
'fontSize' => 10, // 驗證碼字體大小(px)
'use 'useNoise ' => false, // 是否新增雜點
'imageH' => 30, 按鈕 ; 80, // 驗證碼圖片寬度
'length' => 4, // 驗證碼位數
'fonttt 隨機驗證>獲取
'bg' => array(243, 251, 254), // 背景顏色
);
## ); /** * 輸出驗證碼並保存驗證碼的值的 session中 * 驗證碼儲存到 session的格式為: array('verify_code' => '驗證碼值', 'verify_time' => '驗證碼建立時間'); **/ $verify->entry(); }######}##### #------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------######第二個檔案AdminController.class.php程式碼如下:######-------------- -------------------------------------------------- ------------------######<?php######/**###### * 管理員管理###### */#######namespace Admin \Controller;######use Admin\Common\Controller\AuthController;######class AdminController extends AuthController ######{####### public function index()############ public function index()##### ## {###### if(I('get.search'))###### {###### $search=I('get.search');###$where="adminname='$search' 或電子郵件='$search' 或電話='$search'";
}
## if(I('get. group_id ')) { $group_id=I('get.group_id'); $where="group_id='$group_id'";id'";
}
if(I('get.group_name'))
{
$group_name=I('get.group_name');
# $res_ag=D('AdminGroup')->where("title='$group_name'")->field('id')->find();
$group_id=$ res_ag[ 'id'];
$where="group_id='$group_id'";
}
if(I('get.search')== ''和I('get.group_id')=='' 和I('get.group_name')=='')
# {
$where='1';
}
$Admin=new \Admin\Model\AdminModel();
## $count=$Admin->where($where)->count() ;
# $per = 15;
## if($_GET['p']) { $p=$_GET['p' ]; }else { $p=1; } $Page= new \Think\Page($count,$per) ;//實例化分頁類別決定總記錄數與每頁顯示的記錄數(25) $Page->rollPage=10; // 分頁列 每頁顯示的頁數 $Page -> setConfig('header','共%TOTAL_ROW%條'); $Page -> setConfig('first','首頁'); $Page ->; setConfig('last','共%TOTAL_PAGE%頁'); $Page -> setConfig('prev','上一頁'); $Page ->; setConfig('下一頁','下一頁'); $Page -> setConfig('link','indexpagenumb');//pagenumb 會被替換成頁碼 $Page -> setConfig('主題','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 頁/共 %TOTAL_PAGE% 頁 (<font color="red ">'.$per.'條/頁共%TOTAL_ROW%條)'); $show= $Page->show();//分頁顯示輸出 $adminlist = $Admin->where($where)->page($p.','.$per)->select(); $this-> assign('alist',$adminlist);//分配資料集 $this->assign('page',$show); $ this->display(); } //新增管理員 public function add() {#
//取得管理員群組清單
$group=new \Admin\Model\AdminGroupModel();
$grouplist=$group->getGroupList2();
$this->assign('glist',$grouplist);
if(I('post.'))
{
# if(I ('post.adminname'))
{
$adminname=I('post.adminname');
$Admin=new \Admin\Model\AdminModel( );
$res=$Admin->where("adminname='$adminname'")->find();
if($res)
{
$str='X該使用者名稱已存在';
echo $str;
exit();
# }else {
$str='';
## $a='a'; } }}
##M if(I('post.password') and I('post.password2')) { $password=I('post.password'); # $password2=I('post.password2'); if (strlen($password2)<=5) {# $str='X密碼密碼不少於6位元'; echo $str; exit(); }else {# if($password!=$password2 ) { $str='X兩次密碼相同'; echo $str; exit(); }else { $str='';# $a.='a'; } }#n’ # } if(I('post.email')) {# $email=I('post.email'); if(is_email($email)) { $str='';# }else {
## $strstr ='X郵箱格式不正確';
echo $str;
# exit();
}
}
##o
## }##
# if(I('post.phone'))
### {###### $phone=I('post.phone');###### if(is_phone ($phone))###### {###### $str='';###### }else {###### $str='X手機號碼格式不正確' ;###### echo $str;###### exit();###### }######### exit();###### }###### }###### ####### # if($ a=='aa')###### {###### $adminname=I('post.adminname');###### $password2=I('post.password2'); ###### //MD5加密###### $pwd=$Admin->encrypt($password2);###### $email=I('post.email');### #$phone=I('post.phone');
$group_id=I('post.group_id');
$status=I('post.status') ;
$register_time=date('Y-m-d H:i:s');
//php取得ip的演算法
$ip = ($_SERVER["HTTP_VIA “])? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
$ip = ($ip) ? $ip : $_SERVER["REMOTE_ADDR"];
$data=array(
'adminname'=>$adminname,
'password'=>$ pwd,
'email'=>$email,
'phone'=>$phone,
'省份'=>trim(I('post .province')) ,
'city'=>trim(I('post.city')),
'group_id'=>$group_id,
# 'status'=>$ status,
'register_time'=>$register_time,
'register_ip'=>$ip,
'last_login_time'= >date('Y-m-d H:i:s ')
);
$res=$Admin->add($data);
if($ res)
{
##'echo '1';
}else {
echo '0';
}
}## #」 {
$this->display();
}
}
//編輯管理員
## //編輯管理員### ## public function edit($uid)###### {###### //取得管理員資訊###### $Admin= new \Admin\Model\AdminModel();### ### $aMsg=$Admin->getAdminMsg($uid);###### $this->assign('msg',$aMsg) ;###### //取得管理員群組清單## ##### $group=D('admin_group');###### $grouplist=$group->getGroupList2();## #### $this->assign('glist',$list );###### ###### if(IS_POST)###### {######## // var_dump(I('post.'));exit;####exit;####exit;####exit;### ## if(I('post.adminname'))###### {###### $adminname=I('post .adminname');###### $res=$Admin- >where("adminname='$adminname' and uid!='$uid'")->find();##### # if($res)####### {###### $error='X該使用者名稱存在';######已 $this->assign('error',$error );###### $this->display();#### ## exit();###### }###### }###### ##### $email=I('post.email');###### $email=I('post.email'); if($email)###{
if(is_email($email)!==true)
{
$error1='X信箱格式不正確';
$this->assign('error1',$error1);
# $this->display();
exit();
# }
}
$phone=I('post.phone');
if($phone)
{
if(is_phone($phone)!==true)
{
$error2='X手機號碼格式不正確';
$this- >分配('error2',$error2);
$this->display();
exit();
# }
}
$group_id=I('post.group_id');
$login_num=I('post.login_num');
# $status=I('post .status' );
$data=array(
'adminname'=>$adminname,
'email'=>$電子郵件,
'電話'=>$電話,
'省'=>trim(I('post.province')),
'城市' =>trim(I( 'post.city')),
'group_id'=>$group_id,
'login_num'=>$login_num,
'status'=>$status,
);
if(I('post.password'))
{
$password =I('post.password');
//MD5加密
$pwd=$Admin->加密($password);
$data['密碼']=$pwd;
}
$res=$Admin->where("uid=$uid")->save($data);
if($res!==false)
{
layout(false);
$this->success('編輯管理員成功!', U('index'),3);
}else {
佈局(false);
$this->error('操作失敗!');
}
## }else { $this->display(); } } //修改管理員取消狀態# public function changestatus($id,$status)# { $data=array( 'status'=>$status 'status'=>$status
##' # );
$Admin=new \Admin\Model\AdminModel();
$res=$Admin ->where("uid=$id")->save($data );
if($res===false)
{
echo '0';
}else {
### echo '1';###### }###### }###
//刪除管理員
public function del($id)
{
$Admin=new \Admin\Model\AdminModel ();
$res=$Admin->where("uid=$id")->delete();
if($res===false)
{
echo '0';
# }else {
echo '1';
}
# }
//修改密碼
public function changepwd()
##卷 { if($_SESSION['admin_id']!# if($_SESSION['admin_id']!
# if($_SESSION['admin_id']! ='') { $admin_id=$_SESSION['admin_id'];# if(I('post.'))# { $oldpwd=I('post.oldpwd'); if($oldpwd=='')## {
# $this- >assign('error1','原始密碼不能為空!');
$this->display();
exit();
# }
$pwd1=I('post.pwd1');
$pwd2=I('post.pwd2');
if($pwd1=='' )
{
$this->assign('error2','新密碼不能空!');
$this->display();
exit();
}
if($pwd2=='')
{
# $ $ $this-> assign('error3','重複密碼不能為空!');
$this->display();
exit();
}
exit(); }# if($pwd1==$pwd2) { if(strlen($pwd2)>5) { //驗證原密碼是否正確 $Admin=new \Admin\Model\AdminModel(); $res=$Admin->checkPwd($admin_id,$oldpwd); if($res) { //修改密碼###### $newpwd=$Admin->encrypt($pwd2);### ### $data=array(##### 'password'=>$newpwd###### );###### $res2=$Admin->where("uid=$## $res2=$Admin->where("uid=$## admin_id")->save($data);###### layout(false);###### if($res2===false)###### {##### # $this->error('修改密碼失敗! ');###### }else {####### $this->success('編輯密碼成功!');###### }###### }else {# ##### $this->assign('error1','原始密碼錯誤!');###### $this->display();###### exit();# ##### }###### }else {###
$this->assign('error3','新密碼長度不少於5位!');
$this->display();
exit( );
}
}else {
$this->assign('error3','兩次密碼不相同!');
# $this->display();
exit();
}
exit(); } }else { $this->display() ; } }else { $this->redirect('Index/index'); # }}------------------------------------ -------------------------------------------------- -------------------------------------------------- --------------------------第三個檔案如下:<?phpnamespace Admin\Common\Controller;use Think\Controller;use Think\Auth;//權限認證class AuthController extends Controller {protected function _initialize(){//session不存在時,不允許直接存取if(!$_SESSION ['admin_id']){layout(false);$this->error('還沒有登錄,正在跳轉到登入頁', U('Index/index'));}//session存在時,不需要驗證的權限$not_check = array ( 'Admin/changepwd','System/index','System/index_show','System/cleancache','System/clearrubbish',//修改密碼、系統首頁、#################################################################################################### #'ArticleCat/deloldimg','Article/deloldimg','Article/deloldbigimg','Article/deloldfile',//刪除文章分類原圖片、刪除文章原圖片、刪除文章原大圖片、刪除文章原始檔案## ####'GoodsCat/deloldimg',//刪除商品分類原始圖片######);###########//目前作業的請求 模組名稱/方法名稱######## ####if(in_array(CONTROLLER_NAME.'/'.ACTION_NAME, $not_check))######{######return true;######}######## #####$auth = new Auth();######if(!$auth->check(CONTROLLER_NAME.'/'.ACTION_NAME,$_SESSION['admin_id']) and $_SESSION[' a_group_id']!='1')######{######layout(false);######echo '沒有權限!';die();####################################################################################### $this->error('沒有權限');######}######}######}#########
已經解決,謝謝