public function action_login() { if ((bool) arr::get($_GET, 'return', false)) { site::set_last_url($this->request->referrer()); } $error = false; if ($_POST) { $email = arr::get($_POST, 'email', ''); $password = arr::get($_POST, 'password', ''); $remember = arr::get($_POST, 'remember', '') == 'yes'; if (user::login($email, $password, $remember)) { $user = user::get(); notes::success('You have been logged in. Welcome back!'); $lasturl = site::get_last_url(); if ($lasturl) { site::redirect($lasturl); } site::redirect('write'); } else { //notes::error('Wrong username or password. Please try again.'); $error = true; } } $this->bind('error', $error); }
/** * Log in user * @return string */ public function login() { //Login in our member using the logic in the parents class $message = parent::login(); //Add some administrator-specific logic return $message . '...Log this action in an administrator\'s table'; }
public static function create($user) { $sql = "INSERT INTO user(user_name, email_adress, user_password, belong_to) VALUES('"; $sql .= $user["user_name"] . "','" . $user["email_adress"] . "','" . $user["user_password"] . "','" . $user["belong_to"] . "')"; $result = mysql_query($sql) or die("登録失敗しました"); user::login($user); }
/** *Log in a user * @return string */ public function login() { //Login in our member using the logic in the parent class. $message = parent::login(); //Add some member-spcific logic return $message . ' ... Set a flag in the online members table'; }
public function accessLevel($id) { if (user::login()) { //$a = user::GET($id); return user::GET($id); } }
/** * log in a user * @return string */ public function login() { //login in your member using the logic in the perent class. $message = parent::login(); //add some administrator-spcific logic return $message . ' ... log this action in an administrator\'s table'; }
public function loginAction() { if ($_POST) { //get front-data $data = array('Email' => $this->getRequest()->getParam('Email', ''), 'password' => $this->getRequest()->getParam('password', '')); $login = new user(); $result = $login->login($data['Email'], $data['password']); $userinfo = $login->getAllbyEmail($data['Email']); $iflogin = $userinfo[0]['privilege'] == 1 && $result->isValid(); if ($iflogin) { //session_start(); $info = $login->getAllbyEmail($data['Email']); $_SESSION["user"] = $info[0]; $user = new Zend_Session_Namespace('user'); $user->name = $data['Email']; $this->forward('main', 'index'); //$this->forward('logout'); } else { $this->view->code = 'no'; $this->render('loginsuccess'); } } else { $this->view->Email = 'error'; $this->view->password = '******'; $this->render('login'); } }
public static function create($data) { $user = ORM::factory('User'); $user->create_user($data, array('username', 'password', 'email')); $user->add_role('login'); $mail = mail::create('usercreated')->to($user->email)->tokenize(array('username' => $user->username))->send(); user::login(arr::get($data, 'email', ''), arr::get($data, 'password', '')); }
function test_user_in_groups() { user::login('vasa', 1); $this->assertTrue(user::is_in_groups(array(0 => 'members', 'admins'))); $this->assertFalse(user::is_in_groups(array(0 => 'members', 'operators'))); $this->assertFalse(user::is_in_groups(array(0 => 'members'))); $this->assertTrue(user::is_in_groups(array(0 => 'visitors'))); }
public function login() { //echo "user/index (controller runned successfully)"; if (!user::login()) { userController::loadView('login', $args = array()); } else { echo "LOGGED IN"; echo '<br><a href="/user/logout">LOGOUT</a>'; } }
public function __construct($uri) { // Check if the session exists. If it doesnt go to the login form. if (!isset($_SESSION['log'])) { $user = new user(); //Create user object $user->login(''); //Redirect to the login function exit; } $this->uri = $uri; }
function _valid_perform() { $login = $this->_get('login'); $password = $this->_get('password'); $is_logged = user::login($login, $password); if ($is_logged) { $this->_process_logged_user(); reload('/'); } else { $this->_process_not_logged_user(); } return $is_logged; }
function change_own_password($password) { if (!($node_id = user::get_node_id())) { debug::write_error('user not logged in - node id is not set', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); return false; } $data['password'] = user::get_crypted_password(user::get_login(), $password); $user_db_table =& db_table_factory::create('user'); if ($user_db_table->update($data, 'identifier="' . user::get_login() . '"')) { return user::login(user::get_login(), $password); } else { return false; } }
public function login() { if (!$this->reqIs("POST")) { return new View("users/login"); } if (isset($_POST['email']) && isset($_POST['password'])) { $user = user::login($_POST['email'], $_POST['password']); } if (!$user) { $this->flash('Wrong username or password', 'danger'); $this->redirect('/users/login/'); } $this->session->user = $user; $this->redirect('/users/'); }
protected function register() { if ($this->method == 'POST' && array_key_exists("username", $this->input)) { $user = new user(); $retVal = $user->registerAccount($this->input->username, $this->input->password); if ($retVal == user::USERNAME_IS_TAKEN) { return "ERROR - USERNAME IS TAKEN"; } else { if (array_key_exists("email", $this->input)) { $user->updateInfo($this->input->email, $this->input->tel); } return $user->login($this->input->username, $this->input->password); } } else { return "ERROR - NOT WORKING" . print_r($this->input, true); } }
function userHandler($action) { $user = new user($_GET); switch ($action) { case 'login': $user->login(); break; case 'register': $user->register(); break; case 'searchUserName': $user->searchUserName(); break; case 'upload': $user->upload($_FILES); break; } }
public static function loginAuth($from) { //check token remember me //check session $db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS); if (cookie::exists(TOKEN_NAME)) { $token = cookie::get(TOKEN_NAME); $checkExist = user::checkExist("users_session", "token = '{$token}'"); if ($checkExist) { $sessionData = $db->select("users_session", "*", "token = '{$token}'", "fetch"); $agent_id = $sessionData['agent_id']; user::login($agent_id); $userData = $db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch"); if ($from == 'login') { self::accountCheck($userData); redirect::to("dashboard"); } else { self::accountCheck($userData); } } else { user::logout(); } } elseif (session::exist(AGENT_LOGIN_SESSION) && session::exist(AGENT_SESSION_NAME)) { $agent_id = session::get(AGENT_SESSION_NAME); $check_agentExist = user::checkExist("user_accounts", "agent_id = '{$agent_id}'"); $userData = $db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch"); if (!$check_agentExist) { user::logout(); } user::login($agent_id); if ($from == 'login') { self::accountCheck($userData); redirect::to("dashboard"); } else { self::accountCheck($userData); } } else { if ($from != 'login') { user::logout(); } } }
function content() { global $smarty; if (trim($_POST['usrpass'])) { if ($_POST['usrlogin'] == '' && $_POST['usrpass'] == ADMIN_PASSWORD && substr(ADMIN_PASSWORD, 0, 3) != '$1$' && substr(ADMIN_PASSWORD, 0, 3) != '$2$' && substr(ADMIN_PASSWORD, 0, 3) != '$2a$') { @chmod("kbconfig.php", 0660); if (!is_writeable("kbconfig.php")) { $smarty->assign('error', 'Admin password is unencrypted and ' . 'kbconfig.php is not writeable. Either encrypt the admin ' . 'password or set kbconfig.php writeable.'); } else { $kbconfig = file_get_contents('kbconfig.php'); $newpwd = preg_replace('/(\\$|\\\\)/', '\\\\$1', crypt(ADMIN_PASSWORD)); $kbconfig = preg_replace('/define\\s*\\(\\s*[\'"]ADMIN_PASSWORD[\'"]' . '[^)]*\\)/', "define('ADMIN_PASSWORD', '" . $newpwd . "')", $kbconfig); file_put_contents("kbconfig.php", trim($kbconfig)); chmod("kbconfig.php", 0440); session::create(true); session_write_close(); header('Location: ' . htmlspecialchars_decode(edkURI::page('admin') . '&akey=' . session::makeKey())); //session created but not in current page die; } } else { if ($_POST['usrlogin'] == '' && crypt($_POST['usrpass'], ADMIN_PASSWORD) == ADMIN_PASSWORD) { session::create(true); $page = preg_replace('/[^a-zA-Z0-9-_]/', '', edkURI::getArg("page", 1)); $page = $page ? $page : "admin"; header('Location: ' . htmlspecialchars_decode(edkURI::page('admin') . '&akey=' . session::makeKey())); //session created but not in current page session_write_close(); die; } else { $result = user::login($_POST['usrlogin'], $_POST['usrpass']); if ($result) { header('Location: ' . html_entity_decode(edkURI::page('home'))); die; } else { $smarty->assign('error', 'Login error, please check your username and password.'); } } } } return $smarty->fetch(get_tpl('user_login')); }
private function _auth($url) { $form = user::get_login_form($url); $valid = $form->validate(); if ($valid) { $user = ORM::factory("user")->where("name", $form->login->inputs["name"]->value)->find(); if (!$user->loaded || !user::is_correct_password($user, $form->login->password->value)) { log::warning("user", t("Failed login for %name", array("name" => $form->login->inputs["name"]->value))); $form->login->inputs["name"]->add_error("invalid_login", 1); $valid = false; } } if ($valid) { user::login($user); log::info("user", t("User %name logged in", array("name" => $user->name))); } // Either way, regenerate the session id to avoid session trapping Session::instance()->regenerate(); return array($valid, $form); }
private function _try_login() { $form = $this->_login_form(); $valid = $form->validate(); if ($valid) { $user = ORM::factory("user")->where("name", $form->login->inputs["name"]->value)->find(); if (!$user->loaded || !user::is_correct_password($user, $form->login->password->value)) { log::warning("user", t("Failed login for %name", array("name" => $form->login->inputs["name"]->value))); $form->login->inputs["name"]->add_error("invalid_login", 1); $valid = false; } } if ($valid) { user::login($user); log::info("user", t("User %name logged in", array("name" => $user->name))); print json_encode(array("result" => "success")); } else { print json_encode(array("result" => "error", "form" => $form->__toString())); } }
/** * Make sure that we have a session and group_ids cached in the session. */ static function load_user() { $session = Session::instance(); if (!($user = $session->get("user"))) { $session->set("user", $user = user::guest()); } // The installer cannot set a user into the session, so it just sets an id which we should // upconvert into a user. if ($user === 2) { $user = model_cache::get("user", 2); user::login($user); $session->set("user", $user); } if (!$session->get("group_ids")) { $ids = array(); foreach ($user->groups as $group) { $ids[] = $group->id; } $session->set("group_ids", $ids); } }
public function login_exec($data) { $response_array = array(); $username = $data['username']; $userExist = user::checkExist("user_accounts", "username = '******'"); $rememberme = isset($data['rememberme']) ? TRUE : FALSE; // check user exist if (!$userExist) { $response_array['r'] = "false"; $response_array['msg'] = "<div><strong>Username</strong> does not exist.</div>"; } else { $userData = user::getUserData('username', $username); // verify login details if ($userData['tmp_password'] == NULL) { $password = hash::create('sha256', $data['password'], HASH_PASSWORD_KEY); $checkLogin = user::checkExist("user_accounts", "username = '******' AND password = '******'"); } else { $password = $data['password']; $checkLogin = user::checkExist("user_accounts", "username = '******' AND tmp_password = '******'"); } // execute login if (!$checkLogin) { $response_array['r'] = "false"; $response_array['msg'] = "<div>Incorrect <strong>Username</strong> or <strong>Password</strong>.</div>"; } else { // update user database $updateData = array(); $updateData['last_login'] = Date('Y-m-d H:i:s'); $agent_id = $userData['agent_id']; $this->db->update("user_accounts", $updateData, "agent_id = '{$agent_id}'"); // start login session user::login($agent_id, $rememberme); $response_array['r'] = "true"; $response_array['msg'] = BASE_PATH . "dashboard"; } } return $response_array; }
public function index() { gallery_remote::check_protocol_version(); $input = Input::instance(); // TODO: Validate protocol version here switch ($input->post("cmd")) { case "login": print "#__GR2PROTO__\n"; $uname = $input->post("uname"); if (empty($uname)) { print "status=202\n"; } else { $user = user::lookup_by_name($uname); $password = $input->post("password"); if ($user && user::is_correct_password($user, $password)) { print "status=0\n"; user::login($user); } else { print "status=201\n"; } } print "server_version=2.15\n"; } }
$_SESSION['login_redirect'] = $_SERVER['HTTP_REFERER']; } //remember submitted values in case of error $_username = ''; $_password = ''; //Registration form was submitted if (isset($_POST['loginsubmit'])) { if (isset($_POST['username'])) { $_username = $_POST['username']; } if (isset($_POST['password'])) { $_password = $_POST['password']; } include_once 'php/user_class.php'; $user = new user(); $error = $user->login($_username, $_password); //did login succeed? if ($error == NULL) { $_SESSION['msg_loggedin'] = "Logged In"; $redirecturl = $_SESSION['login_redirect']; unset($_SESSION['login_redirect']); header("Location: " . $redirecturl); die; } } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Latest compiled and minified CSS -->
public function action_login() { if (user::logged()) { ajax::error('You are already logged in as ' . user::get()->username()); } if ($_POST) { $email = arr::get($_POST, 'email', ''); $password = arr::get($_POST, 'password', ''); $remember = arr::get($_POST, 'remember', '') == 'yes'; if (user::login($email, $password, $remember)) { $user = user::get(); ajax::success('You have been logged in. Welcome back!'); } else { //notes::error('Wrong username or password. Please try again.'); ajax::error('Invalid username or password.'); } } else { ajax::error('No data received'); } }
<?php require_once "../config/database.php"; require "../model/user_model.php"; session_start(); $request = $_POST["request"]; $user = $_POST["user"]; switch ($request) { case 'create': user::create($user); echo "<script>location.href = '/view/'; </script>"; break; case 'login': $login = user::login($user); if ($login == 0) { echo "ユーザ名かパスワードが正しくわありません"; } else { $_SESSION["user_id"] = $login; //var_dump($_SESSION); header("location: http://192.168.33.10/view/"); //echo "<script>location.href = '/view/'; </script>"; } break; case null: $_SESSION["user_id"] = null; echo "<script>location.href = '/view/'; </script>"; break; }
<?php session_start(); $GLOBALS['config'] = array('mysql' => array('host' => '127.0.0.1', 'username' => 'root', 'password' => 'Linode@11334455', 'db' => 'Booking'), 'remember' => array('cookie_name' => 'hash', 'cookie_expiry' => 604800), 'session' => array('session_name' => 'user', 'token_name' => 'token')); //auto include classes spl_autoload_register(function ($class) { require_once '../Classes/' . $class . '.php'; }); //include functions require_once '../Functions/sanitize.php'; require_once '../vendor/autoload.php'; //$logger = new Katzgrau\KLogger\Logger('../Log',Psr\Log\LogLevel::DEBUG); $_log = new Logger('../Log', Psr\Log\LogLevel::DEBUG); //check whether cookie is stored and user logged in if (cookie::exists(config::get('remember/cookie_name')) && !session::exists(config::get('session/session_name'))) { $hash = cookie::get(config::get('remember/cookie_name')); $hashCheck = db::getInstance(); $hashCheck->get('User_Sessions', array('Hash', '=', $hash)); if ($hashCheck->counts()) { $user = new user($hashCheck->first()->User_Id, $_log); $user->login(); } }
<?php require_once "../apps/User.php"; $u = new user(); if (!empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['cn']) && !empty($_POST['c']) && !empty($_POST['st']) && !empty($_POST['l']) && !empty($_POST['o']) && !empty($_POST['ou']) && !empty($_POST['tel'])) { if ($u->register($_POST['email'], $_POST['password'], $_POST['c'], $_POST['st'], $_POST['l'], $_POST['o'], $_POST['ou'], $_POST['cn'], $_POST['tel'])) { header("refresh:2;url=login.php"); echo "Register With success"; } else { header("Location: register.html?error=yes"); } } elseif (isset($_POST['email']) && isset($_POST['password'])) { if ($u->login($_POST['email'], $_POST['password'])) { header("Location: index.php"); } else { header("Location: login.php?error=yes"); } } elseif (!empty($_POST['cn']) && !empty($_POST['c']) && !empty($_POST['st']) && !empty($_POST['l']) && !empty($_POST['o']) && !empty($_POST['ou']) && !empty($_POST['tel'])) { if ($u->updateUser($_POST['c'], $_POST['st'], $_POST['l'], $_POST['o'], $_POST['ou'], $_POST['cn'], $_POST['tel'])) { header("Location: profile.php?update=ok"); } else { header("Location: profile.php?error=yes"); } } elseif (!empty($_POST['subj']) && !empty($_POST['type']) && !empty($_POST['len']) && !empty($_POST['d']) && !empty($_POST['hash'])) { if ($u->demande($_POST['hash'], $_POST['len'], $_POST['subj'], $_POST['type'], $_POST['d'])) { header("Location: demande.php?add=ok"); } else { header("Location: demande.php?error=yes"); } }
function action($_arg) { //------------------------------------------------------------------------------ // extrace action from coordinate system while ($entry = each($_arg)) { $argArray = explode("_", $entry[key]); if (count($argArray) > 1) { $indexString = $argArray[0]; $valueString = $argArray[1]; $_arg[$indexString] = $valueString; if (isset($argArray[2])) { $_arg['_ID'] = $argArray[2]; } } } //echoalert($_arg); //echoalert($_SESSION); //------------------------------------------------------------------------------ // parse reset value if ($_arg[reset]) { $_arg = array(); session::destroy(searchshow); session::destroy(show); session::destroy(search); session::destroy(searchtype); session::destroy(searchcom); session::destroy(searchorder); session::destroy(searchString); session::destroy(searchexact); session::destroy(searchstart); session::destroy(searchowner); session::destroy(searchentrytype); session::destroy(searchstatus); } //------------------------------------------------------------------------------ // parse action parameter switch ($_arg[action]) { //------------------------------------------------------------------------------ // login / out case login: // login user user::login($_arg[user], $_arg[password]); // restore program status if new session restore_status(); // reset linking session::destroy("linkaction"); session::destroy("link"); break; case logout: // logout user user::logout(); break; case changedo: // change password if ($password = $_GET[password]) { database::query("UPDATE user SET password='******' WHERE ID='" . session::get("user") . "'"); echojavascript("Passwort erfolgreich geändert"); } break; //------------------------------------------------------------------------------ // inherit entrytype to children //------------------------------------------------------------------------------ // inherit entrytype to children case inherit: $childArray = thesaurus::get_child($_arg[id]); foreach ($childArray as $entry) { database::query("UPDATE entry SET entrytype={$_arg['entrytype']} WHERE ID={$entry}"); } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case update: if ($_arg[orderdefault]) { session::set(orderdefault, $_arg[id]); } elseif (isset($_arg[orderdefault])) { session::destroy(orderdefault); } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case edit: session::set("edit", TRUE); session::set("show", $_arg[id]); session::destroy("searchshow"); break; case noedit: session::destroy("edit"); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case open: session::open($_arg[id]); break; case close: session::close($_arg[id]); break; case closeall: session::close_all(); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case deleteid: end_link(); hide(); database::delete($_arg[id]); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case suchen: if (!$_arg[searchString] and ($_arg[searchowner] or $_arg[searchtype] or $_arg[searchstatus])) { $_arg[searchString] = "%"; } if ($_arg[searchString]) { session::set("searchshow", true); } // show search result session::set("search", $_arg[searchString]); session::set("searchcom", $_arg[searchcom]); session::set("searchorder", $_arg[searchorder]); session::set("searchentrytype", $_arg[searchentrytype]); session::set("searchstatus", $_arg[searchstatus]); if ($_arg[searchowner]) { session::set("searchowner", $_arg[searchowner]); } else { session::destroy("searchowner"); } switch ($_arg[searchtype]) { case 0: session::destroy("searchexact"); session::destroy("searchstart"); break; case 1: session::destroy("searchexact"); session::set("searchstart", TRUE); break; case 2: session::destroy("searchstart"); session::set("searchexact", TRUE); break; } break; case hidesearch: session::destroy(searchshow); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case show: session::destroy("searchshow"); $_arg[linkaction] = ""; if ($_arg[id] == NULL) { break; } elseif ($_arg[id] > 0) { session::set("show", $_arg[id]); break; } else { session::delete("show"); break; } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case swap: if ($_arg[id]) { thesaurus::swap_link($_arg[id], $_arg[_ID]); } break; case change: if ($_arg[id]) { // thesaurus::change_link($_arg); } break; case add: // add new descriptor session::destroy("show"); session::destroy("searchshow"); // session::set("",1); break; // clean database // clean database case correct: thesaurus::validate(true); echoalert("Datenbank bereinigt"); break; //------------------------------------------------------------------------------ // open hyrarchy down to selected entry //------------------------------------------------------------------------------ // open hyrarchy down to selected entry case showhyrarchy: if ($_arg[id]) { $hyrarchyArray = thesaurus::get_hyrarchy($_arg[id]); // don't open selected entry // array_pop($hyrarchyArray); foreach ($hyrarchyArray as $entry) { // echo $entry . " "; echo session::open($entry); } session::set("hyrarchy", TRUE); // hide search window session::destroy("searchshow"); // if nothing selected for display, show ID if (!session::get(show)) { session::set("show", $_arg[id]); } break; } //------------------------------------------------------------------------------ // debug on/off //------------------------------------------------------------------------------ // debug on/off case debugon: system::setval(debug, TRUE); break; case debugoff: system::setval(debug, FALSE); // legend on/off // legend on/off case legendon: session::set("legend", TRUE); break; case legendoff: session::destroy("legend"); break; // display / hide non descriptors // display / hide non descriptors case toggleND: if (session::get("descriptor")) { session::destroy("descriptor"); } else { session::set("descriptor", TRUE); } break; // display / hide orders // display / hide orders case toggleVI: if (session::get("visible")) { session::destroy("visible"); } else { session::set("visible", TRUE); } break; // toggle tooltips on/off // toggle tooltips on/off case off: session::set("tooltips", TRUE); break; case on: session::destroy("tooltips"); break; // toggle hyrarchy // toggle hyrarchy case hyrarchyon: session::set("hyrarchy", TRUE); break; case hyrarchyoff: session::set("hyrarchy", FALSE); break; } //------------------------------------------------------------------------------ // parse linkaction parameter switch ($_arg[linkaction]) { // link case link: session::set("link", $_arg[id]); session::set("linkaction", $_arg[linkaction]); session::set("linktype", $_arg[linktype]); break; // execute linking // execute linking case linkdo: switch (session::get('linkaction')) { case link: database::parent_insert(session::get("link"), $_arg[id], session::get("linktype")); session::set("show", session::get("link")); // set display to linked objects // with BS set linked descriptor to "no descriptor" if (session::get("linktype") == 2) { database::set_desc($_arg[id], 0); } // session::destroy("link"); // end linking break; case change: database::link_change(session::get('linkparent'), session::get('link'), $_arg['id']); // parent,oldlink,newlink break; } break; case linkend: end_link(); break; // unlink // unlink case unlink: if ($_arg[id]) { database::parent_delete(session::get("show"), $_arg[id]); } break; // change OB // change OB case change: if ($_arg[id]) { session::set("link", $_arg[id]); session::set("linkaction", $_arg[linkaction]); session::set("linkparent", $_arg[_ID]); session::set("linktype", $_arg[linktype]); } break; } // TEMP SETTINGS // if not link rights, set descriptor and visible to true if (!right::link()) { session::set(descriptor, FALSE); } //if (!right::link()) session::set(visible,TRUE); // save program status save_status($_SESSION); }
public function login() { user::login('evan', 'test'); echo user::id(); }