Пример #1
0
 /**
  *This method parses user submitted login info 
  *
  *@param array $data The user information submitted inthe form data
  *@return void
  */
 public function postIndex()
 {
     //prepare user info to send to the database
     $data = array('email' => Input::get('email'), 'password' => Input::get('password'));
     //check if use exists
     $user = UsersModel::checkUser($data);
     //check if user was found
     if ($user) {
         //check if the passwords do not match
         if ($user['password'] != md5($data['password'])) {
             //reload the form with error message
             $data['error'] = 'Invalid Password. Try again!';
             //load the form
             View::render('login/form', $data);
         }
         //password is correct - set user data in session
         Session::set('userInfo', $user);
         //check if this is admin user, //redirect to the appropriate user
         if ($user['user_type'] == 'admin') {
             Redirect::to($user['user_type']);
         }
         //else, redirect to the home controller
         Redirect::to('home');
     } else {
         //compose the error information
         $data['error'] = 'User not found!';
         //reload the form with the error message
         View::render('login/form', $data);
     }
 }
 /**
  *This method checks for the logged in user.
  *@param null
  *@return void
  */
 public function __construct()
 {
     //check for logged in user
     if (!Session::get('userInfo') or Session::get('userInfo')['user_type'] != 'admin') {
         Redirect::to('home');
     }
 }
 /**
  *This method checks for the logged in user.
  *@param null
  *@return void
  */
 public function __construct()
 {
     //check for logged in user
     if (!Session::get('userInfo')) {
         Redirect::to('login');
     }
     if (Session::get('userInfo')['user_type'] == 'admin') {
         Redirect::to('admin');
     }
 }
 /**
  *This method parses user submitted signup info 
  *
  *@param array $data The post submited form data
  *@return void
  */
 public function postIndex()
 {
     //prepare the user information for sending to the database
     $data = array('email' => Input::get('email'), 'password' => md5(Input::get('password')), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'user_type' => 'user');
     //call model to insert records into the database
     $userCreated = UsersModel::save($data);
     //check if user was created
     if ($userCreated->lastInsertId()) {
         //redirect user to the login page
         Redirect::to('login');
     }
 }
Пример #5
0
 /**
  *This method creats a mailing list in the database in the database
  *@param null
  *@return void
  */
 public function postAddnew()
 {
     //upload the submitted file
     $upload_file = Upload::doUpload('list_csv', 'application/storage/mailing_list_csvs/');
     //proceed if file upload success
     if ($upload_file->success === true) {
         //compose data to save in table
         $list_info = array('name' => Input::get('list_name'), 'description' => Input::get('list_description'), 'recipients' => 0, 'campaigns' => 0, 'csv_file_path' => $upload_file->upload_path_relative);
         //call model to save this information into the database
         $create_list = ListsModel::create($list_info);
         if ($create_list->lastInsertId()) {
             //redirect to manage new list page
             $data = array('list_id' => $create_list->lastInsertId());
             Redirect::with($data)->to('lists/managenew');
         }
     }
 }
 /**
  *This method parses user submitted login info 
  *
  *@param array $data The user information submitted inthe form data
  *@return void
  */
 public function postIndex()
 {
     //check if use exists
     $user = UsersModel::where('email = ?', Input::get('email'))->all();
     //check if user was found
     if ($userData = $user->result_array()) {
         $userData = $userData[0];
         //check if the passwords do not match
         if ($userData['password'] != md5(Input::get('password'))) {
             //reload the form with error message
             $data['error'] = 'Invalid Password. Try again!';
             //load the form
             View::render('login/form', $data);
         } elseif ($userData['activated'] !== true) {
             //reload the form with error message
             $data['error'] = 'Account is nolonger active! Please contant Admin';
             //load the form
             View::render('login/form', $data);
         } else {
             //password is correct - set user data in session
             Session::set('userInfo', $userData);
             $ip_address = $_SERVER['SERVER_ADDR'];
             $geoInfo = json_decode(@file_get_contents("http://ipinfo.io/{$ip_address}/json"));
             //call model to log user info
             $data = array('user_id' => $userData['id'], 'name' => $userData['first_name'] . ' ' . $userData['last_name'], 'email' => $userData['email'], 'ip_address' => $ip_address, 'country' => isset($geoInfo->country) ? $geoInfo->country : '', 'state' => isset($geoInfo->region) ? $geoInfo->region : '', 'city' => isset($geoInfo->city) ? $geoInfo->city : '', 'location' => isset($geoInfo->loc) ? $geoInfo->loc : '', 'host_name' => isset($geoInfo->hostname) ? $geoInfo->hostname : '', 'online' => true);
             $log = LogModel::save($data);
             UsersModel::where('id = ?', $userData['id'])->save(array('online' => true));
             Session::set('log_id', $log->lastInsertId());
             //check if this is admin user, //redirect to the appropriate user
             if ($userData['user_type'] == 'admin') {
                 Redirect::to($userData['user_type']);
             } else {
                 Redirect::to('home');
             }
         }
     } else {
         //compose the error information
         $data['error'] = 'User not found!';
         //reload the form with the error message
         View::render('login/form', $data);
     }
 }
 /**
  *This method update a users physical address information into the database.
  *@param int $user_id The id of the user to update password
  *@return void
  */
 public function updateAddress($user_id)
 {
     $update = UsersModel::saveById(array('id' => $user_id, 'country' => Input::get('country'), 'state' => Input::get('state'), 'city' => Input::get('city'), 'zip' => Input::get('zip')));
     if ($update->updateSuccess()) {
         Redirect::to(array('home'));
     }
 }