function login() { $user = new Axon('tbl_user'); $id = F3::get('POST.id'); if ($user->found(array("id=:id", array(":id" => $id))) == 0) { // Register user $user->id = $id; $user->username = F3::get('POST.username'); $user->email = F3::get('POST.email'); $user->fullname = F3::get('POST.fullname'); $user->image = F3::get('POST.image'); $user->save(); } else { $user->load(array("id=:id", array(":id" => $id))); if ($user->active == 'n') { die(json_encode(array("message" => "hello world", "type" => "error"))); } else { $user->username = F3::get('POST.username'); $user->email = F3::get('POST.email'); $user->fullname = F3::get('POST.fullname'); $user->image = F3::get('POST.image'); $user->save(); } F3::set('SESSION.user', $user); F3::set('SESSION.sid', Snippets::_getRN()); } }
function test() { echo $_SERVER['SERVER_PORT']; $user = new Axon('tbl_user'); $user->load(array("id=:id", array(":id" => 1537994726))); $this->set('SESSION.user', $user); $this->set('SESSION.sid', Snippets::_getRN()); }
function adminLogin() { $admin = new Axon('tbl_admin'); $username = F3::get('POST.usr'); $password = F3::get('POST.pwd'); if ($admin->found(array('username=:username and password=:password', array(':username' => $username, ':password' => md5($password)))) == 1) { $admin->load(array('username=:username and password=:password', array(':username' => $username, ':password' => md5($password)))); F3::set('SESSION.admin', $admin); F3::set('SESSION.asid', Snippets::_getRN()); echo json_encode(array('message' => "You have been logged in ")); } else { echo json_encode(array('mes' => "Either password or usernaem is wrong")); } }