public function post2Url($key = null) { if (!empty($key) && isset($_POST[$key])) { $url = $this->objUrl->getCurrent($key); $post_key = urlencode(stripslashes($_POST[$key])); $url = !empty($post_key) ? $url . '/' . $key . '/' . $post_key : $url; Helper::redirect($url); } }
public static function loginAdmin($user, $url = NULL) { $url = !empty($url) ? SITE_URL . $url : SITE_URL . self::$_dashboard_admin; $_SESSION[self::$_login_admin_id] = $user['id']; $_SESSION[self::$_login_admin_first] = $user['first_name']; $_SESSION[self::$_login_admin_last] = $user['last_name']; $_SESSION[self::$_login_admin_level] = $user['level']; $_SESSION[self::$_valid_login] = 1; Helper::redirect($url); }
function __construct() { $this->article = Load::model('article_model'); if (isset($_SESSION['time'])) { if (Session::timeOut()) { Helper::redirect('user/logout'); } else { Session::set('time', time()); } } }
public static function processLogin($id = null, $url = null, $remember = null) { if (!empty($id)) { $url = !empty($url) ? $url : self::$_default; if (!isset($_SESSION['SugarKMS'])) { $_SESSION['SugarKMS'] = array(); } $_SESSION['SugarKMS'][self::$_login_admin] = $id; $_SESSION['SugarKMS'][self::$_valid_login] = 1; if ($remember == 1) { $hash = md5(time() . $id); $objMember = new Member(); $objMember->updateMember(array('cookie_hash_kms' => $hash, 'time_kms' => time()), $id); setcookie(self::$_cookie_name, 'hash=' . $hash, time() + self::$_cookie_time, '/', $_SERVER['SERVER_NAME']); } Helper::redirect($url); } }
/** * Sets the menu as active by storing menu name in session * @return [type] [description] */ public function activateMenu($parameter) { // instantiate model $MenuManagerModel = new MenuManagerModel(); // retrieve data $menuName = $MenuManagerModel->retrieveMenuName($parameter); // flatten array by one level $menuName = call_user_func_array('array_merge', $menuName); Session::set('active_menu', $menuName); Session::add('feedback_errors', ErrorMessage::get('MENU_ACTIVATED')); Helper::redirect('menumanager/managemenus'); }
private function _loggedIn() { if (Session::get('isLoggedIn')) { return true; } else { Helper::redirect('user/logout'); } }
} $email = $objForm->getPost('email'); $user = $objUser->getByEmail($email); if (!empty($user)) { $objValid->add2Errors('email_duplicate'); } if ($objValid->isValid()) { // add hash for activating account $objValid->_post['hash'] = mt_rand() . date('YmdHis') . mt_rand(); // add registration date $objValid->_post['date'] = Helper::setDate(); if ($objUser->addUser($objValid->_post, $objForm->getPost('password'))) { $_SESSION['link'] = $_POST['link']; Helper::redirect('/start/?page=registered'); } else { Helper::redirect('/start/?page=registered-failed'); } } } require_once '_header.php'; ?> <h1>Login</h1> <form action="" method="post"> <table cellspacing="0" cellpadding="0" class="tbl_insert" border="0"> <tr> <th> <label for="login_email">Login:</label> </th> <td>
public function processURL($cPage, $url_params) { switch ($cPage) { case '': //Helper::redirect(Login::$_default); $member_id = Session::getSession(Login::$_login_admin); $objMember = new Member(); $current_user = $objMember->getMemberById($member_id); require_once ROOT_PATH . DS . PAGES_DIR . DS . 'home.php'; break; case 'login': Helper::redirect('/sugarkms/'); break; case 'logout': require_once ROOT_PATH . DS . PAGES_DIR . DS . 'logout.php'; break; default: $member_id = Session::getSession(Login::$_login_admin); $objMember = new Member(); $current_user = $objMember->getMemberById($member_id); //tim coi co cpage co phai la group nao trong db khong $group = $this->objPage->getGroups(array('name' => $cPage)); if (!empty($group) && count($group) == 1) { //neu cpage la mot trong nhung group da duoc luu trong dbase thi moi xet den params tren url $group = $group[0]; $page_params = array(); //ghi vao page params dua theo url params if (empty($url_params)) { //neu khong co params tren url thi lay params cua default page cho vao $default_page = $this->objPage->getPages(array('default' => 1, 'group_id' => $group['id'])); if (!empty($default_page) && count($default_page) == 1) { //neu co duy nhat 1 default page thi moi xu ly tiep //lay params cua default page $default_page_params = $this->objPage->getPageParams(array('page_id' => $default_page[0]['id'])); //echo '<h1 style="background:white;">'; // var_dump($default_page_params); // echo '</h1>'; if (empty($default_page_params)) { $error = "No default page found."; } else { foreach ($default_page_params as $default_param) { if ($default_param['required_value'] != '') { //chi cho vao khi default page khong co params tuy bien (required value rong~) $page_params[$default_param['param']] = $default_param['required_value']; $this->cPage_id = $default_page[0]['id']; } else { $error = "No default page found."; } } } } else { $error = "No default page found."; } } else { //neu co params trong url //neu chi co 1 thanh phan va thanh phan do la so, tuc la id, vay them action=view vao, //con truong hop member thi split theo "-" roi xet thanh phan dau tien if (count($url_params) == 1) { if (is_numeric($url_params[0])) { $url_params[] = 'view'; } // //} else { //// $first_element = $url_params[0]; //// $array = explode('-', $first_element); //// $length = count($array)-1; //// if(is_numeric($array[$length])) { //// $url_params[0] = $array[$length]; //// $url_params[] = 'view'; //// }; //// //// } // // } // // if(count($url_params) == 2) { // //if($cPage == 'member' && count($url_params) == 2) { // if(is_numeric($url_params[0])) { // $url_params[] = 'view'; // //echo '<h1 style="background:white;">'; //// var_dump($url_params); //// echo '</h1>'; // } // } $pages = $this->objPage->getPages(array('group_id' => $group['id'])); //echo '<h1 style="background:white;">'; // var_dump($url_params); // echo '</h1>'; foreach ($pages as $page) { //echo 'page name: '; // var_dump($page['name']); // echo '<br />'; $params_db = $this->objPage->getPageParams(array('page_id' => $page['id']), array('order' => 'asc')); //echo '<h1 style="background:white;">'; // echo 'params db for page '.$page['name'].': '; // var_dump($params_db); // echo '</h1>'; if (count($params_db) == count($url_params)) { foreach ($params_db as $key => $param_db) { //echo 'current key: '.$key.'<br />'; // echo 'param db name: '.$param_db['param'].'<br />'; // echo 'uri at current key: '.$url_params[$key].'<br />'; // echo '<br />'; if ($param_db['required_value'] != '' && $url_params[$key] != $param_db['required_value']) { //var_dump($url_params[$key]); // var_dump($param_db['required_value']); continue 2; } else { $page_params[$param_db['param']] = $url_params[$key]; //unset($params_db[$key]); } //var_dump($page_params); } if (count($page_params) == count($url_params)) { $this->cPage_id = $page['id']; break; } //echo 'result: '.empty($params_db); } } // echo '<h1 style="background:white;">'; // var_dump($page_params); // var_dump($this->cPage_id); // echo '</h1>'; // if (empty($page_params) || count($page_params) != count($url_params)) { $error = "No record found for this page."; } } if (isset($error)) { require_once ROOT_PATH . DS . PAGES_DIR . DS . 'error.php'; } elseif (isset($page_params) && !empty($this->cPage_id)) { $this->cPage_params = $page_params; $this->processPageSource(); } } else { //neu cpage khong phai la group nao da duoc luu trong database $error = "No page group found."; require_once ROOT_PATH . DS . PAGES_DIR . DS . 'error.php'; } } }
<?php if ($this->admin['access'] != 1) { Helper::redirect('/panel/content/c/pages/a/index'); } $did = $this->objUrl->get('did'); if (!empty($did)) { $type = $this->objLanguage->getType($did); if (!empty($type) && $type['is_assigned'] != 1) { $this->objLanguage->removeType($did); } Helper::redirect($this->objUrl->getCurrent(array('a', 'id', 'did')) . '/a/types'); } else { $id = $this->objUrl->get('id'); if (!empty($id)) { $type = $this->objLanguage->getType($id); if (!empty($type) && $type['is_assigned'] != 1) { require_once 'header.php'; ?> <h1><?php echo $this->objLanguage->labels[21]; ?> : <?php echo $type['content']; ?> </h1> <p> <?php
<?php Login::logout(); Helper::redirect(Login::$_login_page);
<?php $code = Url::getParam('code'); if (!empty($code)) { $objUser = new User(); $user = $objUser->getUserByHash($code); if (!empty($user)) { if ($user['active'] == 0) { if ($objUser->makeActive($user['id'])) { $mess = "<h1>Thank you</h1>"; $mess .= "<p>Your account has now been successfully activated.<br />"; $mess .= "You can now log in and continue with your order.</p>"; } else { $mess = "<h1>Activation unsuccessful</h1>"; $mess .= "<p>There has been a problem activating your account.<br />"; $mess .= "Please contact administrator.</p>"; } } else { $mess = "<h1>Account already activated</h1>"; $mess .= "<p>This account has already been activated.</p>"; } } else { Helper::redirect("/?page=error"); } require_once "_header.php"; echo $mess; require_once "_footer.php"; } else { Helper::redirect("/?page=error"); }
<?php if (Login::isLogged()) { Helper::redirect(Login::$_default); } $objForm = new Form(); $objValid = new Validation($objForm); $objMember = new Member(); if ($objForm->isPost('login_email')) { $member = $objMember->getMembers(array('personal_email' => $objForm->getPost('login_email'), 'password' => Login::hash($objForm->getPost('login_password')))); if (!empty($member) && count($member) == 1) { //echo '<h1>VALID</h1>'; Login::processLogin($member[0]['id'], '/sugarkms/' . $this->objURL->href($this->objURL->get(Login::$_referrer)), $objForm->getPost('remember')); } else { $objValid->add2Errors('login'); } } require_once '_header.php'; ?> <h1>Login</h1> <form action="" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="tbl_insert"> <tr> <?php echo $objValid->validate('login'); ?> <td><label for="login_email">Email:</label></td> <td><input type="text" name="login_email" id="login_email" class="fld" value="" /></td> </tr> <tr> <td><label for="login_password">Password:</label></td> <td><input type="password" name="login_password" id="login_password" class="fld" value="" /></td>
<?php Helper::redirect(SITE_URL . DS . DEFAULT_PAGE); require_once '_header.php'; require_once '_footer.php';
<?php if (Login::isLogged(Login::$_login_admin_id)) { Helper::redirect(SITE_URL . Login::$_dashboard_admin); } $objForm = new Form(); $objValidation = new Validation($objForm); if ($objForm->isPost('login_user')) { $objAdmin = new Admin(); $objValidation->_required = array('login_user', 'login_password'); if ($objAdmin->isUser($objForm->getPost('login_user'), $objForm->getPost('login_password'))) { $result = Login::loginAdmin($objAdmin->_user, Url::getReferrerUrl()); } else { $objValidation->add2Errors('login'); } if ($objValidation->isValid()) { } } ?> <html> <head> <title>XBook Management System</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="css/Core.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/bootstrap-theme.min.css"> <link rel="stylesheet" href="../css/bootstrap-select.min.css">
public static function restrictAdmin() { if (!self::isLogged(self::$_login_admin)) { Helper::redirect(self::$_login_page_admin); } }
} // Controle wanneer iemand op submit (=registreer) heeft gedrukt if (isset($_POST['submit'])) { $email = $_POST['email']; $password = $_POST['password']; try { $db = new Database('mysql', 'localhost', 'examen_eva', 'root', ''); // Maak een nieuwe instantie van de klasse User aan en geef hier de DB aan mee // "Dependency injection" van database klasse $user = new User($db); // Controleren of de user al bestaat $userExists = $user->exists($email); // Als de user bestaat, errormessage tonen en redirecten if ($userExists === TRUE) { Message::setMessage("The email has already been taken.", "error"); Helper::redirect('registration-form.php'); } else { // Toevoegen aan de database $user->create($email, $password); // Cookie aanmaken om gebruiker achteraf te kunnen identificeren $user->createCookie($email); //create SESSION $_SESSION['LOGIN'] = TRUE; $_SESSION['email'] = $email; // Redirecten naar dashboard wanneer gebruiker is toegevoegd & cookie is aangemaakt Helper::redirect('dash.php'); } } catch (Exception $e) { Message::setMessage($e->getMessage(), 'error'); } }
<td> <?php echo $objValid->validate('email'); ?> <input type="text" name="email" id="email" class="fld" value="<?php echo $objForm->stickyText('email', $user['email']); ?> " /> </td> </tr> <tr> <th> </th> <td> <label for="btn" class="sbm sbm_blue fl_l"> <input type="submit" id="btn" class="btn" value="Next" /> </label> </td> </tr> </table> </form> <?php require_once '_footer.php'; } else { Helper::redirect('/?page=error'); }
$objBusiness = new Business(); $business = $objBusiness->getBusiness(); if (!empty($business)) { $objForm = new Form(); $objValid = new Validation($objForm); if ($objForm->isPost('name')) { $objValid->_expected = array('name', 'address', 'telephone', 'email', 'website', 'vat_rate'); $objValid->_required = array('name', 'address', 'telephone', 'email', 'vat_rate'); $objValid->_special = array('email' => 'email'); $vars = $objForm->getPostArray($objValid->_expected); if ($objValid->isValid()) { if ($objBusiness->updateBusiness($vars)) { Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited'); } else { Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id')) . '&action=edited-failed'); } } } require_once 'template/_header.php'; ?> <h1>Business</h1> <form action="" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="tbl_insert"> <tr> <th><label for="name">Name: *</label></th> <td> <?php
<?php session_start(); function __autoload($className) { include_once 'classes/' . $className . '.php'; } try { $db = new Database('mysql', 'localhost', 'examen_eva', 'root', ''); $user = new User($db); $userIsValid = $user->validate(); if (!$userIsValid) { Message::setMessage("Er ging iets mis, probeer opnieuw in te loggen.", 'error'); Cookie::deleteCookie('login'); Helper::redirect('login-form.php'); } } catch (Exception $e) { Message::setMessage($e->getMessage(), 'error'); } $message = Message::getMessage(); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/global.css"> <title>Labo-Welkom</title> </head> <body>
date_create) VALUES (:email, :inhoud, NOW()) '; $placeholders = array(":inhoud" => $inhoud, ":email" => $user); // Query uitvoeren $db->query($insertQuery, $placeholders); Helper::redirect('application.php'); } if (isset($_POST['delete'])) { $verwijder = $_POST['delete']; $deleteQuery = "DELETE FROM todo\n WHERE todo.id_todo = :id_todo\n LIMIT 1"; $deleteQueryPlaceholders = array(':id_todo' => $verwijder); $db->query($deleteQuery, $deleteQueryPlaceholders); Helper::redirect('application.php'); } } catch (Exception $e) { Message::setMessage($e->getMessage(), 'error'); } $message = Message::getMessage(); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/global.css"> <title>Labo-applicatieapp</title> </head>
<?php if ($this->admin['access'] != 1) { Helper::redirect('/panel/content/c/pages/a/index'); } $objForm = new Form($this->objUrl); $objForm->post2Url('srch'); $search = $this->objUrl->get('srch'); $search = urldecode(stripslashes($search)); if (!empty($search)) { $admins = $this->objAdmin->getAll(array('first_name' => $search, 'last_name' => $search)); } else { $admins = $this->objAdmin->getAll(); } $objPaging = new Paging($this->objUrl, $this->objLanguage, $admins, 10); $admins = $objPaging->getRecords(); $paging = $objPaging->getPaging(); require_once 'header.php'; ?> <h1><?php echo $this->objLanguage->labels[85]; ?> </h1> <form method="post" id="search"> <table class="tbl_repeat"> <tr> <th> <input type="text" name="srch" id="srch" class="table-field fll mrr4"
$wave_id = 0; $month_start = $project_type['month_start']; $month_end = $project_type['month_end']; $year_end = $project_type['same_start_end'] == '1' ? $year_start : $year_start + 1; } $params = array('project_type_id' => $project_type_id, 'wave_id' => $wave_id, 'month_start' => $month_start, 'year_start' => $year_start, 'month_end' => $month_end, 'year_end' => $year_end); //var_dump($params); $return = $objProject->addProject($params); if ($return['result']) { $id = $return['id']; if ($project_type_id == 5) { $project_type = 'exco'; } else { $project_type = 'project'; } Helper::redirect($this->objPage->generateURL($project_type, array('id' => $id))); } else { $success = false; } } } } $header = $exco ? 'EXCO' : 'Project'; $header .= ' :: Add'; require_once '_header.php'; ?> <h1><?php echo $header; ?> </h1> <?php
public function createSignage($parameter) { // store recipe id in the session of the recipe item that client wants to generate signage for Session::set('recipe_generate_signage', $parameter); // create message letting user know that they have been redirected Session::add('feedback_errors', ErrorMessage::get('GENERATE_SIGNAGE_FOR_RECIPE')); // redirect user to signage Helper::redirect('signagegenerator/premade'); }
public function runAdmin() { $this->objAdmin = new Admin($this->objLanguage); if ($this->objUrl->main == 'logout') { Login::logout(); } else { if ($this->objUrl->c == 'login' && Login::isLogged()) { Helper::redirect('/panel/content/c/pages/a/index'); } else { if ($this->objUrl->c != 'login' && !Login::isLogged()) { Helper::redirect('/panel'); } else { if (Login::isLogged()) { $this->admin = $this->objAdmin->getOne($_SESSION[Login::$key_user_id]); } } } } $file = ROOT_PATH . DS . 'admin' . DS . 'core' . DS . $this->objUrl->c . DS . $this->objUrl->a . '.php'; if (!is_file($file)) { $file = ROOT_PATH . DS . 'admin' . DS . 'core' . DS . 'error' . DS . 'index.php'; } ob_start(); require_once $file; echo ob_get_clean(); }
session_start(); function __autoload($className) { include_once 'classes/' . $className . '.php'; } $currentPage = basename($_SERVER['PHP_SELF']); if (isset($_SESSION['LOGIN'])) { $login = $_SESSION['LOGIN']; } if (isset($_SESSION['email'])) { $email = $_SESSION['email']; } //voor als de pagina onrechtmatig benaderd wordt if (!$login) { //redirect Helper::redirect('dashboard.php'); } // Haal de messages op die teventueel geset zijn $message = Message::getMessage(); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/global.css"> <title>Labo-login</title> <link rel="stylesheet" href="css/global.css"> </head>
$this->addScript('/admin/js/ckeditor/ckeditor.js'); $this->addScript('/admin/js/ckeditor/adapters/jquery.js'); $objPage = new Page($this->objLanguage); $objForm = new Form($this->objUrl); $objValidation = new Validation($this->objLanguage); $expected = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity'); $required = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity'); if (isset($_POST['name'])) { $array = $objForm->post2Array($expected, 'content', array('identity' => 'sanitise')); if (array_key_exists('identity', $array) && !empty($array['identity']) && $objPage->duplicate($array['identity'])) { $objValidation->add2Errors('identity', 'identity_taken'); } if ($objValidation->isValid($array, $required)) { if ($objPage->add($array)) { Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index'); } } } require_once 'header.php'; ?> <h1><?php echo $this->objLanguage->labels[9]; ?> </h1> <form method="post"> <table class="tbl_insert"> <tr> <th>
public static function logout() { session_destroy(); Helper::redirect('/panel'); }
<?php if (Login::isLogged(Login::$_login_admin)) { Helper::redirect(Login::$_dashboard_admin); } $objForm = new Form(); $objValid = new Validation($objForm); if ($objForm->isPost('login_email')) { $objAdmin = new Admin(); if ($objAdmin->isUser($objForm->getPost('login_email'), $objForm->getPost('login_password'))) { Login::loginAdmin($objAdmin->_id, Url::getReferrerUrl()); } else { $objValid->add2Errors('login'); } } require_once 'template/_header.php'; ?> <h1>Login</h1> <form action="" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="tbl_insert"> <tr> <th><label for="login_email">Login:</label></th> <td> <?php echo $objValid->validate('login'); ?> <input type="text" name="login_email" id="login_email"
<?php $id = Url::getParam('id'); if (!empty($id)) { $objUser = new User(); $user = $objUser->getUser($id); if (!empty($user)) { $objOrder = new Order(); $orders = $objOrder->getClientOrders($id); if (empty($orders)) { $yes = '/admin' . Url::getCurrentUrl() . '&remove=1'; $no = 'javascript:history.go(-1)'; $remove = Url::getParam('remove'); if (!empty($remove)) { $objUser->removeUser($id); Helper::redirect('/admin' . Url::getCurrentUrl(array('action', 'id', 'remove', 'srch', Paging::$_key))); } require_once 'template/_header.php'; ?> <h1>Clients :: Remove</h1> <p>Are you sure you want to remove this client (<?php echo $user['first_name'] . " " . $user['last_name']; ?> )?<br /> There is no undo!<br /> <a href="<?php echo $yes; ?> ">Yes</a> | <a href="<?php echo $no; ?>
<?php $email = ''; $login = FALSE; session_start(); function __autoload($className) { include_once 'classes/' . $className . '.php'; } $currentPage = basename($_SERVER['PHP_SELF']); if (isset($_SESSION['LOGIN'])) { $login = $_SESSION['LOGIN']; } if (isset($_SESSION['email'])) { $email = $_SESSION['email']; } //voor als de pagina onrechtmatig benaderd wordt if (!$login) { //redirect Helper::redirect('dashboard.php'); } // Haal de messages op die teventueel geset zijn $message = Message::getMessage(); if (isset($_POST['submit'])) { session_destroy(); Helper::redirect('logout.php'); }