简体   繁体   English

无法访问本地托管站点的管理仪表板

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

I bought a code from someone and hosted it locally and it was working very wonderful but my problem is. 我从某人那里购买了一个代码并将其托管在本地,它的工作非常出色,但是我的问题是。 I opened the admin table in phpmyadmin and got the admin email and encrypted password. 我在phpmyadmin中打开了管理表,并获得了管理电子邮件和加密密码。 But because I don't know what the password was, I tried adding another admin account via the phpmyadmin (still using local host) but I'm still unable to login to the admin dashboard. 但是因为我不知道密码是什么,所以我尝试通过phpmyadmin添加另一个管理帐户(仍使用本地主机),但是仍然无法登录到管理仪表板。 Any solution? 有什么办法吗?

<?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");
 ?>

Here is the code of a php page named create_hash.php . 这是一个名为create_hash.php的php页面的代码。 It contains a function createHash() to create a new password hash and an example for using it. 它包含一个用于创建新密码哈希的函数createHash()和使用它的示例。

Steps to follow: 遵循的步骤:

  • Place the file create_hash.php somewhere in your project. 将文件create_hash.php放在项目中的某个位置。 BUT BE AWARE : Remove the file from your project after you create a new password! 但是请注意 :创建新密码后,请从项目中删除文件! You can save it - for later use - somewhere else in your file system if you wish, where it can not be run as such; 您可以将其保存(供以后使用),如果需要,可以在文件系统中的其他位置运行,不能在该位置运行。
  • Read the comments in the file, they are important; 阅读文件中的注释,它们很重要;
  • Complete your own password in the example bellow; 在下面的示例中完成您自己的密码;
  • Change the createHash() arguments as you wish; 根据需要更改createHash()参数;
  • Let the file run. 让文件运行。 A new password hash will be displayed on the screen; 屏幕上将显示一个新的密码哈希;
  • Place the new created hash in the admin table; 将新创建的哈希放入admin表;
  • Try to login in the admin dashboard again; 尝试再次登录管理控制台;
  • REMOVE THE FILE create_hash.php FROM YOUR PROJECT! 从您的项目中删除文件create_hash.php

The 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;
//----------------------------------------------------

You have not written anything in action attribute of form element. 您尚未在form元素的action属性中编写任何内容。 Submit your form on some page and check the credentials entered by the user with the database. 在某个页面上提交表单,并检查用户使用数据库输入的凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM