コード例 #1
0
ファイル: user.php プロジェクト: arp19690/newtravel
 public function public_profile($username)
 {
     $redis_function = new Redisfunctions();
     $record = $redis_function->get_user_profile_data($username);
     if (!empty($record)) {
         $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/public-profile", $data);
         $this->template->render();
     } else {
         display_404_page();
     }
 }
コード例 #2
0
ファイル: staticpage.php プロジェクト: arp19690/newtravel
 public function index($page_key = 'about-us')
 {
     $data = array();
     $content_data = $this->redis_functions->get_static_page_content($page_key);
     if (!empty($content_data)) {
         $page_title = stripslashes($content_data->page_title);
         $page_content = stripslashes($content_data->content);
         $input_arr = array(base_url() => 'Home', '#' => $page_title);
         $breadcrumbs = get_breadcrumbs($input_arr);
         $data["content"] = $page_content;
         $data["breadcrumbs"] = $breadcrumbs;
         $data["page_title"] = $page_title;
         $data['meta_title'] = $page_title . " - " . $this->redis_functions->get_site_setting('SITE_NAME');
         $data['meta_description'] = getNWordsFromString($page_content, 50);
         $this->template->write_view("content", "pages/staticpage/static-content", $data);
         $this->template->render();
     } else {
         display_404_page();
     }
 }
コード例 #3
0
ファイル: messages.php プロジェクト: arp19690/newtravel
 public function delete_conversation($other_username)
 {
     if (isset($this->session->userdata["user_id"])) {
         $redis_functions = new Redisfunctions();
         $user_id = $this->session->userdata["user_id"];
         $me_username = $this->session->userdata["user_username"];
         $other_user_records = $redis_functions->get_user_profile_data($other_username);
         if (!empty($other_user_records)) {
             $other_user_id = $other_user_records['user_id'];
             $model = new Common_model();
             $sql = 'SELECT message_id FROM ' . TABLE_MESSAGES . ' WHERE ((message_user_from=' . $other_user_id . ' AND message_user_to=' . $user_id . ') OR (message_user_to=' . $other_user_id . ' AND message_user_from=' . $user_id . '))';
             $chat_records = $model->query($sql);
             if (!empty($chat_records)) {
                 $message_id_arr = array();
                 foreach ($chat_records as $chat_value) {
                     $message_id_arr[] = $chat_value['message_id'];
                 }
                 $redis_functions->set_deleted_message_ids($me_username, $message_id_arr);
                 $this->session->set_flashdata('success', 'Your conversation with ' . stripslashes($other_user_records['user_fullname']) . ' marked as deleted');
             }
         } else {
             $this->session->set_flashdata('error', 'An error occurred. Please try again later.');
         }
         redirect(base_url('my-chats'));
     } else {
         display_404_page();
     }
 }
コード例 #4
0
ファイル: index.php プロジェクト: arp19690/newtravel
 public function facebookAuth($connect = FALSE)
 {
     if ($this->input->get('code')) {
         $this->load->library("SocialLib");
         $model = new Common_model();
         $socialLib = new SocialLib();
         $facebook_user_obj = $socialLib->getFacebookUserObject();
         if ($facebook_user_obj['status'] == 'success') {
             if (!empty($facebook_user_obj['data'])) {
                 $facebook_id = $facebook_user_obj['data']['id'];
                 $facebook_access_token = $facebook_user_obj['accessToken'];
                 if ($connect == FALSE) {
                     if (isset($facebook_user_obj['data']['email'])) {
                         $facebook_name = $facebook_user_obj['data']['name'];
                         $facebook_email = $facebook_user_obj['data']['email'];
                         $is_exists = $model->is_exists('user_password', TABLE_USERS, array('user_email' => $facebook_email, 'user_facebook_id' => $facebook_id));
                         if (empty($is_exists)) {
                             // get user profile picture here
                             $facebook_image_url = getFacebookUserImageSource($facebook_id, NULL, USER_IMG_WIDTH);
                             $new_image_path = USER_IMG_PATH . '/' . getEncryptedString($facebook_id . time()) . '.jpg';
                             copy($facebook_image_url, $new_image_path);
                             $user_password = md5($facebook_id . time());
                             $data_array = array('user_fullname' => addslashes($facebook_name), 'user_email' => $facebook_email, 'user_facebook_id' => $facebook_id, 'user_facebook_accesstoken' => $facebook_access_token, 'user_facebook_array' => json_encode($facebook_user_obj), 'user_created_on' => date('Y-m-d H:i:s'), 'user_ipaddress' => USER_IP, 'user_useragent' => USER_AGENT, 'user_password' => $user_password, 'user_username' => getUniqueUsernameFromEmail($facebook_email), 'user_profile_picture' => $new_image_path);
                             $model->insertData(TABLE_USERS, $data_array);
                             $this->session->set_flashdata('success', 'Welcome aboard, ' . $facebook_name);
                         } else {
                             $user_password = $is_exists[0]['user_password'];
                         }
                         // loggin user in
                         $this->load->library('Login_auth');
                         $login_auth = new Login_auth();
                         $login_auth->login($facebook_email, $user_password, base_url('my-account'), base_url('login'));
                     } else {
                         $this->session->set_flashdata('error', 'Email required when logging in with Facebook');
                         redirect(base_url('login'));
                     }
                 } elseif ($connect == 'connect' && isset($this->session->userdata['user_id'])) {
                     $user_id = $this->session->userdata['user_id'];
                     $next_url = base_url('my-account');
                     $is_exists = $model->is_exists('user_id', TABLE_USERS, array('user_id !=' => $user_id, 'user_facebook_id' => $facebook_id));
                     if (empty($is_exists)) {
                         $data_array = array('user_facebook_id' => $facebook_id, 'user_facebook_accesstoken' => $facebook_access_token, 'user_facebook_array' => json_encode($facebook_user_obj));
                         $model->updateData(TABLE_USERS, $data_array, array('user_id' => $this->session->userdata['user_id']));
                         $this->session->set_flashdata('success', 'Facebook account connected successfully');
                         if ($this->input->get('next')) {
                             $next_url = $this->input->get('next');
                         }
                     } else {
                         $this->session->set_flashdata('error', 'Another user already exists with this Facebook account');
                     }
                     redirect($next_url);
                 }
             } else {
                 $this->session->set_flashdata('error', 'An error occurred. Please try again.');
                 redirect(base_url('login'));
             }
         } else {
             $this->session->set_flashdata('error', $facebook_user_obj['data']);
             redirect(base_url('login'));
         }
     } else {
         display_404_page();
     }
 }
コード例 #5
0
ファイル: payments.php プロジェクト: arp19690/newtravel
 public function paypal_success()
 {
     if ($this->input->get('trip_url_key') && $this->input->get('plan_key') && $this->input->get('id') && $this->input->post()) {
         if ($this->input->post('item_number1') == $this->input->get('trip_url_key')) {
             $user_id = $this->session->userdata['user_id'];
             $user_email = $this->session->userdata['user_email'];
             if ($user_id == getEncryptedString($this->input->get('id'), 'decode')) {
                 $model = new Common_model();
                 $redis_functions = new Redisfunctions();
                 $trip_url_key = $this->input->get('trip_url_key');
                 $featured_plan_key = $this->input->get('plan_key');
                 $post_details = $redis_functions->get_trip_details($trip_url_key);
                 $feature_plan_details = $model->fetchSelectedData('*', TABLE_FEATURED_MASTER, array('pfm_key' => $featured_plan_key));
                 if (!empty($post_details) && !empty($feature_plan_details)) {
                     if ($post_details['post_user_id'] == $user_id) {
                         $paypal_data = $this->input->post();
                         $payment_reference_number = getUniquePaymentReferenceNumber(getEncryptedString($paypal_data['txn_id']));
                         $payment_created_on = date('Y-m-d H:i:s');
                         $data_array = array('payment_reference_number' => $payment_reference_number, 'payment_user_id' => $user_id, 'payment_pfm_id' => $feature_plan_details[0]['pfm_id'], 'payment_post_id' => $post_details['post_id'], 'payment_txn_id' => $paypal_data['txn_id'], 'payment_amount' => $paypal_data['payment_gross'], 'payment_payer_email' => $paypal_data['payer_email'], 'payment_receiver_email' => $paypal_data['receiver_email'], 'payment_status' => '1', 'payment_json' => json_encode($paypal_data), 'payment_created_on' => $payment_created_on);
                         $is_exists = $model->fetchSelectedData('payment_id', TABLE_PAYMENTS, array('payment_post_id' => $post_details['post_id'], 'payment_txn_id' => $paypal_data['txn_id']));
                         if (empty($is_exists)) {
                             $model->insertData(TABLE_PAYMENTS, $data_array);
                             $this->session->set_flashdata('success', 'Payment successful');
                         } else {
                             $this->session->set_flashdata('error', 'Transaction ID already exists');
                             redirect(getTripUrl($trip_url_key));
                         }
                         // Adding post to featured table
                         if ($this->add_post_to_featured($post_details['post_id'], $feature_plan_details[0]['pfm_id']) == FALSE) {
                             $this->session->set_flashdata('error', 'Unauthorized access to post');
                             redirect(getTripUrl($trip_url_key));
                         }
                         // Updating redis table here
                         $redis_functions->set_trip_details($trip_url_key);
                         $redis_functions->set_featured_trips();
                         // Sending invoice email here
                         if (USER_IP != '127.0.0.1') {
                             $invoice_data_array = array('payment_reference_number' => $payment_reference_number, 'payment_created_on' => $payment_created_on, 'payer_user_fullname' => $this->session->userdata['user_fullname'], 'payer_user_email' => $user_email, 'payment_txn_id' => $paypal_data['txn_id'], 'post_title' => $post_details['post_title'], 'pfm_title' => $feature_plan_details['pfm_title'], 'payment_currency' => 'USD', 'payment_amount' => $paypal_data['payment_gross']);
                             $email_model = new Email_model();
                             $invoice_html_data = $email_model->invoice_template($invoice_data_array);
                             $email_model->sendMail($user_email, $invoice_html_data['email_subject'], $invoice_html_data['email_message']);
                         }
                         $page_title = 'Payment confirmed';
                         $input_arr = array(base_url() => 'Home', '#' => $page_title);
                         $breadcrumbs = get_breadcrumbs($input_arr);
                         $data["post_details"] = $post_details;
                         $data["feature_plan_details"] = $feature_plan_details[0];
                         $data["payment_reference_number"] = $payment_reference_number;
                         $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/payments/paypal-success", $data);
                         $this->template->render();
                     } else {
                         $this->session->set_flashdata('error', 'Unauthorized access');
                         display_404_page();
                     }
                 } else {
                     $this->session->set_flashdata('error', 'No such records found');
                     display_404_page();
                 }
             } else {
                 $this->session->set_flashdata('error', 'Invalid request');
                 display_404_page();
             }
         } else {
             $this->session->set_flashdata('error', 'Invalid request');
             display_404_page();
         }
     } else {
         $this->session->set_flashdata('error', 'Invalid request');
         display_404_page();
     }
 }
コード例 #6
0
ファイル: trip.php プロジェクト: arp19690/newtravel
 public function add_to_wishlist($post_url_key)
 {
     if (isset($this->session->userdata['user_id'])) {
         $user_id = $this->session->userdata['user_id'];
         $model = new Common_model();
         $is_owner = $model->fetchSelectedData('post_id', TABLE_POSTS, array('post_user_id' => $user_id, 'post_url_key' => $post_url_key));
         if (!empty($is_owner)) {
             $this->session->set_flashdata('error', 'Sorry, you cannot add your own trip to your wishlist');
         } else {
             $redis_functions = new Redisfunctions();
             $post_details = $redis_functions->get_trip_details($post_url_key);
             $is_exists = $model->fetchSelectedData('wishlist_id', TABLE_WISHLIST, array('wishlist_post_id' => $post_details['post_id'], 'wishlist_user_id' => $user_id, 'wishlist_status' => '1'));
             if (!empty($is_exists)) {
                 $model->updateData(TABLE_WISHLIST, array('wishlist_status' => '0'), array('wishlist_id' => $is_exists[0]['wishlist_id']));
                 $this->session->set_flashdata('error', 'Trip removed from your wishlist');
             } else {
                 $data_array = array('wishlist_user_id' => $user_id, 'wishlist_post_id' => $post_details['post_id'], 'wishlist_created_on' => date('Y-m-d H:i:s'), 'wishlist_ipaddress' => USER_IP, 'wishlist_useragent' => USER_AGENT);
                 $model->insertData(TABLE_WISHLIST, $data_array);
                 $this->session->set_flashdata('success', 'Trip added to your wishlist');
             }
             // updating user redis key
             $redis_functions->set_user_profile_data($this->session->userdata['user_username']);
         }
         redirect(getTripUrl($post_url_key));
     } else {
         display_404_page();
     }
 }