Example #1
1
 function detail($title_none = NULL)
 {
     $cat_news_url = $this->uri->segment(1);
     $cat_news = new Newscatalogue();
     $cat_news->where(array('name_none' => $cat_news_url))->get();
     if (!$cat_news->exists()) {
         show_404();
     }
     $dis['cat_news'] = $cat_news;
     $cat = $this->uri->segment(2);
     $category = new Newscatalogue();
     $category->where(array('name_none' => $cat, 'parentcat_id' => $cat_news->id))->get();
     if (!$category->exists()) {
         show_404();
     }
     $dis['category'] = $category;
     $title_none = geturlfromuri($this->uri->segment(3));
     $news = new Article();
     $news->where(array('title_none' => $title_none, 'newscatalogue_id' => $category->id));
     $news->get();
     if (!$news->exists()) {
         redirect(base_url() . $this->uri->segment(1, '') . '/' . $this->uri->segment(2, ''));
         die;
     }
     $dis['news'] = $news;
     $tag = $news->tag;
     $dis['tag'] = explode(',', $tag);
     $news->view_count = $news->view_count + 1;
     $news->save();
     //related news
     $related_news = new Article();
     $related_news->where('recycle', 0);
     $related_news->where('newscatalogue_id', $news->newscatalogue_id);
     $related_news->where("id !=", $news->id);
     $related_news->order_by('created', 'DESC');
     $related_news->get_paged(0, 15, TRUE);
     $dis['related_news'] = $related_news;
     $arrayCateNewsId = array();
     foreach ($this->guideCate as $row) {
         $arrayCateNewsId[] = $row->id;
     }
     $arrayCateNewsId = array();
     foreach ($this->guideCate as $row) {
         $arrayCateNewsId[] = $row->id;
     }
     // get news view most
     $newViewMost = new Article();
     $newViewMost->where('recycle', 0);
     $newViewMost->where_in('newscatalogue_id', $arrayCateNewsId);
     $newViewMost->order_by('view_count', 'desc');
     $newViewMost->get(5);
     $dis['newViewMost'] = $newViewMost;
     // get news view most
     $newView = new Article();
     $newView->where('recycle', 0);
     $newView->where_in('newscatalogue_id', $arrayCateNewsId);
     $newView->order_by('created', 'desc');
     $newView->get(5);
     $dis['newView'] = $newView;
     $this->page_title = $news->{'title_vietnamese'} . ' | SotayNhadat.vn';
     $this->page_description = $news->short_vietnamese;
     $this->page_keyword = $news->tag;
     $this->url = base_url() . substr($this->uri->uri_string, 1, strlen($this->uri->uri_string));
     $this->isRobotFollow = 1;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/guides/news_de';
     $this->viewfront($dis);
 }
Example #2
0
 function cat($cat = NULL, $offset = 0, $limit = 12)
 {
     if (empty($offset)) {
         $offset = $this->uri->segment(3);
     }
     $cat = $this->uri->segment(2);
     $category = new Newscatalogue();
     $category->where(array('name_none' => $cat))->get();
     if (!$category->exists()) {
         show_404();
     }
     $dis['category'] = $category;
     //category news
     $cat_news = new Article();
     $cat_news->where(array('recycle' => 0));
     $cat_news->where('newscatalogue_id', $category->id);
     $cat_news->order_by('created', 'desc');
     $cat_news->get_paged($offset, $limit, TRUE);
     $dis['news'] = $cat_news;
     setPaginationVb('du-an/' . $cat, $cat_news->paged->total_rows, $limit, 3);
     // get news view most
     $newViewMost = new Article();
     $newViewMost->where('recycle', 0);
     $newViewMost->where_in('newscatalogue_id', $category->id);
     $newViewMost->order_by('view_count', 'desc');
     $newViewMost->get(5);
     $dis['newViewMost'] = $newViewMost;
     //seo
     $this->page_title = $category->title_bar;
     $this->page_description = $category->slogan;
     $this->page_keyword = $category->keyword;
     $this->isRobotFollow = 1;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/project/news_cat';
     $this->viewfront($dis);
 }
Example #3
0
 function pagesigle($url)
 {
     $url = geturlfromuri($this->uri->segment(1));
     $news = new Article();
     $news->where(array('recycle' => 0, 'title_none' => $url))->get();
     if (!$news->exists()) {
         show_404();
     }
     $dis['news'] = $news;
     $arrayCateNewsId = array();
     foreach ($this->guideCate as $row) {
         $arrayCateNewsId[] = $row->id;
     }
     // get news view most
     $newViewMost = new Article();
     $newViewMost->where('recycle', 0);
     $newViewMost->where_in('newscatalogue_id', $this->listAllCat);
     $newViewMost->order_by('view_count', 'desc');
     $newViewMost->get(10);
     $dis['newViewMost'] = $newViewMost;
     $this->page_title = $news->title_vietnamese . " - " . $this->page_title;
     $this->menu_active = 'home';
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/single-page';
     $this->viewfront($dis);
 }
Example #4
0
 function postGuide()
 {
     $news = new Article();
     $news->where(array('recycle' => 0, 'newscatalogue_id' => 90))->get_iterated();
     if (!$news->exists()) {
         show_404();
     }
     $dis['news'] = $news;
     // get news view most
     $newViewMost = new Article();
     $newViewMost->where('recycle', 0);
     $newViewMost->where_in('newscatalogue_id', $this->listAllCat);
     $newViewMost->order_by('view_count', 'desc');
     $newViewMost->get(10);
     $dis['newViewMost'] = $newViewMost;
     $this->page_title = "Hướng dẫn đăng tin - " . $this->page_title;
     $this->menu_active = 'home';
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/postGuide';
     $this->viewfront($dis);
 }
Example #5
0
 function post()
 {
     if ($this->session->userdata('userLoginFlag') != 1) {
         redirect(base_url() . 'dang-nhap');
     }
     $customer = new Estateuser($this->session->userdata('userLoginId'));
     if (!$customer->exists()) {
         show_404();
     }
     if ($customer->isLock == 1) {
         redirect(base_url() . 'chinh-sua-tin-da-dang');
     }
     $dis['customer'] = $customer;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $o = new Estate();
         $o->estatecity_id = $this->input->post('estatecity_id');
         $o->estatedistrict_id = $this->input->post('estatedistrict_id');
         $o->estatedirection_id = $this->input->post('estatedirection_id');
         $o->estatecatalogue_id = $this->input->post('estatecatalogue_id');
         $o->estatetype_id = $this->input->post('estatetype_id');
         $o->estatearea_id = $this->input->post('estatearea_id');
         $o->estateprice_id = $this->input->post('estateprice_id');
         $o->estateward_id = $this->input->post('estateward_id');
         $o->address = $this->input->post('address');
         $o->isArea = $this->input->post('IsArea');
         $o->area = $this->input->post('area');
         $o->legally = $this->input->post('legally');
         $o->isPrice = $this->input->post('IsPrice');
         $o->price_text = $this->input->post('price_text');
         $o->estatedirection_id = $this->input->post('estatedirection_id');
         $o->estateuser_id = $this->session->userdata('userLoginId');
         $o->title = ucfirst(mb_strtolower($this->input->post('title'), "utf-8"));
         $o->description = $this->input->post('description');
         $o->price_text = $this->input->post('price_text');
         $o->area_text = $this->input->post('area_text');
         if ($o->estatecatalogue_id == 1) {
             $o->price_type = $this->input->post('price_type');
         } else {
             $o->price_type = $this->input->post('price_type_2');
         }
         $o->code = $this->add_code(7, $o->max_id() + 1, $o->estatecatalogue_id);
         $o->title_none = remove_vn($this->input->post('title')) . $o->code;
         if ($this->securimage->check($_POST['captcha_code']) == false) {
             $msg = '<div class="frm-error error-capcha">Vui lòng nhập đúng mã xác nhận !</div>';
             $type = 0;
         } else {
             $folder = 'img/project/';
             $dataupload = $this->file_lib->upload('image', $folder, $rename_file = true);
             if (!is_array($dataupload)) {
                 $o->photo = '';
             } else {
                 $o->photo = $folder . $dataupload['file_name'];
                 $img = getimagesize($folder . $dataupload['file_name']);
                 if (!empty($img[2])) {
                     $typeImage = image_type_to_mime_type($img[2]);
                 }
                 $fileWatermark = 'img/watermark/chen-hinh-tin-rao.png';
                 $fileImage = $folder . $dataupload['file_name'];
                 $stamp = imagecreatefrompng($fileWatermark);
                 if ($typeImage == 'image/jpeg') {
                     $im = imagecreatefromjpeg($fileImage);
                 } else {
                     if ($typeImage == 'image/gif') {
                         $im = imagecreatefromgif($fileImage);
                     } else {
                         $im = imagecreatefrompng($fileImage);
                     }
                 }
                 // Get dimensions
                 $sx = imagesx($im);
                 $sy = imagesy($im);
                 $sx1 = imagesx($stamp);
                 $sy1 = imagesy($stamp);
                 // width to calculate positioning of the stamp.
                 imagecopy($im, $stamp, ($sx - $sx1) / 2, ($sy - $sy1) / 2, 0, 0, imagesx($stamp), imagesy($stamp));
                 // Output and free memory
                 header('Content-type: image/png');
                 imagejpeg($im, $fileImage, 100);
             }
             if ($o->save()) {
                 $msg = '<div class="frm-success">Thành công. Tin của bạn đã được đăng thành công !</div>';
                 $type = 1;
                 /*Upload list images for estates*/
                 $numfile = $this->input->post('numfile');
                 foreach ($numfile as $row) {
                     $dataupload = $this->file_lib->upload('image' . $row, $folder, $rename_file = true);
                     if (is_array($dataupload)) {
                         $estate_photos = new Estate_photo();
                         $estate_photos->estate_id = $o->id;
                         $estate_photos->name = $folder . $dataupload['file_name'];
                         $estate_photos->save();
                         $estate_photos->clear();
                         $img = getimagesize($folder . $dataupload['file_name']);
                         if (!empty($img[2])) {
                             $typeImage = image_type_to_mime_type($img[2]);
                         }
                         $fileWatermark = 'img/watermark/chen-hinh-tin-rao.png';
                         $fileImage = $folder . $dataupload['file_name'];
                         $stamp = imagecreatefrompng($fileWatermark);
                         if ($typeImage == 'image/jpeg') {
                             $im = imagecreatefromjpeg($fileImage);
                         } else {
                             if ($typeImage == 'image/gif') {
                                 $im = imagecreatefromgif($fileImage);
                             } else {
                                 $im = imagecreatefrompng($fileImage);
                             }
                         }
                         // Get dimensions
                         $sx = imagesx($im);
                         $sy = imagesy($im);
                         $sx1 = imagesx($stamp);
                         $sy1 = imagesy($stamp);
                         // width to calculate positioning of the stamp.
                         imagecopy($im, $stamp, ($sx - $sx1) / 2, ($sy - $sy1) / 2, 0, 0, imagesx($stamp), imagesy($stamp));
                         // Output and free memory
                         header('Content-type: image/png');
                         imagejpeg($im, $fileImage, 100);
                     }
                 }
                 redirect(base_url() . 'chinh-sua-tin-da-dang');
             }
         }
     }
     $project = new Article();
     $project->where_in('newscatalogue_id', array(84, 85, 86, 87, 88, 89));
     $project->get_iterated();
     $dis['project'] = $project;
     $this->page_title = "Đăng tin rao vặt bất động sản | Rao vặt nhà đất  | SotayNhadat.vn";
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/user/post';
     $dis['msg'] = $msg;
     $dis['type'] = $type;
     $dis['o'] = $o;
     $this->viewfront($dis);
 }
Example #6
0
 function resetNewsViewMost()
 {
     try {
         $dateNow = new DateTime(date('Y-m-d'));
         $dateStart = new DateTime(getconfigkey('date_start_reset_news'));
         $interval = $dateNow->diff($dateStart);
         if ($interval->days % 7 == 0) {
             $cauhinh = new Cauhinh();
             $cauhinh->where('fieldname', 'date_reset_news')->get();
             if (getconfigkey('date_reset_news') == 0) {
                 $news = new Article();
                 $news->where('recycle', 0);
                 $news->where_in('newscatalogue_id', array(71, 73, 72, 74, 75, 77, 80, 81, 82, 78, 79));
                 $news->get_iterated();
                 foreach ($news as $row) {
                     $o = new Article($row->id);
                     $o->view_count = 0;
                     $o->save();
                     $o->clear();
                 }
                 $cauhinh->value = 1;
                 $cauhinh->save();
             }
         } else {
             if (getconfigkey('date_reset_news') != 0) {
                 $cauhinh = new Cauhinh();
                 $cauhinh->where('fieldname', 'date_reset_news')->get();
                 $cauhinh->value = 0;
                 $cauhinh->save();
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
 }