Esempio n. 1
0
    private function loginForm()
    {
        $jsUrl = Cfg::get('js_url');
        $jQuery = <<<JS
    \$().ready(function() {
        \$('#hoverimage').hover ( function () { \$('#extralinks').fadeIn('fast'); },
                                 function () { setTimeout("\$('#extralinks').fadeOut();", 3000 ); });
        \$('a.facebox').facebox({closeImage:   '{$jsUrl}/images/closelabel.png',
                                loadingImage: '{$jsUrl}/images/loading.gif'

        });
    });
JS;
        $formName = 'FancyLogin_loginForm';
        $valid = Validator::factory($formName, 'LF')->addExists(self::LOGIN_FNAME, 'Email field must not be empty')->addExists(self::PASSW_FNAME, 'Password field must not be empty');
        $resp = new Response();
        $html = JS::library(JS::JQUERY) . JS::libraryWithDependancies(JS::FACEBOX) . JS::javaScript($jQuery) . Tag::table() . Tag::tr() . Tag::td(['id' => 'hoverimage', 'class' => 'login', 'nowrap' => 'nowrap']) . $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $resp->set(self::ACTION, __CLASS__ . '->checkLogin()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text(self::LOGIN_FNAME, ['size' => 10, 'style' => 'opacity:0.5;filter:alpha(opacity=50)']) . Tag::_td() . Tag::td() . 'Password:'******'size' => 10, 'style' => 'opacity:0.5;filter:alpha(opacity=50)']) . Tag::_td() . Tag::td() . Tag::submit('Go') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form() . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['id' => 'extralinks', 'style' => 'display: none;']) . Tag::ul(['id' => 'vertMenu']);
        if (Cfg::get('jb_self_register', false)) {
            $html .= Tag::li() . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->newRegistration()')->toUrl(), 'Register New Account', ['class' => 'facebox']) . Tag::_li();
        }
        $html .= Tag::li() . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->forgotPassword()')->toUrl(), 'Forgot My Password', ['class' => 'facebox']) . Tag::_li() . Tag::_ul() . Tag::_td() . Tag::_tr() . Tag::_table();
        return $html;
    }
Esempio n. 2
0
 public function index()
 {
     $formName = 'Login_index';
     $valid = Validator::factory($formName)->addExists(self::LOGIN_FNAME, 'Email field must not be empty')->addExists(self::PASSW_FNAME, 'Password field must not be empty');
     $mobileAttribs = [];
     if (G::isSmartPhone()) {
         $mobileAttribs['type'] = 'email';
     }
     $resp = new Response();
     $html = '<h2>Login</h2>' . $valid->toHtml() . Tag::form(['action' => 'ajax.php', 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $resp->action(__CLASS__ . '->checkLogin()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text(self::LOGIN_FNAME, $mobileAttribs) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Password:'******'Login') . Tag::_td() . Tag::td(['align' => 'right']) . Tag::linkButton('?' . $resp->action(__CLASS__ . '->forgotPassword()')->toUrl(), 'Forgot Password') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
Esempio n. 3
0
    public function editAccount()
    {
        $resp = new Response();
        $uid = G::get('fldUserID');
        $html = '';
        $props = [];
        $jsUrl = Cfg::get('js_url');
        $jQuery = <<<JS
            \$().ready(function() {
                \$('a.facebox').facebox({closeImage:   '{$jsUrl}/images/closelabel.png',
                                        loadingImage: '{$jsUrl}/images/loading.gif'

                });
            });
JS;
        $userSql = DB::driver() == DB::MYSQL ? self::USER_SQL_MYSQL : self::USER_SQL_SQLITE;
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
            $uid = Request::get('fldUserID', G::get('fldUserID'));
            $props['where'] = ['fldUserID' => G::get('fldUserID')];
            $html .= Tag::form() . $resp->action(sprintf('%s->%s()', __CLASS__, __FUNCTION__))->toHidden() . Tag::table() . Tag::tr() . Tag::th() . 'User to edit' . Tag::_th() . Tag::td() . Lists::select('fldUserID', $userSql, ['onChange' => 'submit()', 'default' => $uid]) . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
        }
        $formName = 'Admin_editAccount';
        $valid = Validator::factory($formName)->addEqual('fldPassword', 'fldPassword_CHK', 'Your passwords do not match')->addLength('fldPassword', 'Password must be at least 6 characters', 6, null, true)->addExists('fldFirstName', 'You must enter your first name')->addExists('fldLastName', 'You must enter your last name');
        $row = DB::oneRow(DB::DEF, 'SELECT * FROM tblUser WHERE fldUserID=?', $uid);
        $html .= '<h2>Edit User Account</h2>' . $valid->toHtml() . Tag::form(['name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $resp->action(sprintf('%s->%sSave()', __CLASS__, __FUNCTION__))->set('fldUserID', $uid)->toHidden() . Tag::table();
        $html .= Tag::tr() . Tag::td() . Tag::table() . Tag::tr() . Tag::td() . 'User Name/Email' . Tag::_td() . Tag::td() . Tag::text('fldUser', $row['fldUser']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Old Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword_OLD') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Confirm Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword_CHK') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Title' . Tag::_td() . Tag::td() . Tag::text('fldSalutation', $row['fldSalutation']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'First Name' . Tag::_td() . Tag::td() . Tag::text('fldFirstName', $row['fldFirstName']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Last Name' . Tag::_td() . Tag::td() . Tag::text('fldLastName', $row['fldLastName']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Time Zone' . Tag::_td() . Tag::td() . Lists::select('fldTimeZone', self::TZ_SQL, ['default' => $row['fldTimeZone']]) . Tag::_td() . Tag::_tr();
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
            $html .= Tag::tr() . Tag::td() . 'Security Level' . Tag::_td() . Tag::td() . Lists::select('fldLevel', self::LEVEL_SQL, ['default' => $row['fldLevel']]) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Login Fails' . Tag::_td() . Tag::td() . Tag::text('fldFails', $row['fldFails']) . Tag::_td() . Tag::_tr();
        } else {
            $html .= Tag::tr() . Tag::td() . 'Security Level' . Tag::_td() . Tag::td() . Privileges::getSecurityLevel($row['fldLevel']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Login Fails' . Tag::_td() . Tag::td() . $row['fldFails'] . Tag::_td() . Tag::_tr();
        }
        $html .= Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Save') . Tag::_td() . Tag::_tr();
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
            $html .= Tag::tr() . Tag::td(['colspan' => 2]) . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->newUser()')->toUrl(), 'Create New User', ['class' => 'facebox']) . Tag::_td() . Tag::_tr();
        }
        $html .= Tag::_table() . Tag::_td() . Tag::td(['valign' => 'top', 'align' => 'center']) . Tag::table() . Tag::tr() . Tag::td(['valign' => 'top', 'align' => 'center']) . Gravatar::icon($row['fldUser'], 128) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . Tag::linkButton(Gravatar::getURL(), 'Change Picture', ['target' => '_blank', 'title' => 'your gravatar is associated with your email address ' . $row['fldUser'] . ' (up to 24 hrs to change)']) . Tag::_td() . Tag::_tr();
        if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN')) && $uid != G::get('fldUserID')) {
            $name = $row['fldFirstName'] . ' ' . $row['fldLastName'];
            $html .= Tag::tr() . Tag::td() . Tag::linkButton('?' . $resp->action(__CLASS__ . '->loginAs()')->set('fldUser', $row['fldUser'])->toUrl(), 'Login as this User', ['title' => "Login as this user ({$name})"]) . Tag::_td() . Tag::_tr();
        }
        $html .= Tag::_table() . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
        return JS::library(JS::JQUERY) . JS::libraryWithDependancies(JS::FACEBOX) . JS::javaScript($jQuery) . $html;
    }