public function signin() {
        $email = $this->f3->get('POST.email');
        $password = $this->f3->get('POST.password');

        $v = new Valitron\Validator(array('Email' => $email, 'Password' => $password));
        $v->rule('required', ['Email', 'Password']);
        $v->rule('email', 'Email');

        if ($v->validate()) {
            $account = new Account($this->db);
            $pwd = md5($password);
            $acc = $account->select("*", "email='$email' and password='******'");
            if ($acc) {
                $this->f3->set('SESSION.acc', $acc);
                $acc = $acc[0];
                $acc['lastlogin'] = date('Y-m-d H:i:s');
                $account->update($acc,'id='.$acc['id']);
                $this->f3->reroute('/dashboard');
            } else {
                $this->f3->set('email', $email);
                $this->f3->set('errors', array(array('Login fail, wrong username or password')));
                echo Template::instance()->render('index.html');
            }
        } else {
            $this->f3->set('email', $email);
            $this->f3->set('errors', $v->errors());
            echo Template::instance()->render('index.html');
        }
    }
Beispiel #2
0
function parseBrowse($cId, $eId, $cmd)
{
    global $_PATHS, $_CONF;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("common.tpl.htm");
    switch ($cId) {
        case NAV_ACCOUNT:
            $objAccounts = Account::select("SELECT * FROM punch_account ORDER BY name");
            $arrDomain = explode('.', $_SERVER['HTTP_HOST']);
            $strRootDomain = count($arrDomain) > 2 ? str_replace(array_shift($arrDomain) . ".", "", $_SERVER['HTTP_HOST']) : $_SERVER['HTTP_HOST'];
            //*** Render list.
            foreach ($objAccounts as $objTempAccount) {
                $objTpl->setCurrentBlock("list-item");
                $objTpl->setVariable('ITEM_LINK', "http://" . $objTempAccount->getUri() . "." . $strRootDomain);
                $objTpl->setVariable('ITEM_LABEL', htmlentities($objTempAccount->getName()));
                $objTpl->setVariable('ITEM_EXPORT', "?cid=" . NAV_ACCOUNT . "&cmd=" . CMD_EXPORT . "&eid=" . $objTempAccount->getId());
                $objTpl->setVariable('ITEM_RESTORE', "?cid=" . NAV_ACCOUNT . "&cmd=" . CMD_RESTORE . "&eid=" . $objTempAccount->getId());
                $objTpl->setVariable('ITEM_EDIT', "?cid=" . NAV_ACCOUNT . "&cmd=" . CMD_EDIT . "&eid=" . $objTempAccount->getId());
                $objTpl->setVariable('ITEM_TYPE', "Account");
                $objTpl->setVariable('ITEM_ID', $objTempAccount->getId());
                $objTpl->parseCurrentBlock();
            }
            break;
        case NAV_ADMIN:
            break;
    }
    //*** Return the output.
    return $objTpl->get();
}
 function address()
 {
     $user_id = Account::getUserId();
     $field = array('country', 'region', 'province', 'city', 'district', 'address', 'postcode', 'mobile', 'tel');
     $m = new Account();
     $m->clear();
     $m->setField($field);
     $m->setTable('vcb_user_address');
     $m->setWhere('user_id', '=', $user_id);
     $data = $m->select();
     if (empty($data)) {
         header("location:transfer");
     }
     $this->assign('data', $data);
 }
Beispiel #4
0
<?php

$arrDomain = explode('.', $_SERVER['HTTP_HOST']);
$intCatId = Request::get("cid");
if (isset($_CONF['app']['singleInstance']) && $_CONF['app']['singleInstance']) {
    //*** Check if the account exists.
    $objAccounts = Account::select();
    if ($objAccounts->count() <= 0) {
        //*** Account does not exist.
        header("Location: " . Request::getURI("http") . "/?cid=" . NAV_MYPUNCH_NOACCOUNT);
        exit;
    } else {
        $objAccount = $objAccounts->current();
    }
    //*** Set the PunchId.
    $_CONF['app']['account'] = $objAccount;
    $_CONF['app']['pageTitle'] = sprintf($objLang->get('pageTitle'), $_CONF['app']['account']->getName(), APP_NAME, APP_VERSION);
} else {
    if ($intCatId != NAV_MYPUNCH_NOACCOUNT) {
        if (count($arrDomain) > 2) {
            $strDomain = $arrDomain[count($arrDomain) - 2] . "." . $arrDomain[count($arrDomain) - 1];
            $strSubName = $arrDomain[0];
            //*** Check if the account exists.
            $objAccount = Account::getByUri($strSubName);
            if (!is_object($objAccount)) {
                //*** Account does not exist.
                header("Location: " . Request::getURI("http") . "/?cid=" . NAV_MYPUNCH_NOACCOUNT);
                exit;
            }
            //*** Set the PunchId.
            $_CONF['app']['account'] = $objAccount;
Beispiel #5
0
 public function testSelectWithNoParameters()
 {
     // our mock adapter
     $adapter = $this->adapterMock;
     // prepare the mock to expect the variables passed, and return a row
     $adapter->expects($this->once())->method('select')->with('accounts', null, null, array());
     $accountsTable = new Account($adapter);
     // getInstance doesn't work well in testing
     $result = $accountsTable->select();
 }
Beispiel #6
0
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
require 'autoloader.php';
Autoloader::register();
Config::load(array('dbconfig' => array('char' => array('user' => 'root', 'pass' => '', 'dsn' => 'mysql:host=127.0.0.1;dbname=characters'), 'auth' => array('user' => 'root', 'pass' => '', 'dsn' => 'mysql:host=127.0.0.1;dbname=auth'))));
$accounts = Account::select('id = 1');
foreach ($accounts as $account) {
    $account->delete();
}
DatabaseManager::get('auth')->queue->execute();
DatabaseManager::get('char')->queue->execute();
?>
    </body>
</html>