Ejemplo n.º 1
0
function link_filter($string)
{
    $CI =& get_instance();
    $CI->load->helper('text');
    $link = new Webboard_bad_word(2);
    $link = explode("\n", $link->badword);
    return word_censor($string, $link, '<span style=display:none;></span>');
}
 public function test_censored_words()
 {
     $censored = array('boob', 'nerd', 'ass', 'fart');
     $strs = array('Ted bobbled the ball' => 'Ted bobbled the ball', 'Jake is a nerdo' => 'Jake is a nerdo', 'The borg will assimilate you' => 'The borg will assimilate you', 'Did Mary Fart?' => 'Did Mary $*#?', 'Jake is really a boob' => 'Jake is really a $*#');
     foreach ($strs as $str => $expect) {
         $this->assertEquals($expect, word_censor($str, $censored, '$*#'));
     }
     // test censored words being sent as a string
     $this->assertEquals('test', word_censor('test', 'test'));
 }
Ejemplo n.º 3
0
 /**
  * Word censor
  */
 public function filter_censored_words($str)
 {
     if ($this->word_censor == FALSE) {
         return $str;
     }
     ee()->load->helper('text');
     return word_censor($str, $this->censored_words, $this->censored_replace);
 }
Ejemplo n.º 4
0
 /**
  * 검색결과
  *
  * @desc 게시판 리스트와 동일 (팝업)
  * @author KangMin
  * @since 2012.02.25
  */
 public function index()
 {
     $this->add_language_pack($this->language_pack('bbs_search'));
     $assign = NULL;
     $this->load->helper('security');
     //search_word
     $assign['search_word'] = xss_clean(str_replace(array('"', "'", '?'), '', trim($this->input->get('search_word'))));
     //따옴표 검색은 필요없겄지..
     //접속자가 검색할 수 있는 조건
     //어차피 검색결과가 리스트니까 리스트권한만
     $allow_bbs_list = array();
     //네이밍이 좀 이상한데 이게 article 테이블용
     if (!defined('USER_INFO_group_idx')) {
         define('USER_INFO_group_idx', 0);
     }
     $this->load->model('bbs_setting_model');
     $bbs_allow_group_view_list = $this->bbs_setting_model->get_bbs_setting_section(array('bbs_allow_group_view_list'));
     foreach ($bbs_allow_group_view_list as $k => $v) {
         $value = unserialize($v->value);
         if (in_array(USER_INFO_group_idx, $value) == TRUE) {
             $allow_bbs_list[] = $v->bbs_idx;
         }
     }
     $allow_bbs_list = array_unique($allow_bbs_list);
     //권한있는 테이블이 없으면
     if (count($allow_bbs_list) < 1) {
         $assign['message'] = lang('deny_allow');
         $assign['redirect'] = '/';
         $this->alert($assign);
     } else {
         if (strlen($assign['search_word']) < 1) {
             $assign['message'] = lang('need_search_word');
             $assign['redirect'] = '/';
             $this->alert($assign);
         } else {
             $this->load->helper('text');
             //욕필터링때문에
             //욕필터링
             //게시판별 모든 욕필터링을 가져와서
             $assign['block_string'] = array();
             $block_string = $this->bbs_setting_model->get_bbs_block_string();
             foreach ($block_string as $k => $v) {
                 $assign['block_string'][$v->bbs_idx] = unserialize($v->value);
             }
             //page
             $assign['page'] = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1;
             $this->load->library('pagination');
             $this->load->model('bbs_article_model');
             $assign['total_cnt'] = $this->bbs_article_model->lists_search_total_cnt($assign['search_word'], $allow_bbs_list, ' AND BBS_ARTICLE.is_deleted = 0 ');
             $this->config->load('pagination');
             $pagination_config = $this->config->item($this->viewport);
             unset($config);
             // http://codeigniter-kr.org/user_guide_2.1.0/libraries/pagination.html
             $config['base_url'] = BASE_URL . 'search?search_word=' . $assign['search_word'];
             $config['enable_query_strings'] = TRUE;
             // ?page=10 이런 일반 get 방식
             $config['page_query_string'] = TRUE;
             $config['use_page_numbers'] = TRUE;
             $config['num_links'] = (int) SETTING_count_page_search;
             $config['query_string_segment'] = 'page';
             $config['total_rows'] = $assign['total_cnt'];
             $config['per_page'] = (int) SETTING_count_list_search;
             $config = array_merge($config, $pagination_config);
             $this->pagination->initialize($config);
             $assign['pagination'] = $this->pagination->create_links();
             //lists
             $assign['lists'] = $this->bbs_article_model->lists_search($assign['search_word'], ($assign['page'] - 1) * $config['per_page'], $config['per_page'], $allow_bbs_list, ' AND BBS_ARTICLE.is_deleted = 0 ');
             foreach ($assign['lists'] as $k => &$v) {
                 $v->print_title = cut_string(word_censor($v->title, $assign['block_string'][$v->bbs_idx]), SETTING_cut_length_title_search);
                 $v->print_name = name($v->user_id, $v->name, $v->nickname);
                 $v->print_insert_date = time2date($v->timestamp_insert);
             }
             $this->scope('contents', 'contents/bbs/search', $assign);
             $this->display('layout');
         }
     }
 }
 public function update()
 {
     $data['posts_id'] = $posts_id = $this->uri->segment(3);
     $data['category'] = $category_id = $this->session->userdata('category');
     $data['sub_category'] = $this->session->userdata('sub_category');
     $where_subcategory = " AND category_id={$data['sub_category']}";
     $data['subcategory'] = $this->common_model->getFieldData('category', 'category_name', $where_subcategory);
     $where_subcategory1 = " AND category_id={$data['category']}";
     $data['category_name'] = $this->common_model->getFieldData('category', 'category_name', $where_subcategory1);
     $data['recaptcha_html'] = $this->recaptcha->recaptcha_get_html();
     if ($this->input->server('REQUEST_METHOD') === 'POST') {
         if (!empty($_POST['auto_repost_price'])) {
             $auto_repost_price = $_POST['auto_repost_price'];
         } else {
             $auto_repost_price = "0";
         }
         $tot = $_POST['total'] + $auto_repost_price;
         $parent_id = $_POST['parent_id'];
         $id = $_POST['posts_id'];
         $this->recaptcha->recaptcha_check_answer();
         $this->form_validation->set_rules('title', 'title', 'required|max_length[150]');
         $this->form_validation->set_rules('description', 'description', 'required');
         $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email|matches[confirm_email]');
         $this->form_validation->set_rules('confirm_email', 'Email Address Confirmation', 'required');
         $this->form_validation->set_rules('recaptcha_response_field', 'Recaptcha', 'required|callback_check_captcha');
         $this->form_validation->set_message('check_captcha', 'Wrong Recaptcha');
         $where_check_adult = " AND category_id={$parent_id}";
         $check_adult = $this->common_model->getFieldData("category", "is_adult", $where_check_adult);
         if ($check_adult == "YES") {
             $this->form_validation->set_rules('age', 'age', 'required');
         } else {
             $this->form_validation->set_rules('contact_number', 'Contact Number', 'trim|required|numeric|exact_length[10]');
         }
         //if ($parent_id == 2 || $parent_id == 5 || $parent_id == 10 || $parent_id == 8 || $parent_id == 9 || $parent_id == 1) {
         $this->form_validation->set_rules('location', 'location', 'required');
         //}
         $this->form_validation->set_error_delimiters('<div class="alert alert-error"><a class="close" data-dismiss="alert">&#215;</a><strong>', '</strong></div>');
         //if the form has passed through the validation
         if ($this->form_validation->run() && $this->recaptcha->getIsValid()) {
             $path = './uploads/images';
             $this->load->library('upload');
             $this->upload->initialize(array("upload_path" => $path, "allowed_types" => "*"));
             $data = $this->functions->do_upload_video('video');
             if (isset($data['upload_data'])) {
                 $video_name = $data['upload_data']['file_name'];
                 $_POST['video'] = $video_name;
                 @unlink("./uploads/video" . $this->input->post('old_video'));
             } else {
                 $video_name = $this->input->post('old_vedio');
                 $_POST['video'] = $video_name;
             }
             $old_image1 = $this->input->post('old_image1');
             $old_image2 = $this->input->post('old_image2');
             $old_image3 = $this->input->post('old_image3');
             $old_image4 = $this->input->post('old_image4');
             $old_image5 = $this->input->post('old_image5');
             $old_image6 = $this->input->post('old_image6');
             $old_image7 = $this->input->post('old_image7');
             $old_image8 = $this->input->post('old_image8');
             $old_image9 = $this->input->post('old_image9');
             $old_image10 = $this->input->post('old_image10');
             $old_image11 = $this->input->post('old_image11');
             $old_image12 = $this->input->post('old_image12');
             if ($_FILES['image1']['error'] != '4') {
                 $data = $this->functions->do_upload('image1', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 200, 'height' => 100);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image1'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image1'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image1'));
                 } else {
                     $file_name = $this->input->post('old_image1');
                     $_POST['image1'] = $file_name;
                 }
             } else {
                 if (isset($old_image1)) {
                     $_POST['image1'] = $old_image1;
                 }
             }
             if ($_FILES['image2']['error'] != '4') {
                 $data = $this->functions->do_upload('image2', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image2'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image2'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image2'));
                 } else {
                     $file_name = $this->input->post('old_image2');
                     $_POST['image2'] = $file_name;
                 }
             } else {
                 if (isset($old_image2)) {
                     $_POST['image2'] = $old_image2;
                 }
             }
             if ($_FILES['image3']['error'] != '4') {
                 $data = $this->functions->do_upload('image3', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image3'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image3'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image3'));
                 } else {
                     $file_name = $this->input->post('old_image3');
                     $_POST['image3'] = $file_name;
                 }
             } else {
                 if (isset($old_image3)) {
                     $_POST['image3'] = $old_image3;
                 }
             }
             if ($_FILES['image4']['error'] != '4') {
                 $data = $this->functions->do_upload('image4', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 200, 'height' => 100);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image4'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image4'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image4'));
                 } else {
                     $file_name = $this->input->post('old_image4');
                     $_POST['image4'] = $file_name;
                 }
             } else {
                 if (isset($old_image4)) {
                     $_POST['image4'] = $old_image4;
                 }
             }
             if ($_FILES['image5']['error'] != '4') {
                 $data = $this->functions->do_upload('image5', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image5'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image5'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image5'));
                 } else {
                     $file_name = $this->input->post('old_image5');
                     $_POST['image5'] = $file_name;
                 }
             } else {
                 if (isset($old_image5)) {
                     $_POST['image5'] = $old_image5;
                 }
             }
             if ($_FILES['image6']['error'] != '4') {
                 $data = $this->functions->do_upload('image6', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image6'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image6'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image6'));
                 } else {
                     $file_name = $this->input->post('old_image6');
                     $_POST['image6'] = $file_name;
                 }
             } else {
                 if (isset($old_image6)) {
                     $_POST['image6'] = $old_image6;
                 }
             }
             if ($_FILES['image7']['error'] != '4') {
                 $data = $this->functions->do_upload('image7', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image7'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image7'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image7'));
                 } else {
                     $file_name = $this->input->post('old_image7');
                     $_POST['image7'] = $file_name;
                 }
             } else {
                 if (isset($old_image7)) {
                     $_POST['image7'] = $old_image7;
                 }
             }
             if ($_FILES['image8']['error'] != '4') {
                 $data = $this->functions->do_upload('image8', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image8'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image8'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image8'));
                 } else {
                     $file_name = $this->input->post('old_image8');
                     $_POST['image8'] = $file_name;
                 }
             } else {
                 if (isset($old_image8)) {
                     $_POST['image8'] = $old_image8;
                 }
             }
             if ($_FILES['image9']['error'] != '4') {
                 $data = $this->functions->do_upload('image9', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image9'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image9'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image9'));
                 } else {
                     $file_name = $this->input->post('old_image9');
                     $_POST['image9'] = $file_name;
                 }
             } else {
                 if (isset($old_image9)) {
                     $_POST['image9'] = $old_image9;
                 }
             }
             if ($_FILES['image10']['error'] != '4') {
                 $data = $this->functions->do_upload('image10', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image10'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image10'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image10'));
                 } else {
                     $file_name = $this->input->post('old_image10');
                     $_POST['image10'] = $file_name;
                 }
             } else {
                 if (isset($old_image10)) {
                     $_POST['image10'] = $old_image10;
                 }
             }
             if ($_FILES['image11']['error'] != '4') {
                 $data = $this->functions->do_upload('image11', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image11'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image11'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image11'));
                 } else {
                     $file_name = $this->input->post('old_image11');
                     $_POST['image11'] = $file_name;
                 }
             } else {
                 if (isset($old_image11)) {
                     $_POST['image11'] = $old_image11;
                 }
             }
             if ($_FILES['image12']['error'] != '4') {
                 $data = $this->functions->do_upload('image12', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image12'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image12'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image12'));
                 } else {
                     $file_name = $this->input->post('old_image12');
                     $_POST['image12'] = $file_name;
                 }
             } else {
                 if (isset($old_image12)) {
                     $_POST['image12'] = $old_image12;
                 }
             }
             if ($parent_id == 5) {
                 $work_status = implode(",", $_POST['work_status']);
                 $shift = implode(",", $_POST['shift']);
                 $_POST['work_status'] = $work_status;
                 $_POST['shift'] = $shift;
             }
             if ($this->session->userdata('user_id')) {
                 $user_id = $this->session->userdata('user_id');
             } else {
                 $user_id = "0";
             }
             $disallowed = array('sex', 'greek', 'suck', 'f**k', 'anal');
             if (!empty($_POST['title'])) {
                 $title = word_censor($_POST['title'], $disallowed);
                 $tit = base64_encode(serialize($title));
             } else {
                 $tit = "";
             }
             if (!empty($_POST['location'])) {
                 $location = word_censor($_POST['location'], $disallowed);
             } else {
                 $location = "";
             }
             if (!empty($_POST['description'])) {
                 $description = word_censor($_POST['description'], $disallowed);
                 $descr = base64_encode(serialize($description));
             } else {
                 $descr = "";
             }
             if (!empty($_POST['address'])) {
                 $address = word_censor($_POST['address'], $disallowed);
             } else {
                 $address = "";
             }
             $data_to_store = array('uid' => $user_id, 'category' => isset($_POST['category_id']) ? $_POST['category_id'] : "", 'subcategory' => isset($_POST['sub_category_id']) ? $_POST['sub_category_id'] : "", 'country' => isset($_POST['country']) ? $_POST['country'] : "", 'state' => isset($_POST['state']) ? $_POST['state'] : "", 'city' => isset($_POST['city']) ? $_POST['city'] : "", 'title' => isset($tit) ? $tit : "", 'location' => isset($location) ? $location : "", 'description' => isset($descr) ? $descr : "", 'address' => isset($address) ? $address : "", 'salary' => isset($_POST['salary']) ? $_POST['salary'] : "", 'education' => isset($_POST['education']) ? $_POST['education'] : "", 'work_status' => isset($_POST['work_status']) ? $_POST['work_status'] : "", 'shift' => isset($_POST['shift']) ? $_POST['shift'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'email' => isset($_POST['email']) ? $_POST['email'] : "", 'contact_number' => isset($_POST['contact_number']) ? $_POST['contact_number'] : "", 'inquery' => isset($_POST['inquery']) ? $_POST['inquery'] : "", 'show_ad_links' => isset($_POST['show_ad_links']) ? $_POST['show_ad_links'] : "", 'show_joined_date' => isset($_POST['show_joined_date']) ? $_POST['show_joined_date'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'auto_repost_ad' => isset($_POST['auto_repost_ad']) ? $_POST['auto_repost_ad'] : "", 'auto_repost_day' => isset($_POST['auto_repost_day']) ? $_POST['auto_repost_day'] : "", 'auto_repost_time' => isset($_POST['auto_repost_time']) ? $_POST['auto_repost_time'] : "", 'auto_repost_no_of_time' => isset($_POST['auto_repost_no_of_time']) ? $_POST['auto_repost_no_of_time'] : "", 'auto_repost_price' => isset($_POST['auto_repost_price']) ? $_POST['auto_repost_price'] : "", 'promotions_sponsor_ad' => isset($_POST['promotions_sponsor_ad']) ? $_POST['promotions_sponsor_ad'] : "", 'pets' => isset($_POST['pets']) ? $_POST['pets'] : "", 'fees_paid_by' => isset($_POST['fees_paid_by']) ? $_POST['fees_paid_by'] : "", 'ad_placed_by' => isset($_POST['ad_placed_by']) ? $_POST['ad_placed_by'] : "", 'age' => isset($_POST['age']) ? $_POST['age'] : "", 'selling_price' => isset($_POST['selling_price']) ? $_POST['selling_price'] : "", 'bedrooms' => isset($_POST['bedrooms']) ? $_POST['bedrooms'] : "", 'price' => isset($_POST['price']) ? $_POST['price'] : "", 'total' => isset($tot) ? $tot : "", 'date' => date('Y-m-d H:i:s'), 'video' => isset($_POST['video']) ? $_POST['video'] : "", 'image1' => isset($_POST['image1']) ? $_POST['image1'] : "", 'image2' => isset($_POST['image2']) ? $_POST['image2'] : "", 'image3' => isset($_POST['image3']) ? $_POST['image3'] : "", 'image4' => isset($_POST['image4']) ? $_POST['image4'] : "", 'image5' => isset($_POST['image5']) ? $_POST['image5'] : "", 'image6' => isset($_POST['image6']) ? $_POST['image6'] : "", 'image7' => isset($_POST['image7']) ? $_POST['image7'] : "", 'image8' => isset($_POST['image8']) ? $_POST['image8'] : "", 'image9' => isset($_POST['image9']) ? $_POST['image9'] : "", 'image10' => isset($_POST['image10']) ? $_POST['image10'] : "", 'image11' => isset($_POST['image11']) ? $_POST['image11'] : "", 'image12' => isset($_POST['image12']) ? $_POST['image12'] : "");
             if ($this->post_national_ads_model->update_post_national_ads($id, $data_to_store) == TRUE) {
                 $this->session->set_flashdata('flash_message', 'updated');
                 // redirect("post_national_ads/preview_ad/$id");
                 redirect("post_national_ads/preview_ad/{$id}");
             } else {
                 if (!$this->recaptcha->getIsValid()) {
                     $this->session->set_flashdata('flash_message', 'Wrong captcha');
                     $this->session->set_flashdata('flash_class', 'alert-error');
                 } else {
                     $this->session->set_flashdata('flash_message', 'add Successfully');
                     $this->session->set_flashdata('flash_class', 'alert-error');
                 }
                 $data['flash_message'] = FALSE;
             }
             //}
         }
     }
     $data['post_national_ads_details'] = $this->post_national_ads_model->get_post_national_ads_by_id($posts_id);
     $data['main_content'] = 'post_national_ads_edit_view';
     $this->load->view('includes/template', $data);
 }
 /**
  * Update item by his id
  * @return void
  */
 public function update()
 {
     //product id
     $id = $this->uri->segment(4);
     //if save button was clicked, get the data sent via post
     if ($this->input->server('REQUEST_METHOD') === 'POST') {
         $parent_id = $_POST['category'];
         $this->form_validation->set_rules('country', 'country', 'required');
         $this->form_validation->set_rules('category', 'Main Category', 'required');
         $this->form_validation->set_rules('location', 'location', 'required');
         $this->form_validation->set_rules('title', 'title', 'required|max_length[150]');
         $this->form_validation->set_rules('description', 'description', 'required');
         $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email|matches[confirm_email]');
         $this->form_validation->set_rules('confirm_email', 'Email Address Confirmation', 'required');
         // $this->form_validation->set_rules('contact_number', 'Contact Number', 'trim|required|numeric|exact_length[10]');
         if ($parent_id == 4 || $parent_id == 11) {
             $this->form_validation->set_rules('age', 'age', 'required');
             $this->age_check($_POST['age']);
             $this->form_validation->set_rules('age', '', 'callback_age_check');
             $this->form_validation->set_message('age_check', 'Sorry, the ad poster must be over 18 years of age.');
         }
         if (isset($_POST['featured_ad'])) {
             if (isset($_POST['featured_ad_week_price'])) {
                 $this->form_validation->set_rules('featured_ad_week_price', 'Featured Ad Week Price', 'required');
                 $this->check_default($_POST['featured_ad_week_price']);
                 $this->form_validation->set_rules('featured_ad_week_price', '', 'callback_check_default');
                 $this->form_validation->set_message('check_default', 'Please add upgrades to have a minimum purchase of 0.99');
             }
         }
         $this->form_validation->set_error_delimiters('<div class="alert alert-error"><a class="close" data-dismiss="alert">&#215;</a><strong>', '</strong></div>');
         if ($this->form_validation->run()) {
             $path = './upload/post_ads';
             $this->upload->initialize(array("upload_path" => $path, "allowed_types" => "*"));
             $old_image1 = $this->input->post('old_image1');
             $old_image2 = $this->input->post('old_image2');
             $old_image3 = $this->input->post('old_image3');
             $old_image4 = $this->input->post('old_image4');
             $old_image5 = $this->input->post('old_image5');
             $old_image6 = $this->input->post('old_image6');
             $old_image7 = $this->input->post('old_image7');
             $old_image8 = $this->input->post('old_image8');
             $old_image9 = $this->input->post('old_image9');
             $old_image10 = $this->input->post('old_image10');
             $old_image11 = $this->input->post('old_image11');
             $old_image12 = $this->input->post('old_image12');
             if ($_FILES['image1']['error'] != '4') {
                 $data = $this->functions->do_upload('image1', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image1'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image1'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image1'));
                 } else {
                     $file_name = $this->input->post('old_image1');
                     $_POST['image1'] = $file_name;
                 }
             } else {
                 if (isset($old_image1)) {
                     $_POST['image1'] = $old_image1;
                 }
             }
             if ($_FILES['image2']['error'] != '4') {
                 $data = $this->functions->do_upload('image2', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image2'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image2'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image2'));
                 } else {
                     $file_name = $this->input->post('old_image2');
                     $_POST['image2'] = $file_name;
                 }
             } else {
                 if (isset($old_image2)) {
                     $_POST['image2'] = $old_image2;
                 }
             }
             if ($_FILES['image3']['error'] != '4') {
                 $data = $this->functions->do_upload('image3', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image3'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image3'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image3'));
                 } else {
                     $file_name = $this->input->post('old_image3');
                     $_POST['image3'] = $file_name;
                 }
             } else {
                 if (isset($old_image3)) {
                     $_POST['image3'] = $old_image3;
                 }
             }
             if ($_FILES['image4']['error'] != '4') {
                 $data = $this->functions->do_upload('image4', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image4'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image4'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image4'));
                 } else {
                     $file_name = $this->input->post('old_image4');
                     $_POST['image4'] = $file_name;
                 }
             } else {
                 if (isset($old_image4)) {
                     $_POST['image4'] = $old_image4;
                 }
             }
             if ($_FILES['image5']['error'] != '4') {
                 $data = $this->functions->do_upload('image5', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image5'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image5'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image5'));
                 } else {
                     $file_name = $this->input->post('old_image5');
                     $_POST['image5'] = $file_name;
                 }
             } else {
                 if (isset($old_image5)) {
                     $_POST['image5'] = $old_image5;
                 }
             }
             if ($_FILES['image6']['error'] != '4') {
                 $data = $this->functions->do_upload('image6', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image6'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image6'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image6'));
                 } else {
                     $file_name = $this->input->post('old_image6');
                     $_POST['image6'] = $file_name;
                 }
             } else {
                 if (isset($old_image6)) {
                     $_POST['image6'] = $old_image6;
                 }
             }
             if ($_FILES['image7']['error'] != '4') {
                 $data = $this->functions->do_upload('image7', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image7'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image7'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image7'));
                 } else {
                     $file_name = $this->input->post('old_image7');
                     $_POST['image7'] = $file_name;
                 }
             } else {
                 if (isset($old_image7)) {
                     $_POST['image7'] = $old_image7;
                 }
             }
             if ($_FILES['image8']['error'] != '4') {
                 $data = $this->functions->do_upload('image8', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image8'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image8'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image8'));
                 } else {
                     $file_name = $this->input->post('old_image8');
                     $_POST['image8'] = $file_name;
                 }
             } else {
                 if (isset($old_image8)) {
                     $_POST['image8'] = $old_image8;
                 }
             }
             if ($_FILES['image9']['error'] != '4') {
                 $data = $this->functions->do_upload('image9', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image9'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image9'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image9'));
                 } else {
                     $file_name = $this->input->post('old_image9');
                     $_POST['image9'] = $file_name;
                 }
             } else {
                 if (isset($old_image9)) {
                     $_POST['image9'] = $old_image9;
                 }
             }
             if ($_FILES['image10']['error'] != '4') {
                 $data = $this->functions->do_upload('image10', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image10'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image10'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image10'));
                 } else {
                     $file_name = $this->input->post('old_image10');
                     $_POST['image10'] = $file_name;
                 }
             } else {
                 if (isset($old_image10)) {
                     $_POST['image10'] = $old_image10;
                 }
             }
             if ($_FILES['image11']['error'] != '4') {
                 $data = $this->functions->do_upload('image11', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image11'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image11'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image11'));
                 } else {
                     $file_name = $this->input->post('old_image11');
                     $_POST['image11'] = $file_name;
                 }
             } else {
                 if (isset($old_image11)) {
                     $_POST['image11'] = $old_image11;
                 }
             }
             if ($_FILES['image12']['error'] != '4') {
                 $data = $this->functions->do_upload('image12', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name = $data['upload_data']['file_name'];
                     $_POST['image12'] = $file_name;
                     @unlink("./uploads/post_ads/thumb" . $this->input->post('old_image12'));
                     @unlink("./uploads/post_ads/" . $this->input->post('old_image12'));
                 } else {
                     $file_name = $this->input->post('old_image12');
                     $_POST['image12'] = $file_name;
                 }
             } else {
                 if (isset($old_image12)) {
                     $_POST['image12'] = $old_image12;
                 }
             }
             //if the insert has returned true then we show the flash message
             $redirect_url = $this->input->post('redirect_url');
             foreach ($_POST as $k => $v) {
                 if (in_array($k, array('redirect_url'))) {
                     unset($_POST[$k]);
                 }
             }
             if (!empty($_POST['work_status'])) {
                 $work_status = implode(",", $_POST['work_status']);
                 $shift = implode(",", $_POST['shift']);
                 $_POST['work_status'] = $work_status;
                 $_POST['shift'] = $shift;
             }
             if ($this->session->userdata('user_id')) {
                 $user_id = $this->session->userdata('user_id');
             } else {
                 $user_id = "0";
             }
             $disallowed = array('sex', 'greek', 'suck', 'f**k', 'anal');
             if (!empty($_POST['title'])) {
                 $title = word_censor($_POST['title'], $disallowed);
                 $tit = base64_encode(serialize($title));
             } else {
                 $tit = "";
             }
             if (!empty($_POST['location'])) {
                 $location = word_censor($_POST['location'], $disallowed);
             } else {
                 $location = "";
             }
             if (!empty($_POST['description'])) {
                 $description = word_censor($_POST['description'], $disallowed);
                 $descr = base64_encode(serialize($description));
             } else {
                 $descr = "";
             }
             if (!empty($_POST['address'])) {
                 $address = word_censor($_POST['address'], $disallowed);
             } else {
                 $address = "";
             }
             if (isset($_POST['featured_ad']) || isset($_POST['auto_repost_ad'])) {
                 if (isset($_POST['auto_repost_price'])) {
                     $auto_repost_price = $_POST['auto_repost_price'];
                 } else {
                     $auto_repost_price = 0;
                 }
                 if (isset($_POST['featured_ad_week_price'])) {
                     $featured_ad_week_price = $_POST['featured_ad_week_price'];
                 } else {
                     $featured_ad_week_price = 0;
                 }
                 $total = $auto_repost_price + $featured_ad_week_price;
             }
             $date = date('Y-m-d H:i:s');
             $currentDate = strtotime($date);
             //after 5 minute store in database
             //$futureDate = $currentDate + (60 * 5);
             //end 5 minute code
             $futureDate = $currentDate;
             $formatDate = date("Y-m-d H:i:s", $futureDate);
             $today_date = new DateTime(date('Y-m-d'));
             //                $exp_data = date_add($today_date, new DateInterval('P36D'));
             $res = date('Y-m-d', strtotime('1 week', strtotime($date)));
             $max_value = $this->home_model->get_maximum_value();
             $update_max_val = $max_value + 1;
             $adsType = 'paid';
             $payment_status = 'complete';
             $data_to_store = array('uid' => $user_id, 'ads_type' => $adsType, 'category' => isset($_POST['category']) ? $_POST['category'] : "", 'subcategory' => isset($_POST['subcategory']) ? $_POST['subcategory'] : "", 'country' => isset($_POST['country']) ? $_POST['country'] : "", 'state' => isset($_POST['state']) ? $_POST['state'] : "", 'city' => isset($_POST['city']) ? $_POST['city'] : "", 'title' => isset($tit) ? $tit : "", 'location' => isset($location) ? $location : "", 'description' => isset($descr) ? $descr : "", 'address' => isset($address) ? $address : "", 'salary' => isset($_POST['salary']) ? $_POST['salary'] : "", 'education' => isset($_POST['education']) ? $_POST['education'] : "", 'work_status' => isset($_POST['work_status']) ? $_POST['work_status'] : "", 'shift' => isset($_POST['shift']) ? $_POST['shift'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'email' => isset($_POST['email']) ? $_POST['email'] : "", 'inquery' => isset($_POST['inquery']) ? $_POST['inquery'] : "", 'show_ad_links' => isset($_POST['show_ad_links']) ? $_POST['show_ad_links'] : "", 'show_joined_date' => isset($_POST['show_joined_date']) ? $_POST['show_joined_date'] : "", 'auto_repost_ad' => isset($_POST['auto_repost_ad']) ? $_POST['auto_repost_ad'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'auto_repost_ad' => isset($_POST['auto_repost_ad']) ? $_POST['auto_repost_ad'] : "", 'auto_repost_day' => isset($_POST['auto_repost_day']) ? $_POST['auto_repost_day'] : "", 'auto_repost_time' => isset($_POST['auto_repost_time']) ? $_POST['auto_repost_time'] : "", 'auto_repost_no_of_time' => isset($_POST['auto_repost_no_of_time']) ? $_POST['auto_repost_no_of_time'] : "", 'auto_repost_price' => isset($_POST['auto_repost_price']) ? $_POST['auto_repost_price'] : "", 'featured_ad' => isset($_POST['featured_ad']) ? $_POST['featured_ad'] : "", 'featured_ad_week_price' => isset($_POST['featured_ad_week_price']) ? $_POST['featured_ad_week_price'] : "", 'featured_ad_week' => isset($_POST['featured_ad_week']) ? $_POST['featured_ad_week'] : "", 'total' => isset($total) ? $total : "", 'video' => isset($_POST['video']) ? $_POST['video'] : "", 'image1' => isset($_POST['image1']) ? $_POST['image1'] : "", 'image2' => isset($_POST['image2']) ? $_POST['image2'] : "", 'image3' => isset($_POST['image3']) ? $_POST['image3'] : "", 'image4' => isset($_POST['image4']) ? $_POST['image4'] : "", 'image5' => isset($_POST['image5']) ? $_POST['image5'] : "", 'image6' => isset($_POST['image6']) ? $_POST['image6'] : "", 'image7' => isset($_POST['image7']) ? $_POST['image7'] : "", 'image8' => isset($_POST['image8']) ? $_POST['image8'] : "", 'image9' => isset($_POST['image9']) ? $_POST['image9'] : "", 'image10' => isset($_POST['image10']) ? $_POST['image10'] : "", 'image11' => isset($_POST['image11']) ? $_POST['image11'] : "", 'image12' => isset($_POST['image12']) ? $_POST['image12'] : "", 'promotions_sponsor_ad' => isset($_POST['promotions_sponsor_ad']) ? $_POST['promotions_sponsor_ad'] : "", 'pets' => isset($_POST['pets']) ? $_POST['pets'] : "", 'fees_paid_by' => isset($_POST['fees_paid_by']) ? $_POST['fees_paid_by'] : "", 'ad_placed_by' => isset($_POST['ad_placed_by']) ? $_POST['ad_placed_by'] : "", 'age' => isset($_POST['age']) ? $_POST['age'] : "", 'selling_price' => isset($_POST['selling_price']) ? $_POST['selling_price'] : "", 'bedrooms' => isset($_POST['bedrooms']) ? $_POST['bedrooms'] : "", 'price' => isset($_POST['price']) ? $_POST['price'] : "", 'post_ads_type' => "single", 'date' => $formatDate, 'expire_date' => $res, 'payment_status' => $payment_status, 'status' => 'Active', 'move_to_ad' => $update_max_val);
             if ($this->posts_model->update_posts($id, $data_to_store) == TRUE) {
                 $this->session->set_flashdata('flash_message', 'updated');
             } else {
                 $this->session->set_flashdata('flash_message', 'not_updated');
             }
             $this->session->set_flashdata('flash_message', 'update');
             redirect($redirect_url);
         }
         //validation run
     }
     //if we are updating, and the data did not pass trough the validation
     //the code below wel reload the current data
     //product data
     $where = " AND parent_id= '0' ";
     $data['main_category_opt'] = $this->common_model->getDDArray('category', 'category_id', 'category_name_en', $where);
     $data['country_opt'] = $this->common_model->getDDArray('country', 'country_id', 'country_name');
     $data['posts'] = $this->posts_model->get_posts_by_id($id);
     if ($data['posts'][0]['country'] != "") {
         $data['state_opt'] = $this->common_model->getDDArray('state', 'state_id', 'state_name', " AND country_id='{$data['posts'][0]['country']}'");
     }
     if ($data['posts'][0]['state'] != "") {
         //echo "hiiii"; die;
         $data['city_opt'] = $this->common_model->getDDArray('city', 'city_id', 'city_name', " AND state_id='{$data['posts'][0]['state']}'");
     }
     if ($data['posts'][0]['category'] != "") {
         $where_subcategory = " AND parent_id!= '0' AND parent_id='{$data['posts'][0]['category']}'";
         $data['subcategory_opt'] = $this->common_model->getDDArray('category', 'category_id', 'category_name_en', $where_subcategory);
     }
     $data['main_content'] = 'admin/posts/edit';
     $this->load->view('admin/includes/template', $data);
 }
Ejemplo n.º 7
0
    /**
     * RSS
     *
     * @author KangMin
     * @since  2012.01.24
     */
    public function rss()
    {
        $data = NULL;
        $data['bbs_id'] = $this->bbs_id;
        //권한
        $data['allow'] = $this->get_bbs_allow();
        $this->load->helper('text');
        //욕필터링때문에
        //욕필터링
        $data['block_string'] = array();
        if (BBS_SETTING_bbs_block_string_used == 1) {
            $data['block_string'] = unserialize(BBS_SETTING_bbs_block_string);
        }
        //리스트,뷰 둘다 비회원권한 있는 게시판만
        if ($this->get_rss_allow() == TRUE && BBS_SETTING_bbs_rss_used == 1) {
            $this->load->model('bbs_article_model');
            $data['rss'] = $this->bbs_article_model->lists($this->bbs_idx, 0, (int) BBS_SETTING_bbs_count_list_article, ' AND BBS_ARTICLE.is_deleted = 0 ');
            //$this->load->view('bbs/rss_view', $data);
            header("Content-Type: text/xml; charset=UTF-8;");
            echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
            echo '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">';
            echo '<channel>';
            echo '<title>' . SETTING_browser_title_fix_value . ' - ' . BBS_SETTING_bbs_name . '</title>';
            echo '<link>' . BASE_URL . 'bbs/lists/' . $data['bbs_id'] . '</link>';
            echo '<language>ko</language>';
            echo '<generator>TapBBS</generator>';
            echo '<copyright>' . BASE_URL . '</copyright>';
            foreach ($data['rss'] as $k => $v) {
                ?>
                <item>
                    <title><?php 
                echo word_censor(strip_tags(htmlspecialchars_decode($v->title)), $data['block_string']);
                ?>
</title>
                    <link><?php 
                echo base_url();
                ?>
bbs/view/<?php 
                echo $data['bbs_id'];
                ?>
?idx=<?php 
                echo $v->idx;
                ?>
</link>
                    <description><?php 
                echo htmlspecialchars(nl2br(word_censor(strip_tags(htmlspecialchars_decode($v->contents)), $data['block_string'])));
                ?>
</description>
                    <pubDate><?php 
                echo date('D, d M Y H:i:s O', $v->timestamp_insert);
                ?>
</pubDate>
                    <dc:creator><?php 
                echo name($v->user_id, $v->name, $v->nickname);
                ?>
</dc:creator>
                </item>
                <?php 
            }
            echo '</channel>';
            echo '</rss>';
        }
    }
Ejemplo n.º 8
0
 /**
  * 게시판 최근 게시물 호출
  *
  * @desc 원래 /application/controllers/bbs.php > recently 를 curl을 이용해서 호출했는데, 웹소켓이 동시에 여러개 열리게됨에 따라 변경
  *
  * @author KangMin
  * @since 2012.05.02
  *
  * @param array
  *
  * @return array
  */
 public function recently($req_bbs_ids)
 {
     //배열 아니거나 빈 배열이면 리턴
     if (!is_array($req_bbs_ids) or count($req_bbs_ids) < 1) {
         return FALSE;
     }
     $CI =& get_instance();
     $CI->load->model('bbs_model');
     $bbs_idxs = array();
     $bbs_ids = array();
     //사용중이면서 존재하는지
     $check_bbs_ids = $CI->bbs_model->check_bbs_ids($req_bbs_ids);
     foreach ($check_bbs_ids as $k => $v) {
         $bbs_ids[] = $v->bbs_id;
         $bbs_idxs[] = $v->idx;
     }
     //검증후에 다시 체크
     if (count($bbs_idxs) < 1) {
         return FALSE;
     }
     //해당게시판들의 필요한 설정값 일괄 호출
     $CI->load->model('bbs_setting_model');
     //viewport
     $viewport_field = IS_MOBILE ? '' : '_pc';
     $viewport = IS_MOBILE ? 'mobile' : 'pc';
     $bbs_setting = $CI->bbs_setting_model->get_bbs_setting_section(array('bbs_recently_count' . $viewport_field, 'bbs_block_string_used', 'bbs_block_string', 'bbs_hour_new_icon_used_article', 'bbs_hour_new_icon_path_article', 'bbs_hour_new_icon_value_article', 'bbs_cut_length_recently' . $viewport_field, 'bbs_lists_style' . $viewport_field));
     //설정값 배열 정리
     $bbs_setting_temp = array();
     foreach ($bbs_setting as $k => $v) {
         $bbs_setting_temp[$v->bbs_idx][$v->parameter] = $v->value;
     }
     $bbs_setting = $bbs_setting_temp;
     //캐싱
     $CI->load->driver('cache');
     $CI->load->model('bbs_article_model');
     $CI->load->model('bbs_file_model');
     $CI->load->helper('text');
     //욕필터링때문에
     $lastest_update_time = $CI->bbs_article_model->lastest_update_time();
     foreach ($bbs_idxs as $k => $v) {
         $use_cache = FALSE;
         //캐쉬를 이용여부
         //캐쉬 있으면
         if ($CI->cache->file->get('recently_' . $v . '_' . $viewport)) {
             //캐쉬 생성시각
             $cache_info = $CI->cache->file->get_metadata('recently_' . $v . '_' . $viewport);
             $cache_mtime = $cache_info['mtime'];
             //캐쉬타임이 DB 마지막 업데이트타임보다 작으면 쿼리실행, 아니면 캐쉬이용
             if ($cache_mtime < $lastest_update_time) {
                 $use_cache = FALSE;
             } else {
                 $use_cache = TRUE;
             }
         }
         $use_cache = false;
         if ($use_cache == TRUE) {
             //데이터
             $result[$bbs_ids[$k]] = $CI->cache->file->get('recently_' . $v . '_' . $viewport);
         } else {
             //갯수
             $req_limit = (int) $bbs_setting[$v]['bbs_recently_count' . $viewport_field];
             //욕필터링
             $block_string = array();
             if ($bbs_setting[$v]['bbs_block_string_used'] == 1) {
                 $block_string = unserialize($bbs_setting[$v]['bbs_block_string']);
             }
             //게시판명
             //글이 하나도 없으면 제목도 없어서 표출할 수 없다.
             $data['bbs_name'] = $CI->bbs_model->get_bbs_name($bbs_ids[$k]);
             $data['bbs_lists_style'] = $bbs_setting[$v]['bbs_lists_style' . $viewport_field];
             //lists
             $data['lists'] = $CI->bbs_article_model->lists($v, 0, $req_limit, ' AND BBS_ARTICLE.is_deleted = 0 AND BBS_ARTICLE.is_secret = 0 ', FALSE, TRUE);
             //욕필터링과 다시 정리
             $lists = array();
             $cnt = 0;
             foreach ($data['lists'] as $k2 => $v2) {
                 //새글 아이콘
                 $new_article_icon = '';
                 //사용여부
                 if ($bbs_setting[$v]['bbs_hour_new_icon_used_article'] == 1) {
                     //파일 존재
                     //if(file_exists('.'.$bbs_setting[$v]['bbs_hour_new_icon_path_article']))
                     //{
                     //시간차
                     if ((int) $v2->timestamp_insert >= time() - (int) $bbs_setting[$v]['bbs_hour_new_icon_value_article'] * 60 * 60) {
                         $new_article_icon = $bbs_setting[$v]['bbs_hour_new_icon_path_article'];
                     }
                     //}
                 }
                 $lists[$cnt]['idx'] = $v2->idx;
                 $lists[$cnt]['bbs_id'] = $bbs_ids[$k];
                 $lists[$cnt]['bbs_name'] = $v2->bbs_name;
                 $lists[$cnt]['category_name'] = $v2->category_name;
                 $lists[$cnt]['name'] = name($v2->user_id, $v2->name, $v2->nickname);
                 $lists[$cnt]['title'] = cut_string(word_censor($v2->title, $block_string), $bbs_setting[$v]['bbs_cut_length_recently' . $viewport_field]);
                 $lists[$cnt]['comment_count'] = $v2->comment_count;
                 $lists[$cnt]['vote_count'] = $v2->vote_count;
                 $lists[$cnt]['scrap_count'] = $v2->scrap_count;
                 $lists[$cnt]['timestamp'] = time2date($v2->timestamp_insert);
                 $lists[$cnt]['is_notice'] = $v2->is_notice;
                 $lists[$cnt]['hit'] = $v2->hit;
                 $lists[$cnt]['new_article_icon'] = $new_article_icon;
                 $image = $CI->bbs_file_model->get_image($v2->idx);
                 if ($image) {
                     $thumb_filepath = explode('.', $image[0]->conversion_filename);
                     $thumb_filepath = $thumb_filepath[0] . '_thumb.' . $thumb_filepath[1];
                     if (file_exists($this->upload_path . $thumb_filepath)) {
                         $v2->image = BASE_URL . $this->upload_path . $thumb_filepath;
                     } else {
                         if (file_exists($this->upload_path . $image[0]->conversion_filename)) {
                             $v2->image = BASE_URL . $this->upload_path . $image[0]->conversion_filename;
                         } else {
                             $v2->image = FRONTEND . 'img/noimage.gif';
                         }
                     }
                 } else {
                     $v2->image = FRONTEND . 'img/noimage.gif';
                 }
                 $lists[$cnt]['image'] = $v2->image;
                 $cnt++;
             }
             $data['lists'] = $lists;
             $result[$bbs_ids[$k]] = json_encode($data);
             //캐쉬저장
             $CI->cache->file->save('recently_' . $v . '_' . $viewport, $result[$bbs_ids[$k]], 60 * 60 * 2);
             //2시간, 설정으로 뺄것까진 없을듯..
         }
     }
     return $result;
 }
Ejemplo n.º 9
0
 /**
  * 인덱스용 최근 하루한마디
  *
  * @author KangMin
  * @since 2012.02.25
  */
 public function recently()
 {
     $data = NULL;
     $json = NULL;
     //원격호출 차단
     //환경에 따라 문제가 될 수 있어서 뺌. 2012.05.02, KangMin
     //if($_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR']) return FALSE;
     //갯수
     //픽스, 악용하여 DB를 죽일수도 있어서...
     //관리자모드는 제공하지 않는 플러그인형태이므로 수작업..
     $req_limit = $this->recently_limit;
     // ((int)$this->input->get_post('limit') > 0) ? (int)$this->input->get_post('limit') : 3;
     $this->load->helper('text');
     //욕필터링때문에
     //욕필터링
     $data['block_string'] = $this->block_string;
     //lists
     $data['lists'] = $this->onedayonememo_model->lists(0, $req_limit, ' AND is_deleted = 0 ');
     //욕필터링과 다시 정리
     $lists = array();
     $cnt = 0;
     foreach ($data['lists'] as $k => $v) {
         //새글 아이콘
         $new_article_icon = '';
         //파일 존재
         //if(file_exists('./IMAGEs/icon/new_article.gif'))
         //{
         //시간차
         //if( (int)$v->timestamp >= time() - (24*60*60) ) //24시간
         if (date('Ymd', strtotime(time2date($v->timestamp))) == date('Ymd', strtotime(time2date(time())))) {
             $new_article_icon = FRONTEND_COMMON . '/img/icon/new_article.gif';
         }
         //}
         $lists[$cnt]['idx'] = $v->idx;
         $lists[$cnt]['name'] = name($v->user_id, $v->name, $v->nickname);
         $lists[$cnt]['contents'] = cut_string(word_censor($v->contents, $data['block_string']), $this->cut_length_recently);
         $lists[$cnt]['timestamp'] = time2date($v->timestamp);
         $lists[$cnt]['new_article_icon'] = $new_article_icon;
         $cnt++;
     }
     $json['lists'] = $lists;
     echo json_encode($json);
 }
Ejemplo n.º 10
0
 public function text_helper()
 {
     $this->load->helper('text');
     $string = "Here is a nice text string consisting of eleven words.";
     $string = word_limiter($string, 4, "...");
     $this->htmlp($string);
     $string = "Here is a nice text string consisting of eleven words.";
     $string = character_limiter($string, 20, "...");
     $this->htmlp($string);
     $string = ascii_to_entities($string);
     $this->htmlp($string);
     $string = convert_accented_characters($string);
     $this->htmlp($string);
     $string = "darn shit sucks dinner";
     $disallowed = array('darn', 'shucks', 'golly', 'phooey');
     $string = word_censor($string, $disallowed, 'Beep!');
     $this->htmlp($string);
     $string = highlight_code($string);
     $this->htmlp($string);
     $string = "Here is a nice text string about nothing in particular.";
     $this->htmlp(highlight_phrase($string, "nice text", '<span style="color:#990000;">', '</span>'));
     $string = "Here is a simple string of text that will help us demonstrate this function.";
     $this->htmlp(word_wrap($string, 25));
     $str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg';
     $this->htmlp(ellipsize($str, 32, 0.5));
 }
 public function add()
 {
     if ($this->input->server('REQUEST_METHOD') === 'POST') {
         if (isset($_POST['featured_ad'])) {
             if (isset($_POST['featured_ad_week_price'])) {
                 $this->form_validation->set_rules('featured_ad_week_price', 'Featured Ad Week Price', 'required');
                 $this->check_default($_POST['featured_ad_week_price']);
                 $this->form_validation->set_rules('featured_ad_week_price', '', 'callback_check_default');
                 $this->form_validation->set_message('check_default', 'Please add upgrades to have a minimum purchase of 0.99');
             }
         }
         if (isset($_POST['auto_repost_ad'])) {
             $this->form_validation->set_rules('auto_repost_no_of_time', 'Auto Repost Number of time', 'required');
             $this->form_validation->set_message('auto_repost_no_of_time', 'Number of time Required');
             $this->form_validation->set_rules('auto_repost_day', 'Auto Repost Day', 'required');
             $this->form_validation->set_rules('auto_repost_time', 'Auto Repost Time', 'required');
         }
         $parent_id = $_POST['parent_id'];
         $this->recaptcha->recaptcha_check_answer();
         $this->form_validation->set_rules('title', 'title', 'required|max_length[150]');
         $this->form_validation->set_rules('description', 'description', 'required');
         $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email|matches[confirm_email]');
         $this->form_validation->set_rules('confirm_email', 'Email Address Confirmation', 'required');
         $this->form_validation->set_rules('recaptcha_response_field', 'Recaptcha', 'required|callback_check_captcha');
         $this->form_validation->set_message('check_captcha', 'Wrong Recaptcha');
         $where_check_adult = " AND category_id={$parent_id}";
         $check_adult = $this->common_model->getFieldData("category", "is_adult", $where_check_adult);
         if ($check_adult == "YES") {
             $this->form_validation->set_rules('age', 'age', 'required');
             $this->age_check($_POST['age']);
             $this->form_validation->set_rules('age', '', 'callback_age_check');
             $this->form_validation->set_message('age_check', 'Sorry, the ad poster must be over 18 years of age.');
         } else {
             $this->form_validation->set_rules('contact_number', 'Contact Number', 'trim|required|numeric|exact_length[10]');
         }
         $this->form_validation->set_rules('location', 'location', 'required');
         $this->form_validation->set_error_delimiters('<div class="alert alert-error"><a class="close" data-dismiss="alert">&#215;</a><strong>', '</strong></div>');
         if ($this->form_validation->run() && $this->recaptcha->getIsValid()) {
             $path = './upload/post_ads';
             $this->upload->initialize(array("upload_path" => $path, "allowed_types" => "*"));
             $data = $this->functions->do_upload_video('video');
             if (isset($data['upload_data'])) {
                 $video = $data['upload_data']['file_name'];
             } else {
                 $video = "";
             }
             if (!empty($_FILES['image1']['name'])) {
                 $data = $this->functions->do_upload('image1', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 if (!$this->image_lib->resize()) {
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name1 = $data['upload_data']['file_name'];
                 } else {
                     $file_name1 = "";
                 }
                 $_POST['image1'] = $file_name1;
             }
             if (!empty($_FILES['image2']['name'])) {
                 $data = $this->functions->do_upload('image2', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 if (!$this->image_lib->resize()) {
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name2 = $data['upload_data']['file_name'];
                 } else {
                     $file_name2 = "";
                 }
                 $_POST['image2'] = $file_name2;
             }
             if (!empty($_FILES['image3']['name'])) {
                 $data = $this->functions->do_upload('image3', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name3 = $data['upload_data']['file_name'];
                 } else {
                     $file_name3 = "";
                 }
                 $_POST['image3'] = $file_name3;
             }
             if (!empty($_FILES['image4']['name'])) {
                 $data = $this->functions->do_upload('image4', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name4 = $data['upload_data']['file_name'];
                 } else {
                     $file_name4 = "";
                 }
                 $_POST['image4'] = $file_name4;
             }
             if (!empty($_FILES['image5']['name'])) {
                 $data = $this->functions->do_upload('image5', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name5 = $data['upload_data']['file_name'];
                 } else {
                     $file_name5 = "";
                 }
                 $_POST['image5'] = $file_name5;
             }
             if (!empty($_FILES['image6']['name'])) {
                 $data = $this->functions->do_upload('image6', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name6 = $data['upload_data']['file_name'];
                 } else {
                     $file_name6 = "";
                 }
                 $_POST['image6'] = $file_name6;
             }
             if (!empty($_FILES['image7']['name'])) {
                 $data = $this->functions->do_upload('image7', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name7 = $data['upload_data']['file_name'];
                 } else {
                     $file_name7 = "";
                 }
                 $_POST['image7'] = $file_name7;
             }
             if (!empty($_FILES['image8']['name'])) {
                 $data = $this->functions->do_upload('image8', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name8 = $data['upload_data']['file_name'];
                 } else {
                     $file_name8 = "";
                 }
                 $_POST['image8'] = $file_name8;
             }
             if (!empty($_FILES['image9']['name'])) {
                 $data = $this->functions->do_upload('image9', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name9 = $data['upload_data']['file_name'];
                 } else {
                     $file_name9 = "";
                 }
                 $_POST['image9'] = $file_name9;
             }
             if (!empty($_FILES['image10']['name'])) {
                 $data = $this->functions->do_upload('image10', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name10 = $data['upload_data']['file_name'];
                 } else {
                     $file_name10 = "";
                 }
                 $_POST['image10'] = $file_name10;
             }
             if (!empty($_FILES['image11']['name'])) {
                 $data = $this->functions->do_upload('image11', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name11 = $data['upload_data']['file_name'];
                 } else {
                     $file_name11 = "";
                 }
                 $_POST['image11'] = $file_name11;
             }
             if (!empty($_FILES['image12']['name'])) {
                 $data = $this->functions->do_upload('image12', './uploads/post_ads');
                 $resize_conf = array('source_image' => $data['upload_data']['full_path'], 'new_image' => $data['upload_data']['file_path'] . 'thumb/' . $data['upload_data']['file_name'], 'width' => 300, 'height' => 200);
                 $this->image_lib->initialize($resize_conf);
                 // do it!
                 if (!$this->image_lib->resize()) {
                     // if got fail.
                     $error['resize'][] = $this->image_lib->display_errors();
                 } else {
                     //echo "hi";exit;
                     // otherwise, put each upload data to an array.
                     $success[] = $data['upload_data'];
                 }
                 if (isset($data['upload_data'])) {
                     $file_name12 = $data['upload_data']['file_name'];
                 } else {
                     $file_name12 = "";
                 }
                 $_POST['image12'] = $file_name12;
             }
             if ($this->session->userdata('user_id')) {
                 $user_id = $this->session->userdata('user_id');
             } else {
                 $user_id = "0";
             }
             if (isset($_POST['work_status'])) {
                 $work_status = implode(",", $_POST['work_status']);
             } else {
                 $work_status = "";
             }
             if (isset($_POST['shift'])) {
                 $shift = implode(",", $_POST['shift']);
             } else {
                 $shift = "";
             }
             $date = date('Y-m-d');
             $currentDate = strtotime($date);
             $futureDate = $currentDate + 60 * 5;
             $formatDate = date("Y-m-d H:i:s", $futureDate);
             $res = date('Y-m-d', strtotime('+30 days', strtotime($date)));
             $city_category_price = isset($_POST['city_category_price']) ? $_POST['city_category_price'] : "";
             if (!empty($city_category_price)) {
                 if (isset($_POST['auto_repost_price'])) {
                     $auto_repost_price = $_POST['auto_repost_price'];
                 } else {
                     $auto_repost_price = 0;
                 }
                 if (isset($_POST['featured_ad_week_price'])) {
                     $featured_ad_week_price = $_POST['featured_ad_week_price'];
                 } else {
                     $featured_ad_week_price = 0;
                 }
                 $tot = $auto_repost_price + $featured_ad_week_price + $city_category_price;
                 if (!empty($_POST['promocode'])) {
                     $promocode_name = $_POST['promocode'];
                     $status = "Active";
                     $promocode = $this->write_add_model->get_promocode($promocode_name, $status);
                     $promocode_value = !empty($promocode[0]['code']) ? $promocode[0]['code'] : "";
                     $promocode_type = !empty($promocode[0]['promotype']) ? $promocode[0]['promotype'] : "";
                     if ($promocode_type == 'amount') {
                         $net_total = $tot - $promocode_value;
                     } else {
                         if ($promocode_type == 'percentage') {
                             $percent_total = $tot * $promocode_value;
                             $percent_value = $percent_total / 100;
                             $net_total = $tot - $percent_value;
                         }
                     }
                 } else {
                     $net_total = $tot;
                 }
                 $disallowed = array('sex', 'greek', 'suck', 'f**k', 'anal');
                 if (!empty($_POST['title'])) {
                     $title = word_censor($_POST['title'], $disallowed);
                     $tit = base64_encode(serialize($title));
                 } else {
                     $tit = "";
                 }
                 if (!empty($_POST['location'])) {
                     $location = word_censor($_POST['location'], $disallowed);
                 } else {
                     $location = "";
                 }
                 if (!empty($_POST['description'])) {
                     $description = word_censor($_POST['description'], $disallowed);
                     $descr = base64_encode(serialize($description));
                 } else {
                     $descr = "";
                 }
                 if (!empty($_POST['address'])) {
                     $address = word_censor($_POST['address'], $disallowed);
                 } else {
                     $address = "";
                 }
                 $adsType = 'paid';
                 $data_to_store = array('uid' => $user_id, 'ads_type' => $adsType, 'category' => isset($_POST['category_id']) ? $_POST['category_id'] : "", 'subcategory' => isset($_POST['sub_category_id']) ? $_POST['sub_category_id'] : "", 'country' => isset($_POST['country']) ? $_POST['country'] : "", 'state' => isset($_POST['state']) ? $_POST['state'] : "", 'city' => isset($_POST['city']) ? $_POST['city'] : "", 'title' => isset($tit) ? $tit : "", 'location' => isset($location) ? $location : "", 'description' => isset($descr) ? $descr : "", 'address' => isset($address) ? $address : "", 'salary' => isset($_POST['salary']) ? $_POST['salary'] : "", 'education' => isset($_POST['education']) ? $_POST['education'] : "", 'work_status' => $work_status, 'shift' => $shift, 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'email' => isset($_POST['email']) ? $_POST['email'] : "", 'contact_number' => isset($_POST['contact_number']) ? $_POST['contact_number'] : "", 'inquery' => isset($_POST['inquery']) ? $_POST['inquery'] : "", 'show_ad_links' => isset($_POST['show_ad_links']) ? $_POST['show_ad_links'] : "", 'show_joined_date' => isset($_POST['show_joined_date']) ? $_POST['show_joined_date'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'auto_repost_ad' => isset($_POST['auto_repost_ad']) ? $_POST['auto_repost_ad'] : "", 'auto_repost_day' => isset($_POST['auto_repost_day']) ? $_POST['auto_repost_day'] : "", 'auto_repost_time' => isset($_POST['auto_repost_time']) ? $_POST['auto_repost_time'] : "", 'auto_repost_no_of_time' => isset($_POST['auto_repost_no_of_time']) ? $_POST['auto_repost_no_of_time'] : "", 'auto_repost_price' => isset($_POST['auto_repost_price']) ? $_POST['auto_repost_price'] : "", 'featured_ad' => isset($_POST['featured_ad']) ? $_POST['featured_ad'] : "", 'featured_ad_week_price' => isset($_POST['featured_ad_week_price']) ? $_POST['featured_ad_week_price'] : "", 'featured_ad_week' => isset($_POST['featured_ad_week']) ? $_POST['featured_ad_week'] : "", 'total' => isset($net_total) ? $net_total : "", 'pets' => isset($_POST['pets']) ? $_POST['pets'] : "", 'fees_paid_by' => isset($_POST['fees_paid_by']) ? $_POST['fees_paid_by'] : "", 'ad_placed_by' => isset($_POST['ad_placed_by']) ? $_POST['ad_placed_by'] : "", 'age' => isset($_POST['age']) ? $_POST['age'] : "", 'selling_price' => isset($_POST['selling_price']) ? $_POST['selling_price'] : "", 'bedrooms' => isset($_POST['bedrooms']) ? $_POST['bedrooms'] : "", 'price' => isset($_POST['price']) ? $_POST['price'] : "", 'date' => $formatDate, 'expire_date' => $res, 'video' => $video, 'image1' => isset($_POST['image1']) ? $_POST['image1'] : "", 'image2' => isset($_POST['image2']) ? $_POST['image2'] : "", 'image3' => isset($_POST['image3']) ? $_POST['image3'] : "", 'image4' => isset($_POST['image4']) ? $_POST['image4'] : "", 'image5' => isset($_POST['image5']) ? $_POST['image5'] : "", 'image6' => isset($_POST['image6']) ? $_POST['image6'] : "", 'image7' => isset($_POST['image7']) ? $_POST['image7'] : "", 'image8' => isset($_POST['image8']) ? $_POST['image8'] : "", 'image9' => isset($_POST['image9']) ? $_POST['image9'] : "", 'image10' => isset($_POST['image10']) ? $_POST['image10'] : "", 'image11' => isset($_POST['image11']) ? $_POST['image11'] : "", 'image12' => isset($_POST['image12']) ? $_POST['image12'] : "", 'post_ads_type' => "single", 'status' => "Inactive");
                 $insert_id = $this->write_add_model->add_temp_post($data_to_store);
                 if ($insert_id) {
                     //$this->session->set_flashdata('flash_message', 'add');
                     redirect("write_add/preview_ad_single_city/{$insert_id}");
                 }
             } else {
                 $disallowed = array('sex', 'greek', 'suck', 'f**k', 'anal');
                 if (!empty($_POST['title'])) {
                     $title = word_censor($_POST['title'], $disallowed);
                     $tit = base64_encode(serialize($title));
                 } else {
                     $tit = "";
                 }
                 if (!empty($_POST['location'])) {
                     $location = word_censor($_POST['location'], $disallowed);
                 } else {
                     $location = "";
                 }
                 if (!empty($_POST['description'])) {
                     $description = word_censor($_POST['description'], $disallowed);
                     $descr = base64_encode(serialize($description));
                 } else {
                     $descr = "";
                 }
                 if (!empty($_POST['address'])) {
                     $address = word_censor($_POST['address'], $disallowed);
                 } else {
                     $address = "";
                 }
                 if (isset($_POST['featured_ad']) || isset($_POST['auto_repost_ad'])) {
                     if (isset($_POST['auto_repost_price'])) {
                         $auto_repost_price = $_POST['auto_repost_price'];
                     } else {
                         $auto_repost_price = 0;
                     }
                     if (isset($_POST['featured_ad_week_price'])) {
                         $featured_ad_week_price = $_POST['featured_ad_week_price'];
                     } else {
                         $featured_ad_week_price = 0;
                     }
                     $tot = $auto_repost_price + $featured_ad_week_price;
                     if (!empty($_POST['promocode'])) {
                         $promocode_name = $_POST['promocode'];
                         $status = "Active";
                         $promocode = $this->write_add_model->get_promocode($promocode_name, $status);
                         $promocode_value = !empty($promocode[0]['code']) ? $promocode[0]['code'] : "";
                         $promocode_type = !empty($promocode[0]['promotype']) ? $promocode[0]['promotype'] : "";
                         if ($promocode_type == 'amount') {
                             $net_total = $tot - $promocode_value;
                         } else {
                             if ($promocode_type == 'percentage') {
                                 $percent_total = $tot * $promocode_value;
                                 $percent_value = $percent_total / 100;
                                 $net_total = $tot - $percent_value;
                             }
                         }
                     } else {
                         $net_total = $tot;
                     }
                     $adsType = 'paid';
                     $data_to_store = array('uid' => $user_id, 'ads_type' => $adsType, 'category' => isset($_POST['category_id']) ? $_POST['category_id'] : "", 'subcategory' => isset($_POST['sub_category_id']) ? $_POST['sub_category_id'] : "", 'country' => isset($_POST['country']) ? $_POST['country'] : "", 'state' => isset($_POST['state']) ? $_POST['state'] : "", 'city' => isset($_POST['city']) ? $_POST['city'] : "", 'title' => isset($tit) ? $tit : "", 'location' => isset($location) ? $location : "", 'description' => isset($descr) ? $descr : "", 'address' => isset($address) ? $address : "", 'salary' => isset($_POST['salary']) ? $_POST['salary'] : "", 'education' => isset($_POST['education']) ? $_POST['education'] : "", 'work_status' => $work_status, 'shift' => $shift, 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'email' => isset($_POST['email']) ? $_POST['email'] : "", 'contact_number' => isset($_POST['contact_number']) ? $_POST['contact_number'] : "", 'inquery' => isset($_POST['inquery']) ? $_POST['inquery'] : "", 'show_ad_links' => isset($_POST['show_ad_links']) ? $_POST['show_ad_links'] : "", 'show_joined_date' => isset($_POST['show_joined_date']) ? $_POST['show_joined_date'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'auto_repost_ad' => isset($_POST['auto_repost_ad']) ? $_POST['auto_repost_ad'] : "", 'auto_repost_day' => isset($_POST['auto_repost_day']) ? $_POST['auto_repost_day'] : "", 'auto_repost_time' => isset($_POST['auto_repost_time']) ? $_POST['auto_repost_time'] : "", 'auto_repost_no_of_time' => isset($_POST['auto_repost_no_of_time']) ? $_POST['auto_repost_no_of_time'] : "", 'auto_repost_price' => isset($_POST['auto_repost_price']) ? $_POST['auto_repost_price'] : "", 'featured_ad' => isset($_POST['featured_ad']) ? $_POST['featured_ad'] : "", 'featured_ad_week_price' => isset($_POST['featured_ad_week_price']) ? $_POST['featured_ad_week_price'] : "", 'featured_ad_week' => isset($_POST['featured_ad_week']) ? $_POST['featured_ad_week'] : "", 'total' => isset($net_total) ? $net_total : "", 'pets' => isset($_POST['pets']) ? $_POST['pets'] : "", 'fees_paid_by' => isset($_POST['fees_paid_by']) ? $_POST['fees_paid_by'] : "", 'ad_placed_by' => isset($_POST['ad_placed_by']) ? $_POST['ad_placed_by'] : "", 'age' => isset($_POST['age']) ? $_POST['age'] : "", 'selling_price' => isset($_POST['selling_price']) ? $_POST['selling_price'] : "", 'bedrooms' => isset($_POST['bedrooms']) ? $_POST['bedrooms'] : "", 'price' => isset($_POST['price']) ? $_POST['price'] : "", 'date' => $formatDate, 'expire_date' => $res, 'video' => $video, 'image1' => isset($_POST['image1']) ? $_POST['image1'] : "", 'image2' => isset($_POST['image2']) ? $_POST['image2'] : "", 'image3' => isset($_POST['image3']) ? $_POST['image3'] : "", 'image4' => isset($_POST['image4']) ? $_POST['image4'] : "", 'image5' => isset($_POST['image5']) ? $_POST['image5'] : "", 'image6' => isset($_POST['image6']) ? $_POST['image6'] : "", 'image7' => isset($_POST['image7']) ? $_POST['image7'] : "", 'image8' => isset($_POST['image8']) ? $_POST['image8'] : "", 'image9' => isset($_POST['image9']) ? $_POST['image9'] : "", 'image10' => isset($_POST['image10']) ? $_POST['image10'] : "", 'image11' => isset($_POST['image11']) ? $_POST['image11'] : "", 'image12' => isset($_POST['image12']) ? $_POST['image12'] : "", 'post_ads_type' => "single", 'status' => "Inactive");
                     $insert_id = $this->write_add_model->add_temp_post($data_to_store);
                     if ($insert_id) {
                         //$this->session->set_flashdata('flash_message', 'add');
                         redirect("write_add/preview_ad_single_city/{$insert_id}");
                     }
                 } else {
                     $adsType = 'free';
                     $data_to_store = array('uid' => $user_id, 'ads_type' => $adsType, 'category' => isset($_POST['category_id']) ? $_POST['category_id'] : "", 'subcategory' => isset($_POST['sub_category_id']) ? $_POST['sub_category_id'] : "", 'country' => isset($_POST['country']) ? $_POST['country'] : "", 'state' => isset($_POST['state']) ? $_POST['state'] : "", 'city' => isset($_POST['city']) ? $_POST['city'] : "", 'title' => isset($tit) ? $tit : "", 'location' => isset($location) ? $location : "", 'description' => isset($descr) ? $descr : "", 'address' => isset($address) ? $address : "", 'salary' => isset($_POST['salary']) ? $_POST['salary'] : "", 'education' => isset($_POST['education']) ? $_POST['education'] : "", 'work_status' => $work_status, 'shift' => $shift, 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'email' => isset($_POST['email']) ? $_POST['email'] : "", 'contact_number' => isset($_POST['contact_number']) ? $_POST['contact_number'] : "", 'inquery' => isset($_POST['inquery']) ? $_POST['inquery'] : "", 'show_ad_links' => isset($_POST['show_ad_links']) ? $_POST['show_ad_links'] : "", 'show_joined_date' => isset($_POST['show_joined_date']) ? $_POST['show_joined_date'] : "", 'auto_repost_ad' => isset($_POST['auto_repost_ad']) ? $_POST['auto_repost_ad'] : "", 'postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : "", 'promotions_sponsor_ad' => isset($_POST['promotions_sponsor_ad']) ? $_POST['promotions_sponsor_ad'] : "", 'pets' => isset($_POST['pets']) ? $_POST['pets'] : "", 'fees_paid_by' => isset($_POST['fees_paid_by']) ? $_POST['fees_paid_by'] : "", 'ad_placed_by' => isset($_POST['ad_placed_by']) ? $_POST['ad_placed_by'] : "", 'age' => isset($_POST['age']) ? $_POST['age'] : "", 'selling_price' => isset($_POST['selling_price']) ? $_POST['selling_price'] : "", 'bedrooms' => isset($_POST['bedrooms']) ? $_POST['bedrooms'] : "", 'price' => isset($_POST['price']) ? $_POST['price'] : "", 'payment_status' => "complete", 'date' => $formatDate, 'expire_date' => $res, 'video' => $video, 'image1' => isset($_POST['image1']) ? $_POST['image1'] : "", 'image2' => isset($_POST['image2']) ? $_POST['image2'] : "", 'image3' => isset($_POST['image3']) ? $_POST['image3'] : "", 'image4' => isset($_POST['image4']) ? $_POST['image4'] : "", 'image5' => isset($_POST['image5']) ? $_POST['image5'] : "", 'image6' => isset($_POST['image6']) ? $_POST['image6'] : "", 'image7' => isset($_POST['image7']) ? $_POST['image7'] : "", 'image8' => isset($_POST['image8']) ? $_POST['image8'] : "", 'image9' => isset($_POST['image9']) ? $_POST['image9'] : "", 'image10' => isset($_POST['image10']) ? $_POST['image10'] : "", 'image11' => isset($_POST['image11']) ? $_POST['image11'] : "", 'image12' => isset($_POST['image12']) ? $_POST['image12'] : "", 'post_ads_type' => "single", 'status' => "Inactive");
                     $ads_post_id = $this->write_add_model->addPosts($data_to_store);
                     if ($ads_post_id) {
                         $data['flash_message'] = TRUE;
                         //$this->session->set_flashdata('flash_message', 'add');
                         redirect("write_add/preview_ad_single_city/{$ads_post_id}");
                     }
                 }
             }
         }
     }
     $city_id = $this->uri->segment(3);
     $session = array("city" => $city_id);
     $this->session->set_userdata($session);
     $data['city'] = $city = $this->session->userdata('stack_city_id');
     $data['category'] = $category_id = $this->session->userdata('category');
     $city_data = $this->home_model->getCity_by_field_value('city_id', $city);
     $data['subcategory'] = $sub_cat = $this->session->userdata('sub_category');
     $where_category = " AND category_id={$data['category']}";
     $data['category_name'] = $this->common_model->getFieldData('category', 'category_name', $where_category);
     $where_subcategory = " AND category_id={$sub_cat}";
     $data['sub_category_name'] = $this->common_model->getFieldData('category', 'category_name', $where_subcategory);
     $data['state'] = @$city_data[0]['state_id'];
     $data['country'] = @$city_data[0]['country_id'];
     $data['parent_id'] = @$this->session->userdata('category');
     $data['recaptcha_html'] = $this->recaptcha->recaptcha_get_html();
     if (!empty($category_id)) {
         if ($category_id == '11' || $category_id == '4') {
             $where = " AND category_id={$sub_cat} AND city_id={$city}";
             $city_category_price = $this->common_model->getFieldData('city_category_price', 'price', $where);
             if (!empty($city_category_price) && $city_category_price != "0") {
                 $data['city_category_price'] = $city_category_price;
             } else {
                 $whereStr = " AND category_id={$category_id} AND city_id={$city}";
                 $city_category_price1 = $this->common_model->getFieldData('city_category_price', 'price', $whereStr);
                 if (!empty($city_category_price1) && $city_category_price1 != "0") {
                     $data['city_category_price'] = $city_category_price1;
                 } else {
                     $category_price = $this->city_model->get_category_by_city_id($sub_cat);
                     if (!empty($category_price[0]['price']) && $category_price[0]['price'] !== '0') {
                         $data['city_category_price'] = $category_price[0]['price'];
                     } else {
                         $category_price = $this->city_model->get_category_by_city_id($category_id);
                         $data['city_category_price'] = $category_price[0]['price'];
                     }
                 }
             }
         }
         $where_featured_ad_sub_cat = " AND category_id={$sub_cat} AND city_id={$city}";
         $city_featured_price_sub_cat = $this->common_model->getFieldData('featured_price', 'featured_week_price', $where_featured_ad_sub_cat);
         if (!empty($city_featured_price_sub_cat)) {
             $data['city_featured_price'] = $city_featured_price_sub_cat;
         } else {
             $where_featured_ad_cat = " AND category_id={$category_id} AND city_id={$city}";
             $city_featured_price_cat = $this->common_model->getFieldData('featured_price', 'featured_week_price', $where_featured_ad_cat);
             $data['city_featured_price'] = $city_featured_price_cat;
         }
     }
     $data['main_content'] = 'write_add_view';
     $this->load->view('includes/template', $data);
 }
Ejemplo n.º 12
0
 function add_comment()
 {
     $data = array('User_Id' => $this->session->userdata('Id'), 'Post_Id' => $this->input->post('post_id'));
     $Comment = $this->input->post('comment');
     $disallowed = array('sūds', 'sūdu', 'kroplis');
     $Comment = word_censor($Comment, $disallowed, '****');
     $data['Comment'] = $Comment;
     $Post_Id = $this->input->post('post_id');
     $this->Forum_model->insert_comment($data);
     redirect("Main_controller/show_post/{$Post_Id}");
 }
Ejemplo n.º 13
0
 /**
  * 욕필터링
  */
 protected function word_censor($key_list = array(), $params = array(), $block_string = array())
 {
     if (count($key_list) > 0 and count($params) > 0) {
         foreach ($params as $key => &$param) {
             if (in_array($key, $key_list) === TRUE) {
                 $param = word_censor($param, $block_string);
             }
         }
     }
     return $params;
 }