Exemple #1
0
    public function __construct($title)
    {
        Page::__construct($title);
        $this->bodyClass = 'login';
        $this->addCSS(ADMIN_FOLDER . '/assets/css/login.css');
        $this->AddScript(ADMIN_FOLDER . '/assets/js/login.js');
        $this->AddToHead('<script>
				$(document).ready(function(){
					"use strict";

					Login.init(); // Init login JavaScript
				});
				</script>');
        switch ($this->Action) {
            case 'execute':
                //					die('here');
                $login = $this->getPost('login');
                $password = $this->getPost('password');
                $recaptcha_response_field = $this->getPost('recaptcha_response_field');
                //Validate the form
                if (!$login || !$password) {
                    $this->Msg->SetMsg($this->_T('error_complete_fields'));
                    $this->Msg->SetError(true);
                    $this->Redirect(ADMIN_FOLDER . "/");
                }
                if ((int) $GLOBALS['_S']->Get('log_tries') >= 3) {
                    require_once BASE_PATH . 'includes/recaptchalib.php';
                    $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
                    if (!$resp->is_valid) {
                        # set the error code so that we can display it
                        $this->Msg->SetMsg($this->_T('error_wrong_captcha'));
                        $this->Msg->SetError(true);
                        $this->Redirect(ADMIN_FOLDER . "/");
                    }
                }
                if (!Db_Admin::login($login, $password)) {
                    $tries = (int) $GLOBALS['_S']->Get('log_tries');
                    $GLOBALS['_S']->Set('log_tries', $tries + 1);
                    // User and password do not match
                    $this->LOG->write('Failed login attempt - L: ' . $login . ' P: ' . $password, 'login');
                    $this->Msg->SetMsg($this->_T('error_not_match'));
                    $this->Msg->SetError(true);
                } else {
                    $this->_S->Set('log_tries', 0);
                }
                $this->Redirect(ADMIN_FOLDER . "/");
            default:
                //					$this->Msg->SetMsg ('<strong>Welcome!</strong><br /><br />Use a valid username and password to gain access to the administration panel.');
        }
    }
Exemple #2
0
 public function Header()
 {
     $result = '';
     if (Db_Admin::isLogged()) {
         $result .= $this->TPL->display('page_header', true);
     }
     return $result;
 }
Exemple #3
0
                case 'email':
                    $Page = new Page_Email('');
                    print $Page->Html();
                    break;
            }
        case 'account':
            switch ($spage) {
                case 'user':
                    $Page = new Page_User('');
                    print $Page->Html();
                    break;
                case 'administrators':
                    $Page = new Page_Administrators('');
                    print $Page->Html();
                    break;
                case 'trans':
                    $Page = new Page_Trans('');
                    print $Page->Html();
                    break;
            }
            break;
        case 'logout':
            Db_Admin::logout();
            header('LOCATION: ' . ADMIN_FOLDER . '/');
            exit;
            break;
        default:
            $Page = new Page_Home();
            print $Page->Html();
    }
}
 public function RightColumnContent()
 {
     switch ($this->Action) {
         case 'view':
             $this->CheckIdExist();
             $AdministratorsModel = Db_Admin::getObjectDetails($this->Id);
             $this->TPL->assign('AdministratorsModel', $AdministratorsModel);
             break;
             // view
         // view
         case 'edit':
             $this->CheckIdExist();
             $AdministratorsModel = Db_Admin::getObjectDetails($this->Id);
             $this->TPL->assign('AdministratorsModel', $AdministratorsModel);
             break;
             // edit
         // edit
         case 'add':
             break;
             // add
         // add
         case 'delete':
             $this->CheckIdExist();
             Db_Admin::deleteByField('id', $this->Id, 1);
             $this->Msg->SetMsg($this->_T('success_item_deleted'));
             $this->Redirect($this->PageUrl);
             break;
             // delete
         // delete
         case 'editpassword':
             $this->CheckIdExist();
             $AdministratorsModel = Db_Admin::getObjectDetails($this->Id);
             $this->TPL->assign('AdministratorsModel', $AdministratorsModel);
             break;
             // editpassword
         // editpassword
         case 'savepassword':
             $this->CheckIdExist();
             $password_new = $this->getPost('password_new');
             $password_new = trim($password_new);
             $password_new_conf = $this->getPost('password_new_conf');
             $password_new_conf = trim($password_new_conf);
             //validation
             if (!$password_new || !$password_new_conf) {
                 $this->Msg->SetMsg($this->_T('error_mandatory_fields'));
                 $this->Msg->SetError(true);
                 $this->Redirect($this->PageUrl . '?action=editpassword&id=' . $this->Id);
             }
             if ($password_new != $password_new_conf) {
                 $this->Msg->SetMsg($this->_T('error_confirm_pass'));
                 $this->Msg->SetError(true);
                 $this->Redirect($this->PageUrl . '?action=editpassword&id=' . $this->Id);
             }
             //save
             $this->AdministratorsModel = new Db_Admin($this->DB, $this->Id, 'id');
             $this->AdministratorsModel->password = md5($password_new . SECURE_KEY);
             $this->AdministratorsModel->save();
             $this->Msg->SetMsg(_T('success_item_saved'));
             $this->Redirect($this->PageUrl . '?action=view&id=' . $this->AdministratorsModel->id);
             break;
             // savepassword
         // savepassword
         case 'save':
             if ($this->Id != 0) {
                 $this->CheckIdExist();
             } else {
                 //exit();
                 $password = $this->getPost('password');
                 $password = trim($password);
                 $confirmation = $this->getPost('confirmation');
                 //validare passvord
                 if (!$password || !$confirmation) {
                     $this->Msg->SetMsg($this->_T('error_mandatory_fields'));
                     $this->Msg->SetError(true);
                     $this->Redirect($this->PageUrl . '?action=add');
                 }
                 if ($password != $confirmation) {
                     $this->Msg->SetMsg($this->_T('error_confirm_pass'));
                     $this->Msg->SetError(true);
                     $this->Redirect($this->PageUrl . '?action=add');
                 }
                 $password = md5($password . SECURE_KEY);
             }
             //print_r($_POST);
             $login = $this->getPost('login');
             $nickname = $this->getPost('nickname');
             //Validate the form
             if (!$login) {
                 //exit();
                 $this->Msg->SetMsg($this->_T('error_mandatory_fields'));
                 $this->Msg->SetError(true);
                 if ($this->Id != 0) {
                     $this->Redirect($this->PageUrl . '?action=edit&id=' . $this->Id);
                 } else {
                     $this->Redirect($this->PageUrl . '?action=add');
                 }
             }
             //validation confirm
             if ($this->Id == 0) {
                 if (Db_Admin::verifyUserExist($login)) {
                     $this->Msg->SetMsg($this->_T('error_user_exist'));
                     $this->Msg->SetError(true);
                     if ($this->Id != 0) {
                         $this->Redirect($this->PageUrl . '?action=edit&id=' . $this->Id);
                     } else {
                         $this->Redirect($this->PageUrl . '?action=add');
                     }
                 }
             }
             /// Scriere baza de date
             $this->AdministratorsModel = new Db_Admin($this->DB, $this->Id, 'id');
             $this->AdministratorsModel->login = $login;
             $this->AdministratorsModel->nickname = $nickname;
             if ($this->Id == 0) {
                 $this->AdministratorsModel->password = $password;
             }
             $this->AdministratorsModel->save();
             $this->Msg->SetMsg(_T('success_item_saved'));
             $this->Redirect($this->PageUrl . '?action=view&id=' . $this->AdministratorsModel->id);
             break;
             // save
         // save
         default:
             $Objects = Db_Admin::getAllObjectsSort();
             $ListGrid = false;
             if ($Objects) {
                 $ListGrid = new TGrid();
                 $ListGrid->Spacing = 0;
                 $ListGrid->Width = '100%';
                 $ListGrid->SetClass('table table-hover table-striped table-bordered table-highlight-head');
                 $ListGrid->AddHeaderRow($this->_T('id'), $this->_T('login'), $this->_T('nickname'), $this->_T('Actions'));
                 $ListGrid->BeginBody();
                 foreach ($Objects as $Object) {
                     $Object['login'] = $Object['login'] != '' ? $Object['login'] : '';
                     $Grid_TR = new TGrid_TTR();
                     $Grid_TD = new TGrid_TTD($Object['id'] . ' (&nbsp;<a title="" href="' . $this->PageUrl . '?action=view&id=' . $Object['id'] . '">' . _T('see') . '</a>&nbsp;)');
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['login']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD($Object['nickname']);
                     $Grid_TR->Add($Grid_TD);
                     $Grid_TD = new TGrid_TTD('<a class="bs-tooltip" title="" href="' . $this->PageUrl . '?action=edit&id=' . $Object['id'] . '" data-original-title="' . $this->_T('edit') . '"><i class="icon-pencil"></i></a> <a class="bs-tooltip" title="" href="' . $this->PageUrl . '?action=delete&id=' . $Object['id'] . '" data-original-title="' . $this->_T('delete') . '"><i class="icon-trash"></i></a>');
                     $Grid_TD->AddAttr(new TAttr('class', 'align-center'));
                     $Grid_TR->Add($Grid_TD);
                     $ListGrid->AddTR($Grid_TR);
                 }
                 $ListGrid->EndBody();
                 $ListGrid = $ListGrid->Html();
             }
             $this->TPL->assign('ListGrid', $ListGrid);
             break;
             // default
     }
     $msg = $this->Msg->Html();
     $this->TPL->assign('msg', $msg);
     $this->TPL->assign('Action', $this->Action);
     $result = $this->TPL->display(null, true);
     $this->Msg->Clear();
     return $result;
 }
Exemple #5
0
 * // Executed some code
 * echo Utils::endTimer();
 */
$TIMER = 0;
$page = $spage = '';
if (isset($_REQUEST["params"])) {
    $params = explode("/", $_REQUEST["params"]);
    $page = isset($params[0]) ? $params[0] : '';
    $spage = isset($params[1]) ? $params[1] : '';
    // Parse the params after the ? sign
    $second_params = explode("?", $_SERVER['REQUEST_URI']);
    // If we have any params after this sign
    if (isset($second_params[1]) && $second_params[1] != '') {
        // We separate the params by & sign
        $second_params = explode("&", $second_params[1]);
        foreach ($second_params as $param) {
            // We separate each param by name and value
            $tmp_param = explode("=", $param);
            if ($tmp_param[0] != '' && $tmp_param[1] != '') {
                // We create a variable with the name of the param we send in URL
                ${$tmp_param}[0] = $tmp_param[1];
            }
        }
    }
}
if (!Db_Admin::isLogged()) {
    //Create the login page
    $PageLogin = new Page_Login('');
    print $PageLogin->Html();
    exit;
}