public function post_resetpassword() { $input = Input::all(); $user = Admin_User::find(Auth::user()->userid); if (Hash::check($input['oldpassword'], $user->password) && $input['password'] == $input['repassword']) { $user->password = Hash::make($input['password']); $user->save(); } }
public static function confirmUser($input, $id = 0) { if ($id != 0) { $user = Admin_User::find($id); $user->username = $input['username']; $user->password = Hash::make($input['password']); $user->status = 2; $user->save(); return true; } else { return false; } }
public static function loggedprofile() { $logged_user = Auth::user(); $userInfo = Admin_User::find($logged_user->userid)->userprofile; $data['profileid'] = $userInfo->profileid; // $data['userid'] = $userInfo->userid; $data['fullname'] = $userInfo->fullname; $data['icno'] = $userInfo->icno; $data['dob'] = $userInfo->dob; $data['emel'] = $userInfo->emel; $data['dob'] = $userInfo->dob; $data['address'] = $userInfo->address; $data['postcode'] = $userInfo->postcode; $data['town'] = $userInfo->town; $data['city'] = $userInfo->city; return json_encode($data); }
public function action_verifyupdate() { $input = Input::all(); $rules = array('username' => 'required|exists:users', 'password' => 'required'); // $validation = Validator::make($input, $rules); // if( $validation->fails() ) { // return Redirect::to('home')->with_errors($validation); // } $existedUser = Admin_User::where('validationkey', '=', $input['key'])->where('username', '=', $input['oldpassword'])->where('status', '=', 'Pending')->first(array('userid')); $result = Admin_User::confirmUser($input, $existedUser->userid); if ($result) { $emel = Admin_UserProfile::find($existedUser->userid)->emel; try { $mailer = Message::to($emel); $mailer->from('*****@*****.**', 'System Generate'); $mailer->subject('User Registration Information'); $mailer->body('view: plugins.emailAcc'); $mailer->body->username = $input['username']; $mailer->body->password = $input['password']; $mailer->body->key = $input['key']; $mailer->html(true); $mailer->send(); } catch (Exception $e) { Log::write('email', 'Message was not sent.'); Log::write('email', 'Mailer error: ' . $e->getMessage()); } $credentials = array('username' => $input['username'], 'password' => $input['password']); if (Auth::attempt($credentials)) { return Redirect::to('eis/dashboard'); } else { Session::flash('login_errors', 'Your email or password is invalid - please try again.'); return Redirect::to(URL::base()); } } else { return Redirect::to('home/confirmation/' . $input['key']); } }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "models/Page_Data.class.php"; $pageData = new Page_Data(); $pageData->title = "PHP/MySQL blog demo"; $pageData->addCSS("css/blog.css"); $pageData->addScript("js/editor.js"); $dbInfo = "mysql:host=127.0.0.1;port=3306;dbname=simple_blog"; $dbUser = "******"; $dbPassword = "******"; $db = new PDO($dbInfo, $dbUser, $dbPassword); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); include_once "models/Admin_User.class.php"; $admin = new Admin_User(); $pageData->content = (include_once "controllers/admin/login.php"); if ($admin->isLoggedIn()) { $pageData->content .= (include_once "views/admin/admin-navigation.php"); $navigationIsClicked = isset($_GET['page']); if ($navigationIsClicked) { $controller = $_GET['page']; } else { $controller = "entries"; } $pathToController = "controllers/admin/{$controller}.php"; $pageData->content .= (include_once $pathToController); } $page = (include_once "views/page.php"); echo $page;
public static function createAdmin() { $User = new Admin_User(); $id = $User->insert_get_id(array('username' => 'administrator', 'password' => Hash::make('password'), 'validationkey' => Str::random(32, 'alpha'), 'status' => 2, 'role' => 1)); $profile = new Admin_UserProfile(array('fullname' => 'System Administrator')); $user = Admin_User::find($id); $user->userprofile()->insert($profile); return $id; }
public function delete($table, $id) { if ($table == 'blog_posts') { $this->load->model('blog_post'); $post = new Blog_Post(); $post->load($id); $post->delete(); $edit = !isset($post->id) ? 'Post deleted!' : 'Problem deleting post.'; $this->session->set_flashdata('edit', $edit); } else { if ($table == 'content_pages') { $this->load->model('content_page'); if ($id > 7) { $page = new Content_Page(); $page->load($id); $page->delete(); $edit = !isset($page->id) ? 'Page deleted!' : 'Problem deleting page.'; } else { $edit = 'You may not delete this content.'; } $this->session->set_flashdata('edit', $edit); } else { if ($table == 'admin_users') { $this->load->model('admin_user'); $user = new Admin_User(); $user->load($id); $user->delete(); $edit = !isset($page->id) ? 'User deleted!' : 'Problem deleting user.'; $this->session->set_flashdata('edit', $edit); } } } redirect('admin/' . $table); }