Exemplo n.º 1
0
 function deletePhoto($estateID, $photoID)
 {
     $photoEstates = new Estate_photo($photoID);
     // remove image from folder.
     $pathImage = $_SERVER['DOCUMENT_ROOT'] . '/' . $photoEstates->name;
     unlink($pathImage);
     if ($photoEstates->delete()) {
         flash_message('success', 'Hình ảnh đã được xóa khỏi tin nhà đất');
         redirect(base_url() . 'chinh-sua-tin/' . $estateID);
     } else {
         flash_message('error', 'Đã có lỗi xãy ra !');
         redirect(base_url() . 'chinh-sua-tin/' . $estateID);
     }
 }
Exemplo n.º 2
0
 function index($offset = 0, $limit = 800)
 {
     $estates = new Estate();
     $estates->where('isFree', 0);
     $estates->order_by('id', 'desc');
     $estates->get_paged($offset, $limit, TRUE);
     $xmlFile = "mitula_feed_" . $offset . "_" . $limit . ".xml";
     $xmlFile = $_SERVER['DOCUMENT_ROOT'] . '/feeds/' . $xmlFile;
     //$f = fopen($xmlFile, 'w');
     //create the xml document
     $xmlDoc = new DOMDocument('1.0', 'UTF-8');
     $root = $xmlDoc->createElement('Mitula');
     $xmlDoc->appendChild($root);
     foreach ($estates as $row) {
         $ad = $xmlDoc->createElement('ad');
         // create id for ad
         $id = $xmlDoc->createElement('id');
         $id->appendChild($xmlDoc->createCDATASection($row->code));
         // create url for ad
         $url = $xmlDoc->createElement('name');
         $url->appendChild($xmlDoc->createCDATASection(base_url() . $row->estatecatalogue->name_none . '/' . $row->estatecity->name_none . '/' . $row->title_none . '.html'));
         // create title for ad
         $title = $xmlDoc->createElement('title');
         $title->appendChild($xmlDoc->createCDATASection($row->title));
         // create type for ad
         $type = $xmlDoc->createElement('type');
         $type->appendChild($xmlDoc->createCDATASection($row->estatetype->name));
         // create content for ad
         $content = $xmlDoc->createElement('content');
         $content->appendChild($xmlDoc->createCDATASection($row->description));
         // create price for ad
         $price = $xmlDoc->createElement('price');
         $period = $xmlDoc->createAttribute('period');
         $period->value = 'monthly';
         $price->appendChild($period);
         $price->appendChild($xmlDoc->createCDATASection($row->price_text . ' ' . getpricetype($row->price_type)));
         // create floor_area for ad
         $floor_area = $xmlDoc->createElement('floor_area');
         $floor_area->appendChild($xmlDoc->createCDATASection($row->area_text . ' m2'));
         // create city for ad
         $city = $xmlDoc->createElement('city');
         $city->appendChild($xmlDoc->createCDATASection($row->estatecity->name));
         // create address for ad
         $address = $xmlDoc->createElement('address');
         $address->appendChild($xmlDoc->createCDATASection($row->address));
         $photos = new Estate_photo();
         $photos->where('estate_id', $row->id);
         $photos->get();
         if ($row->photo != null || $photos->result_count() > 0) {
             $pictures = $xmlDoc->createElement('pictures');
             $picture = $xmlDoc->createElement('picture');
             $pictureTitle = $xmlDoc->createElement('picture_title');
             $pictureTitle->appendChild($xmlDoc->createCDATASection($row->title));
             $pictureUrl = $xmlDoc->createElement('picture_url');
             $pictureUrl->appendChild($xmlDoc->createCDATASection(image($row->photo, 'slide_580_380')));
             $picture->appendChild($pictureUrl);
             $picture->appendChild($pictureTitle);
             if ($photos->result_count() > 0) {
                 foreach ($photos as $photo) {
                     $rowPhoto = new Estate_photo($photo->id);
                     $picture = $xmlDoc->createElement('picture');
                     $pictureTitle = $xmlDoc->createElement('picture_title');
                     $pictureTitle->appendChild($xmlDoc->createCDATASection($row->title));
                     $pictureUrl = $xmlDoc->createElement('picture_url');
                     $pictureUrl->appendChild($xmlDoc->createCDATASection(image($rowPhoto->name, 'slide_580_380')));
                     $picture->appendChild($pictureUrl);
                     $picture->appendChild($pictureTitle);
                     $pictures->appendChild($picture);
                 }
             }
             $pictures->appendChild($picture);
         }
         $ad->appendChild($id);
         $ad->appendChild($url);
         $ad->appendChild($title);
         $ad->appendChild($type);
         $ad->appendChild($content);
         $ad->appendChild($price);
         $ad->appendChild($floor_area);
         $ad->appendChild($city);
         $ad->appendChild($address);
         $ad->appendChild($pictures);
         $root->appendChild($ad);
     }
     //make the output pretty
     $xmlDoc->formatOutput = true;
     // Flush XML from memory to file in one go
     $result = file_put_contents($xmlFile, $xmlDoc->saveXML()) or print_r(error_get_last());
     if ($result == false) {
         echo "Error";
     } else {
         echo $xmlFile . " All good, {$result} bytes written";
     }
     die;
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 function deletePhoto($estateID, $photoID)
 {
     $photoEstates = new Estate_photo($photoID);
     // remove image from folder.
     $pathImage = $_SERVER['DOCUMENT_ROOT'] . '/' . $photoEstates->name;
     unlink($pathImage);
     if ($photoEstates->delete()) {
         flash_message('success', 'Hình ảnh đã được xóa khỏi tin nhà đất');
         redirect($this->admin . 'estates/edit/' . $estateID);
     }
 }