예제 #1
0
function get_video_prev($id, $size)
{
    $size = explode('x', strtolower($size));
    $size[0] = prev_size_c(@$size[0]);
    $size[1] = prev_size_c(@$size[1]);
    if (!$size[1] || !$size[0]) {
        return false;
    }
    $pf = ROOT_PATH . '/tmp/attach_thumb/att-' . $id . '-' . $size[0] . '-' . $size[1] . '.jpg';
    if (file_exists($pf)) {
        return $pf;
    }
    $pm = ROOT_PATH . '/tmp/attach_thumb/att-' . $id . '-video.jpg';
    # Exists master-copy?
    if (!file_exists($pm)) {
        $r = array();
        exec('/usr/local/bin/ffmpeg -i ' . ROOT_PATH . '/uploads/att-' . $id . '.dat -an -ss 5 -r 1 -vframes 1 -s 640x480 -y -f mjpeg ' . $pm, $r);
    }
    if (!file_exists($pm)) {
        return $pm;
    }
    $res = resize_image($pm, $size[0], $size[1]);
    @copy($res, $pf);
    return $res;
}
예제 #2
0
 /**
  * Returns thumbnail size image url.
  * @since 1.0
  *
  * @return string
  */
 protected function get_thumb_image_url()
 {
     $url = $this->image_url;
     if ($url) {
         return resize_image($url, 120, 120);
     }
     return;
 }
예제 #3
0
 function save_sized_image($original, $key, $size, $folder)
 {
     $file = $folder . "/" . $key . ".jpg";
     $file_path = IMAGES_DIR . "/" . $file;
     resize_image($original, $size, $file_path);
     if (STORAGE_STRATEGY == 's3') {
         $input = S3::inputFile($file_path);
         S3::putObject($input, S3_BUCKET, $file, S3::ACL_PUBLIC_READ);
     }
 }
예제 #4
0
function create_thumbnail($filename, $thumbdir = 'sm', $width = 32, $quality = 90)
{
    try {
        $fd = dirname($filename) . '/' . $thumbdir;
        @mkdir($fd);
        $name = basename($filename);
        $thumb = $fd . '/' . $name;
        return resize_image($filename, $thumb, $width, $quality);
    } catch (Exception $e) {
    }
    return false;
}
예제 #5
0
function upload_song($tempFile, $title = null, $artist = null, $genre = null, $rating = null)
{
    global $db;
    $extension = strtolower(pathinfo($tempFile, PATHINFO_EXTENSION));
    $id = make_song_id($title, $tempFile);
    if ($id === false) {
        return array('success' => false, 'message' => "Duplicate File");
    }
    if (!$title || !$artist) {
        $result = get_song_info($tempFile, $extension);
        if (!$title) {
            $title = $result['title'];
        }
        if (!$artist) {
            $artist = $result['artist'];
        }
    }
    if (!$rating) {
        $rating = 2.5;
    }
    $i = 1;
    $uploadFile = sanitize_file_name($title) . '.' . $extension;
    while (file_exists(__FILES__ . $uploadFile)) {
        $uploadFile = sanitize_file_name($title) . $i . '.' . $extension;
        $i++;
    }
    switch ($extension) {
        case 'txt':
        case 'chopro':
        case 'pdf':
            // NO PROCESSING
            if (!copy($tempFile, __FILES__ . $uploadFile)) {
                return array('success' => false, 'message' => "failed to copy {$tempFile} to {$uploadFile}");
            }
            break;
        case 'jpg':
        case 'jpeg':
        case 'png':
        case 'gif':
            // RESIZE
            resize_image($tempFile, __FILES__ . $uploadFile, $extension, MAX_FILE_W, MAX_FILE_H);
            break;
        default:
            return array('success' => false, 'message' => "file extension '." . $extension . "'not recognized");
            return;
    }
    $query = "INSERT INTO music (songID, location, title, artist, genre, rating, views, uploaded)";
    $query .= " VALUES ( '" . $db->escape($id) . "','" . $db->escape($uploadFile) . "','";
    $query .= $db->escape($title) . "','" . $db->escape($artist) . "','" . $db->escape($genre) . "'," . $db->escape($rating) . ",0," . time() . " )";
    $result = $db->query($query);
    unlink($tempFile);
    return array('success' => true, 'message' => $title . " successfully uploaded!");
}
예제 #6
0
function process_image($dir, $filename)
{
    // Set up the variables
    $i = strrpos($filename, '.');
    $image_name = substr($filename, 0, $i);
    $ext = substr($filename, $i);
    // Set up the read path
    $image_path = $dir . $filename;
    // Set up the write paths
    $image_path_m = $dir . $image_name . '_m' . $ext;
    $image_path_s = $dir . $image_name . '_s' . $ext;
    // Create an image that's a maximum of 400x300 pixels
    resize_image($image_path, $image_path_m, 250, 250);
    // Create a thumbnail image that's a maximum of 100x100 pixels
    resize_image($image_path, $image_path_s, 120, 100);
}
예제 #7
0
function process_image($dir, $filename)
{
    // Set up the variables
    $dir = $dir . DIRECTORY_SEPARATOR;
    $i = strrpos($filename, '.');
    $image_name = substr($filename, 0, $i);
    $ext = substr($filename, $i);
    // Set up the read path
    $image_path = $dir . DIRECTORY_SEPARATOR . $filename;
    // Set up the write paths
    $image_path_400 = $dir . $image_name . '_400' . $ext;
    $image_path_100 = $dir . $image_name . '_100' . $ext;
    // Create an image that's a maximum of 400x300 pixels
    resize_image($image_path, $image_path_400, 400, 300);
    // Create a thumbnail image that's a maximum of 100x100 pixels
    resize_image($image_path, $image_path_100, 100, 100);
}
 private function save_image($temp_file)
 {
     //generate a random ID for this image
     $file_id = md5(uniqid(rand(), true));
     array_push($this->image_ids, $file_id);
     //copy original
     $original_file_name = IMAGES_DIR . "/original/" . $file_id . ".jpg";
     $moved = move_uploaded_file($temp_file, $original_file_name);
     if (!$moved) {
         $this->add_warning("Sorry something went wrong saving your image");
     } else {
         //save large
         resize_image($original_file_name, IMAGE_LARGE_SIZE, IMAGES_DIR . "/large/" . $file_id . ".jpg");
         //save medium
         resize_image($original_file_name, IMAGE_MEDIUM_SIZE, IMAGES_DIR . "/medium/" . $file_id . ".jpg");
         //save thumbnail
         resize_image($original_file_name, IMAGE_THUMBNAIL_SIZE, IMAGES_DIR . "/thumbnail/" . $file_id . ".jpg");
     }
 }
예제 #9
0
 public function cacheImages($images)
 {
     foreach ($images as $key => $url) {
         if (file_exists($this->getImagesCachePath($url))) {
             # exclude images in already in cache
             unset($images[$key]);
         }
     }
     if (empty($images)) {
         return true;
     }
     $mh = curl_multi_init();
     $cHandlers = array();
     foreach ($images as $url) {
         $cHandlers[$url] = curl_init();
         curl_setopt($cHandlers[$url], CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($cHandlers[$url], CURLOPT_SSL_VERIFYHOST, false);
         curl_setopt($cHandlers[$url], CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($cHandlers[$url], CURLOPT_URL, $url);
         curl_setopt($cHandlers[$url], CURLOPT_RETURNTRANSFER, true);
         curl_setopt($cHandlers[$url], CURLOPT_TIMEOUT, 30);
         curl_multi_add_handle($mh, $cHandlers[$url]);
     }
     $running = NULL;
     do {
         usleep(10000);
         curl_multi_exec($mh, $running);
     } while ($running > 0);
     foreach ($cHandlers as $url => $ch) {
         $imgData = curl_multi_getcontent($ch);
         curl_multi_remove_handle($mh, $ch);
         $cachePath = $this->getImagesCachePath($url);
         $pathinfo = pathinfo($cachePath);
         $tmpfile = cfg()->tmpDir . "/" . uniqid() . "." . $pathinfo['extension'];
         if (file_put_contents($tmpfile, $imgData)) {
             resize_image($tmpfile, $cachePath, cfg()->ali->cache->images->resize);
             unlink($tmpfile);
         }
     }
 }
예제 #10
0
function get_cached_thumbnail_link($width, $link, $forced = false)
{
    global $thumbnail_directory;
    // $link をローカルファイルのパスに変換
    $src = link_to_path($link);
    // $width, $srcをチェック
    if (!preg_match("/^\\d{1,4}\$/", $width) || !file_exists($src)) {
        // 不正なら空文字列を返す
        return "";
    }
    //thumbnailのパスを決める
    $thumbnail_path = thumbnail_path($width, $src);
    if (!$forced && file_exists($thumbnail_path) && stat($thumbnail_path)["mtime"] > stat($src)["mtime"]) {
        // $forced=falseであり、かつ、
        //  キャッシュされているサムネイルが既に存在し、かつ、
        //   それが新しければ何もしない
    } else {
        // 上記以外の場合、キャッシュを生成する
        resize_image($width, $src, $thumbnail_path);
    }
    // キャッシュへのhtmlリンクを返す
    return path_to_link($thumbnail_path);
}
 function upload_file()
 {
     if (!isset($this->file) || is_null($this->file['tmp_name']) || $this->file['name'] == '') {
         //Check File //Chequea sl archivo
         //$this->file['name']=$defecto;// = "Archivo no fue subido";
         $this->ErrorMsg = "Archivo no fue subido";
         return false;
     }
     if ($this->file['size'] > $this->maxsize) {
         //Check Size
         $this->ErrorMsg = "El Archivo Excede el Tamaño permitido de {$this->maxsize} bytes";
         return false;
     }
     if (count($this->allowtypes) > 0 && !in_array($this->file['type'], $this->allowtypes) || count($this->deniedtypes) > 0 && in_array($this->file['type'], $this->deniedtypes)) {
         //Check Type //Chequea el tipo de archivo
         $this->ErrorMsg = "Tipo de Archivo '." . file_extension($this->file['name']) . " -- {$this->file['type']}' No Permitido.";
         return false;
     }
     if (!$this->newfile) {
         $this->newfile = substr(basename($this->file['name']), 0, strrpos($this->file['name'], '.'));
     }
     //No new name specified, default to old name
     $uploaddirtemp = upload_dir($this->uploaddir);
     //Create Upload Dir
     move_uploaded_file($this->file['tmp_name'], $uploaddirtemp . $this->newfile . "." . file_extension($this->file['name']));
     //Move Uploaded File
     if ($maxwidth == "" && ($maxheight = "")) {
         //No need to resize the image, user did not specify to reszie
         $this->final = "." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']);
         return true;
     }
     //User is going to resize the image
     resize_image("." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']), $this->maxwidth, $this->maxheight, $this->scale, $this->relscale, $this->jpegquality);
     $this->final = "." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']);
     return true;
     //Hooray!
 }
예제 #12
0
파일: submitnews.php 프로젝트: armpit/e107
         $submitnews_filearray = array();
         foreach ($uploaded as $c => $v) {
             if (varset($uploaded[$c]['error'], 0) != 0) {
                 $submitnews_error = TRUE;
                 $message = handle_upload_messages($uploaded);
             } else {
                 if (isset($uploaded[$c]['name']) && isset($uploaded[$c]['type']) && isset($uploaded[$c]['size'])) {
                     $filename = $uploaded[$c]['name'];
                     $filetype = $uploaded[$c]['type'];
                     $filesize = $uploaded[$c]['size'];
                     $fileext = substr(strrchr($filename, "."), 1);
                     $today = getdate();
                     $submitnews_file = USERID . "_" . $today[0] . "_" . $c . "_" . str_replace(" ", "_", substr($submitnews_title, 0, 6)) . "." . $fileext;
                     if (is_numeric($pref['subnews_resize']) && $pref['subnews_resize'] > 30 && $pref['subnews_resize'] < 5000) {
                         require_once e_HANDLER . 'resize_handler.php';
                         if (!resize_image(e_UPLOAD . $filename, e_UPLOAD . $submitnews_file, $pref['subnews_resize'])) {
                             rename(e_UPLOAD . $filename, e_UPLOAD . $submitnews_file);
                         }
                     } elseif ($filename) {
                         rename(e_UPLOAD . $filename, e_UPLOAD . $submitnews_file);
                     }
                 }
             }
             if ($filename && file_exists(e_UPLOAD . $submitnews_file)) {
                 $submitnews_filearray[] = $submitnews_file;
             }
         }
     }
 }
 if ($submitnews_error === FALSE) {
     $sql->insert("submitnews", "0, '{$submitnews_user}', '{$submitnews_email}', '{$submitnews_title}', '" . intval($_POST['cat_id']) . "', '{$submitnews_item}', '" . time() . "', '{$ip}', '0', '" . implode(',', $submitnews_filearray) . "' ");
예제 #13
0
파일: db_input.php 프로젝트: alencarmo/OCF
         cpg_die(ERROR, $lang_db_input_php['err_invalid_img'], __FILE__, __LINE__, true);
         // JPEG and PNG only are allowed with GD
         //} elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($CONFIG['thumb_method'] == 'gd1' || $CONFIG['thumb_method'] == 'gd2')) {
     } elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && $CONFIG['GIF_support'] == 0) {
         @unlink($uploaded_pic);
         cpg_die(ERROR, $lang_errors['gd_file_type_err'], __FILE__, __LINE__, true);
         // *** NOT NEEDED CHECK DONE BY 'is_image'
         // Check image type is among those allowed for ImageMagick
         //} elseif (!stristr($CONFIG['allowed_img_types'], $IMG_TYPES[$imginfo[2]]) && $CONFIG['thumb_method'] == 'im') {
         //@unlink($uploaded_pic);
         //cpg_die(ERROR, sprintf($lang_db_input_php['allowed_img_types'], $CONFIG['allowed_img_types']), __FILE__, __LINE__);
         // Check that picture size (in pixels) is lower than the maximum allowed
     } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
         if (USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) {
             //resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $imginfo[0] > $CONFIG['max_upl_width_height'] ? 'wd' : 'ht');
             resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
         } else {
             @unlink($uploaded_pic);
             cpg_die(ERROR, sprintf($lang_db_input_php['err_fsize_too_large'], $CONFIG['max_upl_width_height'], $CONFIG['max_upl_width_height']), __FILE__, __LINE__);
         }
     }
     // Image is ok
 }
 // Upload is ok
 // Create thumbnail and internediate image and add the image into the DB
 $result = add_picture($album, $filepath, $picture_name, 0, $title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, (int) $_POST['width'], (int) $_POST['height']);
 if (!$result) {
     @unlink($uploaded_pic);
     cpg_die(CRITICAL_ERROR, sprintf($lang_db_input_php['err_insert_pic'], $uploaded_pic) . '<br /><br />' . $ERROR, __FILE__, __LINE__, true);
 } elseif ($PIC_NEED_APPROVAL) {
     pageheader($lang_info);
예제 #14
0
<?php

$dir = dirname(__FILE__);
//echo $dir . "<br>";
$folders = scandir($dir);
foreach ($folders as $categorias) {
    //echo $categorias . "<br>";
    if ($categorias != "." && $categorias != ".." && $categorias != "index.php" && $categorias != "thumb.jpg" && $categorias != "all-thumb.gif" && $categorias != "cs-close.png") {
        $cat = $dir . "/" . $categorias;
        //echo $cat."<br/>";
        $list = scandir($cat);
        //create thumbs
        createThumbs($dir . "/" . $categorias . "", $dir . "/" . $categorias . "/thumbs", 75);
        //reducir
        resize_image($dir . "/" . $categorias . "", $dir . "/" . $categorias . "", 650);
        /*foreach ( $list as $imagen ) {
        			if ($imagen != "." && $imagen != ".." && $imagen != "index.php" && $imagen != "thumb.jpg") {
        				// echo $imagen;
        				//echo $dir . "/" . $categorias."/".$imagen."<br/>";				
        				//echo "se crearon los archivos.<br/>";
        			}
        		}*/
    }
}
function createThumbs($pathToImages, $pathToThumbs, $thumbWidth)
{
    // open the directory
    $dir = opendir($pathToImages);
    if (!is_dir($pathToThumbs)) {
        echo "se creo {$pathToThumbs}<br/>";
        if (!mkdir($pathToThumbs, 0777, true)) {
예제 #15
0
$ds = DIRECTORY_SEPARATOR;
//1
$storeFolder = 'uploads';
//2
$campaign_id = $_POST['campaign_id'];
if (!empty($_FILES)) {
    $tempFile = $_FILES['file']['tmp_name'];
    //3
    error_log($tempFile, 3, 'pic_bug.txt');
    $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
    //4
    error_log("-------", 3, 'pic_bug.txt');
    $targetFile = $targetPath . $_FILES['file']['name'];
    //5
    error_log($targetFile, 3, 'pic_bug.txt');
    $img = resize_image($tempFile, 800, 800);
    $fakepath = "http://localhost:8888/carvertise/gallery/admin/uploads/" . $_FILES['file']['name'];
    $carvertisepath = "http://52.23.43.247/gallery/admin/uploads/" . $_FILES['file']['name'];
    if (!imagejpeg($img, 'uploads/' . $_FILES['file']['name'])) {
        error_log("imagejpeg", 3, 'pic_bug.txt');
        echo "Failed to save the cropped image file";
    }
    //move_uploaded_file($img,$targetFile); //6
    $query = "INSERT INTO picture (campaign_id,url) VALUES ('{$campaign_id}','{$carvertisepath}')";
    if (mysqli_query($conn, $query)) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . mysqli_error($conn);
    }
}
function resize_image($file, $w, $h, $crop = FALSE)
예제 #16
0
 function upload_image($album_id = NULL)
 {
     if (!check_correct_login_type($this->main_group_id)) {
         redirect('/', 'refresh');
     }
     $message_info = '';
     $user_id = $this->ion_auth->user()->row()->id;
     //$user_data = $this->m_custom->getUser($user_id);
     $this->data['box_number'] = $this->box_number;
     if (isset($_POST) && !empty($_POST)) {
         if ($this->input->post('button_action') == "upload_image") {
             $can_redirect = 0;
             $upload_rule = array('upload_path' => $this->album_user, 'allowed_types' => $this->config->item('allowed_types_image'), 'max_size' => $this->config->item('max_size'), 'max_width' => $this->config->item('max_width'), 'max_height' => $this->config->item('max_height'));
             $this->load->library('upload', $upload_rule);
             $validate_fail = 0;
             for ($i = 0; $i < $this->box_number; $i++) {
                 $user_today_upload_count = $this->m_user->get_user_today_upload_count($user_id);
                 $user_max_picture_per_day = $this->m_custom->web_setting_get('user_max_picture_per_day');
                 if ($user_today_upload_count >= $user_max_picture_per_day) {
                     $message_info = add_message_info($message_info, 'You already reach max ' . $user_max_picture_per_day . ' picture upload per day. Please upload again after today.');
                     $this->session->set_flashdata('message', $message_info);
                     redirect('user/upload_image', 'refresh');
                 }
                 $post_file = "image-file-" . $i;
                 $post_title = $this->input->post('image-title-' . $i);
                 $post_desc = $this->input->post('image-desc-' . $i);
                 $post_album_id = $this->input->post('image-main-album-' . $i);
                 //For Multiple Image Upload
                 $have_hidden_image = 0;
                 $post_hidden_image = $this->input->post('hideimage-' . $i);
                 if (!empty($post_hidden_image)) {
                     $have_hidden_image = 1;
                     goto HiddenImageSkip;
                 }
                 if (!empty($_FILES[$post_file]['name'])) {
                     if ($post_album_id == '0') {
                         $validate_fail = 1;
                         //$message_info = add_message_info($message_info, 'Main Album cannot be empty.', $post_title);
                         $message_info = add_message_info($message_info, 'Main Album cannot be empty.', $post_desc);
                         goto ValidateFail;
                     }
                     if (!$this->upload->do_upload($post_file)) {
                         $validate_fail = 1;
                         //$message_info = add_message_info($message_info, $this->upload->display_errors(), $post_title);
                         $message_info = add_message_info($message_info, $this->upload->display_errors(), $post_desc);
                     } else {
                         HiddenImageSkip:
                         $image_file_name = '';
                         if ($have_hidden_image == 0) {
                             $image_data = array('upload_data' => $this->upload->data());
                             $image_file_name = $image_data['upload_data']['file_name'];
                         } else {
                             $from_path = $this->temp_folder_cut . $post_hidden_image;
                             $to_path = $this->album_user . $post_hidden_image;
                             if (file_exists($from_path)) {
                                 rename($from_path, $to_path);
                             }
                             $image_file_name = $post_hidden_image;
                         }
                         resize_image($this->album_user . $image_file_name);
                         $data = array('user_id' => $user_id, 'title' => '', 'description' => $post_desc, 'album_id' => $post_album_id, 'image' => $image_file_name);
                         $new_id = $this->m_custom->get_id_after_insert('user_album', $data);
                         if ($new_id) {
                             //$this->m_user->candie_history_insert(5, $new_id, 'user_album');  //Upload self image not need give candie
                             //$message_info = add_message_info($message_info, 'Image for user ' . $this->m_custom->display_users($user_id) . ' success create.', $post_title);
                             $message_info = add_message_info($message_info, 'Image for user ' . $this->m_custom->display_users($user_id) . ' success create.', $post_desc);
                         } else {
                             //$message_info = add_message_info($message_info, $this->ion_auth->errors(), $post_title);
                             $message_info = add_message_info($message_info, $this->ion_auth->errors(), $post_desc);
                         }
                     }
                 }
                 ValidateFail:
             }
             $this->session->set_flashdata('message', $message_info);
             if ($validate_fail == 0) {
                 $this->m_custom->remove_image_temp();
                 redirect('all/album_user/' . $user_id . '/' . $album_id, 'refresh');
             }
         }
     }
     $this->data['main_album_list'] = $this->m_custom->getMainAlbum($user_id, NULL, 1, '0', 'Please Select');
     for ($i = 0; $i < $this->box_number; $i++) {
         $image_title = 'image_title' . $i;
         $this->data[$image_title] = array('name' => 'image-title-' . $i, 'id' => 'image-title-' . $i, 'value' => $this->form_validation->set_value('image-title-' . $i));
         $image_url = 'image_url' . $i;
         $this->data[$image_url] = $this->config->item('empty_image');
         $image_desc = 'image_desc' . $i;
         $this->data[$image_desc] = array('name' => 'image-desc-' . $i, 'id' => 'image-desc-' . $i, 'value' => $this->form_validation->set_value('image-desc-' . $i));
         $image_main_album = 'image_main_album' . $i;
         $this->data[$image_main_album] = array('name' => 'image-main-album-' . $i, 'id' => 'image-main-album-' . $i, 'value' => $this->form_validation->set_value('image-main-album-' . $i));
         $image_main_album_selected = 'image_main_album_selected' . $i;
         $this->data[$image_main_album_selected] = empty($album_id) ? '' : $album_id;
     }
     $this->data['temp_folder'] = $this->temp_folder;
     $this->data['temp_folder_cut'] = $this->temp_folder_cut;
     $this->data['empty_image'] = $this->config->item('empty_image');
     $this->data['message'] = $this->session->flashdata('message');
     $this->data['page_path_name'] = 'user/upload_image';
     $this->load->view('template/index_background_blank', $this->data);
 }
예제 #17
0
         $ok = 1;
     } elseif ($resize_type_thumbs == 3 && $image_info[1] > $dimension_thumbs) {
         $ok = 1;
     }
     if ($ok) {
         if (create_thumbnail($file, $file_thumb, $quality_thumbs, $dimension_thumbs, $resize_type_thumbs)) {
             $log[] = $lang['cni_thumbnail_success'];
             $image_thumb_file = $image_media_file;
         } else {
             $log[] = $lang['cni_thumbnail_error'];
             $image_thumb_file = "";
         }
     }
 }
 if ($do_resize) {
     if (resize_image($file, $quality, $dimension, $resize_type)) {
         $log[] = $lang['cni_resized_success'];
     } else {
         $log[] = $lang['cni_resized_error'];
     }
 }
 if ($do_annotate) {
     if (annotate_image($file)) {
         $log[] = str_replace("{name}", MEDIA_DIR . "/" . $cat_id . "/" . $image_media_file, $lang['cni_annotation_success']);
     } else {
         $log[] = str_replace("{name}", MEDIA_DIR . "/" . $cat_id . "/" . $image_media_file, $lang['cni_annotation_error']);
     }
     if ($big_annotate) {
         if (annotate_image(MEDIA_PATH . "/" . $cat_id . "/" . $big_folder . "/" . $image_media_file)) {
             $log[] = str_replace("{name}", MEDIA_DIR . "/" . $cat_id . "/" . $big_folder . "/" . $image_media_file, $lang['cni_annotation_success']);
         } else {
예제 #18
0
파일: load.php 프로젝트: visavi/rotorcms4
     echo 'Импорт файла*:<br /><input type="text" name="loadfile" value="http://" /><br />';
     echo '<input value="Импортировать" type="submit" /></form></div><br />';
 } else {
     $folder = $new['folder'] ? $new['folder'] . '/' : '';
     echo '<img src="/images/img/download.gif" alt="image" /> <b><a href="/load/files/' . $folder . $new['downs_link'] . '">' . $new['downs_link'] . '</a></b> (' . read_file(BASEDIR . '/load/files/' . $folder . $new['downs_link']) . ') (<a href="load.php?act=delfile&amp;id=' . $id . '" onclick="return confirm(\'Вы действительно хотите удалить данный файл?\')">Удалить</a>)<br />';
     $ext = getExtension($new['downs_link']);
     if (!in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) {
         if (empty($new['downs_screen'])) {
             echo '<br /><b><big>Загрузка скриншота</big></b><br /><br />';
             echo '<div class="form">';
             echo '<form action="load.php?act=loadscreen&amp;id=' . $id . '&amp;uid=' . $_SESSION['token'] . '" method="post" enctype="multipart/form-data">';
             echo 'Прикрепить скрин (jpg,jpeg,gif,png):<br /><input type="file" name="screen" /><br />';
             echo '<input value="Загрузить" type="submit" /></form></div><br />';
         } else {
             echo '<img src="/images/img/gallery.gif" alt="image" /> <b><a href="/load/screen/' . $folder . $new['downs_screen'] . '">' . $new['downs_screen'] . '</a></b> (' . read_file(BASEDIR . '/load/screen/' . $folder . $new['downs_screen']) . ') (<a href="load.php?act=delscreen&amp;id=' . $id . '" onclick="return confirm(\'Вы действительно хотите удалить данный скриншот?\')">Удалить</a>)<br /><br />';
             echo resize_image('load/screen/' . $folder, $new['downs_screen'], $config['previewsize']) . '<br />';
         }
     }
 }
 echo '<br />';
 echo '<b><big>Редактирование</big></b><br /><br />';
 echo '<div class="form">';
 echo '<form action="load.php?act=changedown&amp;id=' . $id . '&amp;uid=' . $_SESSION['token'] . '" method="post">';
 echo 'Название*:<br />';
 echo '<input type="text" name="title" size="50" maxlength="50" value="' . $new['downs_title'] . '" /><br />';
 echo 'Описание*:<br />';
 echo '<textarea cols="25" rows="5" name="text">' . $new['downs_text'] . '</textarea><br />';
 echo 'Автор файла:<br />';
 echo '<input type="text" name="author" maxlength="50" value="' . $new['downs_author'] . '" /><br />';
 echo 'Сайт автора:<br />';
 echo '<input type="text" name="site" maxlength="50" value="' . $new['downs_site'] . '" /><br />';
예제 #19
0
} elseif ($action == "signature") {
    $signatures = isset($_POST['signatures']) && $_POST["signatures"] != "" ? "yes" : "no";
    $signature = trim(urldecode($_POST["signature"]));
    if (preg_match("/^http:\\/\\/\$/i", $signature) or preg_match("/[?&;]/", $signature) or preg_match("#javascript:#is", $signature) or !preg_match("#^https?://(?:[^<>*\"]+|[a-z0-9/\\._\\-!]+)\$#iU", $signature)) {
        $signature = '';
    }
    if (!empty($signature)) {
        $img_size = @GetImageSize($signature);
        if ($img_size == FALSE || !in_array($img_size['mime'], $INSTALLER09['allowed_ext'])) {
            stderr('USER ERROR', 'Not an image or unsupported image!');
        }
        if ($img_size[0] < 5 || $img_size[1] < 5) {
            stderr('USER ERROR', 'Image is too small');
        }
        if ($img_size[0] > $INSTALLER09['sig_img_width'] or $img_size[1] > $INSTALLER09['sig_img_height']) {
            $image = resize_image(array('max_width' => $INSTALLER09['sig_img_width'], 'max_height' => $INSTALLER09['sig_img_height'], 'cur_width' => $img_size[0], 'cur_height' => $img_size[1]));
        } else {
            $image['img_width'] = $img_size[0];
            $image['img_height'] = $img_size[1];
        }
        $updateset[] = "sig_w = " . sqlesc($image['img_width']);
        $updateset[] = "sig_h = " . sqlesc($image['img_height']);
        $updateset[] = "signature = " . sqlesc("[img]" . $signature . "[/img]\n");
    }
    $updateset[] = "signatures = '{$signatures}'";
    if (isset($_POST["info"]) && ($info = $_POST["info"]) != $CURUSER["info"]) {
        $updateset[] = "info = " . sqlesc($info);
    }
    $action = "signature";
} elseif ($action == "security") {
    if (isset($_POST['ssluse']) && ($ssluse = (int) $_POST['ssluse']) && $ssluse != $CURUSER['ssluse']) {
예제 #20
0
 // Avatar Changed
 if (isset($_POST['avatar']) && ($avatar = $_POST['avatar']) != ($curavatar = $user['avatar'])) {
     $avatar = trim(urldecode($avatar));
     if (preg_match("/^http:\\/\\/\$/i", $avatar) or preg_match("/[?&;]/", $avatar) or preg_match("#javascript:#is", $avatar) or !preg_match("#^https?://(?:[^<>*\"]+|[a-z0-9/\\._\\-!]+)\$#iU", $avatar)) {
         $avatar = '';
     }
     if (!empty($avatar)) {
         $img_size = @GetImageSize($avatar);
         if ($img_size == FALSE || !in_array($img_size['mime'], $TBDEV['allowed_ext'])) {
             stderr("{$lang['modtask_user_error']}", "{$lang['modtask_not_image']}");
         }
         if ($img_size[0] < 5 || $img_size[1] < 5) {
             stderr("{$lang['modtask_user_error']}", "{$lang['modtask_image_small']}");
         }
         if ($img_size[0] > $TBDEV['av_img_width'] or $img_size[1] > $TBDEV['av_img_height']) {
             $image = resize_image(array('max_width' => $TBDEV['av_img_width'], 'max_height' => $TBDEV['av_img_height'], 'cur_width' => $img_size[0], 'cur_height' => $img_size[1]));
         } else {
             $image['img_width'] = $img_size[0];
             $image['img_height'] = $img_size[1];
         }
         $updateset[] = "av_w = " . $image['img_width'];
         $updateset[] = "av_h = " . $image['img_height'];
     }
     $modcomment = get_date(time(), 'DATE', 1) . "{$lang['modtask_avatar_change']}" . htmlspecialchars($curavatar) . "{$lang['modtask_to']}" . htmlspecialchars($avatar) . "{$lang['modtask_by']}" . $CURUSER['username'] . ".\n" . $modcomment;
     $updateset[] = "avatar = " . sqlesc($avatar);
 }
 /* Uncomment if you have the First Line Support mod installed...
 
     // Support
     if ((isset($_POST['support'])) && (($support = $_POST['support']) != $user['support']))
     {
예제 #21
0
function add_update_course($course_data, $isadmin = FALSE)
{
    require_once AT_INCLUDE_PATH . '../mods/_core/file_manager/filemanager.inc.php';
    global $addslashes;
    global $db;
    global $system_courses;
    global $MaxCourseSize;
    global $msg;
    global $_config;
    global $_config_defaults;
    global $stripslashes;
    $Backup = new Backup($db);
    $missing_fields = array();
    if ($course_data['title'] == '') {
        $missing_fields[] = _AT('title');
    }
    if (!$course_data['instructor']) {
        $missing_fields[] = _AT('instructor');
    }
    if ($missing_fields) {
        $missing_fields = implode(', ', $missing_fields);
        $msg->addError(array('EMPTY_FIELDS', $missing_fields));
    }
    $course_data['access'] = $addslashes($course_data['access']);
    $course_data['title'] = $addslashes($course_data['title']);
    $course_data['description'] = $addslashes($course_data['description']);
    $course_data['hide'] = $addslashes($course_data['hide']);
    $course_data['pri_lang'] = $addslashes($course_data['pri_lang']);
    $course_data['created_date'] = $addslashes($course_data['created_date']);
    $course_data['copyright'] = $addslashes($course_data['copyright']);
    $course_data['icon'] = $addslashes($course_data['icon']);
    $course_data['banner'] = $addslashes($course_data['banner']);
    $course_data['course_dir_name'] = $addslashes($course_data['course_dir_name']);
    $course_data['course'] = intval($course_data['course']);
    $course_data['notify'] = intval($course_data['notify']);
    $course_data['hide'] = intval($course_data['hide']);
    $course_data['instructor'] = intval($course_data['instructor']);
    $course_data['category_parent'] = intval($course_data['category_parent']);
    $course_data['rss'] = intval($course_data['rss']);
    // Course directory name (aka course slug)
    if ($course_data['course_dir_name'] != '') {
        //validate the course_dir_name, allow only alphanumeric, underscore.
        if (preg_match('/^[\\w][\\w\\d\\_]+$/', $course_data['course_dir_name']) == 0) {
            $msg->addError('COURSE_DIR_NAME_INVALID');
        }
        //check if the course_dir_name is already being used
        $sql = "SELECT COUNT(course_id) as cnt FROM %scourses WHERE course_id!=%d AND course_dir_name='%s'";
        $num_of_dir = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $course_data['course_dir_name']), TRUE);
        if (intval($num_of_dir['cnt']) > 0) {
            $msg->addError('COURSE_DIR_NAME_IN_USE');
        }
    }
    // Custom icon
    if ($_FILES['customicon']['name'] != '') {
        // Use custom icon instead if it exists
        $course_data['icon'] = $addslashes($_FILES['customicon']['name']);
    }
    if ($_FILES['customicon']['error'] == UPLOAD_ERR_FORM_SIZE) {
        // Check if filesize is too large for a POST
        $msg->addError(array('FILE_MAX_SIZE', $_config['prof_pic_max_file_size'] . ' ' . _AT('bytes')));
    }
    if ($course_data['release_date']) {
        $day_release = intval($course_data['day_release']);
        $month_release = intval($course_data['month_release']);
        $year_release = intval($course_data['year_release']);
        $hour_release = intval($course_data['hour_release']);
        $min_release = intval($course_data['min_release']);
        if (!checkdate($month_release, $day_release, $year_release)) {
            //or date is in the past
            $msg->addError('RELEASE_DATE_INVALID');
        }
        if (strlen($month_release) == 1) {
            $month_release = "0{$month_release}";
        }
        if (strlen($day_release) == 1) {
            $day_release = "0{$day_release}";
        }
        if (strlen($hour_release) == 1) {
            $hour_release = "0{$hour_release}";
        }
        if (strlen($min_release) == 1) {
            $min_release = "0{$min_release}";
        }
        $release_date = "{$year_release}-{$month_release}-{$day_release} {$hour_release}:{$min_release}:00";
    } else {
        $release_date = "0000-00-00 00:00:00";
    }
    if ($course_data['end_date']) {
        $day_end = intval($course_data['day_end']);
        $month_end = intval($course_data['month_end']);
        $year_end = intval($course_data['year_end']);
        $hour_end = intval($course_data['hour_end']);
        $min_end = intval($course_data['min_end']);
        if (!checkdate($month_end, $day_end, $year_end)) {
            //or date is in the past
            $msg->addError('END_DATE_INVALID');
        }
        if (strlen($month_end) == 1) {
            $month_end = "0{$month_end}";
        }
        if (strlen($day_end) == 1) {
            $day_end = "0{$day_end}";
        }
        if (strlen($hour_end) == 1) {
            $hour_end = "0{$hour_end}";
        }
        if (strlen($min_end) == 1) {
            $min_end = "0{$min_end}";
        }
        $end_date = "{$year_end}-{$month_end}-{$day_end} {$hour_end}:{$min_end}:00";
    } else {
        $end_date = "0000-00-00 00:00:00";
    }
    $initial_content_info = explode('_', $course_data['initial_content'], 2);
    //admin
    $course_quotas = '';
    if ($isadmin) {
        $instructor = $course_data['instructor'];
        $quota = intval($course_data['quota']);
        $quota_entered = intval($course_data['quota_entered']);
        $filesize = intval($course_data['filesize']);
        $filesize_entered = intval($course_data['filesize_entered']);
        //if they checked 'other', set quota=entered value, if it is empty or negative, set to default (-2)
        if ($quota == '2') {
            if ($quota_entered == '' || empty($quota_entered) || $quota_entered < 0) {
                $quota = AT_COURSESIZE_DEFAULT;
            } else {
                $quota = floatval($quota_entered);
                $quota = megabytes_to_bytes($quota);
            }
        }
        //if they checked 'other', set filesize=entered value, if it is empty or negative, set to default
        if ($filesize == '2') {
            if ($filesize_entered == '' || empty($filesize_entered) || $filesize_entered < 0) {
                $filesize = AT_FILESIZE_DEFAULT;
                $msg->addFeedback('COURSE_DEFAULT_FSIZE');
            } else {
                $filesize = floatval($filesize_entered);
                $filesize = megabytes_to_bytes($filesize);
            }
        }
        $course_quotas = "max_quota='{$quota}', max_file_size='{$filesize}',";
    } else {
        $instructor = $_SESSION['member_id'];
        if (!$course_data['course']) {
            $course_quotas = "max_quota=" . AT_COURSESIZE_DEFAULT . ", max_file_size=" . AT_FILESIZE_DEFAULT . ",";
            $row = $Backup->getRow($initial_content_info[0], $initial_content_info[1]);
            if (count($initial_content_info) == 2 && $system_courses[$initial_content_info[1]]['member_id'] == $_SESSION['member_id']) {
                if ($MaxCourseSize < $row['contents']['file_manager']) {
                    $msg->addError('RESTORE_TOO_BIG');
                }
            } else {
                $initial_content_info = intval($course_data['initial_content']);
            }
        } else {
            unset($initial_content_info);
            $course_quotas = "max_quota='{$system_courses[$course_data[course]][max_quota]}', max_file_size='{$system_courses[$course_data[course]][max_file_size]}',";
        }
    }
    if ($msg->containsErrors()) {
        return FALSE;
    }
    //display defaults
    if (!$course_data['course']) {
        $menu_defaults = ",home_links='{$_config['home_defaults']}', main_links='{$_config['main_defaults']}', side_menu='{$_config['side_defaults']}'";
    } else {
        $menu_defaults = ',home_links=\'' . $system_courses[$course_data['course']]['home_links'] . '\', main_links=\'' . $system_courses[$course_data['course']]['main_links'] . '\', side_menu=\'' . $system_courses[$course_data['course']]['side_menu'] . '\'';
    }
    $sql = "REPLACE INTO %scourses \n                SET \n                course_id=%d, \n                member_id='%s', \n                access='%s', \n                title='%s', \n                description='%s', \n                course_dir_name='%s', \n                cat_id=%d, \n                content_packaging='%s', \n                notify=%d, \n                hide=%d, \n                {$course_quotas}\n                primary_language='%s',\n                created_date='%s',\n                rss=%d,\n                copyright='%s',\n                icon='%s',\n                banner='%s',\n                release_date='%s', \n                end_date='%s' \n                {$menu_defaults}";
    $result = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $course_data['instructor'], $course_data['access'], $course_data['title'], $course_data['description'], $course_data['course_dir_name'], $course_data['category_parent'], $course_data['content_packaging'], $course_data['notify'], $course_data['hide'], $course_data['pri_lang'], $course_data['created_date'], $course_data['rss'], $course_data['copyright'], $course_data['icon'], $course_data['banner'], $release_date, $end_date));
    if (!$result) {
        echo at_db_error();
        echo 'DB Error';
        exit;
    }
    $new_course_id = $_SESSION['course_id'] = at_insert_id();
    if (isset($isadmin)) {
        global $sqlout;
        write_to_log(AT_ADMIN_LOG_REPLACE, 'courses', $result, $sqlout);
    }
    if (isset($isadmin)) {
        //get current instructor and unenroll from course if different from POST instructor
        $old_instructor = $system_courses[$course_data['course']]['member_id'];
        if ($old_instructor != $course_data['instructor']) {
            //remove old from course enrollment
            $sql = "DELETE FROM %scourse_enrollment WHERE course_id=%d AND member_id=%d";
            $result = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $old_instructor));
            global $sqlout;
            write_to_log(AT_ADMIN_LOG_DELETE, 'course_enrollment', $result, $sqlout);
        }
    }
    //enroll new instructor
    $sql = "REPLACE INTO %scourse_enrollment VALUES (%d, %d, 'y', 0, '" . _AT('instructor') . "', 0)";
    $result = queryDB($sql, array(TABLE_PREFIX, $course_data['instructor'], $new_course_id));
    if (isset($isadmin)) {
        global $sqlout;
        write_to_log(AT_ADMIN_LOG_REPLACE, 'course_enrollment', $result, $sqlout);
    }
    // create the course content directory
    $path = AT_CONTENT_DIR . $new_course_id . '/';
    @mkdir($path, 0700);
    @copy(AT_CONTENT_DIR . 'index.html', AT_CONTENT_DIR . $new_course_id . '/index.html');
    // create the course backup directory
    $path = AT_BACKUP_DIR . $new_course_id . '/';
    @mkdir($path, 0700);
    @copy(AT_CONTENT_DIR . 'index.html', AT_BACKUP_DIR . $new_course_id . '/index.html');
    /* insert some default content: */
    if (!$course_data['course_id'] && $course_data['initial_content'] == '1') {
        $contentManager = new ContentManager($db, $new_course_id);
        $contentManager->initContent();
        $cid = $contentManager->addContent($new_course_id, 0, 1, _AT('welcome_to_atutor'), addslashes(_AT('this_is_content')), '', '', 1, date('Y-m-d H:00:00'));
        $announcement = _AT('default_announcement');
        $sql = "INSERT INTO %snews VALUES (NULL, %d, %d, NOW(), 1, '%s', '%s')";
        $result = queryDB($sql, array(TABLE_PREFIX, $new_course_id, $instructor, _AT('welcome_to_atutor'), $announcement));
        if ($isadmin) {
            global $sqlout;
            write_to_log(AT_ADMIN_LOG_INSERT, 'news', $result, $sqlout);
        }
    } else {
        if (!$course_data['course'] && count($initial_content_info) == 2) {
            $Backup->setCourseID($new_course_id);
            $Backup->restore($material = TRUE, 'append', $initial_content_info[0], $initial_content_info[1]);
        }
    }
    // custom icon, have to be after directory is created
    if ($_FILES['customicon']['tmp_name'] != '') {
        $course_data['comments'] = trim($course_data['comments']);
        $owner_id = $_SESSION['course_id'];
        $owner_type = "1";
        if ($_FILES['customicon']['error'] == UPLOAD_ERR_INI_SIZE) {
            $msg->addError(array('FILE_TOO_BIG', get_human_size(megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1)))));
        } else {
            if (!isset($_FILES['customicon']['name']) || $_FILES['customicon']['error'] == UPLOAD_ERR_NO_FILE || $_FILES['customicon']['size'] == 0) {
                $msg->addError('FILE_NOT_SELECTED');
            } else {
                if ($_FILES['customicon']['error'] || !is_uploaded_file($_FILES['customicon']['tmp_name'])) {
                    $msg->addError('FILE_NOT_SAVED');
                }
            }
        }
        if (!$msg->containsErrors()) {
            $course_data['description'] = $addslashes(trim($course_data['description']));
            $_FILES['customicon']['name'] = addslashes($_FILES['customicon']['name']);
            if ($course_data['comments']) {
                $num_comments = 1;
            } else {
                $num_comments = 0;
            }
            $path = AT_CONTENT_DIR . $owner_id . "/custom_icons/";
            if (!is_dir($path)) {
                @mkdir($path);
            }
            // if we can upload custom course icon, it means GD is enabled, no need to check extension again.
            $gd_info = gd_info();
            $supported_images = array();
            if ($gd_info['GIF Create Support']) {
                $supported_images[] = 'gif';
            }
            if ($gd_info['JPG Support'] || $gd_info['JPEG Support']) {
                $supported_images[] = 'jpg';
            }
            if ($gd_info['PNG Support']) {
                $supported_images[] = 'png';
            }
            // check if this is a supported file type
            $filename = $stripslashes($_FILES['customicon']['name']);
            $path_parts = pathinfo($filename);
            $extension = strtolower($path_parts['extension']);
            $image_attributes = getimagesize($_FILES['customicon']['tmp_name']);
            if ($extension == 'jpeg') {
                $extension = 'jpg';
            }
            // resize the original but don't backup a copy.
            $width = $image_attributes[0];
            $height = $image_attributes[1];
            $original_img = $_FILES['customicon']['tmp_name'];
            $thumbnail_img = $path . $_FILES['customicon']['name'];
            if ($width > $height && $width > 79) {
                $thumbnail_height = intval(79 * $height / $width);
                $thumbnail_width = 79;
                if (!resize_image($original_img, $thumbnail_img, $height, $width, $thumbnail_height, $thumbnail_width, $extension)) {
                    $msg->addError('FILE_NOT_SAVED');
                }
            } else {
                if ($width <= $height && $height > 79) {
                    $thumbnail_height = 100;
                    $thumbnail_width = intval(100 * $width / $height);
                    if (!resize_image($original_img, $thumbnail_img, $height, $width, $thumbnail_height, $thumbnail_width, $extension)) {
                        $msg->addError('FILE_NOT_SAVED');
                    }
                } else {
                    // no resizing, just copy the image.
                    // it's too small to resize.
                    copy($original_img, $thumbnail_img);
                }
            }
        } else {
            $msg->addError('FILE_NOT_SAVED');
        }
    }
    //----------------------------------------
    /* delete the RSS feeds just in case: */
    if (file_exists(AT_CONTENT_DIR . 'feeds/' . $new_course_id . '/RSS1.0.xml')) {
        @unlink(AT_CONTENT_DIR . 'feeds/' . $course_data['course'] . '/RSS1.0.xml');
    }
    if (file_exists(AT_CONTENT_DIR . 'feeds/' . $new_course_id . '/RSS2.0.xml')) {
        @unlink(AT_CONTENT_DIR . 'feeds/' . $new_course_id . '/RSS2.0.xml');
    }
    if ($isadmin) {
        $_SESSION['course_id'] = -1;
    }
    $_SESSION['course_title'] = $stripslashes($course_data['title']);
    return $new_course_id;
}
예제 #22
0
                echo '<a href="slideshow.php?slide_id=' . $p . '&curdirpath=' . $pathurl . '">' . $image_tag[$p] . '</a>';
                echo '</div>';
                echo '</li>';
            }
            $p++;
        }
    }
    echo '</ul>';
}
//end slide==all
/*	ONE AT A TIME VIEW */
$course_id = api_get_course_int_id();
// This is for viewing all the images in the slideshow one at a time.
if ($slide_id != 'all' && !empty($image_files_only)) {
    if (file_exists($image) && is_file($image)) {
        $image_height_width = resize_image($image, $target_width, $target_height);
        $image_height = $image_height_width[0];
        $image_width = $image_height_width[1];
        $height_width_tags = null;
        if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
            $height_width_tags = 'width="' . $image_width . '" height="' . $image_height . '"';
        }
        // This is done really quickly and should be cleaned up a little bit using the API functions
        $tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
        if ($path == '/') {
            $pathpart = '/';
        } else {
            $pathpart = $path . '/';
        }
        $sql = "SELECT * FROM {$tbl_documents}\n\t\t        WHERE c_id = {$course_id} AND path='" . Database::escape_string($pathpart . $image_files_only[$slide]) . "'";
        $result = Database::query($sql);
예제 #23
0
if (function_exists('bcn_display')) {
    bcn_display();
}
?>
				</ul>
			</div>
			<?php 
if (has_post_thumbnail()) {
    ?>

				<div class="featured-img">
					
					<?php 
    $img_height = 222;
    $img_width = 700;
    resize_image(thumb_url(), $img_width, $img_height);
    ?>
								
				</div>

			<?php 
}
?>
							
			<div class="content-main">
				<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
				
예제 #24
0
function do_download($formatter, $options)
{
    global $DBInfo;
    if (!$options['value']) {
        if (!function_exists('do_uploadedfiles')) {
            include_once dirname(__FILE__) . '/UploadedFiles.php';
        }
        do_uploadedfiles($formatter, $options);
        return;
    }
    $value =& $options['value'];
    $down_mode = (!empty($options['mode']) and $options['mode'][0] == 'a') ? 'attachment' : (!empty($DBInfo->download_mode) ? $DBInfo->download_mode : 'inline');
    // SubPage:foobar.png == SubPage/foobar.png
    // SubPage:thumbnails/foobar.png == SubPage/thumbnails/foobar.png
    // SubPage/FoobarPage:thumbnails/foobar.png == SubPage/FoobarPage/thumbnails/foobar.png
    // check acceptable subdirs
    $acceptable_subdirs = array('thumbnails');
    $tmp = explode('/', $value);
    $subdir = '';
    if (($c = count($tmp)) > 1) {
        if (in_array($tmp[$c - 2], $acceptable_subdirs)) {
            $subdir = $tmp[$c - 2] . '/';
            unset($tmp[$c - 2]);
            $value = implode('/', $tmp);
        }
    }
    if (($p = strpos($value, ':')) !== false or ($p = strrpos($value, '/')) !== false) {
        $subpage = substr($value, 0, $p);
        $file = substr($value, $p + 1);
        $value = $subpage . '/' . $file;
        # normalize page arg
        if ($subpage and $DBInfo->hasPage($subpage)) {
            $pagename =& $subpage;
            $key = $DBInfo->pageToKeyname($subpage);
        }
    }
    if (!isset($pagename[0])) {
        $pagename =& $formatter->page->name;
        $key = $DBInfo->pageToKeyname($formatter->page->name);
    }
    $prefix = '';
    if (isset($key[0])) {
        // for compatibility
        $dir = $DBInfo->upload_dir . '/' . $key;
        if (!is_dir($dir) and !empty($DBInfo->use_hashed_upload_dir)) {
            // support hashed upload_dir
            $prefix = get_hashed_prefix($key);
            $dir = $DBInfo->upload_dir . '/' . $prefix . $key;
        }
    }
    if ($value[0] == '/' or $key == 'UploadFile') {
        $dir = $DBInfo->upload_dir;
    }
    if (file_exists($dir)) {
        $handle = opendir($dir);
    } else {
        $dir = $DBInfo->upload_dir;
        $handle = opendir($dir);
    }
    $file = explode('/', $value);
    $file = $file[count($file) - 1];
    $params = $options;
    // copy request params
    /**
     * Thumbnail feature
     *
     * foo/bar/foo.png
     * - pagename = foo/bar
     * - attached image = foo.png
     * foo/bar/foo.png?thumb=1
     * - generate thumbnail with default width
     * foo/bar/foo.png?thumbwidth=320
     * - generate thumbnails/foo.w320.png
     *   if 320 is acceptable width
     * foo/bar/thumbnails/foo.w320.png
     * == foo/bar/foo.png?thumbwidth=320
     * foo/bar/foo.w320.png
     * == foo/bar/foo.png?thumbwidth=320
     * you can also upload foo.w320.png manually
     */
    // check thumbnail width from filename
    if (preg_match('@(\\.w(\\d+)\\.(png|jpe?g|gif))$@i', $file, $m)) {
        // drop w320 from given filename
        $orgfile = substr($file, 0, -strlen($m[1])) . '.' . $m[3];
        $params['thumbwidth'] = $m[2];
        unset($params['thumb']);
    }
    // check file exists
    $tmp = _l_filename($file);
    if (file_exists($dir . '/' . $subdir . $tmp)) {
        $_l_file = $subdir . $tmp;
        if (!empty($orgfile)) {
            unset($orgfile);
            // no need to generate thumbnails
            unset($params['thumbwidth']);
            $nothumb = true;
        }
    } else {
        $_l_file = !empty($orgfile) ? _l_filename($orgfile) : _l_filename($file);
        if (!file_exists("{$dir}/{$_l_file}")) {
            header("HTTP/1.1 404 Not Found");
            echo "File not found";
            return;
        }
    }
    $lines = @file($DBInfo->data_dir . '/mime.types');
    if ($lines) {
        foreach ($lines as $line) {
            rtrim($line);
            if (preg_match('/^\\#/', $line)) {
                continue;
            }
            $elms = preg_split('/\\s+/', $line);
            $type = array_shift($elms);
            foreach ($elms as $elm) {
                $mime[$elm] = $type;
            }
        }
    } else {
        $mime = array();
    }
    $realfile = $dir . '/' . $_l_file;
    # set filename
    if (preg_match("/\\.(.{1,4})\$/", $file, $match)) {
        $ext = strtolower($match[1]);
        $mimetype = !empty($mime[$ext]) ? $mime[$ext] : '';
        $ext = '.' . $ext;
    }
    // auto generate thumbnails
    if (empty($nothumb) and !empty($mimetype) and preg_match('@image/(png|jpe?g|gif)$@', $mimetype)) {
        list($w, $h) = getimagesize($realfile);
        $thumbfile = '';
        if (!empty($params['thumbwidth'])) {
            // check allowed thumb widths.
            $thumb_widths = isset($DBInfo->thumb_widths) ? $DBInfo->thumb_widths : array('120', '240', '320', '480', '600', '800', '1024');
            $width = 320;
            // default
            if (!empty($DBInfo->default_thumb_width)) {
                $width = $DBInfo->default_thumb_width;
            }
            if (!empty($thumb_widths)) {
                if (in_array($params['thumbwidth'], $thumb_widths)) {
                    $width = $params['thumbwidth'];
                } else {
                    header("HTTP/1.1 404 Not Found");
                    echo "Invalid thumbnail width", "<br />", "valid thumb widths are ", implode(', ', $thumb_widths);
                    return;
                }
            } else {
                $width = $params['thumbwidth'];
            }
            if ($w > $width) {
                $thumb_width = $width;
                $force_thumb = true;
            }
        } else {
            // automatically generate thumb images to support low-bandwidth mobile version
            if ($params['is_mobile']) {
                $force_thumb = (!isset($params['m']) or $params['m'] == 1);
            } else {
                if (!isset($params['thumb']) and !empty($DBInfo->max_image_width) and $w > $DBInfo->max_image_width) {
                    $force_thumb = true;
                    $thumb_width = $DBInfo->max_image_width;
                }
            }
        }
        while (!empty($params['thumb']) or $force_thumb) {
            if (empty($thumb_width)) {
                $thumb_width = 320;
                // default
                if (!empty($DBInfo->default_thumb_width)) {
                    $thumb_width = $DBInfo->default_thumb_width;
                }
            }
            $thumbfiles = array();
            $thumbname = preg_replace('@' . $ext . '$@i', '.w' . $thumb_width . $ext, $_l_file);
            $thumbfiles[] = $thumbname;
            $thumbfiles[] = 'thumbnails/' . $thumbname;
            foreach ($thumbfiles as $file) {
                $thumbfile = $dir . '/' . $file;
                if (file_exists($thumbfile)) {
                    $thumb_ok = true;
                    break;
                }
            }
            if ($thumb_ok) {
                break;
            }
            if ($w <= $thumb_width) {
                if (!empty($orgfile)) {
                    header("HTTP/1.1 404 Not Found");
                    echo "the thumbnail width have to smaller than original";
                    return;
                }
                $thumbfile = $realfile;
                break;
            }
            if (!file_exists($dir . "/thumbnails")) {
                @mkdir($dir . "/thumbnails", 0777);
            }
            require_once 'lib/mediautils.php';
            // generate thumbnail using the gd func or the ImageMagick(convert)
            resize_image($ext, $realfile, $thumbfile, $w, $h, $thumb_width);
            break;
        }
        if (!empty($thumbfile)) {
            $realfile = $thumbfile;
        }
    }
    if (empty($mimetype)) {
        $mimetype = "application/x-unknown";
    }
    if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
        // IE: rawurlencode()
        $fn = preg_replace('/[:\\x5c\\/*?"<>|]/', '_', $file);
        $fname = 'filename="' . rawurlencode($fn) . '"';
        // fix IE bug
        $fname = preg_replace('/\\./', '%2e', $fname, substr_count($fname, '.') - 1);
        #header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        #header('Pragma: public');
    } else {
        if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mozilla')) {
            // Mozilla: RFC 2047
            $fname = 'filename="=?' . $DBInfo->charset . '?B?' . base64_encode($file) . '?="';
        } else {
            // etc. Safari, Opera 9: RFC 2231
            $fn = preg_replace('/[:\\x5c\\/{?]/', '_', $file);
            $fname = 'filename*=' . $DBInfo->charset . "''" . rawurlencode($fn) . '';
            //$fname='filename="'.$fn.'"';
        }
    }
    if (!empty($DBInfo->use_resume_download)) {
        $header = array("Content-Description: MoniWiki PHP Downloader");
        dl_file_resume($mimetype, $realfile, $fname, $down_mode, $header);
        return;
    }
    header("Content-Type: {$mimetype}\r\n");
    header("Content-Length: " . filesize($realfile));
    header("Content-Disposition: {$down_mode}; " . $fname);
    header("Content-Description: MoniWiki PHP Downloader");
    $mtime = filemtime($realfile);
    $lastmod = gmdate("D, d M Y H:i:s", $mtime) . ' GMT';
    $etag = md5($lastmod . $thumbfile);
    header("Last-Modified: " . $lastmod);
    header('ETag: "' . $etag . '"');
    header("Pragma:");
    $maxage = 60 * 60 * 24 * 7;
    header('Cache-Control: public, max-age=' . $maxage);
    $need = http_need_cond_request($mtime, $lastmod, $etag);
    if (!$need) {
        header('X-Cache-Debug: Cached OK');
        header('HTTP/1.0 304 Not Modified');
        @ob_end_clean();
        return;
    }
    $fp = readfile($realfile);
    return;
}
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
{
    global $CONFIG, $USER_DATA, $PIC_NEED_APPROVAL, $CURRENT_PIC_DATA;
    global $lang_errors, $lang_db_input_php;
    $image = $CONFIG['fullpath'] . $filepath . $filename;
    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;
    $orig = $CONFIG['fullpath'] . $filepath . $CONFIG['orig_pfx'] . $filename;
    // $mini = $CONFIG['fullpath'] . $filepath . $CONFIG['mini_pfx'] . $filename;
    $work_image = $image;
    if (!is_known_filetype($image)) {
        return array('error' => $lang_db_input_php['err_invalid_fext'] . ' ' . $CONFIG['allowed_file_extensions'], 'halt_upload' => 0);
    } elseif (is_image($filename)) {
        $imagesize = cpg_getimagesize($image);
        if ($CONFIG['read_iptc_data']) {
            // read IPTC data
            $iptc = get_IPTC($image);
            if (is_array($iptc) && !$title && !$caption && !$keywords) {
                //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
                $title = isset($iptc['Headline']) ? trim($iptc['Headline']) : $title;
                $caption = isset($iptc['Caption']) ? trim($iptc['Caption']) : $caption;
                $keywords = isset($iptc['Keywords']) ? implode($CONFIG['keyword_separator'], $iptc['Keywords']) : $keywords;
            }
        }
        // resize picture if it's bigger than the max width or height for uploaded pictures
        if (max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']) {
            if (USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) {
                $resize_method = $CONFIG['picture_use'] == "thumb" ? $CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use'] : $CONFIG['picture_use'];
                resize_image($image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $resize_method, 'false');
                $imagesize = cpg_getimagesize($image);
            } elseif (USER_IS_ADMIN) {
                // skip resizing for admin
                $picture_original_size = true;
            } else {
                @unlink($uploaded_pic);
                $msg = sprintf($lang_db_input_php['err_fsize_too_large'], $CONFIG['max_upl_width_height'], $CONFIG['max_upl_width_height']);
                return array('error' => $msg, 'halt_upload' => 1);
            }
        }
        // create backup of full sized picture if watermark is enabled for full sized pictures
        if (!file_exists($orig) && $CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')) {
            if (!copy($image, $orig)) {
                return false;
            } else {
                $work_image = $orig;
            }
        }
        if (!file_exists($thumb)) {
            // create thumbnail
            if (($result = resize_image($work_image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false", 1)) !== true) {
                return $result;
            }
        }
        if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($imagesize[0], $imagesize[1]) && !file_exists($normal)) {
            // create intermediate sized picture
            $resize_method = $CONFIG['picture_use'] == "thumb" ? $CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use'] : $CONFIG['picture_use'];
            $watermark = $CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') ? 'true' : 'false';
            if (($result = resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $resize_method, $watermark)) !== true) {
                return $result;
            }
        }
        // watermark full sized picture
        if ($CONFIG['enable_watermark'] == '1' && ($CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')) {
            $wm_max_upl_width_height = $picture_original_size ? max($imagesize[0], $imagesize[1]) : $CONFIG['max_upl_width_height'];
            // use max aspect of original image if it hasn't been resized earlier
            if (($result = resize_image($work_image, $image, $wm_max_upl_width_height, $CONFIG['thumb_method'], 'any', 'true')) !== true) {
                return $result;
            }
        }
    } else {
        $imagesize[0] = $iwidth;
        $imagesize[1] = $iheight;
    }
    clearstatcache();
    $image_filesize = filesize($image);
    $total_filesize = is_image($filename) ? $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb) : $image_filesize;
    // Test if disk quota exceeded
    if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota'] && $category == FIRST_USER_CAT + USER_ID) {
        $result = cpg_db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE  {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
        $record = mysql_fetch_array($result);
        $total_space_used = $record[0];
        mysql_free_result($result);
        if ($total_space_used + $total_filesize >> 10 > $USER_DATA['group_quota']) {
            @unlink($image);
            if (is_image($image)) {
                @unlink($normal);
                @unlink($thumb);
            }
            $msg = $lang_errors['quota_exceeded'] . '<br />&nbsp;<br />' . strtr($lang_errors['quota_exceeded_details'], array('[quota]' => $USER_DATA['group_quota'], '[space]' => $total_space_used >> 10));
            return array('error' => $msg, 'halt_upload' => 1);
        }
    }
    // Test if picture requires approval
    if (GALLERY_ADMIN_MODE) {
        $approved = 'YES';
    } elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
        $approved = 'YES';
    } elseif (!$USER_DATA['pub_upl_need_approval'] && $category < FIRST_USER_CAT) {
        $approved = 'YES';
    } else {
        $approved = 'NO';
    }
    $PIC_NEED_APPROVAL = $approved == 'NO';
    // User ID is recorded when in admin mode
    $user_id = USER_ID;
    // Populate Array to pass to plugins, then to SQL
    $CURRENT_PIC_DATA['aid'] = $aid;
    $CURRENT_PIC_DATA['filepath'] = $filepath;
    $CURRENT_PIC_DATA['filename'] = $filename;
    $CURRENT_PIC_DATA['filesize'] = $image_filesize;
    $CURRENT_PIC_DATA['total_filesize'] = $total_filesize;
    $CURRENT_PIC_DATA['pwidth'] = $imagesize[0];
    $CURRENT_PIC_DATA['pheight'] = $imagesize[1];
    $CURRENT_PIC_DATA['owner_id'] = $user_id;
    $CURRENT_PIC_DATA['title'] = $title;
    $CURRENT_PIC_DATA['caption'] = $caption;
    $CURRENT_PIC_DATA['keywords'] = $keywords;
    $CURRENT_PIC_DATA['approved'] = $approved;
    $CURRENT_PIC_DATA['user1'] = $user1;
    $CURRENT_PIC_DATA['user2'] = $user2;
    $CURRENT_PIC_DATA['user3'] = $user3;
    $CURRENT_PIC_DATA['user4'] = $user4;
    $CURRENT_PIC_DATA['pic_raw_ip'] = $raw_ip;
    $CURRENT_PIC_DATA['pic_hdr_ip'] = $hdr_ip;
    $CURRENT_PIC_DATA['position'] = $position;
    $CURRENT_PIC_DATA['guest_token'] = USER_ID == 0 ? cpg_get_guest_token() : '';
    $CURRENT_PIC_DATA = CPGPluginAPI::filter('add_file_data', $CURRENT_PIC_DATA);
    if (USER_ID > 0 || $CONFIG['allow_guests_enter_file_details'] == 1) {
        $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, guest_token) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '{$CURRENT_PIC_DATA['guest_token']}')";
    } else {
        $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, guest_token) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '', '', '', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '{$CURRENT_PIC_DATA['guest_token']}')";
    }
    $result = cpg_db_query($query);
    // Put the pid in current_pic_data and call the plugin filter for file data success
    $CURRENT_PIC_DATA['pid'] = mysql_insert_id($CONFIG['LINK_ID']);
    CPGPluginAPI::action('add_file_data_success', $CURRENT_PIC_DATA);
    //return $result;
    return true;
}
예제 #26
0
            if ($icon_name_delete != "default.png") {
                $deletepath = $default_icon_path . $icon_name_delete;
                $delete_thumb = $default_thumb_folder . $icon_name_delete;
                if (file_exists($deletepath)) {
                    unlink($deletepath);
                }
                if (file_exists($delete_thumb)) {
                    unlink($delete_thumb);
                }
            }
            $new_file_name = $icon_name;
            move_uploaded_file($_FILES['fomr_upld_cat_icon']['tmp_name'], $default_icon_path . $new_file_name);
            copy($default_icon_path . $new_file_name, $default_thumb_folder . $new_file_name);
            include 'image_resizer.php';
            resize_image($default_icon_path, 64, $new_file_name);
            resize_image($default_thumb_folder, 32, $new_file_name);
            $update_query = "UPDATE " . $table_name . " SET category_name='{$category_name}', dir_name='{$dir_name}' \r\n\t,icon_name='{$new_file_name}' WHERE cat_id={$category_id}";
            $res = $wpdb->query($update_query);
        } else {
            // File upload part ends
            $update_query = "UPDATE " . $table_name . " SET category_name='{$category_name}', dir_name='{$dir_name}' WHERE cat_id={$category_id}";
            $res = $wpdb->query($update_query);
        }
        if ($res) {
            ?>
<div class="updated"><p><strong><?php 
            _e('Category Value Updated.');
            ?>
</strong></p></div>
<?php 
        } else {
 function save($p, $vars)
 {
     //print_r($p); return;
     //print_r($vars); return;
     //$user_id = $_SESSION['USERID'];
     //$from_ip = getenv ("REMOTE_ADDR");
     $c = new Category($this->db_conn);
     $c->getData($vars['id']);
     $old_photo = $c->photo;
     $c->name_cht = $vars['name_cht'];
     $c->name_eng = $vars['name_eng'];
     $c->brief_cht = $vars['brief_cht'];
     $c->brief_eng = $vars['brief_eng'];
     $c->desp_cht = $vars['desp_cht'];
     $c->desp_eng = $vars['desp_eng'];
     $c->vw_cht = $vars['vw_cht'];
     $c->vw_eng = $vars['vw_eng'];
     $c->hotspot_cht = $vars['hotspot_cht'];
     $c->hotspot_eng = $vars['hotspot_eng'];
     $c->seq = $vars['seq'];
     $c->code = $vars['code'];
     //$this->gotoURL("user.php?action=list");
     //上傳
     $uploaddir = HTML_ROOT_PATH . "photo/cat/" . $c->id . "/";
     if ($vars['photo_del'] == "Y") {
         $old_logo = "";
         $deletefile = $uploaddir . $old_logo;
         //舊圖圖檔路徑
         if (file_exists($deletefile)) {
             //檢查文件OR目錄是否存在
             unlink($deletefile);
             //刪除文件
             $c->photo = "";
             //資料庫檔案名清空
         }
     }
     if ($vars['photo']['name'] != "") {
         if (!is_dir($uploaddir)) {
             mkdir($uploaddir, 0777);
         }
         $pos = strrpos($vars['photo']['name'], ".");
         //查詢"."在$vars['logo']['name']最後一次出現位置 (取得檔名長度)
         $extension = strtolower(substr($vars['photo']['name'], $pos + 1));
         //返回$vars['logo']['name']從(檔名長度)加.開始  (取得檔案類型)
         $dst_file = "logo_" . $c->id . "." . $extension;
         //會員ID的圖檔名
         $dst_file_path = $uploaddir . $dst_file;
         //加上圖檔路徑目錄
         $photoname = $dst_file;
         //會員ID圖檔名塞進$photoname變數
         if ($old_logo != "") {
             $deletefile = $uploaddir . $old_photo;
             if (file_exists($deletefile)) {
                 unlink($deletefile);
                 $c->logo = "";
             }
         }
         $src_file = $vars['photo']['tmp_name'];
         $im = @imagecreatefromjpeg($vars['photo']['tmp_name']);
         //php從jpeg文件OR URL新建一圖象
         $imx = imagesx($im);
         //取圖寬
         $imy = imagesy($im);
         //取圖高
         $new_w = 400;
         $new_h = 400;
         if ($imx > $new_w || $imy > $new_h) {
             // 縮圖
             $src_file = resize_image($vars['photo']['tmp_name'], $src_file, $new_w, $new_h);
         }
         $photouploadfile = $uploaddir . $dst_file;
         if (copy($src_file, $photouploadfile)) {
             //logo圖檔複製到指定目錄
             $c->photo = $photoname;
             //print_r($photoname);                      //資料庫logo欄位寫進 會員ID的圖檔名
         } else {
             echo $photouploadfile . "<br>";
             echo "Possible Photo file upload attack!\n";
         }
     }
     $c->update();
     $this->gotoURL("category.php?action=list");
     //$this->gotoURL("category.php?action=show&id=".$c->id);
     //$this->browse($p);
 }
예제 #28
0
    $output = isset($thumb) ? $thumb : $dst;
    imagejpeg($output, '', 90);
    imagedestroy($dst);
    imagedestroy($src);
    return true;
}
$image = false;
if (isset($_REQUEST['id'])) {
    if (!isset($_SESSION)) {
        session_start();
    }
    if (isset($_SESSION['images'][$_REQUEST['id']])) {
        $image = $_SESSION['images'][$_REQUEST['id']];
        //unset($_SESSION['images'][$_REQUEST['id']]);
        $image = base64_decode($image);
    }
} else {
    $image = isset($_REQUEST['img']) ? file_get_contents($_REQUEST['img']) : false;
}
if ($image) {
    $size = isset($_REQUEST['size']) ? explode('x', $_REQUEST['size']) : false;
    $crop = isset($_REQUEST['crop']) ? $_REQUEST['crop'] : false;
    header("Content-Type: image/jpeg");
    header("Accept-Ranges: bytes");
    header("Cache-Control: max-age=9999, must-revalidate");
    if ($size) {
        resize_image($image, $size[0], $size[1], $crop);
    } else {
        echo $image;
    }
}
예제 #29
0
function save_thumbnail($thumb_img_url)
{
    // create and save thumbnail
    // save thumbnail
    $imageServerPath = $_SERVER['DOCUMENT_ROOT'] . '/web_test/image_test/upload_image/';
    $thumbServerPath = $_SERVER['DOCUMENT_ROOT'] . '/web_test/image_test/thumbnails/';
    $defaultImagePath = $_SERVER['DOCUMENT_ROOT'] . '/web_test/image_test/';
    $imageName;
    if (isset($thumb_img_url)) {
        $imageName = $thumb_img_url;
    } else {
        $imageName = 'default_backdrop_img.jpg';
        if (!is_dir($imageServerPath)) {
            @mkdir($imageServerPath);
        }
        // copy default image file
        if (!file_exists($imageServerPath . $imageName)) {
            // file check
            if (!copy($defaultImagePath . $imageName, $imageServerPath . $imageName)) {
                // copy
                echo "<center>default image file copy error</center>";
                // fail
            } else {
                if (file_exists($imageServerPath . $imageName)) {
                    // success
                }
            }
        }
    }
    if (!is_dir($thumbServerPath)) {
        @mkdir($thumbServerPath);
    }
    $exif_data = exif_read_data($imageServerPath . $imageName, 0, true);
    $exist_thumbnail = false;
    foreach ($exif_data as $key => $section) {
        if (in_array("THUMBNAIL", $section)) {
            $exist_thumbnail = true;
            break;
        }
    }
    if ($exist_thumbnail) {
        $thumbData = exif_thumbnail($thumbServerPath . $imageName, $thumb_width, $thumb_height, $thumb_type);
        $thumb = imagecreatefromstring($thumbData);
    } else {
        $thumb_width = 200;
        $thumb_height = 200;
        $thumb = resize_image($imageServerPath . $imageName, 200, 200);
    }
    if (!is_dir($thumbServerPath)) {
        @mkdir($thumbServerPath);
    }
    if (imagejpeg($thumb, $thumbServerPath . $imageName, 100)) {
    } else {
        // 실패시 db에 저장했던 내용 취소를 위한 롤백
        echo "thumbnail 실패";
        exit;
    }
    // if
    return $imageName;
}
예제 #30
0
                                                      reference = '$reference',reference_contact ='$reference_contact',hobby='$hobby',habit='$habit' where rec_id = '$emp_edit_id'";
					                  $result_insert_personal = mysql_query($sql_insert_personal) or die("Error in query:" . $sql_insert_personal . "<br>" . mysql_error() . "<br>" . mysql_errno());
                  }
                  if ($_FILES["emp_pic"]["name"] <> "") {
                      $filename      = $_FILES["emp_pic"]["name"];
                      $file_arr      = explode(".", $filename);
					            $file_ext      = strtolower($file_arr[sizeof($file_arr) - 1]);

					            if ($file_ext == 'jpg' || $file_ext == 'gif' || $file_ext == 'bmp' || $file_ext == 'jpeg') {
                          
                          $filename = str_replace(" ", "_", $filename); // Add _ inplace of blank space in file name, you can remove this line
                          $time     = time();
                          $file     = $time . "_" . $filename;
                          $up_file  = "employee_picture/" . $file;   // upload directory path is set
                          if (move_uploaded_file($_FILES['emp_pic']['tmp_name'], $up_file)) {     //  upload the file to the server
                              resize_image($up_file, '100', '100', 'false', "employee_picture/thumb/" . $file, 'false', 'false');
                              $flag = 1;
                              $sql_insert = "update " . $mysql_table_prefix . "employee_master set 
																						employee_picture = '$file'
																						where rec_id = '$emp_rec_id'";
                             $result_insert = mysql_query($sql_insert) or die("Error in query:" . $sql_insert . "<br>" . mysql_error() . "<br>" . mysql_errno());
                          } else {
                              $flag = 0;
                              $msg  = 'error in upload image file';
                          }
                      } else {
                          $flag   = 0;
                          $msg    = 'Please upload image file not ' . $file_ext;
                      }
                  }
                  $mode   = 'personal_detail';