Esempio n. 1
0
 /**
  * Method render
  * @access public
  * @param boolean $ajax_render [default value: false]
  * @return mixed
  * @since 1.1.9
  */
 public function render($ajax_render = false)
 {
     $gallery_table = new Table();
     $gallery_table->setId("PhotoGalleryTable" . rand(0, 999999))->activatePagination();
     $header = new RowTable();
     for ($i = 0; $i < $this->nb_col; $i++) {
         $header->add();
     }
     $gallery_table->addRow($header->setHeaderClass(0));
     $ind = 0;
     $last_ind = -1;
     $gallery_row = null;
     $files = scandir($this->path, 1);
     for ($i = 0; $i < sizeof($files); $i++) {
         $file = $files[$i];
         if ($file != "." && $file != "..") {
             $getExt = explode(".", $file);
             $countExt = count($getExt);
             $fExt = $countExt - 1;
             $myExt = $getExt[$fExt];
             if ((is_dir($this->path . $file) || $this->in_arrayi($myExt, $this->picture_ext)) && $file != $this->thumbnail_folder) {
                 if ($ind != $last_ind && $ind % $this->nb_col == 0) {
                     if ($gallery_row != null) {
                         $gallery_table->addRow($gallery_row);
                     }
                     $gallery_row = new RowTable();
                     $gallery_row->setWidth("25%");
                     $last_ind = $ind;
                 }
                 if (is_dir($this->path . $file)) {
                     if ($this->subfolder) {
                         $folder_pic = new Picture($this->folder_pic, 128, 128, 0, Picture::ALIGN_ABSMIDDLE, $file);
                         $url = $this->getPage()->getCurrentURL();
                         if (($pos = find($url, "gallery_event=")) > 0) {
                             $pos2 = find($url, "&", 0, $pos);
                             if ($pos2 == 0) {
                                 $url = substr($url, 0, $pos - 1);
                             } else {
                                 $url1 = substr($url, 0, $pos - 1);
                                 $url2 = substr($url, $pos2, strlen($url));
                                 $url = $url1 . $url2;
                             }
                         }
                         if (find($url, "?") > 0) {
                             $url = $url . "&";
                         } else {
                             $url = $url . "?";
                         }
                         $url = $url . "gallery_event=" . urlencode(str_replace($this->original_path, "", $this->path . $file));
                         $folder_link = new Link($url, Link::TARGET_NONE, new Object($folder_pic, "<br/>", $file));
                         $gallery_row->add($folder_link);
                         $ind++;
                     }
                 } else {
                     if ($this->in_arrayi($myExt, $this->picture_ext)) {
                         $pic_file = str_replace(str_replace("\\", "/", realpath(SITE_DIRECTORY)) . "/", "", str_replace("\\", "/", realpath($this->path)) . "/" . $file);
                         $pic_file_lower_ext = str_replace("." . $myExt, strtolower("." . $myExt), $pic_file);
                         if ($pic_file_lower_ext != $pic_file) {
                             $path_file_lower_ext = str_replace($pic_file, $pic_file_lower_ext, str_replace("\\", "/", realpath(SITE_DIRECTORY . "/" . $pic_file)));
                             if (!rename(realpath(SITE_DIRECTORY . "/" . $pic_file), $path_file_lower_ext)) {
                                 $pic_file_lower_ext = $pic_file;
                             }
                         }
                         $pic_name = str_replace("." . $myExt, "", $file);
                         $pic_thumbnail = $pic_file_lower_ext;
                         if (trim($this->thumbnail_folder) != "") {
                             if (in_array(strtolower($myExt), array("jpg", "jpeg", "gif", "png"))) {
                                 if (!is_dir(realpath($this->path) . "/" . $this->thumbnail_folder)) {
                                     mkdir(realpath($this->path) . "/" . $this->thumbnail_folder);
                                 }
                                 $pic_thumbnail_path = realpath($this->path . "/" . $this->thumbnail_folder) . "/" . str_replace("." . $myExt, strtolower("." . $myExt), $file);
                                 $pic_thumbnail = str_replace(str_replace("\\", "/", realpath(SITE_DIRECTORY)) . "/", "", str_replace("\\", "/", realpath($this->path . "/" . $this->thumbnail_folder)) . "/" . str_replace("." . $myExt, strtolower("." . $myExt), $file));
                                 if (strtolower($myExt) == "gif") {
                                     // convert to jpg
                                     $pic_thumbnail_path = str_replace(".gif", ".jpg", $pic_thumbnail_path);
                                     $pic_thumbnail = str_replace(".gif", ".jpg", $pic_thumbnail);
                                 }
                                 if (!file_exists($pic_thumbnail_path)) {
                                     if (strtolower($myExt) == "jpg" || strtolower($myExt) == "jpeg") {
                                         jpegReductionFixe($pic_file_lower_ext, $pic_thumbnail_path, 128, 128);
                                     } else {
                                         if (strtolower($myExt) == "png") {
                                             pngReductionFixe($pic_file_lower_ext, $pic_thumbnail_path, 128, 128);
                                         } else {
                                             $tmp_file = realpath($this->path . "/" . $this->thumbnail_folder) . "/temp.jpg";
                                             gif2jpeg($pic_file_lower_ext, $tmp_file);
                                             jpegReductionFixe($tmp_file, $pic_thumbnail_path, 128, 128);
                                             unlink($tmp_file);
                                         }
                                     }
                                 }
                             }
                         }
                         $pic = new Picture($pic_thumbnail, 128, 128, 0, Picture::ALIGN_ABSMIDDLE, $pic_name);
                         $pic->addLightbox("Lightbox" . $gallery_table->getId(), $pic_file_lower_ext, "\$(window).width()-(\$(window).width()*0.2)", "\$(window).height()-(\$(window).height()*0.2)");
                         $gallery_row->add(new Object($pic, "<br/>", $pic_name));
                         $ind++;
                     }
                 }
             }
         }
     }
     if ($gallery_row != null) {
         while ($ind % $this->nb_col != 0) {
             $gallery_row->add();
             $ind++;
         }
         $gallery_table->addRow($gallery_row);
     }
     return $gallery_table->render($ajax_render);
 }
Esempio n. 2
0
 public function addpost()
 {
     $this->form_validation->set_rules('posttype', 'Post type', 'required|xss_clean');
     if ($this->input->post('posttype') == 'upload') {
         $this->form_validation->set_rules('file_name', 'File', 'required|callback_url_check|xss_clean');
     } else {
         $this->form_validation->set_rules('url', 'Url', 'required|callback_url_check|xss_clean');
     }
     $this->form_validation->set_rules('title', 'Title', 'required|xss_clean');
     $this->form_validation->set_rules('categories', 'Categories', 'required|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         $this->post($this->input->post('type'));
     } else {
         $this->load->helper('date');
         $format = 'DATE_RFC822';
         $time = time();
         $data['title'] = $this->filter_words($this->input->post('title'));
         $data['categories'] = json_encode($_POST['categories']);
         $data['unique_id'] = uniqid();
         //$data['description']		= $this->input->post('description');
         $data['tags'] = $this->input->post('tags');
         $data['posttype'] = $this->input->post('posttype');
         $type = '';
         if ($data['posttype'] == 'upload') {
             $data['file'] = $this->input->post('file_name');
             $data['url'] = base_url('uploads/' . $data['file']);
             $do_water_mark = get_settings('memento_settings', 'do_water_mark', 'Yes');
             if ($do_water_mark == 'Yes' && is_animated($data['url']) == FALSE) {
                 //resized_to_fixed_width('./uploads/'.$data['file'],500);
                 $text = get_settings('memento_settings', 'water_mark_text', 'N/A');
                 put_watermark('./uploads/' . $data['file'], $text);
             }
             $data['thumb_url'] = base_url('uploads/' . $data['file']);
             $type = 'photo';
         } else {
             if ($data['posttype'] == 'video' || $data['posttype'] == 'vine') {
                 $data['url'] = $this->input->post('url');
                 $data['thumb_url'] = $this->get_video_thumb($data['url']);
                 $data['thumb_url'] = image_from_url($data['thumb_url'], rand(1, 100) . time() . '.jpg');
                 $type = 'video';
             } else {
                 $url = image_from_url($this->input->post('url'));
                 $data['url'] = $url;
                 $data['thumb_url'] = $data['url'];
                 $type = 'photo';
             }
         }
         if (is_animated(str_replace(base_url(), './', $data['url']))) {
             $fileinfo = fileinfo_from_url($data['url']);
             gif2jpeg(str_replace(base_url(), './', $data['url']), './uploads/still/' . $fileinfo['filename'] . '.jpg', 6);
             $data['thumb_url'] = base_url('uploads/still/' . $fileinfo['filename'] . '.jpg');
         }
         $fileinfo = fileinfo_from_url($data['thumb_url']);
         create_rect_thumb(str_replace(base_url(), './', $data['thumb_url']), './uploads/rect_thumbs/');
         $data['rect_thumb'] = base_url('/uploads/rect_thumbs/' . $fileinfo['filename'] . '.jpg');
         $publish_directly = get_settings('memento_settings', 'publish_directly', 'Yes');
         $data['status'] = $publish_directly == 'Yes' ? 1 : 2;
         // 2 = pending
         $data['need_safety_filter'] = $this->input->post('need_safety_filter');
         $data['create_time'] = $time;
         $data['publish_time'] = $time;
         $user = $this->user_model->get_user_profile($this->session->userdata('user_email'));
         $data['created_by'] = $user->id;
         $id = $this->user_model->insert_post($data);
         if ($data['posttype'] == 'video' && $publish_directly == 'Yes') {
             redirect(site_url('video/' . $data['unique_id'] . '/' . url_title($data['title'])));
         } else {
             redirect(site_url('meme/' . $data['unique_id'] . '/' . url_title($data['title'])));
         }
     }
 }