/home/coolpkct/www/websites/cake3.cool.rocks/admin/commands/account.php
<?php
/**
 * Part of Showkase web site management package
 *
 * @package Showkase
 * @author Jack Hardie {@link http://www.jhardie.com}
 * @copyright Copyright (c) 2012, SimpleViewer Inc.
 */
 defined('SK_ACCESS')||die('<h1>403: Forbidden</h1>');
 $sep = DIRECTORY_SEPARATOR;
 require_once "commands{$sep}command.php" ;
 require_once "classes{$sep}accountscreen.php";
 
/**
 * Command - show account admin screen
 *
 * @package Showkase
 */
 class Account extends Command {
    function doExecute( Request $request ) {
        unset ($_SESSION['pageIndex']);
        $context = array('token' => $request->newToken());
        $context['match'] = true;
        $context['okNewUser'] = true;
        $context['okNewPass'] = true;
        $context['okOldPass'] = true;
        $changed = false;
        $auth = new Auth();
        if ($request->propertyIsSet('accountsubmitted')) {
            try {
                if (!$request->validatePost()) {
                    throw new Exception('No action. Re-submission or remote submission is not allowed.');
                }
                $user = trim($request->getProperty('user'));
                $password = trim($request->getProperty('password1'));
                $context['match'] = ($password == $request->getProperty('password2'));
                $context['okNewUser'] = (strlen($user) > 0);
                $context['okNewPass'] = (strlen($password) > 4);
                $context['okOldPass'] = $auth->confirmPass($request->getProperty('password'));
                if (
                    $context['match']
                    && $context['okOldPass']
                    && $context['okNewPass']
                    && $context['okNewUser']
                ) {
                    $changed = $auth->changeLogin($user, $password);
                }
            } catch (Exception $e) {
                $context['changed'] = false;
                Board::addExceptionMessage($e);
            }
        }
        if ($changed) {
            Board::addMessage('Login details changed.');
        }
        $screen = new AccountScreen('Showkase &ndash; user account', 'account', 'admin account');
        print $screen->getHtml($context);
    }
}