function login() { $username = empty($_REQUEST['username']) ? '' : $_REQUEST['username']; $password = empty($_REQUEST['password']) ? '' : $_REQUEST['password']; $user_model = new User($this->dbconn); if ($user_model->login($username, $password)) { User::loadCurrentUser(); $_SESSION['system_message'] = _('Успешно се логнахте!'); //REMEMBER ME if (isset($_REQUEST['remember'])) { setcookie("cookname", $_REQUEST['username'], time() + 2592000, "/"); setcookie("cookpass", md5($_REQUEST['password']), time() + 2592000, "/"); } setcookie('userId', $user_model->id, time() + 86400 * 365 * 2); } else { setcookie("cookname", "", time() - 60 * 60 * 24, "/"); setcookie("cookpass", "", time() - 60 * 60 * 24, "/"); header('Location: index.php'); exit; } }
include 'inc/config.inc.php'; $page = empty($_REQUEST['page']) ? 'main' : str_replace(array('http://', '.', '/'), "", $_REQUEST['page']); $act = empty($_REQUEST['act']) ? '' : $_REQUEST['act']; $id = empty($_REQUEST['id']) ? null : $_REQUEST['id']; $header = new HeaderController(); // assign options arrays $smarty->assign('page', $page); $smarty->assign('act', $act); $smarty->assign('id', $id); if (method_exists($header, $act)) { $header->{$act}($id); } $header->index(); if (isset($_SESSION['user_id'])) { User::loadCurrentUser(); } if (isset($_SESSION['user'])) { $smarty->Assign('user', $_SESSION['user']); } //create current page object if (isset($page)) { $page_object_name = ucfirst($page) . "Controller"; if (file_exists('php/' . $page_object_name . '.php')) { $controller = ucfirst($page_object_name); $page_object = new $controller(); if ($act && method_exists($page_object, $act)) { $page_object->{$act}($id); } else { $page_object->index($id); }