Example #1
20
 public function myAccount()
 {
     if (isset($this->session->userdata["user_id"])) {
         $data = array();
         $model = new Common_model();
         $user_id = $this->session->userdata["user_id"];
         $username = $this->session->userdata["user_username"];
         if ($this->input->post()) {
             $arr = $this->input->post();
             //                prd($arr);
             if (isset($arr["btn_submit"])) {
                 $user_dob = NULL;
                 if (!empty($arr['dob_dd']) && !empty($arr['dob_mm']) && !empty($arr['dob_yy'])) {
                     $user_dob = $arr['dob_yy'] . '-' . $arr['dob_mm'] . '-' . $arr['dob_dd'];
                 }
                 $location_details = get_location_details_from_google(trim($arr['user_location']));
                 $location_lat_long = getLatLonByAddress(trim($arr['user_location']));
                 $data_array = array('user_fullname' => addslashes($arr['user_fullname']), 'user_gender' => addslashes($arr['user_gender']), 'user_location' => addslashes($arr['user_location']), 'user_city' => $location_details['city'], 'user_state' => $location_details['state'], 'user_country' => $location_details['country'], 'user_location' => trim($arr['user_location']), 'user_latitude' => $location_lat_long['latitude'], 'user_longitude' => $location_lat_long['longitude'], 'user_tagline' => addslashes($arr['user_tagline']), 'user_about' => addslashes($arr['user_about']), 'user_relationship_status' => addslashes($arr['user_relationship_status']), 'user_dob' => $user_dob);
                 if (isset($arr['user_username'])) {
                     $username = trim($arr['user_username']);
                     $checkUsername = $model->is_exists("user_id", TABLE_USERS, array("username" => $username, "user_id !=" => $user_id));
                     if (!empty($checkUsername)) {
                         $this->session->set_flashdata("error", "That username is already taken. Please choose another.");
                     } else {
                         $data_array['user_username'] = $username;
                         $data_array['user_changed_username'] = '******';
                     }
                 }
                 $this->session->set_flashdata("success", "Personal details updated successfully");
                 $model->updateData(TABLE_USERS, $data_array, array("user_id" => $user_id));
                 // updating redis keys now
                 $this->redis_functions->set_user_profile_data($username);
                 @$this->session->set_userdata("user_fullname", trim($arr["user_fullname"]));
                 @$this->session->set_userdata("user_username", $username);
             }
             redirect(base_url('my-account'));
         } else {
             $record = $this->redis_functions->get_user_profile_data($username);
             $page_title = $record["user_fullname"];
             $input_arr = array(base_url() => 'Home', '#' => $page_title);
             $breadcrumbs = get_breadcrumbs($input_arr);
             $data["record"] = $record;
             $data["breadcrumbs"] = $breadcrumbs;
             $data["page_title"] = $page_title;
             $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME');
             $this->template->write_view("content", "pages/user/my-account", $data);
             $this->template->render();
         }
     } else {
         require_once APPPATH . 'controllers/index.php';
         $index_controller = new Index();
         $index_controller->login();
     }
 }
Example #2
0
 public function register()
 {
     if (!isset($this->session->userdata['user_id'])) {
         $data = array();
         $model = new Common_model();
         if ($this->input->post()) {
             $redirect_url = base_url();
             if ($this->input->get('next')) {
                 $redirect_url = $this->input->get('next');
             }
             $arr = $this->input->post();
             //                prd($arr);
             $user_email = trim(strtolower($arr["user_email"]));
             $is_email_exists = $model->is_exists('user_id', TABLE_USERS, array('user_email' => $user_email));
             if (empty($is_email_exists)) {
                 // valid email
                 $verification_code = substr(getEncryptedString($arr['user_email'] . $arr['user_gender'] . time()), 0, 30);
                 $user_username = getUniqueUsernameFromEmail($user_email);
                 $location_details = get_location_details_from_google(trim($arr['user_location']));
                 $location_lat_long = getLatLonByAddress(trim($arr['user_location']));
                 $data_array = array('user_fullname' => $arr['user_fullname'], 'user_gender' => strtolower($arr['user_gender']), 'user_username' => $user_username, 'user_email' => $user_email, 'user_password' => md5($arr['user_password']), 'user_ipaddress' => USER_IP, 'user_useragent' => USER_AGENT, 'user_created_on' => date('Y-m-d H:i:s'), 'user_status' => '0', 'user_verification_code' => $verification_code, 'user_city' => $location_details['city'], 'user_state' => $location_details['state'], 'user_country' => $location_details['country'], 'user_location' => trim($arr['user_location']), 'user_latitude' => $location_lat_long['latitude'], 'user_longitude' => $location_lat_long['longitude']);
                 $user_id = $model->insertData(TABLE_USERS, $data_array);
                 // updating redis keys now
                 $this->redis_functions->set_user_profile_data($user_username);
                 if (USER_IP != '127.0.0.1') {
                     $verification_url = base_url('activate?code=' . $verification_code);
                     $this->load->library('EmailTemplates');
                     $EmailTemplates = new EmailTemplates();
                     $messageText = $EmailTemplates->registerEmail(ucwords($arr['user_fullname']), $verification_url);
                     $email_model = new Email_model();
                     $email_model->sendMail($arr['user_email'], 'Verification Email - ' . $this->redis_functions->get_site_setting('SITE_NAME'), $messageText);
                 }
                 $this->session->set_flashdata('success', '<strong>Success!</strong> We have sent you an email. Please verify your email address');
                 redirect($redirect_url);
             } else {
                 // invalid email
                 $this->session->set_flashdata('error', '<strong>Oops!</strong> Email already exists');
                 $this->session->set_flashdata('post', $arr);
                 redirect(base_url('register?next=' . $this->input->get('next')));
             }
         } else {
             $page_title = 'Register';
             $input_arr = array(base_url() => 'Home', '#' => $page_title);
             $breadcrumbs = get_breadcrumbs($input_arr);
             $data["breadcrumbs"] = $breadcrumbs;
             $data["page_title"] = $page_title;
             $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME');
             $this->template->write_view("content", "pages/index/register", $data);
             $this->template->render();
         }
     } else {
         redirect('my-account');
     }
 }
Example #3
0
 public function add_new_step_two($url_key)
 {
     $data = array();
     $user_id = $this->session->userdata["user_id"];
     $model = new Common_model();
     $trip_details = $this->redis_functions->get_trip_details($url_key);
     $post_title = stripslashes($trip_details['post_title']);
     $post_id = $trip_details['post_id'];
     if ($this->input->post() && isset($user_id)) {
         $arr = $this->input->post();
         if (isset($arr['post_source']) && !empty($arr['post_source'])) {
             $model->deleteData(TABLE_POST_REGIONS, array('pr_post_id' => $post_id));
             $i = 1;
             foreach ($arr['post_source'] as $key => $source_value) {
                 $post_source = $source_value;
                 $post_destination = $arr['post_destination'][$key];
                 $from_date = $arr['date_from_yy'][$key] . '-' . $arr['date_from_mm'][$key] . '-' . $arr['date_from_dd'][$key];
                 $to_date = $arr['date_to_yy'][$key] . '-' . $arr['date_to_mm'][$key] . '-' . $arr['date_to_dd'][$key];
                 $travel_medium = $arr['travel_medium'][$key];
                 // now fetching LAT-LONG
                 $post_source_lat_long = getLatLonByAddress($post_source);
                 $post_destination_lat_long = getLatLonByAddress($post_destination);
                 // fetching address details from google
                 $post_source_address_details = get_location_details_from_google($post_source);
                 $post_destination_address_details = get_location_details_from_google($post_destination);
                 $data_array = array('pr_post_id' => $post_id, 'pr_order_number' => $i, 'pr_source_location' => addslashes($post_source), 'pr_destination_location' => addslashes($post_destination), 'pr_source_city' => addslashes($post_source_address_details['city']), 'pr_source_region' => addslashes($post_source_address_details['state']), 'pr_source_country' => addslashes($post_source_address_details['country']), 'pr_source_latitude' => addslashes($post_source_lat_long['latitude']), 'pr_source_longitude' => addslashes($post_source_lat_long['longitude']), 'pr_destination_city' => addslashes($post_destination_address_details['city']), 'pr_destination_region' => addslashes($post_destination_address_details['state']), 'pr_destination_country' => addslashes($post_destination_address_details['country']), 'pr_destination_latitude' => addslashes($post_destination_lat_long['latitude']), 'pr_destination_longitude' => addslashes($post_destination_lat_long['longitude']), 'pr_from_date' => $from_date, 'pr_to_date' => $to_date, 'pr_travel_medium' => $travel_medium);
                 $model->insertData(TABLE_POST_REGIONS, $data_array);
                 $i++;
             }
         }
         // setting post details to redis
         $this->redis_functions->set_trip_details($url_key);
         redirect(base_url('trip/post/edit/3/' . $url_key));
     } else {
         $input_arr = array(base_url() => 'Home', base_url('trips') => 'Trips', '#' => $post_title);
         $breadcrumbs = get_breadcrumbs($input_arr);
         $data["breadcrumbs"] = $breadcrumbs;
         $data["post_records"] = $trip_details;
         $data["page_title"] = $post_title;
         $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME');
         $this->template->write_view("content", "pages/trip/post/step-2", $data);
         $this->template->render();
     }
 }