示例#1
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);
 }
示例#2
0
 public function postFree()
 {
     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($this->input->post('title'));
         $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->name_contact = $this->input->post('name_contact');
         $o->address_contact = $this->input->post('address_contact');
         $o->phone_contact = $this->input->post('phone_contact');
         $o->mobile_contact = $this->input->post('mobile_contact');
         $o->email_contact = $this->input->post('email_contact');
         $o->isFree = 1;
         $o->active = 1;
         $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'];
             }
             if ($o->save()) {
                 $msg = '<div class="frm-success">Cảm ơn Bạn! Tin của Bạn đã được gửi đến Chúng tôi thành công. Thông thường sau 30 phút, tin sẽ được kích hoạt<br /><br />Bạn chưa đăng ký thành viên nên Chúng tôi sẽ kiểm duyệt tin đăng của Bạn trước khi hiển thị. Bạn không thể sửa/xóa tin đăng này. Để thuận tiện hơn, Bạn có thể <a style="color: #018e07;font-weight: bolder;" href="' . base_url() . 'dang-ky' . '">đăng ký thành viên</a> - Tin đăng được hiển thị ngay và nhận nhiều hỗ trợ từ Chúng tôi! <br/><br/>  Hoặc, Bạn có thể tiếp tục <a style="color: #018e07;font-weight: bolder;" href="' . base_url() . 'dang-tin-rao-vat-nha-dat-mien-phi' . '">đăng tin rao vặt miễn phí</a>!</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);
                     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();
                     }
                 }
             }
         }
     }
     $dis['msg'] = $msg;
     $dis['type'] = $type;
     $dis['o'] = $o;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/estates/post-free';
     $this->page_title = "Đăng tin rao vặt nhà đất | rao vặt bất động sản | SotayNhadat.vn";
     $this->page_description = "Đăng tin rao vặt nhà đất, căn hộ, đất nền, biệt thự...không cần đăng ký thành viên tại SotayNhadat.vn. Giúp Bạn giao dịch nhà đất đơn giản, nhanh chóng hơn!";
     $this->viewfront($dis);
 }