示例#1
0
 protected function handleEditValidationSuccess($video, $site = '')
 {
     if ($video->Id == NULL) {
         $uplPath = $this->config->item('resource_folder') . '/video';
         $uplConfig['upload_path'] = $uplPath;
         $uplConfig['allowed_types'] = '*';
         $this->load->library('upload', $uplConfig);
         if ($this->upload->do_upload('uplVideo')) {
             $data = $this->upload->data();
             $outputFile = $this->convertVideo($uplPath . '/' . $data['file_name']);
             $thumbnailPath = $this->config->item('resource_folder') . '/video_thumbnail';
             $thumbnailFile = create_thumbnail($outputFile, $this->config->item('thumbnail_video_width'), $this->config->item('thumbnail_video_height'), $thumbnailPath);
             if ($outputFile && $thumbnailFile) {
                 $resourceVideo = new Resource_model();
                 $resourceVideo->Path = $outputFile;
                 $resourceVideoId = $resourceVideo->save();
                 $resourceThumbnail = new Resource_model();
                 $resourceThumbnail->Path = $thumbnailFile;
                 $resourceThumbnailId = $resourceThumbnail->save();
             }
         } else {
             $this->addDataForView('err', $this->upload->display_errors('<div>', '</div>'));
             $this->template->load($this->template_admin, $this->getEditViewName(), $this->getDataForView());
             return;
         }
         if (isset($resourceVideoId)) {
             $video->IdResource = $resourceVideoId;
             $video->IdThumbnail = $resourceThumbnailId;
             $video->OwnerBy = $this->Account_model->getLoggedInUserId();
         }
     }
     parent::handleEditValidationSuccess($video, $site);
 }
 public function return_img_thumb($src)
 {
     $input = \Request::all();
     $width = isset($input['width']) ? $input['width'] : 140;
     $height = isset($input['height']) ? $input['height'] : 140;
     $save = isset($input['save']);
     $path_array = explode(".", $src);
     $ext = array_pop($path_array);
     $file_path = implode(".", $path_array);
     $thumb_format = $file_path . "-{$width}" . "x" . "{$height}.jpg";
     if (file_exists(real_imgs_dir . $thumb_format)) {
         $img = imgs_dir . $thumb_format;
     } else {
         // Create Thumb
         if (!file_exists(real_imgs_dir . $src)) {
             die("{$src} --> image doesn't exist.");
         } else {
             //				dd();
             $save_dir = false;
             if (CREATE_THUMBS && $save) {
                 $save_dir = real_imgs_dir . $thumb_format;
             } elseif ($width != 140 || $height != 140) {
                 $save_dir = false;
             }
             //if !=140 don't save
             //				dd($save_dir);
             create_thumbnail(real_imgs_dir . $src, $save_dir, $width, $height);
             $img = imgs_dir . $thumb_format;
         }
         // die("f**k Get Thumb Didn't work on : $src");
     }
     $this->return_img($img, 'jpg');
 }
示例#3
0
文件: cfg.php 项目: jfkz/aquarel-cms
function listFiles($dir)
{
    global $cfg;
    $list = array();
    $full = $cfg['root'] . trim($dir, '/\\') . DIR_SEP;
    $thumb = $cfg['root'] . $cfg['thumb']['dir'] . DIR_SEP . trim($dir, '/\\') . DIR_SEP;
    $files = scandir($full);
    natcasesort($files);
    for ($i = -1, $iCount = count($files); ++$i < $iCount;) {
        $ext = substr($files[$i], strrpos($files[$i], '.') + 1);
        if (!in_array($files[$i], $cfg['hide']['file']) && !in_array($ext, $cfg['deny'][$cfg['type']]) && in_array($ext, $cfg['allow'][$cfg['type']]) && is_file($full . $files[$i])) {
            $imgSize = array(0, 0);
            if (in_array($ext, $cfg['allow']['image'])) {
                if ($cfg['thumb']['auto'] && !file_exists($thumb . $files[$i])) {
                    create_thumbnail($full . $files[$i], $thumb . $files[$i]);
                }
                $imgSize = getimagesize($full . $files[$i]);
            }
            $stats = getSize($full . $files[$i]);
            $list[] = array('name' => $files[$i], 'ext' => $ext, 'width' => $imgSize[0], 'height' => $imgSize[1], 'size' => $stats['_size'], 'date' => date($cfg['thumb']['date'], $stats['mtime']), 'r_size' => $stats['size'], 'mtime' => $stats['mtime'], 'thumb' => '/' . $cfg['url'] . '/' . $cfg['thumb']['dir'] . '/' . $dir . $files[$i]);
        }
    }
    switch ($cfg['sort']) {
        case 'size':
            usort($list, 'sortSize');
            break;
        case 'date':
            usort($list, 'sortDate');
            break;
        default:
            //name
            break;
    }
    return $list;
}
示例#4
0
 public function edit_post()
 {
     $data = array();
     if (!($user = $this->user->get($this->user_id))) {
         $this->response(array('msg', 'User not found, call Grumpy cat!'), 500);
     }
     if ($this->post('username')) {
         if ($this->user->get_by(array('us_username' => $this->post('username'), 'us_id !=' => $this->user_id))) {
             $this->response(array('msg', 'Username already used'), 201);
         }
         $data['us_username'] = $this->post('username');
     }
     if ($this->post('email')) {
         if ($this->user->get_by(array('us_email' => $this->post('email'), 'us_id !=' => $this->user_id))) {
             $this->response(array('msg', 'Email already used'), 201);
         }
         $data['us_email'] = $this->post('email');
     }
     if ($this->post('first_name')) {
         $data['us_first_name'] = $this->post('first_name');
     }
     if ($this->post('last_name')) {
         $data['us_last_name'] = $this->post('last_name');
     }
     if ($this->post('pwd')) {
         $data['us_password'] = $this->post('pwd');
     }
     if ($this->post('gender')) {
         $data['us_gender'] = $this->post('gender');
     }
     if ($this->post('dob')) {
         $data['us_dob'] = date('Y-m-d', strtotime($this->post('dob')));
     }
     if ($this->post('us_avatar')) {
         $data['us_avatar'] = $this->post('us_avatar');
     }
     if (!empty($_FILES['photo'])) {
         $path = 'uploads/users/';
         $name = 'profile_picture_' . $user['us_id'] . time();
         $unlink_picture = $path . $user['us_avatar'];
         $upload_file = $this->_upload_profile($name, $path, $_FILES['photo']);
         if ($upload_file == FALSE) {
             $this->response(array('msg' => 'BAD REQUEST, ERROR PHOTO'), 400);
         } else {
             if (file_exists($unlink_picture) && $user['us_avatar'] != '') {
                 unlink($unlink_picture);
             }
             create_thumbnail($path . $upload_file, '800', '800', $path . $upload_file);
             $data['us_avatar'] = $upload_file;
         }
     }
     $data['us_user_modified'] = $this->user_username;
     $data['us_date_modified'] = date('Y-m-d H:i:s');
     if ($this->user->update($this->user_id, $data)) {
         $this->response(array('msg', 'Success'), 200);
     } else {
         $this->response(array('msg', 'Database Problem, call Grumpy cat!'), 500);
     }
 }
示例#5
0
function makethumbnail($image_name, $src, $dest)
{
    global $_CONF, $CONF_SE;
    $do_create = 0;
    if ($image_info = @getimagesize($src)) {
        if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
            $do_create = 1;
        }
    }
    if ($do_create) {
        $dimension = intval($CONF_SE['auto_thumbnail_dimension']) ? intval($CONF_SE['auto_thumbnail_dimension']) : 100;
        $resize_type = intval($CONF_SE['auto_thumbnail_resize_type']) ? intval($CONF_SE['auto_thumbnail_resize_type']) : 1;
        $quality = intval($CONF_SE['auto_thumbnail_quality']) && intval($CONF_SE['auto_thumbnail_quality']) <= 100 ? intval($CONF_SE['auto_thumbnail_quality']) : 100;
        if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
            $new_thumb_name = $new_name;
            $chmod = @chmod($dest, $CONF_SE['image_perms']);
        }
    }
}
function get_thumb($src, $width = 140, $height = 140)
{
    // th($src,$width,$height);
    // die;
    // die('hello');
    $path_array = explode(".", $src);
    $ext = array_pop($path_array);
    $file_path = implode(".", $path_array);
    $thumb_format = $file_path . "-{$width}" . "x" . "{$height}.jpg";
    // --------------------just temprory--------------------------------------------------
    // if(file_exists(real_imgs_dir.$thumb_format)){
    // 	// die("1-".imgs_dir.$thumb_format);
    //   		return imgs_dir.$thumb_format;
    //   	}elseif(file_exists(real_imgs_dir.$file_path.".".$ext)){
    //           die("2-");
    //           return imgs_dir.$file_path.".".$ext;
    //   	}else{
    //   		die("3-".real_imgs_dir.$file_path.".".$ext);
    //   		return '';
    //   	}
    // ----------------------------------------------------------------------
    if (file_exists(real_imgs_dir . $thumb_format)) {
        // die("file_exists: ".real_imgs_dir.$thumb_format);
        return imgs_dir . $thumb_format;
    } else {
        // Create Thumb
        if (!file_exists(real_imgs_dir . $src)) {
            die("{$src} --> image doesn't exist.");
        } else {
            // die("Current image is: $src") ;
            create_thumbnail(real_imgs_dir . $src, real_imgs_dir . $thumb_format, $width, $height);
            return imgs_dir . $thumb_format;
        }
        die("f**k Get Thumb Didn't work on : {$src}");
    }
}
示例#7
0
     } else {
         $log[] = str_replace("{name}", str_replace(ROOT_PATH, "", $backup_orig) . "/" . $cat_id . "/" . $image_media_file, $lang['cni_backup_error']);
     }
 }
 $file_thumb = THUMB_PATH . "/" . $cat_id . "/" . $image_media_file;
 if ($do_thumb && $auto_thumbs && $image_thumb_file == "" && !file_exists($file_thumb)) {
     $ok = 0;
     if ($resize_type_thumbs == 1 && ($image_info[0] > $dimension_thumbs || $image_info[1] > $dimension_thumbs)) {
         $ok = 1;
     } elseif ($resize_type_thumbs == 2 && $image_info[0] > $dimension_thumbs) {
         $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'];
     }
 }
示例#8
0
/**
* Upload Attachment - filedata is generated here
* Uses upload class
*
* @param string			$form_name		The form name of the file upload input
* @param int			$forum_id		The id of the forum
* @param bool			$local			Whether the file is local or not
* @param string			$local_storage	The path to the local file
* @param bool			$is_message		Whether it is a PM or not
* @param \filespec		$local_filedata	A filespec object created for the local file
* @param \phpbb\mimetype\guesser	$mimetype_guesser	The mimetype guesser object if used
* @param \phpbb\plupload\plupload	$plupload		The plupload object if one is being used
*
* @return object filespec
*/
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
{
    global $auth, $user, $config, $db, $cache;
    global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container;
    $filedata = array('error' => array());
    $upload = $phpbb_container->get('files.upload');
    if ($config['check_attachment_content'] && isset($config['mime_triggers'])) {
        $upload->set_disallowed_content(explode('|', $config['mime_triggers']));
    } else {
        if (!$config['check_attachment_content']) {
            $upload->set_disallowed_content(array());
        }
    }
    $filedata['post_attach'] = $local || $upload->is_valid($form_name);
    if (!$filedata['post_attach']) {
        $filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND'];
        return $filedata;
    }
    $extensions = $cache->obtain_attach_extensions($is_message ? false : (int) $forum_id);
    $upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
    /** @var \phpbb\files\filespec $file */
    $file = $local ? $upload->handle_upload('files.types.local', $local_storage, $local_filedata) : $upload->handle_upload('files.types.form', $form_name);
    if ($file->init_error()) {
        $filedata['post_attach'] = false;
        return $filedata;
    }
    // Whether the uploaded file is in the image category
    $is_image = isset($extensions[$file->get('extension')]['display_cat']) ? $extensions[$file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false;
    if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id)) {
        // Check Image Size, if it is an image
        if ($is_image) {
            $file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']);
        }
        // Admins and mods are allowed to exceed the allowed filesize
        if (!empty($extensions[$file->get('extension')]['max_filesize'])) {
            $allowed_filesize = $extensions[$file->get('extension')]['max_filesize'];
        } else {
            $allowed_filesize = $is_message ? $config['max_filesize_pm'] : $config['max_filesize'];
        }
        $file->upload->set_max_filesize($allowed_filesize);
    }
    $file->clean_filename('unique', $user->data['user_id'] . '_');
    // Are we uploading an image *and* this image being within the image category?
    // Only then perform additional image checks.
    $file->move_file($config['upload_path'], false, !$is_image);
    // Do we have to create a thumbnail?
    $filedata['thumbnail'] = $is_image && $config['img_create_thumbnail'] ? 1 : 0;
    if (sizeof($file->error)) {
        $file->remove();
        $filedata['error'] = array_merge($filedata['error'], $file->error);
        $filedata['post_attach'] = false;
        return $filedata;
    }
    // Make sure the image category only holds valid images...
    if ($is_image && !$file->is_image()) {
        $file->remove();
        if ($plupload && $plupload->is_active()) {
            $plupload->emit_error(104, 'ATTACHED_IMAGE_NOT_IMAGE');
        }
        // If this error occurs a user tried to exploit an IE Bug by renaming extensions
        // Since the image category is displaying content inline we need to catch this.
        trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
    }
    $filedata['filesize'] = $file->get('filesize');
    $filedata['mimetype'] = $file->get('mimetype');
    $filedata['extension'] = $file->get('extension');
    $filedata['physical_filename'] = $file->get('realname');
    $filedata['real_filename'] = $file->get('uploadname');
    $filedata['filetime'] = time();
    /**
     * Event to modify uploaded file before submit to the post
     *
     * @event core.modify_uploaded_file
     * @var	array	filedata	Array containing uploaded file data
     * @var	bool	is_image	Flag indicating if the file is an image
     * @since 3.1.0-RC3
     */
    $vars = array('filedata', 'is_image');
    extract($phpbb_dispatcher->trigger_event('core.modify_uploaded_file', compact($vars)));
    // Check our complete quota
    if ($config['attachment_quota']) {
        if ($config['upload_dir_size'] + $file->get('filesize') > $config['attachment_quota']) {
            $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
            $filedata['post_attach'] = false;
            $file->remove();
            return $filedata;
        }
    }
    // Check free disk space
    if ($free_space = @disk_free_space($phpbb_root_path . $config['upload_path'])) {
        if ($free_space <= $file->get('filesize')) {
            if ($auth->acl_get('a_')) {
                $filedata['error'][] = $user->lang['ATTACH_DISK_FULL'];
            } else {
                $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
            }
            $filedata['post_attach'] = false;
            $file->remove();
            return $filedata;
        }
    }
    // Create Thumbnail
    if ($filedata['thumbnail']) {
        $source = $file->get('destination_file');
        $destination = $file->get('destination_path') . '/thumb_' . $file->get('realname');
        if (!create_thumbnail($source, $destination, $file->get('mimetype'))) {
            $filedata['thumbnail'] = 0;
        }
    }
    return $filedata;
}
/**
* Upload Attachment - filedata is generated here
* Uses upload class
*/
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false)
{
    global $auth, $user, $config, $db, $cache;
    global $phpbb_root_path, $phpEx;
    $filedata = array('error' => array());
    include_once $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
    $upload = new fileupload();
    if ($config['check_attachment_content'] && isset($config['mime_triggers'])) {
        $upload->set_disallowed_content(explode('|', $config['mime_triggers']));
    }
    if (!$local) {
        $filedata['post_attach'] = $upload->is_valid($form_name) ? true : false;
    } else {
        $filedata['post_attach'] = true;
    }
    if (!$filedata['post_attach']) {
        $filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND'];
        return $filedata;
    }
    $extensions = $cache->obtain_attach_extensions($is_message ? false : (int) $forum_id);
    $upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
    $file = $local ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name);
    if ($file->init_error) {
        $filedata['post_attach'] = false;
        return $filedata;
    }
    $cat_id = isset($extensions[$file->get('extension')]['display_cat']) ? $extensions[$file->get('extension')]['display_cat'] : ATTACHMENT_CATEGORY_NONE;
    // Make sure the image category only holds valid images...
    if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && !$file->is_image()) {
        $file->remove();
        // If this error occurs a user tried to exploit an IE Bug by renaming extensions
        // Since the image category is displaying content inline we need to catch this.
        trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
    }
    // Do we have to create a thumbnail?
    $filedata['thumbnail'] = $cat_id == ATTACHMENT_CATEGORY_IMAGE && $config['img_create_thumbnail'] ? 1 : 0;
    // Check Image Size, if it is an image
    if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id) && $cat_id == ATTACHMENT_CATEGORY_IMAGE) {
        $file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']);
    }
    // Admins and mods are allowed to exceed the allowed filesize
    if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id)) {
        if (!empty($extensions[$file->get('extension')]['max_filesize'])) {
            $allowed_filesize = $extensions[$file->get('extension')]['max_filesize'];
        } else {
            $allowed_filesize = $is_message ? $config['max_filesize_pm'] : $config['max_filesize'];
        }
        $file->upload->set_max_filesize($allowed_filesize);
    }
    $file->clean_filename('unique', $user->data['user_id'] . '_');
    // Are we uploading an image *and* this image being within the image category? Only then perform additional image checks.
    $no_image = $cat_id == ATTACHMENT_CATEGORY_IMAGE ? false : true;
    $file->move_file($config['upload_path'], false, $no_image);
    if (sizeof($file->error)) {
        $file->remove();
        $filedata['error'] = array_merge($filedata['error'], $file->error);
        $filedata['post_attach'] = false;
        return $filedata;
    }
    $filedata['filesize'] = $file->get('filesize');
    $filedata['mimetype'] = $file->get('mimetype');
    $filedata['extension'] = $file->get('extension');
    $filedata['physical_filename'] = $file->get('realname');
    $filedata['real_filename'] = $file->get('uploadname');
    $filedata['filetime'] = time();
    // Check our complete quota
    if ($config['attachment_quota']) {
        if ($config['upload_dir_size'] + $file->get('filesize') > $config['attachment_quota']) {
            $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
            $filedata['post_attach'] = false;
            $file->remove();
            return $filedata;
        }
    }
    // Check free disk space
    if ($free_space = @disk_free_space($phpbb_root_path . $config['upload_path'])) {
        if ($free_space <= $file->get('filesize')) {
            $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
            $filedata['post_attach'] = false;
            $file->remove();
            return $filedata;
        }
    }
    // Create Thumbnail
    if ($filedata['thumbnail']) {
        $source = $file->get('destination_file');
        $destination = $file->get('destination_path') . '/thumb_' . $file->get('realname');
        if (!create_thumbnail($source, $destination, $file->get('mimetype'))) {
            $filedata['thumbnail'] = 0;
        }
    }
    return $filedata;
}
示例#10
0
/**
* display a page of thumbnails
*
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
* @param imageList (array) list containing all image file names
* @param fileList (array) file properties
* @param page (int) current page number
* @param thumbnailWidth (int) width of thumbnails
* @param colWidth (int) width of columns
* @param numberOfCols (int) number of columns
* @param numberOfRows (int) number of rows
* @global curDirPath
*/
function display_thumbnails($imageList, $fileList, $page, $thumbnailWidth, $colWidth, $numberOfCols, $numberOfRows)
{
    global $curDirPath;
    global $searchCmdUrl;
    // get index of first thumbnail on the page
    $displayed = get_offset($page);
    $html = '';
    // loop on rows
    for ($rows = 0; $rows < $numberOfRows; $rows++) {
        $html .= "<tr>\n";
        // loop on columns
        for ($cols = 0; $cols < $numberOfCols; $cols++) {
            // get index of image
            $num = $imageList[$displayed];
            // get file name
            $fileName = $fileList[$num]['path'];
            // visibility style
            if ($fileList[$num]['visibility'] == 'i') {
                $style = "style=\"font-style: italic; color: silver;\"";
            } else {
                $style = '';
            }
            // display thumbnail
            /*echo "<td style=\"text-align: center;\" style=\"width:"
              . $colWidth . "%;\">\n"
              ;*/
            // omit colwidth since already in th
            $html .= "<td style=\"text-align: center;\">\n";
            $html .= "<a href=\"" . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . "?docView=image&file=" . download_url_encode($fileName) . "&cwd=" . $curDirPath . $searchCmdUrl)) . "\">";
            // display image description using title attribute
            $title = "";
            if ($fileList[$num]['comment']) {
                $text = $fileList[$num]['comment'];
                $text = cutstring($text, 40, false, 5, "...");
                $title = "title=\"" . $text . "\"";
            }
            $html .= create_thumbnail($fileName, $thumbnailWidth, $title);
            // unset title for the next pass in the loop
            unset($title);
            $html .= "</a>\n";
            // display image name
            $imgName = strlen(basename($fileList[$num]['path'])) > 25 ? substr(basename($fileList[$num]['path']), 0, 25) . "..." : basename($fileList[$num]['path']);
            $html .= "<p " . $style . ">" . $imgName . "</p>";
            $html .= "</td>\n";
            // update image number
            $displayed++;
            // finished ?
            if ($displayed >= count($imageList)) {
                $html .= "</tr>\n";
                return $html;
            }
        }
        // end loop on columns
        $html .= "</tr>\n";
    }
    // end loop on rows
    return $html;
}
$logo = "../";
$title = "Control panel | ";
session_start();
include '../connect.php';
$username = $_SESSION["user"];
if (!empty($_SESSION['user'])) {
    //if(isset($_POST['fupload'])) {
    require 'image_inc.php';
    if (isset($_FILES['fupload'])) {
        if (preg_match('/[.](jpg)|(gif)|(png)$/', $_FILES['fupload']['name'])) {
            $filename = $_FILES['fupload']['name'];
            $source = $_FILES['fupload']['tmp_name'];
            $path_to_image_directory = 'images/fullsized/';
            $target = $path_to_image_directory . $filename;
            move_uploaded_file($source, $target);
            create_thumbnail($filename, $filename . '_thumb.png', 100, 100);
        }
    }
    ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="author" content="" />
    <title>Dynamic Thumbnails</title>
</head>
 
<body>
示例#12
0
            create_thumbnail($uploaddir, $large, $new_width = 'auto', $new_height = 350, $quality = 70);
            $hasil = $koneksi_db->sql_query("INSERT INTO photo (gambar,peristiwa,keterangan) VALUES ('{$simpan}','{$peristiwa}','{$keterangan4}')");
            $admin .= '<div class="sukses">Photo 4 Berhasil dimasukkan ke database</div>';
            unlink($uploaddir);
        }
        if (!empty($image_name5)) {
            $files = $_FILES['image5']['name'];
            $tmp_files = $_FILES['image5']['tmp_name'];
            $simpan = md5(rand(1, 100) . $files) . '.jpg';
            $uploaddir = $temp . $simpan;
            $uploads = move_uploaded_file($tmp_files, $uploaddir);
            if (file_exists($uploaddir)) {
                @chmod($uploaddir, 0644);
            }
            $large = $normal . $simpan;
            create_thumbnail($uploaddir, $large, $new_width = 'auto', $new_height = 350, $quality = 70);
            $hasil = $koneksi_db->sql_query("INSERT INTO photo (gambar,peristiwa,keterangan) VALUES ('{$simpan}','{$peristiwa}','{$keterangan5}')");
            $admin .= '<div class="sukses">Photo 5 Berhasil dimasukkan ke database</div>';
            unlink($uploaddir);
        }
    }
    $hasil = $koneksi_db->sql_query("SELECT * FROM photo_peristiwa WHERE id={$id}");
    $data = $koneksi_db->sql_fetchrow($hasil);
    $id = $data['id'];
    $idperistiwa = $data['id'];
    $judulperistiwa = $data['judul'];
    $admin .= '<div class="border">';
    $admin .= '<table><tr><td>List Photo Peristiwa </td><td>&nbsp;<b>
<a href=admin.php?pilih=photo&amp;mod=yes&aksi=editperistiwa&id=' . $id . '>
' . $judulperistiwa . '</a></b></td></tr></table>';
    $admin .= '<table><tr>';
示例#13
0
文件: ajax.php 项目: jfkz/aquarel-cms
 $height = isset($_POST['resizeHeight']) ? intval($_POST['resizeHeight']) : 0;
 $key = 'uploadFiles';
 if (!empty($dir) && '/' != $dir && !empty($_FILES[$key])) {
     for ($i = -1, $iCount = count($_FILES[$key]['name']); ++$i < $iCount;) {
         $ext = substr($_FILES[$key]['name'][$i], strrpos($_FILES[$key]['name'][$i], '.') + 1);
         if (!in_array($ext, $cfg['deny'][$cfg['type']]) && in_array($ext, $cfg['allow'][$cfg['type']])) {
             $freeName = getFreeFileName($_FILES[$key]['name'][$i], $cfg['root'] . $dir);
             if (in_array($ext, $cfg['allow']['image'])) {
                 if ($width || $height) {
                     create_thumbnail($_FILES[$key]['tmp_name'][$i], $cfg['root'] . $dir . $freeName, $width, $height, 100, false, true);
                     chmod($cfg['root'] . $dir . $freeName, $cfg['chmod']['file']);
                 } else {
                     if (move_uploaded_file($_FILES[$key]['tmp_name'][$i], $cfg['root'] . $dir . $freeName)) {
                         chmod($cfg['root'] . $dir . $freeName, $cfg['chmod']['file']);
                         if ($cfg['thumb']['auto']) {
                             create_thumbnail($cfg['root'] . $dir . $freeName, $cfg['root'] . $cfg['thumb']['dir'] . DIR_SEP . $dir . DIR_SEP . $freeName);
                             chmod($cfg['root'] . $cfg['thumb']['dir'] . DIR_SEP . $dir . DIR_SEP . $freeName, $cfg['chmod']['file']);
                         }
                         $reply['downloaded'][] = array(true, $freeName);
                     } else {
                         $reply['downloaded'][] = array(false, $freeName);
                     }
                 }
             } else {
                 if (move_uploaded_file($_FILES[$key]['tmp_name'][$i], $cfg['root'] . $dir . $freeName)) {
                     chmod($cfg['root'] . $dir . $freeName, $cfg['chmod']['file']);
                     $reply['downloaded'][] = array(true, $freeName);
                 } else {
                     $reply['downloaded'][] = array(false, $freeName);
                 }
             }
 function move_uploaded_attachment($upload_mode, $file)
 {
     global $error, $error_msg, $lang, $upload_dir;
     if (!is_uploaded_file($file)) {
         message_die(GENERAL_ERROR, 'Unable to upload file. The given source has not been uploaded.', __LINE__, __FILE__);
     }
     switch ($upload_mode) {
         case 'copy':
             if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) {
                 if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . basename($this->attach_filename), 0666);
             break;
         case 'move':
             if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) {
                 if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             break;
         case 'ftp':
             ftp_file($file, basename($this->attach_filename), $this->type);
             break;
     }
     if (!$error && $this->thumbnail == 1) {
         if ($upload_mode == 'ftp') {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . basename($this->attach_filename);
         } else {
             $source = $upload_dir . '/' . basename($this->attach_filename);
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . basename($this->attach_filename);
         }
         if (!create_thumbnail($source, $dest_file, $this->type)) {
             if (!$file || !create_thumbnail($file, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
示例#15
0
    include_once '../pv_core.php';
    include_once '../modules/module_imagefunctions.php';
}
global $Pivot_Vars;
CheckLogin();
chdir($Paths['upload_path']);
// -- main --
if (!$img) {
    $img = $Pivot_Vars['image'];
}
// get original image attributes
$attr = get_image_attributes($img);
$img = new Attributes($attr['name'], $attr['w'], $attr['h'], $attr['x'], $attr['y']);
if (isset($Pivot_Vars['crop'])) {
    // create the thumbnail!
    create_thumbnail();
} else {
    // show the JS crop editor!
    print_crop_editor();
}
// -- main --
// Nothing to change from here
// -------------------------------
function get_image_attributes($img)
{
    if (!file_exists($img)) {
        $img = stripslashes(urldecode($img));
    }
    if (!file_exists($img)) {
        echo "<br />{$img} can not be opened. <br />";
        echo "Current Path: " . getcwd() . "<br />";
 while ($row = $db->sql_fetchrow($result)) {
     @flush();
     echo '.';
     if ($i % 50 == 0) {
         echo '<br />';
     }
     if (!thumbnail_exists(basename($row['physical_filename']))) {
         if (!intval($config['allow_ftp_upload'])) {
             $source = $upload_dir . '/' . basename($row['physical_filename']);
             $dest_file = @amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . basename($row['physical_filename']);
         } else {
             $source = $row['physical_filename'];
             $dest_file = THUMB_DIR . '/t_' . basename($row['physical_filename']);
         }
         if (!create_thumbnail($source, $dest_file, $row['mimetype'])) {
             $info .= sprintf($lang['Sync_thumbnail_resetted'], $row['physical_filename']) . '<br />';
             $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . " SET thumbnail = 0 WHERE attach_id = " . (int) $row['attach_id'];
             $db->sql_query($sql);
         } else {
             $info .= sprintf($lang['Sync_thumbnail_recreated'], $row['physical_filename']) . '<br />';
             $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . " SET thumbnail = 1 WHERE attach_id = " . (int) $row['attach_id'];
             $db->sql_query($sql);
         }
     }
     $i++;
 }
 $db->sql_freeresult($result);
 // Sync Thumbnails (make sure all non-existent thumbnails are deleted) - the other way around
 // Get all Posts/PM's with the Thumbnail Flag NOT set
 // Go through all of them and make sure the Thumbnail does NOT exist. If it does exist, delete it
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false)
{
    global $_CLASS, $config;
    $filedata = array();
    $filedata['error'] = array();
    include_once SITE_FILE_ROOT . 'includes/forums/functions_upload.php';
    $upload = new fileupload();
    if (!$local) {
        $filedata['post_attach'] = $upload->is_valid($form_name) ? true : false;
    } else {
        $filedata['post_attach'] = true;
    }
    if (!$filedata['post_attach']) {
        $filedata['error'][] = 'No filedata found';
        return $filedata;
    }
    $extensions = obtain_attach_extensions($forum_id);
    if (!empty($extensions['_allowed_'])) {
        $upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
    }
    if ($local) {
        $file = $upload->local_upload($local_storage);
    } else {
        $file = $upload->form_upload($form_name);
    }
    if ($file->init_error) {
        $filedata['post_attach'] = false;
        return $filedata;
    }
    $cat_id = isset($extensions[$file->get('extension')]['display_cat']) ? $extensions[$file->get('extension')]['display_cat'] : ATTACHMENT_CATEGORY_NONE;
    // Do we have to create a thumbnail?
    $filedata['thumbnail'] = $cat_id == ATTACHMENT_CATEGORY_IMAGE && $config['img_create_thumbnail'] ? 1 : 0;
    // Check Image Size, if it is an image
    if (!$_CLASS['auth']->acl_gets('m_', 'a_') && $cat_id == ATTACHMENT_CATEGORY_IMAGE) {
        $file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']);
    }
    if (!$_CLASS['auth']->acl_gets('a_', 'm_')) {
        $allowed_filesize = $extensions[$file->get('extension')]['max_filesize'] != 0 ? $extensions[$file->get('extension')]['max_filesize'] : ($is_message ? $config['max_filesize_pm'] : $config['max_filesize']);
        $file->upload->set_max_filesize($allowed_filesize);
    }
    $file->clean_filename('unique', $_CLASS['core_user']->data['user_id'] . '_');
    $file->move_file($config['upload_path']);
    if (!empty($file->error)) {
        $file->remove();
        $filedata['error'] = array_merge($filedata['error'], $file->error);
        $filedata['post_attach'] = false;
        return $filedata;
    }
    $filedata['filesize'] = $file->get('filesize');
    $filedata['mimetype'] = $file->get('mimetype');
    $filedata['extension'] = $file->get('extension');
    $filedata['physical_filename'] = $file->get('realname');
    $filedata['real_filename'] = $file->get('uploadname');
    $filedata['filetime'] = time();
    // Check our complete quota
    if ($config['attachment_quota']) {
        if ($config['upload_dir_size'] + $file->get('filesize') > $config['attachment_quota']) {
            $filedata['error'][] = $_CLASS['core_user']->lang['ATTACH_QUOTA_REACHED'];
            $filedata['post_attach'] = false;
            $file->remove();
            return $filedata;
        }
    }
    // Check free disk space
    if ($free_space = @disk_free_space($config['upload_path'])) {
        if ($free_space <= $file->get('filesize')) {
            $filedata['error'][] = $_CLASS['core_user']->lang['ATTACH_QUOTA_REACHED'];
            $filedata['post_attach'] = false;
            $file->remove();
            return $filedata;
        }
    }
    // Create Thumbnail
    if ($filedata['thumbnail']) {
        $source = $file->get('destination_file');
        $destination = $file->get('destination_path') . '/thumb_' . $file->get('realname');
        if (!create_thumbnail($source, $destination, $file->get('mimetype'))) {
            $filedata['thumbnail'] = 0;
        }
    }
    return $filedata;
}
示例#18
0
function require_thumb($aid, $location, $width = 100, $height = 100, $do_cut = false)
{
    global $pun_config;
    if ($aid && is_file($location)) {
        $thum_fname = require_thumb_name($aid, $width, $height, $do_cut);
        if (!is_file($thum_fname)) {
            @set_time_limit(10);
            // if any error, create_thumbnail() will not call again, but
            // thumbnail will be copy of err_thumb.gif
            copy(PUN_ROOT . $pun_config['file_thumb_path'] . 'err_thumb.gif', $thum_fname);
            create_thumbnail($location, $thum_fname, $width, $height, $do_cut);
        }
        return $thum_fname;
    } else {
        return $pun_config['file_thumb_path'] . 'err_none.gif';
    }
}
示例#19
0
            define("GIS_SWF", 4);
            include "includes/hft_image.php";
            $namafile_name = $_FILES['gambar']['name'];
            if (!empty($namafile_name)) {
                $files = $_FILES['gambar']['name'];
                $tmp_files = $_FILES['gambar']['tmp_name'];
                $tempnews = 'mod/slider/images/temp/';
                $namagambar = md5(rand(1, 100) . $files) . '.jpg';
                $uploaddir = $tempnews . $namagambar;
                $uploads = move_uploaded_file($tmp_files, $uploaddir);
                if (file_exists($uploaddir)) {
                    @chmod($uploaddir, 0644);
                }
                $gnews = 'mod/slider/images/';
                $nsmall = $gnews . $namagambar;
                create_thumbnail($uploaddir, $nsmall, $new_width = 660, $new_height = 350, $quality = 70);
                $cekmax = mysql_query("SELECT (MAX(`ordering`)+1) FROM `header`");
                $getcekmax = mysql_fetch_row($cekmax);
                if (!$getcekmax) {
                    $getcekmax = '1';
                }
                $hasil = $koneksi_db->sql_query("INSERT INTO header (header,ordering) VALUES ('{$namagambar}','" . $getcekmax[0] . "')");
                if ($hasil) {
                    $admin .= '<div class="alert alert-success fade in">
<button data-dismiss="alert" class="close close-sm" type="button">
<i class="icon-remove"></i></button>
<strong>Well done!</strong> You successfully add new Slider.</div>';
                    unlink($uploaddir);
                }
                $style_include[] = '<meta http-equiv="refresh" content="3; url=?pilih=slider&amp;mod=yes" />';
            }
示例#20
0
 } elseif ($attachment_type === Config::ATTACHMENT_TYPE_IMAGE) {
     if ($file_exists) {
         $attachment_id = $same_attachments[0]['id'];
     } else {
         $img_dimensions = image_get_dimensions($upload_type, $uploaded_file_path);
         if ($img_dimensions['x'] < Config::MIN_IMGWIDTH && $img_dimensions['y'] < Config::MIN_IMGHEIGHT) {
             // Cleanup
             DataExchange::releaseResources();
             display_error_page($smarty, new MinImgDimentionsError());
             exit(1);
         }
         $abs_img_path = Config::ABS_PATH . "/{$board['name']}/img/{$file_names[0]}";
         $abs_thumb_path = Config::ABS_PATH . "/{$board['name']}/thumb/{$file_names[1]}";
         if (!use_oekaki()) {
             move_uploded_file($uploaded_file_path, $abs_img_path);
             $thumb_dimensions = create_thumbnail($abs_img_path, $abs_thumb_path, $img_dimensions, $upload_type, Config::THUMBNAIL_WIDTH, Config::THUMBNAIL_HEIGHT);
             if ($thumb_dimensions === FALSE) {
                 // Cleanup
                 unlink($abs_img_path);
                 DataExchange::releaseResources();
                 display_error_page($smarty, kotoba_last_error());
                 exit(1);
             }
         } else {
             copy_uploded_file($uploaded_file_path, $abs_img_path);
             copy_uploded_file(Config::ABS_PATH . "/shi/{$_SESSION['oekaki']['thumbnail']}", $abs_thumb_path);
             $thumb_dimensions = array('x' => Config::THUMBNAIL_WIDTH, 'y' => Config::THUMBNAIL_HEIGHT);
         }
         $spoiler = isset($_REQUEST['spoiler']) && $_REQUEST['spoiler'] == '1' ? true : false;
         $attachment_id = images_add($file_hash, $file_names[0], $img_dimensions['x'], $img_dimensions['y'], $uploaded_file_size, $file_names[1], $thumb_dimensions['x'], $thumb_dimensions['y'], $spoiler);
     }
示例#21
0
            $admin .= '<div class="error">' . $error . '</div>';
        } else {
            if (!empty($dokumen_name)) {
                //////////////////////
                $dokumen = $_FILES['dokumen']['name'];
                $type_dokumen = $_FILES['dokumen']['type'];
                $tmp_dokumen = $_FILES['dokumen']['tmp_name'];
                $tempdokumen = 'mod/download/files/';
                $namadokumen = $dokumen;
                $uploaddirdokumen = $tempdokumen . $namadokumen;
                $namadokumen = $tempdokumen . $namadokumen;
                $uploadsdokumen = move_uploaded_file($tmp_dokumen, $uploaddirdokumen);
                if (file_exists($uploaddirdokumen)) {
                    @chmod($uploaddirdokumen, 0644);
                }
                create_thumbnail($uploaddir, $nsmall, $new_width = 415, $new_height = 'auto', $quality = 85);
                $judul = $_POST['judul'];
                $konten = $_POST['message'];
                $topik = $_POST['topik'];
                //masukkan data
                $tgl = date('Y-m-d H:i:s');
                $hasil = $koneksi_db->sql_query("INSERT INTO mod_download (date,judul,keterangan,url,kid) VALUES ('{$tgl}','{$judul}','{$konten}','{$namadokumen}','{$topik}')");
                if ($hasil) {
                    $admin .= '<div class="sukses">Berhasil memasukkan Download dg judul <u>' . stripslashes($_POST['judul']) . '
	<br>nama file : ' . $namadokumen . '
	
	</u></div>';
                    unlink($uploaddir);
                }
            } else {
                $judul = $_POST['judul'];
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
$ext = end(explode(".", $fileName));
$filename = generateRandomString(151);
$image = $path . $filename . ".png";
$sql = "INSERT INTO  facultyinfo(image,name,designation,description,type) VALUES ('" . $image . "','" . $_POST["name"] . "',' " . $_POST["designation"] . "','" . $_POST["description"] . "','" . $_POST["type"] . "')";
if ($conn->query($sql) === TRUE) {
    $response['message'] = "sqldone";
} else {
    $response['message'] = $sql . "-" . $conn->error;
    $response['staus'] = false;
    die(json_encode($response));
}
$scratchpath = "../images/scratch/" . $filename . "." . $ext;
if (move_uploaded_file($fileTmpLoc, $scratchpath)) {
    $response['message'] = "{$fileName} upload is complete";
} else {
    $response['message'] = "move_uploaded_file function failed";
    $response['staus'] = false;
}
create_thumbnail($scratchpath, $image, 180, 180);
create_thumbnail($scratchpath, "../images/full/" . $filename . ".png", 0, 0);
create_thumbnail($scratchpath, "../images/medium/" . $filename . ".png", 450, 0);
create_thumbnail($scratchpath, "../images/thumb/" . $filename . ".png", 180, 180);
unlink($scratchpath);
echo json_encode($response);
示例#23
0
function rebuilt_file_db()
{
    $idir = rm_dots_dir(scandir($GLOBALS['BT_ROOT_PATH'] . $GLOBALS['dossier_images']));
    // scans also subdir of img/* (in one single array of paths)
    foreach ($idir as $i => $e) {
        $subelem = $GLOBALS['BT_ROOT_PATH'] . $GLOBALS['dossier_images'] . '/' . $e;
        if (is_dir($subelem)) {
            unset($idir[$i]);
            // rm folder entry itself
            $subidir = rm_dots_dir(scandir($subelem));
            foreach ($subidir as $j => $im) {
                $idir[] = $e . '/' . $im;
            }
        }
    }
    foreach ($idir as $i => $e) {
        $idir[$i] = '/' . $e;
    }
    $fdir = rm_dots_dir(scandir($GLOBALS['BT_ROOT_PATH'] . $GLOBALS['dossier_fichiers']));
    // supprime les miniatures de la liste...
    $idir = array_filter($idir, function ($file) {
        return !(preg_match('#-thb\\.jpg$#', $file) or strpos($file, 'index.html') == 4);
    });
    $files_disk = array_merge($idir, $fdir);
    $files_db = $files_db_id = array();
    // supprime les fichiers dans la DB qui ne sont plus sur le disque
    foreach ($GLOBALS['liste_fichiers'] as $id => $file) {
        if (!in_array($file['bt_path'] . '/' . $file['bt_filename'], $files_disk)) {
            unset($GLOBALS['liste_fichiers'][$id]);
        }
        $files_db[] = $file['bt_path'] . '/' . $file['bt_filename'];
        $files_db_id[] = $file['bt_id'];
    }
    // ajoute les images/* du disque qui ne sont pas encore dans la DB.
    foreach ($idir as $file) {
        $filepath = $GLOBALS['BT_ROOT_PATH'] . $GLOBALS['dossier_images'] . '/' . $file;
        if (!in_array($file, $files_db)) {
            $time = filemtime($filepath);
            $id = date('YmdHis', $time);
            // vérifie que l’ID ne se trouve pas déjà dans le tableau. Sinon, modifie la date (en allant dans le passé)
            while (array_key_exists($id, $files_db_id)) {
                $time--;
                $id = date('YmdHis', $time);
            }
            $files_db_id[] = $id;
            $new_img = array('bt_id' => $id, 'bt_type' => 'image', 'bt_fileext' => strtolower(pathinfo($filepath, PATHINFO_EXTENSION)), 'bt_filesize' => filesize($filepath), 'bt_filename' => $file, 'bt_content' => '', 'bt_wiki_content' => '', 'bt_dossier' => 'default', 'bt_checksum' => sha1_file($filepath), 'bt_statut' => 0, 'bt_path' => preg_match('#^/[0-9a-f]{2}/#', $file) ? substr($file, 0, 3) : '');
            list($new_img['bt_dim_w'], $new_img['bt_dim_h']) = getimagesize($filepath);
            // l’ajoute au tableau
            $GLOBALS['liste_fichiers'][] = $new_img;
        }
        // crée une miniature de l’image
        create_thumbnail($filepath);
    }
    // fait pareil pour les files/*
    foreach ($fdir as $file) {
        if (!in_array($file, $files_db)) {
            $filepath = $GLOBALS['BT_ROOT_PATH'] . $GLOBALS['dossier_fichiers'] . '/' . $file;
            $time = filemtime($filepath);
            $id = date('YmdHis', $time);
            // vérifie que l’ID ne se trouve pas déjà dans le tableau. Sinon, modifie la date (en allant dans le passé)
            while (array_key_exists($id, $files_db_id)) {
                $time--;
                $id = date('YmdHis', $time);
            }
            $files_db_id[] = $id;
            $ext = strtolower(pathinfo($filepath, PATHINFO_EXTENSION));
            $new_file = array('bt_id' => $id, 'bt_type' => detection_type_fichier($ext), 'bt_fileext' => $ext, 'bt_filesize' => filesize($filepath), 'bt_filename' => $file, 'bt_content' => '', 'bt_wiki_content' => '', 'bt_dossier' => 'default', 'bt_checksum' => sha1_file($filepath), 'bt_statut' => 0, 'bt_path' => '');
            // l’ajoute au tableau
            $GLOBALS['liste_fichiers'][] = $new_file;
        }
    }
    // tri le tableau fusionné selon les bt_id (selon une des clés d'un sous tableau).
    $GLOBALS['liste_fichiers'] = tri_selon_sous_cle($GLOBALS['liste_fichiers'], 'bt_id');
    // finalement enregistre la liste des fichiers.
    file_put_contents($GLOBALS['fichier_liste_fichiers'], '<?php /* ' . chunk_split(base64_encode(serialize($GLOBALS['liste_fichiers']))) . ' */');
}
示例#24
0
         $dest = THUMB_TEMP_PATH . "/" . $thumb;
     }
     $do_create = 0;
     if ($image_info = @getimagesize($src)) {
         if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
             $do_create = 1;
         }
     }
     if ($do_create) {
         require ROOT_PATH . 'includes/image_utils.php';
         $convert_options = init_convert_options();
         if (!$convert_options['convert_error']) {
             $dimension = intval($config['auto_thumbnail_dimension']) ? intval($config['auto_thumbnail_dimension']) : 100;
             $resize_type = intval($config['auto_thumbnail_resize_type']) ? intval($config['auto_thumbnail_resize_type']) : 1;
             $quality = intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100 ? intval($config['auto_thumbnail_quality']) : 100;
             if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
                 $new_thumb_name = $thumb;
             }
         }
     }
 }
 if (!$uploaderror) {
     $additional_field_sql = "";
     $additional_value_sql = "";
     if (!empty($additional_image_fields)) {
         $table = $direct_upload ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
         $table_fields = $site_db->get_table_fields($table);
         foreach ($additional_image_fields as $key => $val) {
             if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
                 $additional_field_sql .= ", {$key}";
                 $additional_value_sql .= ", '" . un_htmlspecialchars(trim($HTTP_POST_VARS[$key])) . "'";
示例#25
0
         $style_include[] = '<meta http-equiv="refresh" content="1; url=?pilih=mnkaryawan&mod=yes">';
         unlink($uploaddir);
     }
 } else {
     //masukkan data
     $tglmelamar = $_POST['tglmelamar'];
     $nama = text_filter($_POST['nama']);
     $kotalahir = $_POST['kotalahir'];
     $tgllahir = $_POST['tgllahir'];
     $kelamin = $_POST['kelamin'];
     $agama = $_POST['agama'];
     $menikah = $_POST['menikah'];
     $alamat = $_POST['alamat'];
     $kota = $_POST['kota'];
     $kodepos = $_POST['kodepos'];
     $propinsi = $_POST['propinsi'];
     $negara = $_POST['negara'];
     $telepon = $_POST['telepon'];
     $handphone = $_POST['handphone'];
     $namafile_name = $_FILES['gambar']['name'];
     $departemen = $_POST['departemen'];
     $jabatan = $_POST['jabatan'];
     $status = $_POST['status'];
     $pendidikan_terakhir = $_POST['pendidikan_terakhir'];
     //masukkan data
     $hasil = $koneksi_db->sql_query("INSERT INTO hrd_karyawan (tglmelamar,nama,kotalahir,tgllahir,kelamin,agama,menikah,alamat,kota,kodepos,propinsi,negara,telepon,handphone,departemen,jabatan,status,pendidikan_terakhir,tipe) VALUES ('{$tglmelamar}','{$nama}','{$kotalahir}','{$tgllahir}','{$kelamin}','{$agama}','{$menikah}','{$alamat}','{$kota}','{$kodepos}','{$propinsi}','{$negara}','{$telepon}','{$handphone}','{$departemen}','{$jabatan}','{$status}','{$pendidikan_terakhir}','0')");
     if ($hasil) {
         $admin .= '<div class="alert alert-success"><strong>Berhasil!</strong> Data karyawan dengan nama <u>' . stripslashes($_POST['nama']) . '</u> berhasil disimpan</div>';
         $style_include[] = '<meta http-equiv="refresh" content="1; url=?pilih=karyawan&mod=yes">';
     }
 }
示例#26
0
<?php

/*
 * This file's function is used for post filter
 */
require_once '../../../wp-config.php';
create_thumbnail($_GET['file'], $_GET['height'], $_GET['width']);
function create_thumbnail($img, $height, $width = '')
{
    $gallery_root = ABSPATH . get_option('lg_gallery_folder');
    // this will prevent some unshown thumb
    $mem = get_option('lg_buffer_size');
    ini_set("memory_limit", $mem);
    $img = $gallery_root . $img;
    $path = pathinfo($img);
    switch (strtolower($path["extension"])) {
        case "jpeg":
        case "jpg":
            Header("Content-type: image/jpeg");
            $img = imagecreatefromjpeg($img);
            break;
        case "gif":
            Header("Content-type: image/gif");
            $img = imagecreatefromgif($img);
            break;
        case "png":
            Header("Content-type: image/png");
            $img = imagecreatefrompng($img);
            break;
        default:
            break;
示例#27
0
                       </button>
                       <strong>Error !</strong> <br>' . $error . '.
                   </div>';
 } else {
     $files = $_FILES['gambar']['name'];
     $tmp_files = $_FILES['gambar']['tmp_name'];
     $tempnews = 'mod/news/images/temp/';
     $namagambar = md5(rand(1, 100) . $files) . '.jpg';
     $uploaddir = $tempnews . $namagambar;
     $uploads = move_uploaded_file($tmp_files, $uploaddir);
     if (file_exists($uploaddir)) {
         @chmod($uploaddir, 0644);
     }
     $gnews = 'files/';
     $nsmall = $gnews . $namagambar;
     create_thumbnail($uploaddir, $nsmall, $new_width = 2000, $new_height = 800, $quality = 100);
     $query = mysql_query("INSERT INTO `halaman` (`judul`,`konten`,`seftitle`) VALUES ('{$judul}','{$konten}','{$seftitle}')");
     unlink($uploaddir);
     if ($query) {
         $admin .= '<div class="alert alert-success fade in">
                       <button data-dismiss="alert" class="close close-sm" type="button">
                           <i class="icon-remove"></i>
                       </button>
                       <strong>Well done!</strong> Berhasil menambah Halaman.
                   </div>  ';
         //	header("location:?pilih=admin_pages");
     } else {
         $admin .= '<div class="alert alert-block alert-danger fade in">
                       <button data-dismiss="alert" class="close close-sm" type="button">
                           <i class="icon-remove"></i>
                       </button>
示例#28
0
    $target_path = $targets['base'] . $targets['filename'];
    $status = check_uploaded_file($_FILES['uploadedfile']['tmp_name']);
    // $status['success'] (0,1) - $status['desc'] (text)
    $size = array('width' => 0, 'height' => 0);
    //Holds final dimensions of resized image
    if ($status['success']) {
        if (!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
            //if(!is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
            //if(!resize($_FILES['uploadedfile']['tmp_name'], $target_path)) {
            $status['success'] = 0;
            $status['desc'] = "Unable to accept file, try again later.<br>\n";
        } elseif (!resize($target_path, $target_path, $size)) {
            //file was successfully moved onto the server
            $status['success'] = 0;
            $status['desc'] = "Unable to resize file.<br>\n";
        } elseif (!create_thumbnail($target_path, "photos/thumbs/" . $targets['filename'])) {
            $status['success'] = 0;
            $status['desc'] = "Unable to create thumbnail.<br>\n";
        } else {
            // Photo successfully uploaded, now add an entry in the database
            $result = mydb::cxn()->query("insert into photo_of_the_week(path,thumbpath,photographer,location,description,height,width)\n\t\t\t\t\t\t\t\t\t\tvalues(\t\"photo_of_the_week/photos/" . $targets['filename'] . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"photo_of_the_week/photos/thumbs/" . $targets['filename'] . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"" . mydb::cxn()->real_escape_string($_POST['photographer']) . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"" . mydb::cxn()->real_escape_string($_POST['location']) . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"" . mydb::cxn()->real_escape_string($_POST['description']) . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t" . $size['height'] . "," . $size['width'] . ")") or die("Failed while adding photo entry to dB: " . mydb::cxn()->error());
        }
    }
    // end 'if($status['success'])'
}
// end 'if(isset($_POST['MAX_FILE_SIZE']))'
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
示例#29
0
                 $tempFile = $_FILES['uploadpp']['tmp_name'];
                 $origName = substr($_FILES['uploadpp']['name'], 0, -4);
                 $name_space = strtolower($_FILES['uploadpp']['name']);
                 $middle_name = str_replace(" ", "_", $name_space);
                 $middle_name = str_replace(".jpeg", ".jpg", $name_space);
                 $glnrrand = rand(10, 99);
                 $bigPhoto = str_replace(".", "_" . $glnrrand . ".", $middle_name);
                 $smallPhoto = str_replace(".", "_t.", $bigPhoto);
                 $targetFile = str_replace('//', '/', $targetPath) . $bigPhoto;
                 $origPath = '/' . $page2 . '/';
                 $dbSmall = $origPath . $smallPhoto;
                 $dbBig = $origPath . $bigPhoto;
                 require_once '../include/functions_thumb.php';
                 // Move file and create thumb
                 move_uploaded_file($tempFile, $targetFile);
                 create_thumbnail($targetPath, $targetFile, $smallPhoto, LS_USERAVATWIDTH, LS_USERAVATHEIGHT, 80);
                 // SQL insert
                 $lsdb->query('UPDATE ' . $lstable . ' SET picture = "' . $dbSmall . '" WHERE id = "' . $page2 . '" LIMIT 1');
             } else {
                 $errors['e'] = $tl['error']['e24'] . '<br />';
                 $errors = $errors;
             }
         } else {
             $errors['e'] = $tl['error']['e24'] . '<br />';
             $errors = $errors;
         }
     } else {
         $errors['e'] = $tl['error']['e24'] . '<br />';
         $errors = $errors;
     }
 } else {
示例#30
0
    /**
     * Executes the command thumbnail:generate.
     *
     * Generate a thumbnail for all attachments which need one and don't have it yet.
     *
     * @param InputInterface $input The input stream used to get the argument and verboe option.
     * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
     *
     * @return int 0.
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $io->section($this->user->lang('CLI_THUMBNAIL_GENERATING'));
        $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE thumbnail = 0';
        $result = $this->db->sql_query($sql);
        $nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails');
        $this->db->sql_freeresult($result);
        if ($nb_missing_thumbnails === 0) {
            $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE'));
            return 0;
        }
        $extensions = $this->cache->obtain_attach_extensions(true);
        $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE thumbnail = 0';
        $result = $this->db->sql_query($sql);
        if (!function_exists('create_thumbnail')) {
            require $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
        }
        $progress = $this->create_progress_bar($nb_missing_thumbnails, $io, $output);
        $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING'));
        $progress->start();
        $thumbnail_created = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE) {
                $source = $this->phpbb_root_path . 'files/' . $row['physical_filename'];
                $destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
                if (create_thumbnail($source, $destination, $row['mimetype'])) {
                    $thumbnail_created[] = (int) $row['attach_id'];
                    if (count($thumbnail_created) === 250) {
                        $this->commit_changes($thumbnail_created);
                        $thumbnail_created = array();
                    }
                    $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename']));
                } else {
                    $progress->setMessage('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>');
                }
            }
            $progress->advance();
        }
        $this->db->sql_freeresult($result);
        if (!empty($thumbnail_created)) {
            $this->commit_changes($thumbnail_created);
        }
        $progress->finish();
        $io->newLine(2);
        $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE'));
        return 0;
    }