public function validateExtended()
 {
     $this->validateEmail();
     if ($this->getElementValue('password1') != '') {
         if (strlen($this->getElementValue('password1')) < 6) {
             $this->getElement('password1')->setValidationError('User a longer password, at least 6 chars.');
         }
         if ($this->getElementValue('password1') != $this->getElementValue('password2')) {
             $this->getElement('password2')->setValidationError('Those passwords do not match.');
         }
         if ($this->user->getUsername() == Session::getUser()->getUsername()) {
             $passwordCurrent = $this->getElementValue('passwordCurrent');
             if (empty($passwordCurrent)) {
                 $this->getElement('passwordCurrent')->setValidationError('If changing your password, you must enter your current password first.');
             }
             try {
                 AuthBackend::getBackend()->checkCredentials($this->user->getUsername(), $passwordCurrent);
             } catch (Exception $e) {
                 $this->getElement('passwordCurrent')->setValidationError('This does not appear to be your current password.');
             }
         }
     }
 }
Exemplo n.º 2
0
set_include_path(get_include_path() . PATH_SEPARATOR . 'src/main/php/' . PATH_SEPARATOR . '/usr/share/php/' . PATH_SEPARATOR . 'vendor/jwread/lib-allure/src/main/php/');
date_default_timezone_set('Europe/London');
function __autoload($class)
{
    $class = DIRECTORY_SEPARATOR . $class . '.php';
    foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
        if (file_exists($path . $class)) {
            require_once $path . $class;
            return;
        }
    }
}
require_once 'includes/functions.php';
require_once 'libAllure/Exceptions.php';
require_once 'libAllure/ErrorHandler.php';
require_once 'libAllure/Database.php';
require_once 'libAllure/Form.php';
require_once 'libAllure/Logger.php';
require_once 'libAllure/User.php';
require_once 'libAllure/Inflector.php';
require_once 'libAllure/Session.php';
require_once 'libAllure/AuthBackend.php';
require_once 'libAllure/AuthBackendDatabase.php';
require_once 'libAllure/HtmlLinksCollection.php';
require_once 'config.php';
\libAllure\ErrorHandler::getInstance()->beGreedy();
$db = new \libAllure\Database(CFG_DB_DSN, CFG_DB_USER, CFG_DB_PASS);
\libAllure\DatabaseFactory::registerInstance($db);
\libAllure\AuthBackend::setBackend(new \libAllure\AuthBackendDatabase());
\libAllure\Session::checkCredentials('SYSTEM', '');
Exemplo n.º 3
0
require_once 'includes/widgets/header.php';
use libAllure\DatabaseFactory;
use libAllure\AuthBackend;
use libAllure\HtmlLinksCollection;
$db = DatabaseFactory::getInstance();
$sql = 'SELECT count(u.id) AS count FROM users u';
$stmt = $db->prepare($sql);
$stmt->execute();
$countUsers = $stmt->fetchRow();
$countUsers = $countUsers['count'];
$setupLinks = new HtmlLinksCollection();
if ($countUsers == 1 || isset($_REQUEST['recreate'])) {
    $sql = 'DELETE FROM users WHERE username = "******"';
    $stmt = $db->prepare($sql)->execute();
    $adminPassword = uniqid();
    $sql = 'INSERT INTO users (username, password, `group`) VALUES (:username, :password, 1)';
    $stmt = $db->prepare($sql);
    $stmt->bindValue(':username', 'admin');
    $stmt->bindValue(':password', AuthBackend::getInstance()->hashPassword($adminPassword));
    $stmt->execute();
    $tpl->assign('message', 'User account created. Your username is <strong>admin</strong> and your password is <strong>' . $adminPassword . '</strong>');
    $setupLinks->add('login.php', 'Login');
} else {
    $tpl->assign('message', 'Admin account already exists.');
    $setupLinks->add('login.php', 'Login');
    $setupLinks->add('?recreate', 'Recreate');
}
$tpl->assign('links', $setupLinks);
$tpl->display('notification.tpl');
require_once 'includes/widgets/footer.php';
Exemplo n.º 4
0
}
class PermissionException extends SimpleFatalError
{
}
class PrivilegeException extends PermissionException
{
}
$db = new \libAllure\Database('mysql:host=localhost;dbname=pfrog', 'root', '');
\libAllure\DatabaseFactory::registerInstance($db);
\libAllure\Session::setSessionName('pfrogUser');
\libAllure\Session::start();
define('CFG_PASSWORD_SALT', 'asdf');
date_default_timezone_set('Europe/London');
$eh = \libAllure\ErrorHandler::getInstance();
$eh->beGreedy();
define('INC_COMMON', true);
require_once 'core.php';
require_once 'libAllure/Database.php';
define('LEVEL_ADMIN', 30);
if (\libAllure\Session::isLoggedIn()) {
    $user = \libAllure\Session::getUser();
}
require_once 'libAllure/AuthBackendDatabase.php';
$backend = new \libAllure\AuthBackendDatabase();
\libAllure\AuthBackend::setBackend($backend);
$breadcrumbs = array();
$breadcrumbs[] = '<a href = "index.php">index</a>';
require_once 'libAllure/Template.php';
$tpl = new \libAllure\Template('pfrog');
require_once 'includes/Game.php';
$game = new Game();