public function sendMail($to_email, $subject, $message) { $redis_functions = new Redisfunctions(); $this->load->library('email'); $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; $this->email->initialize($config); $from_email = $redis_functions->get_site_setting('SITE_EMAIL'); $from_name = $redis_functions->get_site_setting('SITE_NAME'); $this->email->from($from_email, $from_name); $this->email->to($to_email); $this->email->subject($subject); $this->email->message($message); if ($this->email->send()) { $model = new Common_model(); $data_array = array('es_to_email' => $to_email, 'es_subject' => addslashes($subject), 'es_message' => addslashes($message), 'es_from_email' => $from_email, 'es_ipaddress' => USER_IP); return $model->insertData(TABLE_EMAILS_SENT, $data_array); } else { return FALSE; } }
public function updateSitemap() { $this->ci =& get_instance(); $this->ci->load->database(); $this->ci->load->model('Common_model'); // $model = $this->ci->Common_model; $model = new Common_model(); $xml = '<?xml version = "1.0" encoding = "UTF-8"?>' . "\n"; $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n"; $xml .= '<url><loc>' . base_url() . '</loc><lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . '+00:00</lastmod><changefreq>weekly</changefreq><priority>1.00</priority></url>' . "\n"; // all the static links $static_links_without_base_url = array('contact-us', 'about-us', 'how-it-works', 'privacy-policy', 'terms', 'login', 'register', 'forgot-password'); foreach ($static_links_without_base_url as $slKey => $slValue) { $xml .= '<url><loc>' . base_url($slValue) . '</loc><lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . '+00:00</lastmod><changefreq>weekly</changefreq><priority>0.85</priority></url>' . "\n"; } // all the active trips $trip_records = $model->fetchSelectedData('url_key', TABLE_TRIPS, array('trip_status' => '1')); foreach ($trip_records as $trKey => $trValue) { $trip_url = getTripUrl($trValue['url_key']); $xml .= '<url><loc>' . $trip_url . '</loc><lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . '+00:00</lastmod><changefreq>weekly</changefreq><priority>0.85</priority></url>' . "\n"; } // all the active users $user_records = $model->fetchSelectedData('username', TABLE_USERS, array('user_status' => '1')); foreach ($user_records as $urKey => $urValue) { $public_profile_url = getPublicProfileUrl($urValue['username']); $xml .= '<url><loc>' . $public_profile_url . '</loc><lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . '+00:00</lastmod><changefreq>weekly</changefreq><priority>0.85</priority></url>' . "\n"; } // all the active blogs $blog_records = $model->fetchSelectedData('blog_url_key', TABLE_BLOGS, array('blog_status' => '1')); foreach ($blog_records as $brKey => $brValue) { $blog_url = base_url('blog/read/' . $brValue['blog_url_key']); $xml .= '<url><loc>' . $blog_url . '</loc><lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . '+00:00</lastmod><changefreq>weekly</changefreq><priority>0.85</priority></url>' . "\n"; } // all the view photo pages $photo_records = $model->fetchSelectedData('image_name', TABLE_PHOTOS, array('image_name !=' => '', 'album_key !=' => '')); foreach ($photo_records as $prKey => $prValue) { $photo_url = base_url('view/album/' . $prValue['image_name']); $xml .= '<url><loc>' . $photo_url . '</loc><lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . '+00:00</lastmod><changefreq>weekly</changefreq><priority>0.85</priority></url>' . "\n"; } $xml .= '</urlset>'; // prd($xml); $file = fopen(APPPATH . '/../sitemap.xml', 'w'); fwrite($file, $xml); fclose($file); die; }
function __construct() { parent::__construct(); }
public function set_trip_faqs() { $model = new Common_model(); $records = $model->fetchSelectedData('faq_id, faq_question, faq_answer', TABLE_FAQ, array('faq_type' => 'trip', 'faq_status' => '1'), 'faq_order'); $this->ci->redis->set('trip_faqs', json_encode($records)); return $records; }
function __construct() { $this->load->database(); parent::__construct(); }
function getUniquePaymentReferenceNumber($reference_number = NULL) { require_once APPPATH . '/models/common_model.php'; $model = new Common_model(); $reference_number = strtoupper(substr($reference_number, 0, 10)); $is_exists = $model->is_exists('payment_id', TABLE_PAYMENTS, array('payment_reference_number' => $reference_number)); if (!empty($is_exists)) { $reference_number = getUniquePaymentReferenceNumber(rand(100, 99999) . '-' . $reference_number); } return $reference_number; }
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(); } }
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 __construct() { parent::__construct(); $this->table_name = "admin"; }
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')); } }
function __construct() { parent::__construct(); //$this->load->helper(array()); }
public function add_post_to_featured($post_id, $pfm_id) { $model = new Common_model(); $user_id = $this->session->userdata['user_id']; $is_valid = $model->fetchSelectedData('post_id', TABLE_POSTS, array('post_id' => $post_id, 'post_user_id' => $user_id)); if (!empty($is_valid)) { $featured_plan_details = $model->fetchSelectedData('pfm_hours', TABLE_FEATURED_MASTER, array('pfm_id' => $pfm_id)); $featured_hours = $featured_plan_details[0]['pfm_hours']; $start_timestamp = time(); $end_timestamp = $start_timestamp + $featured_hours * 60 * 60; // disabling all the previous featured post for same post id $model->updateData(TABLE_POST_FEATURED, array('pf_status' => '0'), array('pf_post_id' => $post_id)); $data_array = array('pf_post_id' => $post_id, 'pf_start_date' => date('Y-m-d H:i:s', $start_timestamp), 'pf_end_date' => date('Y-m-d H:i:s', $end_timestamp), 'pf_pfm_id' => $pfm_id, 'pf_created_on' => date('Y-m-d H:i:s')); return $model->insertData(TABLE_POST_FEATURED, $data_array); } else { return FALSE; } }
?> <div class="checkout-coll"> <div class="checkout-head"> <div class="chk-left"> <div class="chk-lbl"><p>Increase your reach</p></div> <div class="chk-lbl-a">Reach out to more audience. Choose a plan that suits you best.</div> </div> <div class="chk-right"> </div> <div class="clear"></div> </div> <div class="chk-details"> <div class="chk-detais-row"> <?php $model = new Common_model(); $featured_master_records = $model->fetchSelectedData('*', TABLE_FEATURED_MASTER, array('pfm_status' => '1'), 'pfm_amount'); if (!empty($featured_master_records)) { foreach ($featured_master_records as $key => $value) { $get_featured_url = base_url('trip/get-featured?tkey=' . $post_details['post_url_key'] . '&fkey=' . $value['pfm_key']); ?> <div class="chk-line"> <span class="chk-l"> <a href="<?php echo $get_featured_url; ?> " class="a-no-underline" target="_blank" style="color: #4a90a4;"><?php echo stripslashes($value['pfm_title']); ?> :</a> </span>
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(); } }
/** * 学生考试的paper_id */ public function get_student_exam_paper($uid, $exam_id) { if (empty(self::$_paper_ids[$uid][$exam_id])) { self::$_paper_ids = array(); $sql = "SELECT paper_id FROM rd_exam_test_paper\n\t WHERE exam_id={$exam_id} AND uid={$uid} AND etp_flag=2"; self::$_paper_ids[$uid][$exam_id] = self::$_db->fetchOne($sql); } return self::$_paper_ids[$uid][$exam_id]; }
public function get_user_profile_data($username, $user_fields = NULL) { if ($user_fields == NULL) { $user_fields = 'user_id, user_fullname, user_username, user_email, user_city, user_state, user_country, user_location, user_latitude, user_longitude, user_dob, user_gender, user_relationship_status, user_about, user_tagline, user_profile_picture, user_facebook_id, user_languages_known'; } $model = new Common_model(); $records = $model->fetchSelectedData($user_fields, TABLE_USERS, array('user_username' => $username)); if (!empty($records)) { $records = $records[0]; } // to fetch trips posted by the user $trips_posted_records = $model->fetchSelectedData('post_id, post_url_key, post_published', TABLE_POSTS, array('post_user_id' => $records['user_id']), 'post_id', 'DESC'); $records['trips_posted'] = $trips_posted_records; // to fetch the trips owner has joined $records['trips_joined'] = $this->get_joined_trips($username); // to fetch user's wishlist $wishlist_records = $model->getAllDataFromJoin('post_url_key', TABLE_WISHLIST, array(TABLE_POSTS => 'post_id = wishlist_post_id'), 'LEFT', array('wishlist_status' => '1', 'post_published' => '1', 'wishlist_user_id' => $records['user_id']), 'wishlist_id', 'DESC'); $records['my_wishlist'] = $wishlist_records; return $records; }