簡體   English   中英

無法訪問本地托管站點的管理儀表板

[英]Can't access the admin dashboard of my locally hosted site

我從某人那里購買了一個代碼並將其托管在本地,它的工作非常出色,但是我的問題是。 我在phpmyadmin中打開了管理表,並獲得了管理電子郵件和加密密碼。 但是因為我不知道密碼是什么,所以我嘗試通過phpmyadmin添加另一個管理帳戶(仍使用本地主機),但是仍然無法登錄到管理儀表板。 有什么辦法嗎?

<?php   require("../includes/config.php");

        require_once(ROOT_PATH . "core/class.admin.php");
    $login = new ADMIN();
    if($login->
is_loggedin() != ""){
        $login->
redirect(BASE_URL.'administrator');
    }
    if(isset($_POST['loginBtn'])){
        $username = strip_tags($_POST['userID']);
        $password = strip_tags($_POST['password']);
                if($login->
doLogin($username, $password)){
            $login->
redirect(BASE_URL.'administrator');
        }
else{
            $error = "Email Address or Password does not match, please try again!";
        }
        }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
Naija Helper</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="http://creativeweb.com.ng" />
<!-- css -->
<link href="<?php echo BASE_URL;
?>
css/bootstrap.min.css" rel="stylesheet" />
<link href="<?php echo BASE_URL;
?>
css/fancybox/jquery.fancybox.css" rel="stylesheet">
<link href="<?php echo BASE_URL;
?>
css/jcarousel.css" rel="stylesheet" />
<link href="<?php echo BASE_URL;
?>
css/flexslider.css" rel="stylesheet" />
<link href="<?php echo BASE_URL;
?>
js/owl-carousel/owl.carousel.css" rel="stylesheet">
<link href="<?php echo BASE_URL;
?>
css/style.css" rel="stylesheet" />
<style type="text/css">
    .formWrapper {
        width: 40%;
        margin: auto;
    }
    @media (max-width: 767px) {
        .formWrapper {
            width: 70%;
            margin: auto;
        }
    }
    @media (max-width: 480px) {
        .formWrapper {
            width: 90%;
            margin: auto;
        }
    }
</style>
</head>
<div class="featured_content" style="margin: 0px;
">
    <div class="formWrapper">
        <div align="center" style="margin-bottom: 20px;
">
            <a style="padding-bottom: 20px;
" href="<?php echo BASE_URL;
?>
">
            <img src="<?php echo BASE_URL;
?>
img/logo.png" alt="logo"/>
</a>
        </div>
        <div align="center" style="margin-bottom: 10px;
">
            <span style="font-size: 28px;
">
Adminstrators only</span>
<br>
            <span>
Secure admin access</span>
        </div>
        <div style="background: #FFF;
 padding: 50px 20px 20px;
 border-radius: 5px;
">
            <?php               if(isset($error))               {
                    ?>
                    <div class="alert alert-danger">
                       <i class="fa fa-exclamation-triangle">
</i>
 &nbsp;
 <?php echo $error;
 ?>
 !                  </div>
                    <?php               }
            ?>
            <form id="contact-form" method="post" action="" role="form" novalidate>
                <div class="form-group has-feedback">
                    <label for="email">
Email Address*</label>
                    <input type="text" class="form-control" id="userID" name="userID" required                  placeholder="Enter your Email Or Username">
                    <i class="fa fa-envelope form-control-feedback">
</i>
                </div>
                <div class="form-group has-feedback">
                    <label for="password">
Password*</label>
                    <input type="password" class="form-control" id="password" name="password" required placeholder="Password">
                    <i class="fa fa-lock form-control-feedback">
</i>
                </div>
                <br>
                <input type="submit" style="width: 100%;
 padding: 20px;
border-radius: 5px;
"               value="Login" name="loginBtn" class="btn btn-default">
            </form>
        </div>
        <div class="row">
            <div class="col-md-6">
                <span style="font-size: 12px;
 padding-left: 10px;
">
                <a style="color: #666;
" href="register">
<i class="fa fa-lock">
</i>
 Register</a>
</span>
            </div>
            <div class="col-md-6" align="right">
                <span style="font-size: 12px;
 padding-right: 10px;
">
                <a style="color: #666;
" href="#">
<i class="fa fa-lock">
</i>
 Forgot Password</a>
</span>
            </div>
        </div>
            </div>
</div>
<?php include(ROOT_PATH."includes/footer.php");
 ?>

這是一個名為create_hash.php的php頁面的代碼。 它包含一個用於創建新密碼哈希的函數createHash()和使用它的示例。

遵循的步驟:

  • 將文件create_hash.php放在項目中的某個位置。 但是請注意 :創建新密碼后,請從項目中刪除文件! 您可以將其保存(供以后使用),如果需要,可以在文件系統中的其他位置運行,不能在該位置運行。
  • 閱讀文件中的注釋,它們很重要;
  • 在下面的示例中完成您自己的密碼;
  • 根據需要更改createHash()參數;
  • 讓文件運行。 屏幕上將顯示一個新的密碼哈希;
  • 將新創建的哈希放入admin表;
  • 嘗試再次登錄管理控制台;
  • 從您的項目中刪除文件create_hash.php

create_hash.php:

<?php

/**
 * Create a password hash.<br/>
 * 
 * The two digit cost parameter is the base-2 logarithm of the iteration count for<br/>
 * the underlying Blowfish-based hashing algorithmeter and must be in range 04-31.
 * 
 * @param string $password Password to be hashed.
 * @param integer $algo [optional] PASSWORD_DEFAULT|PASSWORD_BCRYPT. Used algorithm.
 * @param integer $cost [optional] Default: 10. Base-2 logarithm of the iteration count. Range 04-31.
 * return string Hashed password (min. 60 characters long).
 */
function createHash($password, $algo = PASSWORD_BCRYPT, $cost = PASSWORD_BCRYPT_DEFAULT_COST) {
    try {
        if ($algo != PASSWORD_BCRYPT || $algo != PASSWORD_DEFAULT) {
            throw new Exception('Incorrect hashing algorithm!');
        }

        if ($cost < 4 || $cost > 31) {
            throw new Exception(' The hashing cost must be in range 04-31!');
        }
    } catch (Exception $exc) {
        echo $exc->getMessage();
        exit();
    }

    $options = array(
        'cost' => $cost,
    );

    return password_hash($password, $algo, $options);
}

//----------------------------------------------------
// Example of using the hashing function createHash().
// Give a password with at least 8 characters,
// including ciphers, letters - lowercase and 
// uppercase, alpha characters (#, $, @, etc).
//----------------------------------------------------
$password = "Lorem#20Ipsum17";
$hash = createHash($password, PASSWORD_BCRYPT, 12);
echo $hash;
//----------------------------------------------------

您尚未在form元素的action屬性中編寫任何內容。 在某個頁面上提交表單,並檢查用戶使用數據庫輸入的憑據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM