/** *This method parses user submitted login info * *@param null *@return void */ public function postForget() { echo "<pre>"; print_r(Input::get()); exit; //load the login form View::render('login/form'); }
/** *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'); } }
/** *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')); } }
/** *This method new list info into the database *@param null *@return void */ public function postManagenew() { echo "<pre>"; print_r(ArrayHelper::clean(Input::get())->get()); exit; }
/** *This method sets the value of the request parameter * *@param null *@return Object \RouteParser */ public function setParameters() { //set the url parameter from the UrlParserObjectInstance $this->parameters = $this->UrlParserObjectInstance->getParameters(); //populate the Input Class data Input::setGet()->setPost(); //return this object instance return $this; }
/** *This method sets the value of the request parameter * *@param null *@return Object \RouteParser */ public function setParameters() { //set the requestParamKeys $this->requestParamKeys = count($this->methodMetaDataArray) > 1 ? ArrayHelper::slice($this->methodMetaDataArray, 1)->get() : array(); //check if the requestParamKeys contain values if (count($this->requestParamKeys) > 0) { //get the url parameter from the UrlParserObjectInstance $requestParamValues = $this->UrlParserObjectInstance->getParameters(); //get the number of keys $requestParamKeysLen = count($this->requestParamKeys); //check if the keys are more than then values if ($requestParamKeysLen >= count($requestParamValues)) { //padd the $requestParamValues with null values $requestParamValues = array_pad($requestParamValues, $requestParamKeysLen, null); //combine the two arrays into one $requestParams = array_combine($this->requestParamKeys, $requestParamValues); //populate the Input Class data Input::setGet()->setPost()->setUrl($requestParams); //return this object instance return $this; } else { //split the array to only remain with the number defined inthe keys $requestParamValues = ArrayHelper::slice($requestParamValues, 0, $requestParamKeysLen)->get(); //combine the two arrays into one $requestParams = array_combine($this->requestParamKeys, $requestParamValues); //populate the Input Class data Input::setGet()->setPost()->setUrl($requestParams); //return this object instance return $this; } } else { //populate the Input Class data Input::setUrl($this->UrlParserObjectInstance->getParameters())->setGet()->setPost(); //return this object instance return $this; } }