Example #1
0
function cp_authenticate($session = true)
{
    cp_session_cleanup();
    if (isset($_REQUEST[CP_USERNAME_FIELD])) {
        if (string_is_empty($_REQUEST[CP_USERNAME_FIELD])) {
            return 'The username field was left blank';
        }
        if (string_is_empty($_REQUEST[CP_PASSWORD_FIELD])) {
            return 'The password field was left blank';
        }
        list($username, $password) = explode('|', file_first_line(FILE_CP_USER));
        if ($username == $_REQUEST[CP_USERNAME_FIELD] && $password == sha1($_REQUEST[CP_PASSWORD_FIELD])) {
            if ($session) {
                cp_session_create($username);
            }
            return true;
        }
        return 'The supplied username/password combination is not valid';
    } else {
        if (isset($_COOKIE[CP_COOKIE_NAME])) {
            return cp_session_authenticate($_COOKIE[CP_COOKIE_NAME]);
        }
    }
}
Example #2
0
<?php

require_once 'includes/functions.php';
require_once 'global-header.php';
$password = get_random_password();
file_write(FILE_CP_USER, 'administrator|' . sha1($password));
cp_session_cleanup(true);
?>

    <div class="block-center margin-top-bottom-10px" style="width: 550px;">
      Your TradeX control panel login information has been set and is listed below.
      Please bookmark the control panel and write down both the username and password
      for safe keeping!

      <br /><br />

      <a href="index.php">TradeX Control Panel</a><br />
      <b>Username:</b> administrator<br />
      <b>Password:</b> <?php 
echo $password;
?>
    </div>

<?php 
require_once 'global-footer.php';