function getUserImage($user_id, $facebook_id, $facebook_type = NULL, $width = NULL, $height = NULL) { $fileName = USER_IMG_PATH . "/" . getEncryptedString($user_id) . ".jpg"; if (!is_file($fileName)) { if (!empty($facebook_id)) { $returnValue = getFacebookUserImageSource($facebook_id, $facebook_type, $width, $height); } else { $returnValue = base_url(NO_IMAGE_PATH); } } else { $returnValue = base_url($fileName); } return $returnValue; }
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(); } }
public function get_unread_chats_ajax($other_username_enc, $latest_timestamp) { $json_data = array('status' => 'error', 'message' => 'An error occurred'); if (isset($this->session->userdata["user_id"])) { $custom_model = new Custom_model(); $redis_functions = new Redisfunctions(); $user_id = $this->session->userdata["user_id"]; $other_username = getEncryptedString($other_username_enc, 'decode'); $other_user_records = $redis_functions->get_user_profile_data($other_username); if (!empty($other_user_records)) { $other_user_id = $other_user_records['user_id']; $where_str = 'm1.`message_user_from` = ' . $other_user_id . ' and m1.`message_user_to` = ' . $user_id . ' AND m1.message_timestamp > ' . $latest_timestamp; $chat_records = $custom_model->get_chat_history($user_id, $other_user_id, $fields = NULL, $where_str); $str = $latest_message_timestamp = NULL; if (!empty($chat_records)) { $str = $chat_records; // Marking previous messages as read $latest_message_id = $chat_records[count($chat_records) - 1]['message_id']; $latest_message_timestamp = $chat_records[count($chat_records) - 1]['message_timestamp']; $this->mark_previous_messages_as_read($latest_message_id, $user_id, $other_user_id); } $json_data = array('status' => 'success', 'message' => 'Success', 'data' => $str, 'latest_timestamp' => $latest_message_timestamp); } else { $json_data = array('status' => 'error', 'message' => 'Not a valid choice'); } } $json_data = json_encode($json_data); echo $json_data; return $json_data; }
public function changeProfilePicture() { if (isset($this->session->userdata['user_id']) && !empty($_FILES) && $_FILES['user_img']['size'] > 0 && $_FILES['user_img']['error'] == 0) { $model = new Common_model(); $user_id = $this->session->userdata['user_id']; $user_record = $model->fetchSelectedData('user_profile_picture, user_username', TABLE_USERS, array('user_id' => $user_id)); $user_record = $user_record[0]; $redirect_url = base_url('my-account'); if ($this->input->post('next')) { $redirect_url = $this->input->post('next'); } $source = $_FILES['user_img']['tmp_name']; $destination = USER_IMG_PATH . "/" . getEncryptedString($user_id . time()) . ".jpg"; $this->load->library('SimpleImage'); $simpleImage = new SimpleImage(); $simpleImage->uploadImage($source, $destination, USER_IMG_WIDTH, USER_IMG_HEIGHT); // removing older picture @unlink($user_record['user_profile_picture']); $model->updateData(TABLE_USERS, array('user_profile_picture' => $destination), array('user_id' => $user_id)); $this->session->set_flashdata('success', '<strong>Success!</strong> Your profile picture has been changed'); // updating redis keys now $this->redis_functions->set_user_profile_data($user_record['user_username']); redirect($redirect_url); } else { redirect(base_url('login')); } }
$(document).ready(function () { var new_chat_html = '<div class="h-liked-item"><div class="h-liked-item-i"><div class="h-liked-item-l"><a href="<?php echo base_url('user'); ?> /{{username}}"><img alt="{{fullname}}" src="{{profile_picture}}"></a></div><div class="h-liked-item-c"><div class="h-liked-item-cb"><div class="h-liked-item-p"><div class="h-liked-price"><a href="<?php echo base_url('user'); ?> /{{username}}">{{fullname}}</a></div><div class="h-liked-title">{{message_text}}</div><div class="h-liked-foot"><span class="h-liked-comment">{{message_date_time}}</span></div></div></div><div class="clear"></div></div></div><div class="clear"></div></div>' // Scroll to bottom of the chat scroll_to_bottom('.chat-log'); // Now running AJAX frequecntly to see if any new chats came in setInterval(function () { var other_username_enc = '<?php echo getEncryptedString($_GET['username']); ?> '; var latest_timestamp = $('input.latest_timestamp').val(); get_unread_chats(other_username_enc, latest_timestamp, new_chat_html); }, 1500); // Send message here $('.send-msg-btn').click(function (e) { e.preventDefault(); var message_text = $('.my-message').val(); if (message_text != '') { var to_username = $('.my-message').attr('data-to-username'); send_new_chat(to_username, message_text, new_chat_html); }
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(); } }
public function removeMediaAjax($url_key) { if ($this->input->get('id')) { $pm_id = getEncryptedString($this->input->get('id'), 'decode'); if ($this->removePostMedia($url_key, $pm_id) == TRUE) { $output = array('status' => 'success', 'message' => 'Media successfully removed.'); } else { $output = array('status' => 'error', 'message' => 'An error occurred. Please try again.'); } } else { $output = array('status' => 'error', 'message' => 'Invalid URL or Parameter passed'); } $output = json_encode($output); echo $output; return $output; }
</div> </div> <div class="clear"></div> <div class="booking-devider"></div> </div> </div> <?php // if any media exists then display it below if (isset($post_records['post_media']) == TRUE) { if (!empty($post_records['post_media']) == TRUE) { foreach ($post_records['post_media'] as $media_type => $value) { if (!empty($value)) { foreach ($value as $tmp_key => $tmp_value) { $pm_id_enc = getEncryptedString($tmp_value->pm_id); ?> <div class="region-info" id="media-div-<?php echo $pm_id_enc; ?> "> <div class="booking-form"> <div class="bookin-three-coll"> <div class="booking-form-i"> <label>Title:</label> <div class="input"> <input type="hidden" name="existing_media_id[]" value="<?php echo $pm_id_enc; ?> "/> <input type="text" name="existing_media_title[]" placeholder="Enter Title" value="<?php