Example #1
0
 public function avatar_post($id)
 {
     $tempImage = tempnam_sfx(sys_get_temp_dir(), "jpg");
     $imageName = base64_to_png($this->post('image'), $tempImage);
     $thumbImage = create_thumb($imageName);
     $nameThumb = name_thumb($imageName);
     $handle = fopen($imageName, "r");
     $data = fread($handle, filesize($imageName));
     $headers = array('Authorization: Client-ID ' . IMGUR_CLIENT_ID);
     $postFields = array('image' => base64_encode($data));
     $dataImage = send_post(IMGUR_URL_UPLOAD_IMAGE, $postFields, $headers);
     $handle = fopen($nameThumb, "r");
     $data = fread($handle, filesize($nameThumb));
     $headers = array('Authorization: Client-ID ' . IMGUR_CLIENT_ID);
     $postFields = array('image' => base64_encode($data));
     $dataThumb = send_post(IMGUR_URL_UPLOAD_IMAGE, $postFields, $headers);
     $val['avatar_thumbnail'] = $dataThumb['data']['link'];
     $val['avatar_standar'] = $dataImage['data']['link'];
     $userId = $this->user_model->update($id, $val);
     if (!is_null($userId)) {
         //unlink($imageName);
         //unlink($nameThumb);
         $this->response(array('avatars' => $val), 200);
     } else {
         $this->response(array('error' => 'Internal Server Error'), 500);
     }
 }
function upload_image($image, $target, $thumb = array('dest' => '', 'size' => array('w' => 257, 'h' => 218), 'ratio' => false), $prev_img = NULL)
{
    $CI =& get_instance();
    initialize_upload($target);
    if ($CI->upload->do_upload($image)) {
        if ($prev_img) {
            if (is_file($target . $prev_img)) {
                @unlink($target . $prev_img);
            }
        }
        $data = $CI->upload->data();
        $image = $data['file_name'];
        $image_path = $data['full_path'];
        $image_name = $data['raw_name'];
        $image_ext = $data['file_ext'];
        if ($thumb) {
            //$thumb_size = array('w' => 200, 'h' =>220);
            if ($thumb['dest']) {
                $dest = $thumb['dest'];
            } else {
                $dest = $target;
            }
            create_thumb($image_path, $dest . $image, $thumb['size'], $thumb['ratio']);
        }
        return $image;
    } else {
        $CI->session->set_flashdata('error_message', $CI->upload->display_errors());
        return false;
        //return $CI->upload->display_errors();
    }
}
Example #3
0
 function update_employer_status()
 {
     if ($this->input->post('feature_in_slider') == '1') {
         $image_file = $this->user_model->get_image($this->input->post('id'));
         if (!file_exists("./uploads/user/images/banner/" . $image_file['image'])) {
             $this->load->helper('image_helper');
             $file_path = "./uploads/user/images/" . $image_file['image'];
             $image = create_image_from_any($file_path);
             //create image object to create thumbnail for the slider
             $image_param = array('image' => $image_file['image'], 'image_loc' => "./uploads/user/images/", 'thumb_loc' => "./uploads/user/images/banner/", 'thumb_w' => BANNER_W, 'thumb_h' => BANNER_H, 'master_dim' => 'height');
             create_thumb($image_param);
         }
     }
     $this->user_model->update_employer_status();
     echo 'success';
     exit;
 }
Example #4
0
function is_picture($picture_filename, $galid)
{
    global $config;
    $picture_path = $config['gallery_path'] . "/{$galid}/{$picture_filename}";
    $thumbnail_path = $config['gallery_path'] . "/{$galid}/_thb_{$picture_filename}";
    // check filename patterns
    if (eregi("^_thb_*", $picture_filename) || !eregi(".jpg\$", $picture_filename) && !eregi(".png\$", $picture_filename) && !eregi(".gif\$", $picture_filename)) {
        return false;
    }
    // does it exist, is it a regular file and does it have the expected permissions ?
    if (!check_perms($picture_path)) {
        return false;
    }
    // an associated thumbnail is required... same job again !
    if (!check_perms($thumbnail_path)) {
        create_thumb($picture_path, $thumbnail_path, 100);
    }
    return true;
}
Example #5
0
function save_pic($url, $nick, $comment, $saved_file, $ext)
{
    global $fetch_log;
    $file_name = md5_file($saved_file);
    $path = STORAGE_PATH . $file_name . '.' . $ext;
    rename($saved_file, $path);
    $thumb_path = THUMB_PATH . $file_name . '.jpg';
    list($w, $h) = create_thumb($path, $thumb_path);
    chmod($path, 0664);
    chmod($thumb_path, 0664);
    $pic = new Pic(array('nick' => $nick, 'original_url' => $url, 'path' => $path, 'comment' => $comment, 'thumb' => $thumb_path, 'width' => $w, 'height' => $h, 'ctime' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])));
    if (ORM::all('pic', array('checksum' => $pic->checksum))->count() === 0) {
        if ($pic->save()) {
            file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tpic save SUCCESS\t{$url}\n", FILE_APPEND);
        } else {
            file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\terror saving image: " . var_export($pic->errors(), true) . "\t{$url}\n", FILE_APPEND);
        }
    } else {
        file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tduplicate image\t{$url}\n", FILE_APPEND);
    }
}
Example #6
0
 public function UploadImage($imgdata, $folder = 'Temp')
 {
     $base_dir = WWW_ROOT . DS . 'files/' . $folder;
     if (!is_dir($base_dir)) {
         mkdir($base_dir, 0755, true);
     }
     $arr_img = explode(".", $imgdata["name"]);
     $ext = strtolower($arr_img[count($arr_img) - 1]);
     if ($imgdata['error'] == 0 && in_array($ext, array('jpg', 'gif', 'png'))) {
         $fname = removeSpecialChar($imgdata['name']);
         $file = time() . "_" . $fname;
         if (upload_my_file($imgdata['tmp_name'], $base_dir . '/' . $file)) {
             $save_path = "thumb_" . $file;
             create_thumb($base_dir . '/' . $file, 150, $base_dir . '/' . $save_path);
             $array = array('image' => $file, 'thumb' => $save_path);
             return $array;
         } else {
             return '0';
         }
     } else {
         return '0';
     }
 }
Example #7
0
    function draw_video_modal($videos)
    {
        ?>
<div class="modal fade" id="videos-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Video</h4>
      </div>
      <div class="modal-body" id="videos-sort-container">
		<div id="videos-sort">
			<?php 
        if (isset($videos) && $videos) {
            foreach ($videos->result() as $video) {
                ?>
			<div id="video-thumb-<?php 
                echo $video->id;
                ?>
" class="video-form form-inline" data-img-url="<?php 
                echo base_url() . str_replace('./', '', create_thumb($video->thumb, 746, 439));
                ?>
"  role="form">
				<div class="image-wrapper form-group"><img src="<?php 
                echo base_url() . str_replace('./', '', create_thumb($video->thumb, 211, 126));
                ?>
" width="211" height="126" alt=""/></div>
				<div class="image-title form-group">
					<input type="text" name="video-url[<?php 
                echo $video->id;
                ?>
]" value="<?php 
                echo $video->url;
                ?>
" class="form-control" placeholder="Youtube URL"/>
					<span class="image-control">
						<button type="button" class="btn btn-primary btn-sm save-video">Save</button>
						<button type="button" class="btn btn-danger btn-sm delete-video">Delete</button>
						<span class="spinner"></span>
					</span>
				</div>
			</div>
			<?php 
            }
        }
        ?>
		</div>
      </div>
      <div class="modal-footer">
      	<a id="upload_video_thumb" href="#" class="btn btn-primary btn-sm active pull-left" role="button">Add Video</a>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <span class="spinner"></span>
        <p class="clearfix" style="text-align: left; margin-top: 10px;">Press Add Video button to select your video thumbnail and then place Youtube URL.<br /><b>Note:</b> Maximum video thumbnail size is 10MB, width 1024px and height 768px. Only jpg/jpeg/png allowed. Best Dimension 746x439px.</p>
      </div>
    </div>
  </div>
</div>
<?php 
    }
Example #8
0
if (!isset($_POST['x']) || !isset($_POST['y']) || !isset($_POST['src'])) {
    die;
}
$x = $_POST['x'];
$y = $_POST['y'];
$path_prestr = '../../';
$img_path = $path_prestr . $_POST['src'];
$img_ext = get_ext($img_path);
$img_size = @getimagesize($img_path);
$new_width = trim($_POST['w']);
$new_weight = trim($_POST['h']);
$size_ischanged = 0;
//是否对图片进行了缩放
if ($img_size[0] != $new_width) {
    $tmp_path = str_replace('.' . $img_ext, '_tmp.' . $img_ext, $img_path);
    if (create_thumb($img_path, $tmp_path, $new_width, $new_weight)) {
        $img_path = $tmp_path;
        $size_ischanged = 1;
    } else {
        exit;
    }
}
$ico_path = str_replace('.' . $img_ext, '_ico.' . $img_ext, $img_path);
$temp_img = '';
if ($img_ext == 'jpg' || $img_ext == 'jpeg') {
    $temp_img = imagecreatefromjpeg($img_path);
}
if ($img_ext == 'gif') {
    $temp_img = imagecreatefromgif($img_path);
}
if ($img_ext == 'png') {
Example #9
0
             $editclanname = @escape($_POST['editclanname'], 'string');
             $editurl = escape($_POST['editwebsite'], 'url');
             $editnation = escape($_POST['editnation'], 'string');
             $editicq = escape($_POST['editicq'], 'integer');
             $editemail = escape_for_email($_POST['editemail']);
             $updir = 'include/images/opponents/';
             $this_id = $getid;
             $outar['thumbwidth'] = 100;
             if (!empty($_FILES['editlogo']['tmp_name'])) {
                 $uploadname = $getid . '_' . $_FILES["editlogo"]["name"];
                 if ($getpicname != '.no-image-opponent.png' and $getpicname != 'thumb_.no-image-opponent.png') {
                     @unlink('include/images/opponents/' . $getpicname . '');
                     @unlink('include/images/opponents/thumb_' . $getpicname . '');
                 }
                 move_uploaded_file($_FILES["editlogo"]["tmp_name"], $updir . $uploadname);
                 create_thumb($updir . $uploadname, $updir . 'thumb_' . $uploadname, $outar['thumbwidth']);
             } else {
                 $uploadname = $getpicname;
             }
             // DB UPDATE
             db_query("UPDATE `prefix_opponents` SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tname \t= '" . $editclanname . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ttag \t= '" . $editclantag . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tpage \t= '" . $editurl . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\temail \t= '" . $editemail . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ticq \t= '" . $editicq . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tnation \t= '" . $editnation . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tlogo \t= '" . $uploadname . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tid = " . $getid . "");
             wd('admin.php?opponents', 'Daten gespeichert', 3);
             $design->footer(1);
         }
         $outar['ANTISPAM'] = get_antispam('adminuser_action', 0, true);
         $tpl->set_ar_out($outar, 1);
         $design->footer();
     }
     break;
 default:
     // Gegnerliste ausgeben
Example #10
0

    $photos_ext_accept = array('jpg','gif','png','jpeg');

if(in_array(strtolower(file_extension($_FILES['photo_file']['name'][$i])),$photos_ext_accept)){

       
  
           
$fl = new save_file($_FILES['photo_file']['tmp_name'][$i],$upload_folder,$_FILES['photo_file']['name'][$i]);

if($fl->status){
$file_saved =  $fl->saved_filename;
if($default_uploader_chmod){@chmod(CWD . "/". $file_saved,$default_uploader_chmod);} 

$thumb_saved =  create_thumb($file_saved,$settings['photos_thumb_width'],$settings['photos_thumb_hieght'],true);
if($default_uploader_chmod){@chmod(CWD . "/". $thumb_saved,$default_uploader_chmod);} 
    
db_query("insert into photos_data (name,img,thumb,cat,date) values('$name[$i]','$file_saved','$thumb_saved','$cat',now())");
      
}else{
$err_msg .= "<b> $phrases[error] : </b> $phrases[the_file]  ".$_FILES['photo_file']['name'][$i]."  : ".$fl->last_error_description." <br>" ;   
}



     }else{
    $err_msg .= "<b> $phrases[error] : </b> $phrases[the_file]  ".$_FILES['photo_file']['name'][$i]."  : $phrases[this_filetype_not_allowed] <br>" ;

             }
        }
Example #11
0
 function update_exec()
 {
     if ($this->m_blogs->check_author($this->input->post('blog_id')) == 0) {
         echo "go to hell";
     } else {
         //if user uploads an image
         if ($_FILES['photo']['error'] == 0) {
             //$new_post = $this->db->insert_id();
             //set the config to upload the files -> config/upload.php
             if (!$this->upload->do_upload('photo')) {
                 $a = array('error' => $this->upload->display_errors());
                 $this->session->set_flashdata('log', $a['error']);
                 redirect('member/blog/update/' . $this->input->post('blog_id'));
             } else {
                 $image_data = array('upload_data' => $this->upload->data());
                 //update blogs
                 $update = $this->m_blogs->update();
                 //update post
                 $this->m_posts->update();
                 //update tags
                 $data['post'] = $this->m_posts->get_post_by_type_ref(2, $this->input->post('blog_id'));
                 //type_id:2 = blog
                 $this->m_tags->update($data['post']->ID);
                 //update image
                 //check if blog has photo in table photos
                 $a = $this->m_photos->read($data['post']->ID);
                 if (count($a) > 0) {
                     //yes, update
                     //remove the previous image(?)
                     $prev_image = $this->m_photos->read($data['post']->ID);
                     if (is_file('./uploads/' . $prev_image[0]->src)) {
                         unlink('./uploads/' . $prev_image[0]->src);
                     }
                     if (is_file('./uploads/thumbs/' . $prev_image[0]->thumb)) {
                         unlink('./uploads/thumbs/' . $prev_image[0]->thumb);
                     }
                     $thumb = create_thumb($image_data['upload_data']['file_name']);
                     $this->m_photos->update($data['post']->ID, $image_data['upload_data'], $thumb);
                 } else {
                     //no, insert
                     $thumb = create_thumb($image_data['upload_data']['file_name']);
                     $post_info = $this->m_posts->get_post_by_type_ref(2, $this->input->post('blog_id'));
                     $this->m_photos->create($post_info->ID, $image_data['upload_data'], $thumb);
                 }
                 redirect('member/blog');
             }
         } else {
             //if user doesn't upload an image, just update the database
             //update blogs
             $update = $this->m_blogs->update();
             //update post
             $this->m_posts->update();
             //update tags
             $post = $this->m_posts->get_post_by_type_ref(2, $this->input->post('blog_id'));
             //type_id:2 = blog
             $ch_tag = $this->m_tags->read($post->ID);
             if (!empty($ch_tag)) {
                 $this->m_tags->update($post->ID);
             } else {
                 $this->m_tags->create($post->ID);
             }
             redirect('member/blog');
         }
     }
 }
Example #12
0
 function update_exec()
 {
     if ($this->m_projects->check_author($this->input->post('project_id')) == 0) {
         #echo "go to hell";
         redirect('denied');
     } else {
         $not_empty_upload = 0;
         //upload loop (max 3 photos)
         #foreach($_FILES['photo'] as $key => $value){
         for ($i = 1; $i <= 3; $i++) {
             //if user uploads an image
             if (!empty($_FILES['photo' . $i]['name'])) {
                 //$new_post = $this->db->insert_id();
                 //set the config to upload the files -> config/upload.php
                 if (!$this->upload->do_upload('photo' . $i)) {
                     $a[] = array('error' => $this->upload->display_errors());
                     $errors = true;
                     #$a = array('error' => $this->upload->display_errors());
                     #$this->session->set_flashdata('log', $a['error']);
                     #redirect('member/blog/create');
                 } else {
                     #$image_data = array('upload_data' => $this->upload->data());
                     $files[] = $this->upload->data();
                 }
                 $not_empty_upload += 1;
             }
         }
         if ($not_empty_upload == 0) {
             //user doesn't uplaod anything
             //update projects
             $update = $this->m_projects->update();
             //update post
             $this->m_posts->update();
             //update tags
             $post = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
             //type_id:3 = project
             $ch_tag = $this->m_tags->read($post->ID);
             if (!empty($ch_tag)) {
                 $this->m_tags->update($post->ID);
             } else {
                 $this->m_tags->create($post->ID);
             }
             redirect('member/project');
         } else {
             if (isset($a) && count($a) == $not_empty_upload) {
                 #print_r($a);
                 $this->session->set_flashdata('log', $a[$not_empty_upload - 1]['error']);
                 redirect('member/project/update/' . $this->input->post('project_id'));
             } elseif (isset($files)) {
                 #$image_data = array('upload_data' => $this->upload->data());
                 //update projects
                 $update = $this->m_projects->update();
                 //update post
                 $this->m_posts->update();
                 //update tags
                 $data['post'] = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
                 //type_id:3 = project
                 $this->m_tags->update($data['post']->ID);
                 foreach ($files as $r) {
                     $thumb = create_thumb($r['file_name']);
                     $post_info = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
                     $this->m_photos->create($post_info->ID, $r, $thumb);
                     #$thumb = create_thumb($r['file_name']);
                     #$this->m_photos->create($post_id,$r,$thumb);
                 }
                 /*
                 //update image
                 //check if project has photo in table photos
                 $a = $this->m_photos->read($data['post']->ID);
                 if(count($a)>0){
                 //yes, update
                 	
                 	//remove the previous image(?)
                 	$prev_image = $this->m_photos->read($data['post']->ID);
                 	if(is_file('./uploads/'.$prev_image[0]->src)){
                 		unlink('./uploads/'.$prev_image[0]->src);
                 	}
                 	if(is_file('./uploads/thumbs/'.$prev_image[0]->thumb)){
                 		unlink('./uploads/thumbs/'.$prev_image[0]->thumb);
                 	}
                 	
                 	$thumb = create_thumb($image_data['upload_data']['file_name']);
                 	$this->m_photos->update($data['post']->ID,$image_data['upload_data'],$thumb);
                 	
                 }else{
                 //no, insert
                 	
                 	$thumb = create_thumb($image_data['upload_data']['file_name']);
                 	$post_info = $this->m_posts->get_post_by_type_ref(3, $this->input->post('project_id'));
                 	$this->m_photos->create($post_info->ID,$image_data['upload_data'],$thumb);
                 }
                 */
                 redirect('member/project');
             }
         }
     }
 }
Example #13
0
 function _delete_video()
 {
     $response = array('success' => FALSE);
     if ($this->input->post()) {
         $this->form_validation->set_rules('user_id', 'User ID', 'trim|required');
         $this->form_validation->set_rules('template_id', 'Template ID', 'trim|required');
         $this->form_validation->set_rules('id', 'Video ID', 'trim|required');
         if ($this->form_validation->run() == TRUE) {
             $video_id = preg_replace("/[^0-9]/", "", $this->input->post('id'));
             $this->db->where('id', $video_id);
             $this->db->where('template_id', (int) $this->input->post('template_id'));
             $query = $this->db->get('template_videos');
             if ($query->num_rows() > 0) {
                 $row = $query->row();
                 $this->db->where('id', $video_id);
                 $this->db->where('template_id', (int) $this->input->post('template_id'));
                 $this->db->delete('template_videos');
                 $response = array('success' => TRUE);
                 unlink(create_thumb($row->thumb, 211, 126));
                 unlink(create_thumb($row->thumb, 746, 439));
                 unlink($row->thumb);
             }
         }
     }
     echo json_encode($response);
     exit;
 }
    @chmod($file_path, 0644);
    //创建缩略图
    $sthumb_width = intval($config['sthumb_width']);
    $sthumb_height = intval($config['sthumb_height']);
    $sthumb_width = 0 >= $sthumb_width ? null : $sthumb_width;
    $sthumb_height = 0 >= $sthumb_height ? null : $sthumb_height;
    if ($sthumb_width && $sthumb_height) {
        create_thumb($file_path, $file_ext, $sthumb_width, $sthumb_height);
    } else {
        if (empty($sthumb_width) && $sthumb_height) {
            create_thumb($file_path, $file_ext, null, $sthumb_height);
        } else {
            if ($sthumb_width && empty($sthumb_height)) {
                create_thumb($file_path, $file_ext, $sthumb_width);
            } else {
                create_thumb($file_path, $file_ext);
            }
        }
    }
    $file_url = $save_url . $new_file_name;
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 0, 'url' => $file_url));
    exit;
}
function alert($msg)
{
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 1, 'message' => $msg));
    exit;
 public function upload_img_file($arr, $id)
 {
     $fileUpload = WWW_ROOT . 'files' . DS . $id;
     if (!is_dir($fileUpload)) {
         mkdir($fileUpload, 0777);
     }
     if (!is_dir($fileUpload . '/thumb')) {
         mkdir($fileUpload . '/thumb', 0777);
     }
     if (!is_dir($fileUpload . '/minithumb')) {
         mkdir($fileUpload . '/minithumb', 0777);
     }
     $fname = removeSpecialChar($arr['name']);
     $file = time() . "_" . $fname;
     if (upload_my_file($arr['tmp_name'], $fileUpload . '/' . $file)) {
         $save_path = "thumb_" . $file;
         $min_save_path = "mini_thumb_" . $file;
         create_thumb($fileUpload . '/' . $file, 150, $fileUpload . '/thumb/' . $save_path);
         create_thumb($fileUpload . '/' . $file, 42, $fileUpload . '/minithumb/' . $min_save_path);
         return $file;
     } else {
         return 0;
     }
 }
Example #16
0
 function update_exec()
 {
     if ($this->m_reviews->check_author($this->input->post('review_id')) == 0) {
         #echo "go to hell";
         redirect('denied');
     } else {
         $not_empty_upload = 0;
         //upload loop (max 3 photos)
         #foreach($_FILES['photo'] as $key => $value){
         for ($i = 1; $i <= 3; $i++) {
             //if user uploads an image
             if (!empty($_FILES['photo' . $i]['name'])) {
                 //$new_post = $this->db->insert_id();
                 //set the config to upload the files -> config/upload.php
                 if (!$this->upload->do_upload('photo' . $i)) {
                     $a[] = array('error' => $this->upload->display_errors());
                     $errors = true;
                     #$a = array('error' => $this->upload->display_errors());
                     #$this->session->set_flashdata('log', $a['error']);
                     #redirect('member/blog/create');
                 } else {
                     #$image_data = array('upload_data' => $this->upload->data());
                     $files[] = $this->upload->data();
                 }
                 $not_empty_upload += 1;
             }
         }
         if ($not_empty_upload == 0) {
             //user doesn't uplaod anything
             //update reviews
             $update = $this->m_reviews->update();
             //update post
             $this->m_posts->update();
             //update tags
             $post = $this->m_posts->get_post_by_type_ref(1, $this->input->post('review_id'));
             //type_id:1 = review
             $ch_tag = $this->m_tags->read($post->ID);
             if (!empty($ch_tag)) {
                 $this->m_tags->update($post->ID);
             } else {
                 $this->m_tags->create($post->ID);
             }
             redirect('member/review');
         } else {
             if (isset($a) && count($a) == $not_empty_upload) {
                 #print_r($a);
                 $this->session->set_flashdata('log', $a[$not_empty_upload - 1]['error']);
                 redirect('member/review/update/' . $this->input->post('review_id'));
             } elseif (isset($files)) {
                 //update reviews
                 $update = $this->m_reviews->update();
                 //update post
                 $this->m_posts->update();
                 //update tags
                 $data['post'] = $this->m_posts->get_post_by_type_ref(1, $this->input->post('review_id'));
                 //type_id:1 = review
                 $this->m_tags->update($data['post']->ID);
                 foreach ($files as $r) {
                     $thumb = create_thumb($r['file_name']);
                     $post_info = $this->m_posts->get_post_by_type_ref(1, $this->input->post('review_id'));
                     $this->m_photos->create($post_info->ID, $r, $thumb);
                 }
                 redirect('member/review');
             }
         }
     }
 }
Example #17
0
 /**
  * Processing current upload, aka 'after user click upload button to upload his files'
  *
  * @param bool $just_check If enabled, no uploading will occur, just checking process 
  */
 public function process($just_check = false)
 {
     global $SQL, $dbprefix, $config, $lang;
     ($hook = kleeja_run_hook('process_func_uploading_cls')) ? eval($hook) : null;
     //run hook
     #To prevent flooding, user must wait, waiting-time is grapped from Kleeja settings, admin is exceptional
     if (!user_can('enter_acp') && user_is_flooding()) {
         return $this->errors[] = sprintf($lang['YOU_HAVE_TO_WAIT'], $config['usersectoupload']);
     }
     #if captcha enabled
     if ($config['safe_code']) {
         #captcha is wrong
         if (!kleeja_check_captcha()) {
             return $this->errors[] = $lang['WRONG_VERTY_CODE'];
         }
     }
     #files uploading
     $files = rearrange_files_input($_FILES['file']);
     if (empty($files)) {
         $this->errors[] = $lang['CHOSE_F'];
     }
     foreach ($files as $file) {
         #if total uploaded files reached the limit
         if ($this->total >= $config['filesnum']) {
             break;
         }
         #no file content
         if (empty($file['tmp_name'])) {
             continue;
         }
         #filename without extension?
         if (strpos($file['name'], '.') === false) {
             #TODO: try to figure out the extension for popular files
             $this->errors[] = sprintf($lang['WRONG_F_NAME'], htmlspecialchars($file['name']));
             continue;
         }
         #clean filename, what about other language?
         $filename = strtr($file['name'], 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
         $filename = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), strtolower($filename));
         #get the extension and the right filename
         $file_extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
         $filename = str_replace('.', '_', substr($filename, 0, strrpos($filename, '.')));
         #if file extension is not allowed?
         if (!in_array($file_extension, array_keys($this->allowed_extensions))) {
             $this->errors[] = sprintf($lang['FORBID_EXT'], $file_extension);
             continue;
         }
         #file check for first 265 content
         if (check_file_content($file['tmp_name']) == false && !$just_check) {
             $this->errors[] = sprintf($lang['NOT_SAFE_FILE'], $filename);
             continue;
         }
         #file size exceed allowed one
         if ($this->allowed_extensions[$file_extension] > 0 && $file['size'] >= $this->allowed_extensions[$file_extension]) {
             $this->errors[] = sprintf($lang['SIZE_F_BIG'], htmlspecialchars($file_extension['name']), readable_size($this->allowed_extensions[$file_extension]));
             continue;
         }
         #modify filename to apply Admin changes
         $filename = change_filename($file['name'], $file_extension);
         ($hook = kleeja_run_hook('uploading_process_func_loop_files')) ? eval($hook) : null;
         //run hook
         #if this is listed as live-ext from Kleeja settings
         $live_exts = array_map('trim', explode(',', $config['imagefolderexts']));
         $folder_to_upload = $this->uploading_folder;
         if (in_array($file_extension, $live_exts)) {
             # live-exts folder, if empty use default folder
             $folder_to_upload = trim($config['imagefolder']) == '' ? trim($config['foldername']) : $this->uploading_folder;
         }
         #is this file an image?
         $is_img = in_array($file_extension, array('png', 'gif', 'jpg', 'jpeg')) ? true : false;
         #now upload
         $upload_result = move_uploaded_file($file['tmp_name'], $folder_to_upload . '/' . $filename);
         #if uploading went ok
         if ($upload_result && !$just_check) {
             #sometime can nott see the file after uploading without this fix
             @chmod($folder . '/' . $filename, 0644);
             #generate delete code
             $delete_code = md5($filename . uniqid());
             #insert to the DB
             $insert_id = $this->add_to_database($filename, $folder_to_upload, $file['size'], $file_extension, $file['name'], $delete_code);
             #if insertion goes bad, rollback, delete the file and show error
             if (!$insert_id) {
                 @unlink($folder . '/' . $filname);
                 $this->errors[] = sprintf($lang['CANT_UPLAOD'], $filename);
                 continue;
             }
             # inforamation of file, used for generating a url boxes
             $file_info = array('::ID::' => $insert_id, '::NAME::' => $filename, '::DIR::' => $folder_to_upload, '::FNAME::' => $file['name'], '::EXT::' => $file_extension, '::CODE::' => $delete_code);
             #if image
             if ($is_img) {
                 # generate thumb always
                 create_thumb($folder_to_upload . '/' . $filename, $file_extension, $folder_to_upload . '/thumbs/' . $filename, $this->thumb_dimensions['width'], $this->thumb_dimensions['height']);
                 #show thumb if enabled
                 if ($config['thumbs_imgs']) {
                     $this->results[$insert_id]['thumb'] = kleeja_get_link('thumb', $file_info);
                 }
                 #if watermark enabled
                 if ($config['write_imgs']) {
                     create_watermark($folder_to_upload . '/' . $filename, $file_extension);
                 }
                 $this->results[$insert_id]['image'] = kleeja_get_link('image', $file_info);
             } else {
                 $this->results[$insert_id]['file'] = kleeja_get_link('file', $file_info);
             }
             #if delete code is enabled to be displayed
             if ($config['del_url_file']) {
                 $this->results[$insert_id]['delete_code'] = kleeja_get_link('del', $file_info);
             }
             #uploaded files increment++
             $this->total++;
         } else {
             $this->errors[] = sprintf($lang['CANT_UPLAOD'], $filename);
         }
     }
     #end-foreach
     #total files equal zero, then show a message to tell user to select files
     if ($this->total == 0 && !sizeof($this->errors)) {
         $this->errors[] = $lang['CHOSE_F'];
     }
 }
Example #18
0
$pictures = read_pictures_in_dir($path);
$nr_pics = sizeof($pictures);
echo "\n\t<form action='index.php' method='post'>\n\t\t<input type='submit' name='start' value='fertigstellen'>\n\t</form>";
echo "<table><tr>";
if ($nr_pics > 0) {
    $i = 1;
    if (!file_exists($path . "thumb")) {
        //Event. Verzeichnis für Voransicht erstellen
        umask(02);
        mkdir($path . "thumb", 0770);
    }
    foreach ($pictures as $pic) {
        $filename = $path . $pic;
        $thumbfilename = $path . "thumb" . DIRECTORY_SEPARATOR . $pic;
        if (!file_exists($thumbfilename)) {
            create_thumb($filename, $thumbfilename);
        }
        //Event.  Voransicht erstellen
        echo "\t<td><img src='{$thumbfilename}'></td>";
        if ($i % 3 == 0) {
            echo "\n</tr>\n<tr>";
        }
        $i++;
    }
}
echo "</tr></table>";
echo "\n\t<form action='index.php' method='post'>\n\t\t<input type='submit' name='fertigstellen' value='fertigstellen'>\n\t</form>";
echo create_footer("");
?>

    if (!$name_photo) {
        die('图像名称不能为空!');
    }
    $img = getimagesize($yuan_pic);
    $extension = strtolower($path_info['extension']);
    $save_name = rand_str() . '.' . $extension;
    $save = ROOT_DIR_NONE . "/upload/" . $save_name;
    $save_e = "/upload/" . $save_name;
    $sql = "insert into eachbb_member.photo (description,u_id,u_name,photo,album_id,created_at,width,height)values('{$text_photo}',{$id},'{$name_photo}','{$save_e}',{$upload_select_id},now(),{$img['0']},{$img['1']});";
    $last = "insert into eachbb_member.lastest_news (resource_id,resource_type,u_id,created_at,u_name,u_avatar,form,photo)values('{$upload_select_id}','image','{$user->id}',now(),'{$user->name}','{$user->avatar}','添加了新的照片。','{$save_e}')";
    $u_name = $user->name;
    $u_avatar = $user->avatar;
}
if (move_uploaded_file($yuan_pic, $save)) {
    if ($db->execute($sql) && $db->execute($last)) {
        create_thumb('small', $save_e, 100, 100);
        $alpum = $_POST['alpum'];
        echo "<script>alert('添加成功!');</script>";
        if ($alpum) {
            if (is_numeric($alpum)) {
                redirect("/yard/photo_show.php?id={$alpum}");
            } else {
                echo "非法操作!";
            }
        } else {
            redirect('/yard/album_list.php');
        }
    } else {
        echo "添加失败!";
    }
} else {
Example #20
0
 function createthumb()
 {
     if (IS_POST) {
         $info = array('status' => 2, 'info' => '', 'url' => '');
         $arccatid = I('post.article_catid');
         $catid = I('post.category_d');
         //查询是否有没有处理完的图片
         $thumbpath = F('thumbpath');
         if (empty($thumbpath)) {
             //开始查询要处理的图片数据
             $temarr = array();
             $map['pic'] = array('neq', 0);
             if ($arccatid != 0) {
                 $map['category_id'] = $arccatid;
             }
             $list = M('Article')->where($map)->field('pic')->select();
             foreach ($list as $val) {
                 $temarr[] = $val['pic'];
             }
             if ($catid != 0) {
                 $map['category_id'] = $catid;
             }
             $list = M('goods')->where($map)->field('pic,xc')->select();
             foreach ($list as $val) {
                 $temarr[] = $val['pic'];
                 //拆分相册
                 $xcarr = explode('|', $val['xc']);
                 foreach ($xcarr as $val) {
                     $temarr[] = $val;
                 }
             }
             //把查到的数量保存到缓存中
             F('thumbpath', $temarr);
             $thumbpath = $temarr;
         }
         //开始生成图片
         $jishu = 0;
         //处理的总数量
         $sucstr = '';
         //成功字符串
         $failjishu = 0;
         //失败的数量
         $failstr = '';
         //错误字符串
         $num = count($thumbpath);
         $num = $num > 50 ? 50 : $num;
         //一次只处理50个数据
         $i = 0;
         for ($i; $i < $num; $i++) {
             if (count($thumbpath) > 0) {
                 $spath = get_picture($thumbpath[$i], 'path');
                 $thupath = str_replace('image/', 'image/thumb/', $spath);
                 $spath = path_a($spath);
                 $dpath = str_replace('image/', 'image/thumb/', $spath);
                 if (file_exists($spath)) {
                     //源文件存在
                     if (file_exists($dpath)) {
                         unlink($dpath);
                     }
                     $result = create_thumb($spath, $dpath, C('THUMB_WIDTH'), C('THUMB_HEIGHT'));
                     if ($result === true) {
                         M('Picture')->where("id={$thumbpath[$i]}")->save(array('thumbpath' => $thupath));
                         $jishu++;
                         $sucstr .= $spath . '->' . $dpath . '<br>';
                     } else {
                         $failjishu++;
                         $failstr .= $spath . '->' . $dpath . '<br>';
                     }
                 } else {
                     $failjishu++;
                     $failstr .= '<span style="color:red;">' . $spath . "此路径文件丢失数据库id为{$thumbpath[$i]}请联系管理员自行处理</span><br>";
                 }
                 unset($thumbpath[$i]);
             }
         }
         $tishistr = '全部完成';
         if (count($thumbpath) <= 0) {
             $info['status'] = 1;
         } else {
             $tishistr = '还剩' . count($thumbpath) . '个。继续生成中......';
         }
         F('thumbpath', array_values($thumbpath));
         $info['info'] = "成功生成{$jishu}个缩略图,失败{$failjishu}个,{$failstr},{$tishistr}";
         $this->ajaxreturn($info);
         exit;
     } else {
         //文章分类树
         $catelist = F('sys_category_tree');
         if (empty($catelist)) {
             $catelist = F_get_cate_list(true, 'article');
             F('sys_category_tree', $catelist);
         }
         $catelist[0] = '全部分类';
         $field = array(array('field' => 'arccat_catid', 'name' => 'arccat_catid', 'type' => 'select', 'title' => '文章分类', 'note' => '', 'extra' => $catelist, 'is_show' => 3));
         $this->assign('fieldarr1', $field);
         $this->display();
     }
 }
Example #21
0
    $fende = strtolower($fende);
    if (!empty($_FILES['file']['name']) and $size[0] > 10 and $size[1] > 10 and ($size[2] == 2 or $size[2] == 3 or $size[2] == 1) and ($fende == 'gif' or $fende == 'jpg' or $fende == 'jpeg' or $fende == 'png')) {
        $name = $_FILES['file']['name'];
        $tmp = explode('.', $name);
        $tm1 = count($tmp) - 1;
        $endung = escape($tmp[$tm1], 'string');
        unset($tmp[$tm1]);
        $name = escape(implode('', $tmp), 'string');
        $besch = escape($_POST['text'], 'string');
        $id = db_result(db_query("SHOW TABLE STATUS FROM `" . DBDATE . "` LIKE 'prefix_usergallery'"), 0, 'Auto_increment');
        $bild_url = 'include/images/usergallery/img_' . $id . '.' . $endung;
        if (@move_uploaded_file($_FILES['file']['tmp_name'], $bild_url)) {
            @chmod($bild_url, 0777);
            db_query("INSERT INTO prefix_usergallery (uid,name,endung,besch) VALUES (" . $uid . ",'" . $name . "','" . $endung . "','" . $besch . "')");
            $bild_thumb = 'include/images/usergallery/img_thumb_' . $id . '.' . $endung;
            create_thumb($bild_url, $bild_thumb, $allgAr['gallery_preview_width']);
            @chmod($bild_thumb, 0777);
            echo '<b>Datei ' . $name . '.' . $endung . ' erfolgreich hochgeladen</b><br />';
            $page = $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]);
            echo 'Bildlink: <a target="_blank" href="http://' . $page . '/' . $bild_url . '">http://' . $page . '/' . $bild_url . '</a><br />';
            echo 'Oder klein: <a target="_blank" href="http://' . $page . '/' . $bild_thumb . '">http://' . $page . '/' . $bild_thumb . '</a><br /><br />';
        }
    }
}
// bilder abfragen
$limit = $img_per_site;
$page = $menu->getA(3) == 'p' ? $menu->getE(3) : 1;
$MPL = db_make_sites($page, '', $limit, 'index.php?user-usergallery-' . $uid, "usergallery` WHERE uid = " . $uid);
$anfang = ($page - 1) * $limit;
$erg = db_query("SELECT `name`, `besch`, `endung`, `id` FROM `prefix_usergallery` WHERE `uid` = " . $uid . " ORDER BY `id` DESC LIMIT " . $anfang . "," . $limit);
$tpl->set('imgperline', $allgAr['gallery_imgs_per_line']);
Example #22
0
File: index.php Project: hoogle/ttt
            $offset_y = 0;
        }
        $composite_img->cropImage($edge, $edge, $crop_x, $crop_y);
        $blank_img->compositeImage($composite_img, Imagick::COMPOSITE_OVER, $offset_x, $offset_y);
        $blank_img->setImageFormat('jpeg');
        $blank_img->writeImage($thumb_file);
        $blank_img->clear();
    }
    return $blank_img;
}
//http://122.116.58.213/lab/crop_thumb/?file=fruit
//file: 1279166339 logo_muchiii Whatsup fruit
$file = $_GET['file'];
$source_file = "/home/www/develop/lab/crop_thumb/{$file}.jpg";
$thumb_file = "/home/www/develop/lab/crop_thumb/thumb/thumb-{$file}.jpg";
create_thumb($source_file, $thumb_file, THUMBNAIL_CROP_EDGE, $w, $h);
if ($w > $h) {
    $max_edge = $w;
    $offsetx = $w / 2 - THUMBNAIL_CROP_EDGE / 2;
    $offsety = $max_edge / 2 - $h / 2;
    $moffsety = $max_edge / 2 - THUMBNAIL_CROP_EDGE / 2;
    $ol = 0;
} else {
    $max_edge = $h;
    $offsety = 0;
    $offsetx = $max_edge / 2 - THUMBNAIL_CROP_EDGE / 2;
    $moffsety = $max_edge / 2 - THUMBNAIL_CROP_EDGE / 2;
    $ol = $max_edge / 2 - $w / 2;
}
?>
<div style="margin:30px 200px;width:1000px;height:700px;background-color:#ccc;">
*/
if ($p_picture['type'] != 'image/jpeg') {
    $success = false;
    array_push($errors, "The file is not jpg.");
}
//Sanitize the filename
$n_picture = iconv("UTF-8", "ASCII//TRANSLIT", $p_picture['name']);
$n_picture = preg_replace("/[^[:alnum:]._-]/", '_', $n_picture);
$n_picture = time() . '-' . $n_picture;
//make the filename unique
$n_picture = strtolower($n_picture);
//make the filename and extension lowercase
if (!file_exists($picture_path)) {
    mkdir($picture_path, 0777, true);
}
if (!move_uploaded_file($p_picture['tmp_name'], $picture_path . '/' . $n_picture)) {
    $success = false;
    array_push($errors, "File upload error.");
}
//create thumb
if (!file_exists($thumb_path)) {
    mkdir($thumb_path, 0777, true);
}
$thumb = $thumb_path . '/thumb_' . $n_picture;
$picture = $picture_path . '/' . $n_picture;
if (!file_exists($thumb)) {
    if (create_thumb($picture, $thumb, $twidth, $theight) === false) {
        print "Thumb creating failed: " . $n_picture . __FILE__ . __LINE__;
    }
}
$p_picture = $n_picture;
Example #24
0
    die('请先登录!');
}
$id = $user->id;
$created_at = date("Y-m-d H:i:s");
$path_info = pathinfo($_FILES['src'][name]);
$yuan_pic = $_FILES['src'][tmp_name];
$extension = strtolower($path_info['extension']);
$save_name = rand_str() . '.' . $extensio;
$save = ROOT_DIR_NONE . "/upload/" . $save_name;
$save_e = "/upload/" . $save_name;
if (move_uploaded_file($yuan_pic, $save)) {
    $sql = "insert into eachbb_member.member_avatar(u_id,photo,create_at,status)values({$id},'{$save_e}','{$created_at}',0);";
    if ($db->execute($sql)) {
        create_thumb('big', $save_e, 300, 300);
        create_thumb('normal', $save_e, 165, 165);
        create_thumb('small', $save_e, 98, 98);
        alert("上传成功!");
        if ($_SESSION['page_from'] == 'baby') {
            redirect('/baby/index.php');
        } else {
            redirect('/yard/info.php');
        }
    } else {
        alert("上传失败!");
    }
} else {
    debug_info('fail to upload file:' . $yuan_pic, 'js');
}
?>
	</body>
</html>
Example #25
0
    move_uploaded_file($tmp_file, $org_file);
    $info = ImageInfo::getImageInfo($org_file);
    $latitude = $info['lat'];
    $longitude = $info['lng'];
    $photo_shot = $info['photo_shot'];
    $description = $_GET['description'];
    $tags = explode(',', $_GET['tags']);
    if (!empty($latitude)) {
        // Create three pictures, 2 thumbnails and one main
        // Dimensions
        // Small: 160x120
        // Medium: 260x180
        // Large: 640x480
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_small.jpg", 160, 120), 'uri_path' => $uri_path . $filename . "_small.jpg", 'type' => 0));
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_medium.jpg", 260, 180), 'uri_path' => $uri_path . $filename . "_medium.jpg", 'type' => 1));
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_large.jpg", 640, 480), 'uri_path' => $uri_path . $filename . "_large.jpg", 'type' => 2));
        $db->insertPicture($user_id, $phy_path . $filename . ".jpg", $uri_path . $filename . ".jpg", $latitude, $longitude, $photo_shot, $description, $tags, $thumbnails);
        echo "Added in DB";
    } else {
        echo "No exif-data found!";
    }
}
function create_thumb($path, $new_path, $new_w, $new_h)
{
    // TO-DO: Need to verify path, need to use some faster library for resizing, this is slooow..
    $src_img = imagecreatefromjpeg($path);
    $dst_img = ImageCreateTrueColor($new_w, $new_h);
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, $old_x, $old_y);
    imagejpeg($dst_img, $new_path);
Example #26
0
    $besch = escape($_REQUEST['besch'], 'string');
    $row = db_fetch_assoc(db_query("SELECT `cat` FROM `prefix_gallery_imgs` WHERE `id` = " . $id));
    db_query("UPDATE `prefix_gallery_imgs` SET `besch` = '" . $besch . "' WHERE `id` = " . $id);
    $azk = $row['cat'];
}
// Bild erneuern
if ($menu->getA(1) == 'r') {
    $id = $menu->getE(1);
    $row = db_fetch_assoc(db_query("SELECT `endung`,`cat` FROM `prefix_gallery_imgs` WHERE `id` = " . $id));
    $endung = $row['endung'];
    $bild_url = 'include/images/gallery/img_' . $id . '.' . $endung;
    if (file_exists($bild_url)) {
        $bild_thumb = 'include/images/gallery/img_thumb_' . $id . '.' . $endung;
        $bild_norm = 'include/images/gallery/img_norm_' . $id . '.' . $endung;
        create_thumb($bild_url, $bild_thumb, $allgAr['gallery_preview_width']);
        create_thumb($bild_url, $bild_norm, $allgAr['gallery_normal_width']);
    }
    $azk = $row['cat'];
}
if ($menu->getA(1) == 'M') {
    $pos = $menu->getE(2);
    $id = $menu->getE(1);
    $cat = db_result(db_query("SELECT `cat` FROM `prefix_gallery_cats` WHERE `id` = " . $id), 0);
    $nps = $menu->getA(2) == 'u' ? $pos + 1 : $pos - 1;
    $anz = db_result(db_query("SELECT COUNT(*) FROM `prefix_gallery_cats` WHERE `cat` = " . $cat), 0);
    if ($nps < 0) {
        db_query("UPDATE `prefix_gallery_cats` SET `pos` = " . $anz . " WHERE `id` = " . $id);
        db_query("UPDATE `prefix_gallery_cats` SET `pos`  = `pos` -1 WHERE `cat` = " . $cat);
    }
    if ($nps >= $anz) {
        db_query("UPDATE `prefix_gallery_cats` SET `pos`  = -1 WHERE `id` = " . $id);
Example #27
0
 public function upload_foto()
 {
     if (!$this->session->userdata('logged_in')) {
         die;
     }
     $config['upload_path'] = './img/users/';
     $config['allowed_types'] = 'jpeg|jpg|png';
     $config['max_size'] = '1024';
     $config['max_width'] = '500';
     $config['max_height'] = '500';
     $config['overwrite'] = TRUE;
     $config['file_name'] = 'user_picture_' . $this->input->post('id');
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload('file')) {
         $error = $this->upload->display_errors();
         //var_dump($error);
         $result = FALSE;
         $img_url = '';
     } else {
         $data = $this->upload->data();
         //update data
         $update['picture'] = './img/users/' . $data['raw_name'] . $data['file_ext'];
         $this->db->where('id', $this->input->post('id'));
         $this->db->update('users', $update);
         $result = TRUE;
         $img_url = base_url() . str_replace('./', '', create_thumb($update['picture'], 100, 100));
         $error = '';
     }
     $response = array('success' => $result, 'img_url' => $img_url, 'error' => strip_tags($error));
     echo json_encode($response);
     exit;
 }
Example #28
0
    $fende = strtolower($fende);
    if (!empty($_FILES['file']['name']) and $size[0] > 10 and $size[1] > 10 and ($size[2] == 2 or $size[2] == 3 or $size[2] == 1) and ($fende == 'gif' or $fende == 'jpg' or $fende == 'jpeg' or $fende == 'png')) {
        $name = $_FILES['file']['name'];
        $tmp = explode('.', $name);
        $tm1 = count($tmp) - 1;
        $endung = escape($tmp[$tm1], 'string');
        unset($tmp[$tm1]);
        $name = escape(implode('', $tmp), 'string');
        $besch = escape($_POST['text'], 'string');
        $id = db_result(db_query("SHOW TABLE STATUS FROM `" . DBDATE . "` LIKE 'prefix_usergallery'"), 0, 'Auto_increment');
        $bild_url = 'include/images/usergallery/img_' . $id . '.' . $endung;
        if (@move_uploaded_file($_FILES['file']['tmp_name'], $bild_url)) {
            @chmod($bild_url, 0777);
            db_query("INSERT INTO prefix_usergallery (uid,name,endung,besch) VALUES (" . $uid . ",'" . $name . "','" . $endung . "','" . $besch . "')");
            $bild_thumb = 'include/images/usergallery/img_thumb_' . $id . '.' . $endung;
            create_thumb($bild_url, $bild_thumb, '120');
            @chmod($bild_thumb, 0777);
            echo '<div id="contentBigTop"><div class="HeadText"><a href="">Hochgeladen</a></div></div>';
            echo '<div id="contentBig">';
            echo '<div class="contenText">';
            echo '<b>Datei ' . $name . '.' . $endung . ' erfolgreich hochgeladen</b><br />';
            $page = $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]);
            echo 'Bildlink: <a target="_blank" href="http://' . $page . '/' . $bild_url . '">http://' . $page . '/' . $bild_url . '</a><br />';
            echo 'Oder klein: <a target="_blank" href="http://' . $page . '/' . $bild_thumb . '">http://' . $page . '/' . $bild_thumb . '</a>';
            echo '</div>';
            echo '</div>';
        }
    }
}
# bilder abfragen
$limit = $img_per_site;
Example #29
0
    $i = 0;
    foreach ($videos->result() as $video) {
        if ($i == 0) {
            echo '<div class="embed-responsive embed-responsive-16by9">';
            echo '<div onclick="play($(this));" id="youtube-main" data-youtubeurl="' . $video->url . '"><img src="' . base_url() . str_replace('./', '', create_thumb($video->thumb, 746, 439)) . '"/></div>';
            echo '</div>';
            echo '<div class="video-nav">';
            echo '<div id="carousel-video" class="carousel video" data-ride="carousel">';
            echo '<div class="carousel-inner video">';
            echo '<div class="item active">';
        }
        if ($i % 3 == 0 && $i != 0) {
            echo '</div>';
            echo '<div class="item">';
        }
        echo '<div class="widget-video-thumb"><img src="' . base_url() . str_replace('./', '', create_thumb($video->thumb, 211, 126)) . '" alt=""  data-youtubeurl="' . $video->url . '" onclick="play($(this));"/></div>';
        $i++;
    }
    echo '</div>';
    //<div class="item">
    echo '</div>';
    //<div class="carousel-inner video">
    echo '<a class="left carousel-control" href="#carousel-video" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> </a> <a class="right carousel-control" href="#carousel-video" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> </a>';
    echo '</div>';
    //<div id="carousel-video" class="carousel video" data-ride="carousel">
    echo '</div>';
    //<div class="video-nav">
} else {
    echo '<div class="blank-video"><button type="button" class="btn btn-warning edit-widget center-block" data-toggle="modal" data-target="#videos-modal">Add Video</button></div>';
}
?>
Example #30
0
/**
 * 获取图片
 * @param int $id
 * @param string $field
 * @return 完整的数据  或者  指定的$field字段值
 * @author huajie <*****@*****.**>
 */
function get_picture($id = null, $field = null, $wh = null)
{
    $revalue = '';
    $id = trim($id);
    if (empty($id)) {
        $revalue = false;
    }
    if (is_numeric($id)) {
        $cakey = md5($id . '_' . $field . '_' . $wh);
        //$revalue=F('_picture/'.$cakey);
        $pkey = '_picture/' . $id % 100;
        $picarr = F($pkey);
        $revalue = $picarr[$cakey];
        if (empty($revalue) || APP_DEBUG) {
            $picture = M('Picture')->where(array('status' => 1))->getById($id);
            if (!empty($field) && !empty($wh)) {
                $wharr = explode('_', $wh);
                if (count($wharr == 2)) {
                    $revalue = str_replace('/Uploads/image/', IMAGE_CACHE_DIR, $picture['path']);
                    $revalue = substr($revalue, 0, strrpos($revalue, '.')) . '_' . $wh . substr($revalue, strrpos($revalue, '.'));
                    //判断之前是不是已经生成
                    if (!file_exists(path_a($revalue))) {
                        $result = create_thumb(path_a($picture['path']), path_a($revalue), $wharr[0], $wharr[1]);
                        if ($result !== true) {
                            $revalue = $picture['path'];
                        }
                    }
                }
            } else {
                if (!empty($field)) {
                    $revalue = $picture[$field];
                    if ($field == 'thumbpath') {
                        if (!file_exists(path_a($revalue))) {
                            $result = create_thumb(path_a($picture['path']), path_a($revalue), C('THUMB_WIDTH'), C('THUMB_HEIGHT'));
                            if ($result !== true) {
                                $revalue = $picture['path'];
                            }
                        }
                    }
                } else {
                    $revalue = $picture['path'];
                }
            }
            $picarr[$cakey] = $revalue;
            F($pkey, $picarr);
        }
    } else {
        $revalue = $id;
    }
    return empty($revalue) ? '' : path_r($revalue);
}