PHP的一段登陸代碼,該怎麼解決

來源:互聯網
上載者:User
PHP的一段登陸代碼
現在有段PHP代碼, 我要把登陸密碼設為指定的數字, 不從資料庫裡面取, 大家給我看看改如何修改?


/**
**============================================================================
* ============================================================================
*/

$dir_name=str_replace('\\','/',dirname(__FILE__));
$admindir=substr($dir_name,strrpos($dir_name,'/')+1);
define('CMS_PATH',str_replace($admindir,'',$dir_name));
define('INC_PATH',CMS_PATH.'includes/');
define('DATA_PATH',CMS_PATH.'data/');
include(INC_PATH.'fun.php');
include(DATA_PATH.'confing.php');
include(INC_PATH.'mysql.class.php');
if(file_exists(DATA_PATH.'sys_info.php')){
include(DATA_PATH.'sys_info.php');
}
$mysql=new mysql(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME,DB_CHARSET,DB_PCONNECT);
session_start();
$_SESSION['login_in']=empty($_SESSION['login_in'])?'':$_SESSION['login_in'];
$_SESSION['admin']=empty($_SESSION['admin'])?'':$_SESSION['admin'];
if($_SESSION['login_in']&&$_SESSION['admin']){header("location:admin.php");}
$action=empty($_GET['action'])?'login':$_GET['action'];
$password=empty($_POST['password'])?'':$_POST['password'];
$user=empty($_POST["user"])?'':$_POST['password'];
$code=empty($_POST['code'])?'':$_POST['code'];
$submit=empty($_POST['submit'])?'':$_POST['submit'];
go_url($action);

function login(){
global $_sys;
include('template/admin_login.html');
}
function ck_login(){
global $submit,$user,$password,$_sys,$code;
$submit=$_POST['submit'];
$user=fl_html(fl_value($_POST['user']));
$password=fl_html(fl_value($_POST['password']));
$code=$_POST['code'];
if(!isset($submit)){
msg('請從登陸頁面進入');
}
if(empty($user)||empty($password)){
msg("密碼或使用者名稱不可為空");
}
if(!empty($_sys['safe_open'])){
foreach($_sys['safe_open'] as $k=>$v){
if($v=='3'){
if($code!=$_SESSION['code']){msg("驗證碼不正確!");}
}
}
}
check_login($user,$password);

}

function out(){
login_out();
}
?>


------解決方案--------------------
那你將你的check_login($user,$password);
方法的$password變數直接設定為數字就可。在方法裡面就將你傳遞的數字在你的方法裡面進行比對。
------解決方案--------------------
fun.php 貼出這個檔案的代碼
------解決方案--------------------
PHP code
check_login($user,$password) { ($password == '12345') ? $_SESSION['login_in'] = yes : die("error");}
------解決方案--------------------
有幾個注釋的地方自己看看 因為不知道你其他代碼是否有用到那些變數處理.

PHP code
function check_login($user, $password) {    /*    $rel=$GLOBALS['mysql']->fetch_asc("select id,admin_name,admin_password,admin_purview,is_disable from ".DB_PRE."admin where admin_name='".$user."' limit 0,1");    $rel=empty($rel)?'':$rel[0];    if(empty($rel)){        msg('不存在該系統管理使用者','login.php');    }    $password=md5($password);    if($rel['is_disable']){        msg('該帳號已經被鎖定,無法登陸');    }      */    $oldPassword = '12345'; //預設固定密碼    if ($password != $oldPassword) {        msg("輸入的密碼不正確");    }    if (!isset($_SESSION)) {        session_start();    }    $_SESSION['admin'] = $rel['admin_name'];    //$_SESSION['admin_purview'] = $rel['admin_purview']; //這裡需要根據車給你需代碼進行處理    //$_SESSION['admin_id'] = $rel['id']; 這裡id 需要根據程式碼進行處理    $_SESSION['admin_time'] = time();    $_SESSION['login_in'] = 1;    $_SESSION['login_time'] = mktime();    $ip = fl_value(get_ip());    $ip = fl_html($ip);    $_SESSION['admin_ip'] = $ip;    //unset($rel);    header("location:admin.php");} 
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.