Esempio n. 1
0
$varsline = GetVars();
if (!empty($_FILES)) {
    $gallerypics = $_REQUEST['json_gallerypics'];
    $gallerypics = stripslashes($gallerypics);
    $gallerypics = json_decode($gallerypics);
    $item = $_FILES['Filedata']['tmp_name'];
    $id = (int) $_REQUEST['id'];
    $table = $_REQUEST['table'];
    $currtime = time();
    $sql = "INSERT INTO {$table} (`reportid`,`hide`,`newstype`,`date`) VALUES ({$id},0,7,{$currtime})";
    mysql_query($sql);
    $lastid = mysql_insert_id();
    $sql = "UPDATE {$table} SET `prior`={$lastid} WHERE id={$lastid}";
    mysql_query($sql);
    $size = getimagesize($item);
    foreach ($gallerypics as $key2 => $value2) {
        $picprefix = $value2->picprefix;
        $ext = $value2->ext;
        $newname = $picprefix . $lastid . '.' . $ext;
        $newname = $par->document_root . '/' . $newname;
        $mode = $value2->mode;
        $w = $value2->w;
        $h = $value2->h;
        CreateAdminPic($mode, $item, $newname, $w, $h);
        if (isset($value2->watermarkfile)) {
            put_watermark($newname, $newname, $value2->watermarkpos, 100, $par->document_root . '/' . $value2->watermarkfile);
        }
    }
    unlink($item);
    echo ' ';
}
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'])));
         }
     }
 }