function save_image($image_url, $storage_folder) { $remote_image = file_get_contents($image_url); preg_match('@(.*?)\\.([^\\.]+)$@', basename($image_url), $matches); $local_image_name = urldecode($matches[1]); $local_image_ext = $matches[2]; $counter = 2; while (file_exists("images/media_items/{$local_image_name}.{$local_image_ext}")) { $local_image_name = $local_image_name . "({$counter})"; $counter++; } $fp = fopen("{$storage_folder}{$local_image_name}.{$local_image_ext}", 'c'); $success = fwrite($fp, $remote_image); if (!$success) { return false; } else { make_thumb("images/media_items/{$local_image_name}.{$local_image_ext}", "images/media_items/thumbs/{$local_image_name}.{$local_image_ext}", 100); return "{$local_image_name}.{$local_image_ext}"; } }
function _upload_file() { $ret_info = array(); // 返回到客户端的信息 $file = $_FILES['Filedata']; if ($file['error'] == UPLOAD_ERR_NO_FILE) { $this->json_error('no_upload_file'); exit; } import('uploader.lib'); // 导入上传类 import('image.func'); $uploader = new Uploader(); $uploader->allowed_type(IMAGE_FILE_TYPE); // 限制文件类型 $uploader->allowed_size(SIZE_GOODS_IMAGE); // 限制单个文件大小2M $uploader->addFile($file); if (!$uploader->file_info()) { $this->json_error($uploader->get_error()); exit; } /* 取得剩余空间(单位:字节),false表示不限制 */ $store_mod =& m('store'); $settings = $store_mod->get_settings($this->store_id); $remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $this->mod_uploadedfile->get_file_size($this->store_id) : false; /* 判断能否上传 */ if ($remain !== false) { if ($remain < $file['size']) { $this->json_error('space_limit_arrived'); exit; } } /* 指定保存位置的根目录 */ $uploader->root_dir(ROOT_PATH); $filename = $uploader->random_filename(); /* 上传 */ $file_path = $uploader->save($this->save_path, $filename); // 保存到指定目录 if (!$file_path) { $this->json_error('file_save_error'); exit; } $file_type = $this->_return_mimetype($file_path); /* 文件入库 */ $data = array('store_id' => $this->store_id, 'file_type' => $file_type, 'file_size' => $file['size'], 'file_name' => $file['name'], 'file_path' => $file_path, 'belong' => $this->belong, 'item_id' => $this->item_id, 'add_time' => gmtime()); $file_id = $this->mod_uploadedfile->add($data); if (!$file_id) { $this->json_error('file_add_error'); exit; } if ($this->instance == 'goods_image') { /* 生成缩略图 */ $thumbnail = dirname($file_path) . '/small_' . basename($file_path); $bignail = dirname($file_path) . '/big_' . basename($file_path); $middlenail = dirname($file_path) . '/middle_' . basename($file_path); $smallnail = dirname($file_path) . '/little_' . basename($file_path); make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $bignail, 900, 900, THUMB_QUALITY); //生成900*900的缩略图 make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $middlenail, 420, 420, THUMB_QUALITY); //生成420*420的缩略图 make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $smallnail, 60, 60, THUMB_QUALITY); //生成60*60的缩略图 make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $thumbnail, THUMB_WIDTH, THUMB_HEIGHT, THUMB_QUALITY); //生成170*170的缩略图 /* 更新商品相册 */ $data = array('goods_id' => $this->item_id, 'image_url' => $file_path, 'thumbnail' => $thumbnail, 'bignail' => $bignail, 'middlenail' => $middlenail, 'smallnail' => $smallnail, 'sort_order' => 255, 'file_id' => $file_id); if (!$this->mod_goods_image->add($data)) { $this->json_error($this->mod_goods_imaged->get_error()); return false; } $ret_info = array_merge($ret_info, array('thumbnail' => $thumbnail)); } /* 返回客户端 */ $ret_info = array_merge($ret_info, array('file_id' => $file_id, 'file_path' => $file_path, 'instance' => $this->instance)); $this->json_result($ret_info); }
function update_posts($id, $data) { $array["title"] = $data["title"]; $array["url"] = $data["url"]; $array["type"] = $data["type"]; $array["raw_content"] = str_replace('class="my-math"', 'class="my-math" lang="latex"', $data["content"]); $array["content"] = strip_tags(trim($data["content"])); $array["category_id"] = $data["category_id"]; $array["updated_on"] = $data["updated_on"]; $insert_partial_data = $this->db->update("posts", $array, array('id' => $id)); if (!empty($data['image']) && $data['image']['name'] != "") { $image = $data['image']; $path = FCPATH . "uploads/post/" . $id . "/"; if (!is_dir($path)) { $images_files = FCPATH . 'uploads/post/' . $id; $this->recursiveRemoveDirectory($images_files); } $old = umask(0); mkdir($path, 0777, true); umask($old); $image['name'] = str_replace(" ", "-", $image['name']); $offset = strpos($image['name'], '.'); $image['name_for_listing'] = substr_replace($image['name'], HEIGHT_FOR_POST_LISTING . "_" . WIDTH_FOR_POST_LISTING, $offset) . ".jpg"; $image['name_for_detail_listing'] = substr_replace($image['name'], HEIGHT_FOR_POST_DETAILS . "_" . WIDTH_FOR_POST_DETAILS, $offset) . ".jpg"; $upload = move_uploaded_file($image['tmp_name'], $path . $image['name']); if ($upload) { make_thumb($path . $image['name_for_listing'], $path . $image['name'], HEIGHT_FOR_POST_LISTING, WIDTH_FOR_POST_LISTING); make_thumb($path . $image['name_for_detail_listing'], $path . $image['name'], HEIGHT_FOR_POST_DETAILS, WIDTH_FOR_POST_DETAILS); $this->db->where("id", $id); $this->db->update("posts", array("img" => $image['name'])); } } $this->db->delete('post_belongs_to_tags', array('post_id' => $id)); if (!empty($data['tag'])) { $tags = $data['tag']; $i = 0; foreach ($tags as $tag) { $is_tag_exist = $this->db->get_where("tags", array("tag" => $tag))->row_array(); if (!empty($is_tag_exist)) { $post_tags[$i]["tag_id"] = $is_tag_exist['id']; $post_tags[$i]["post_id"] = $id; } else { $tag_id = $this->create_tag($tag); $post_tags[$i]['tag_id'] = $tag_id; $post_tags[$i]["post_id"] = $id; } $i++; } if (!empty($post_tags)) { $this->db->insert_batch("post_belongs_to_tags", $post_tags); } } $this->db->delete('post_belongs_to_topics', array('post_id' => $id)); if (!empty($data['topic'])) { $j = 0; foreach ($data['topic'] as $topic) { $topic_data = $this->db->get_where("topics", array("topic" => $topic))->row_array(); if (!empty($topic_data)) { $topic_array[$j]["topic_id"] = $topic_data["id"]; $topic_array[$j]["post_id"] = $id; } else { $topic_id = $this->create_topic($topic); $this->db->insert("topics_belongs_to_category", array("topic_id" => $topic_id, "category_id" => $data["category_id"])); $topic_array[$j]["topic_id"] = $topic_id; $topic_array[$j]["post_id"] = $id; } $j++; } if (!empty($topic_array)) { $this->db->insert_batch("post_belongs_to_topics", $topic_array); } } if ($insert_partial_data) { $response["rc"] = TRUE; $response["msg"] = "Post updated successfully"; } else { $response["rc"] = FALSE; $response["msg"] = "Error while updating post"; } return $response; }
function minimg($amg, $prm) { if ($prm == 'no') { return; } $mg = first_img($amg); if ($mg) { return make_thumb($mg, $prm); } elseif (rstr(87)) { return mini_empty($prm); } }
$imgcreatefrom = "ImageCreateFromJPEG"; } if ($arr_image_details[2] == 3) { $imgt = "ImagePNG"; $imgcreatefrom = "ImageCreateFromPNG"; } if ($imgt) { $source_image = $imgcreatefrom($src); $new_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($new_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $original_width, $original_height); /* create the physical thumbnail image to its destination */ $imgt($new_image, $dest . $thumb_name . $ext); } } $imagesArr = FilterImages(Readir($imagesDirPath), $imageExt); $imagesResort = array(); $imagesMeta = array(); foreach ($imagesArr as $key => $value) { array_push($imagesResort, $value); } foreach ($imagesResort as $key => $value) { $ext = pathinfo($value, PATHINFO_EXTENSION); $path = $imagesDirPath . $value; list($width, $height) = getimagesize($path); $imgsize = filesize($path) / 1000; make_thumb($path, $thumbPath, 80); $imagesMeta[] = array("filename" => $value, "width" => $width, "height" => $height, "filesize" => $imgsize, "filepath" => $path, "thumbpath" => $thumbPath . basename($value, ".{$ext}") . '_thumb.' . $ext, "description" => "some description"); } $json = json_encode($imagesMeta); file_put_contents('data.json', $json);
function affiche_prod($v, $id) { if (!is_numeric($v)) { $v = id_of_suj($v); } list($day, $frm, $suj, $img, $nod, $thm, $lu, $re) = pecho_arts($v); $p["suj"] = $suj; $p["img"] = first_img($img); $p["thumb"] = make_thumb(first_img($img), "no"); $p["id"] = $v; $p["sty"] = "panel"; $chsup = explode(" ", $_SESSION['prmb'][18]); foreach ($chsup as $cat) { $va = sql('msg', 'qdd', 'v', 'ib="' . $v . '" AND val="' . $cat . '"'); $ct = $cat == 'prix' ? 'price' : $cat; if ($va) { $p[$ct] = $cat . ': ' . trim($va); } } $p["add2cart"] = ljb("txtbox", "SaveJ", 'cart_shop___' . $v, "add"); return template($p, 'products'); }
public function addScreenshot($fileData) { $file = $fileData["tmp_name"]; $name = $fileData["name"]; $dirName = dirname(__DIR__) . '/files/screenshots/' . $this->getId() . '/'; $targetName = $dirName . $this->getScreenshotCount() . '.png'; $thumbName = $dirName . $this->getScreenshotCount() . '_thumb.png'; $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (!is_dir($dirName)) { mkdir($dirName, 0777, true); } if ($ext == "jpg" || $ext == "jpeg") { imagepng(imagecreatefromstring(file_get_contents($file)), $targetName); } else { if ($ext == "png") { rename($file, $targetName); } else { return 1; } } make_thumb($targetName, $thumbName, 150); chmod($targetName, "0777"); chmod($thumbName, "0777"); $db = new DatabaseManager(); $db->query("UPDATE `addon_addons` SET `screenshots`=" . ($this->getScreenshotCount() + 1) . " WHERE id= " . $this->id . ""); echo $db->fetchMysqli()->error; $this->screenshots++; }
function uploadNewPics($overRideThumb = false) { global $config; $thumbOnly = $config->uploadThumbOnly; $PicIDs = array(); if ($thumbOnly && !$overRideThumb) { $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where ThumbUpload=0"; $result = getSQLResult("uploadNewPics 1", $query); for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) { $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime); } foreach ($PicIDs as $PicID => $values) { $filename = $values["Filename"]; make_thumb($filename, "/dev/shm/upload/thumb.jpg", 240); $pic = file_get_contents("/dev/shm/upload/thumb.jpg"); $upload = uploadPic($pic, $values['PictureTime'], true, $PicID); if ($upload) { $query = "update Motion set ThumbUpload=1 where MID=?"; $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID); } } } else { $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where FullUpload=0"; $result = getSQLResult("uploadNewPics 2", $query); for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) { $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime); } foreach ($PicIDs as $PicID => $values) { $filename = $values["Filename"]; $pic = file_get_contents($filename); logMessage("Found pic to upload PicID={$PicID} filename={$filename}, size=" . strlen($pic)); $upload = uploadPic($pic, $values['PictureTime'], false, $PicID); if ($upload) { $query = "update Motion set ThumbUpload=1,FullUpload=1 where MID=?"; $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID); } } } }
} else { //we will give an unique name, for example the time in unix time format $image_name = time(); //the new name will be containing the full path where will be stored (images folder) $master_name = $img_base_dir . 'temp/masters/' . $image_name . '.' . $extension; $copied = copy($_FILES[$fileElementName]['tmp_name'], $master_name); //we verify if the image has been uploaded, and print error instead if (!$copied) { $error .= 'Copy unsuccessfull!'; $errors = 1; } else { // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name = $img_base_dir . 'temp/thumbs/' . $image_name . '_350.' . $extension; // call the function that will create the thumbnail. The function will get as parameters //the image name, the thumbnail name and the width and height desired for the thumbnail $thumb = make_thumb($master_name, $thumb_name, WIDTH, HEIGHT); } } } } //--------- END SECOND SCRIPT -------------------------------------------------------------------- //return variables to javascript $filename = $_FILES[$fileElementName]['name']; $filesize = $sizekb; $fileloc = $thumb_name; //for security reason, we force to remove all uploaded file @unlink($_FILES[$fileElementName]); //image dimensions $masterWH = getimagesize($master_name); $masterW = $masterWH[0]; $masterH = $masterWH[1];
function file_handler() { list($uploads_dir, $thumbs_dir) = setup_dir(); $files = $_FILES['files']; $results = array(); foreach ($files['error'] as $key => $error) { $result = isset($_POST['qid']) ? array('qid' => $_POST['qid']) : array(); $name = escape_special_char($files['name'][$key]); $host = get_cdn(); if ($error == UPLOAD_ERR_OK) { if ($files['size'][$key] > get_size_limit()) { $result['status'] = 'failed'; $result['err'] = 'size_limit'; } else { $temp = $files['tmp_name'][$key]; if ($duplicate = is_duplicate($temp)) { $result['status'] = 'success'; $result['thumb'] = ($duplicate['thumb'] == 'none' ? '' : $host) . $duplicate['thumb']; $result['path'] = $host . $duplicate['path']; $result['name'] = $duplicate['name']; $result['width'] = $duplicate['width']; $result['height'] = $duplicate['height']; $result['exlong'] = $duplicate['exlong']; $result['extiny'] = $duplicate['extiny']; } else { $mime = file_mime_type($temp); switch ($mime) { case 'image/jpeg': if (!preg_match('/\\.(jpg|jpeg|jpe|jfif|jfi|jif)$/i', $name)) { $name .= '.jpg'; } break; case 'image/png': if (!preg_match('/\\.(png)$/i', $name)) { $name .= '.png'; } break; case 'image/gif': if (!preg_match('/\\.(gif)$/i', $name)) { $name .= '.gif'; } break; case 'image/svg+xml': if (!preg_match('/\\.(svg)$/i', $name)) { $name .= '.svg'; } break; default: $result['status'] = 'failed'; $result['err'] = 'wrong_type'; } if (!isset($result['status']) || !$result['status'] == 'failed') { $name = rename_if_exists($name, $uploads_dir); $path = "{$uploads_dir}/{$name}"; if (!move_uploaded_file($temp, ABSPATH . '/' . $path)) { $result['status'] = 'failed'; $result['err'] = 'write_prohibited'; } else { watermark($path); $thumb = make_thumb($name, $path, $thumbs_dir); if ($duplicate = duplicate_hash($name, $path, $thumb)) { $result['status'] = 'success'; } else { $result['status'] = 'error'; $result['err'] = 'fail_duplicate'; } $result['path'] = $host . $path; $result['name'] = $name; $result['thumb'] = $thumb['generated'] ? $host . $thumb['path'] : 'none'; if (isset($thumb['width'])) { $result['width'] = $thumb['width']; $result['height'] = $thumb['height']; $result['exlong'] = $thumb['exlong']; $result['extiny'] = $thumb['extiny']; } } } } } } else { switch ($error) { case UPLOAD_ERR_INI_SIZE: $result['status'] = 'failed'; $result['err'] = 'php_upload_size_limit'; break; case UPLOAD_ERR_FORM_SIZE: $result['status'] = 'failed'; $result['err'] = 'size_limit'; break; case UPLOAD_ERR_PARTIAL: $result['status'] = 'failed'; $result['err'] = 'part_upload'; break; case UPLOAD_ERR_NO_FILE: $result['status'] = 'failed'; $result['err'] = 'no_file'; break; case UPLOAD_ERR_NO_TMP_DIR: $result['status'] = 'failed'; $result['err'] = 'no_tmp'; break; case UPLOAD_ERR_CANT_WRITE: $result['status'] = 'failed'; $result['err'] = 'write_prohibited'; break; } } array_push($results, $result); } return $results; }
echo "<div class='thumbnail'>"; // show the delete button only in edit mode, not in view mode if ($_GET['mode'] === 'edit') { echo "<a class='align_right' href='app/delete_file.php?id=" . $uploads_data['id'] . "&type=" . $uploads_data['type'] . "&item_id=" . $uploads_data['item_id'] . "' onClick=\"return confirm('Delete this file ?');\">"; echo "<img src='img/small-trash.png' title='delete' alt='delete' /></a>"; } // end if it is in edit mode // get file extension $ext = filter_var(Tools::getExt($uploads_data['real_name']), FILTER_SANITIZE_STRING); $filepath = 'uploads/' . $uploads_data['long_name']; $thumbpath = $filepath . '_th.jpg'; // list of extensions with a corresponding img/thumb-*.png image $common_extensions = array('avi', 'csv', 'doc', 'docx', 'mov', 'pdf', 'ppt', 'rar', 'xls', 'xlsx', 'zip'); // Make thumbnail only if it isn't done already if (!file_exists($thumbpath)) { make_thumb($filepath, $ext, $thumbpath, 100); } // only display the thumbnail if the file is here if (file_exists($thumbpath) && preg_match('/(jpg|jpeg|png|gif)$/i', $ext)) { // we add rel='gallery' to the images for fancybox to display it as an album (possibility to go next/previous) echo "<a href='uploads/" . $uploads_data['long_name'] . "' class='fancybox' rel='gallery' "; if ($uploads_data['comment'] != 'Click to add a comment') { echo "title='" . $uploads_data['comment'] . "'"; } echo "><img class='thumb' src='" . $thumbpath . "' alt='thumbnail' /></a>"; // not an image } elseif (in_array($ext, $common_extensions)) { echo "<img class='thumb' src='img/thumb-" . $ext . ".png' alt='' />"; // special case for mol files } elseif ($ext === 'mol' && $_SESSION['prefs']['chem_editor'] && $_GET['mode'] === 'view') { // we need to escape \n in the mol file or we get unterminated string literal error in JS
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { define("WIDTH_I", "240"); define("HEIGHT_I", "240"); $fileName = $_FILES["pic"]["name"]; $fileTmpLoc = $_FILES["pic"]["tmp_name"]; $moveResult = move_uploaded_file($fileTmpLoc, "{$fileName}"); if ($moveResult == true) { make_thumb($fileName, $fileName, WIDTH_I, HEIGHT_I); echo "<div id='data'>" . data_uri($fileName) . "</div>"; @unlink($fileName); } } function get_extension($str) { $str = strtolower($str); $arr = explode('.', $str); if (sizeof($arr) < 2) { return ""; } return $str = $arr[sizeof($arr) - 1]; } function data_uri($file) { $type = get_extension($file); $mime = 'image/' . $type; $contents = file_get_contents($file); $base64 = base64_encode($contents); return 'data:' . $mime . ';base64,' . $base64; }
echo "<script>window.alert('Maaf, hanya mendukung Jpg, jpeg, dan PNG.');\n\t\t\t\t\t\t window.location=('../?v=buku&act=edit&isbn={$Pisbn}&info=FileIsNotSupported')</script>"; $errors = 1; } else { // get the size of the image in bytes // $_FILES[\'image\'][\'tmp_name\'] is the temporary filename of the file in which the uploaded file was stored on the server $size = getimagesize($_FILES['image']['tmp_name']); $sizekb = filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($sizekb > MAX_SIZE * 1024) { /* echo '<h1>You have exceeded the size limit!</h1>'; echo '<h1>Copy unsuccessfull!</h1>'; */ echo "<script>window.alert('Maaf, file harus < 800 KB');\n\t\t\t\t\t\t window.location=('../?v=buku&act=edit&isbn={$Pisbn}&info=ImageTooLarge')</script>"; $errors = 1; } else { //we will give an unique name, for example the time in unix time format $image_name = time() . '.' . $extension; //the new name will be containing the full path where will be stored (images folder) $upd = mysql_query("UPDATE buku SET \n\t\t\t\t\t\t\t\t\tjudul='{$Pjudul}',\n \t\tnomorEdisi='{$PnomorEdisi}',\n \t\tcopyright='{$Pcopyright}',\n \t\tdeskripsi='{$Pdeskripsi}',\n \t\tIDPenerbit='{$PIDPenerbit}',\n \t\tharga='{$Pharga}',\n \t\tfileGambar='{$image_name}'\n \t\t\n \t\tWHERE isbn='{$Pisbn}'\n \t\t"); $newname = "../img/" . $image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); //we verify if the image has been uploaded, and print error instead // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name = '../img/thumb_' . $image_name; // call the function that will create the thumbnail. The function will get as parameters //the image name, the thumbnail name and the width and height desired for the thumbnail $thumb = make_thumb($newname, $thumb_name, WIDTH, HEIGHT); header("location:../?v=buku&act=edit&isbn={$Pisbn}&info=Success"); } }
$thumbs_dir = "../galleries/" . $gallery['name'] . "/gallery-thumbs/"; $thumbs_width = 200; $thumbs_height = $thumbs_width; $images_per_row = 15; /** generate photo gallery **/ $image_files = get_files($images_dir); if (count($image_files)) { $index = 0; foreach ($image_files as $index => $file) { $index++; $thumbnail_image = $thumbs_dir . $file; if (!file_exists($thumbnail_image)) { $extension = get_file_extension($thumbnail_image); $extension = strtolower($extension); if ($extension) { make_thumb($images_dir . $file, $thumbnail_image, $thumbs_width, $thumbs_height, $extension); } } ?> <div class="photo-link"><span class="galleryImage"><img src="<?php echo $thumbnail_image; ?> " style="width:150px; height:150px;" /><input type="checkbox" name="files[]" value="<?php echo $file; ?> " id="<?php echo $file; ?> " /><input name="delete_CheckBox" type="hidden" value="false" /></span></div> <?php }
$dest_file = $fullDir . '/' . $resumableFilename . '.part' . $resumableChunkNumber; // Create the temporary directory if (!is_dir($fullDir)) { mkdir($fullDir, 0777, true); } // Move the temporary file if (!move_uploaded_file($file['tmp_name'], $dest_file)) { header('HTTP/1.1 500 Internal Server Error'); header('Content-type: text/plain'); exit("Error during upload part"); } else { $storePath = $rootDir . $path . $resumableFilename; $thumbPath = $thumbDir . $path . $resumableFilename; // Check if all the parts present, and assemble the final destination file if (create_file_from_chunks($fullDir, $rootDir . $path, $resumableFilename, $resumableChunkSize, $resumableTotalSize)) { make_thumb($storePath, $thumbPath, $fileExt, 200); } else { header('HTTP/1.1 500 Internal Server Error'); header('Content-type: text/plain'); exit("Cannot assemble destination file"); } } } } } } /** * Check if all the parts exist, and gather all the parts of the file together * * @param string $tempDir - the temporary directory holding all the parts of the file * @param string @rootDir - the root directory where all files are saved too
$files_paged = array_chunk($files, $max_page); /* if there's no thumbnails dir, make dir and a thumbnail for each file */ if (!file_exists('thumbnails/' . $dir)) { set_time_limit(0); //prevent timing when making the thumbnails mkdir('thumbnails/' . $dir, 0755, true); foreach ($files as $file) { if (!file_exists("thumbnails/" . $file)) { make_thumb($file, "thumbnails/" . $file, 300); } } } if (count($files_paged)) { foreach ($files_paged[$page - 1] as $file) { if (!file_exists("thumbnails/" . $file)) { make_thumb($file, "thumbnails/" . $file, 300); } $name = preg_replace('/^' . $dir . '\\//', '', $file); echo imageHtml($file, $name, $dir); } } if (count($files_paged) > 1) { echo paginationHtml($files_paged, $page); } /* functions to generate html */ function imageHtml($file, $name, $dir) { return "<div class='image' title='" . $name . "'><a href='" . $file . "'><img src='thumbnails/" . $file . "'></a></div>"; } function paginationHtml($paginated, $page) {
echo json_encode($response); } else { // PHP variable containing the MySQL query for inserting the new product in database and send a response back to client with details. $sql = mysql_query("INSERT INTO products (name, price, colour, description, category, subcategory, stockNo) VALUES('{$name}','{$price}','{$colour}','{$desc}','{$cat}','{$subcat}', 50)") or die; $response["success"] = TRUE; $response["details"] = "Product successfully inserted to database"; echo json_encode($response); } // Only handles JPEG images for now // Grabs image from JSON request and renames it with the same name as the product id $pid = mysql_insert_id(); $newname = "{$pid}.jpg"; // The images are then moved to a specific folder on the server move_uploaded_file($_FILES['imagefile']['tmp_name'], "../assets/images/products/{$newname}"); // Executes the function make_thumb that creates a thumbnail for use on product lists, keeping the higher resolution for a specific request for a better quality, e.g. product view make_thumb("../assets/images/products/{$newname}", "../assets/images/products/thumbs/{$newname}"); exit; } else { $sql = mysql_query("UPDATE products SET name='{$name}', price='{$price}', description='{$desc}', category='{$cat}', subcategory='{$subcat}', stockNo=50 WHERE id='{$id}'"); $response["success"] = TRUE; $response["details"] = "Product Updated"; echo json_encode($response); } function make_thumb($src, $dest) { // read the source image $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); // finds the desired height relative to the desired width $desired_width = 128;
} else { $file_name = $db->escape($file['name']); } $file_real_path = PHPDISK_ROOT . $settings['file_path'] . '/'; $file_store_path = date('Y/m/d/'); //$file_store_path_store = is_utf8() ? convert_str('utf-8','gbk',$file_store_path) : $file_store_path; make_dir($file_real_path . $file_store_path); $file_real_name = md5(uniqid(mt_rand(), true) . microtime() . $pd_uid); $file_ext = get_real_ext($file_extension); $dest_file = $file_real_path . $file_store_path . $file_real_name . $file_ext; $file_mime = strtolower($db->escape($file['type'])); if (@in_array($file_extension, array('jpg', 'jpeg', 'png', 'gif', 'bmp'))) { $img_arr = @getimagesize($file['tmp_name']); if ($img_arr[2]) { $is_image = 1; @make_thumb($file['tmp_name'], $file_real_path . $file_store_path . $file_real_name_store . '_thumb.' . $file_extension, $settings['thumb_width'], $settings['thumb_height']); } else { $is_image = 0; } } else { $is_image = 0; } $rs = $db->fetch_one_array("select file_name,file_extension,file_store_path,file_real_name from {$tpf}files where file_id='{$file_id}' and userid='{$pd_uid}' limit 1"); if ($rs) { $file_ext = $rs[file_extension] ? '.' . $rs[file_extension] : ''; @unlink(PHPDISK_ROOT . $settings[file_path] . '/' . $rs[file_store_path] . '/' . $rs[file_real_name] . $file_ext); @unlink(PHPDISK_ROOT . $settings[file_path] . '/' . $rs[file_store_path] . '/' . $rs[file_real_name] . '_thumb' . $file_ext); } unset($rs); $server_oid = @$db->result_first("select server_oid from {$tpf}servers where server_id>1 order by is_default desc limit 1"); if (!$error && upload_file($file['tmp_name'], $dest_file)) {
$attachID = isset($_REQUEST["attachID"]) && intval($_REQUEST["attachID"]) > 0 ? intval($_REQUEST["attachID"]) : false; if ($job == "setPfCover") { $response["result"] = "false"; if ($attachID > 0 && $pfID > 0) { $sql = "SELECT `attachFilePath`,`isCover` FROM `pfAttaches` WHERE `attachID` = '{$attachID}'"; $ai = $db->queryRow($sql); if (isset($ai->attachFilePath)) { if ($ai->isCover == 1) { @unlink("users/" . $member->memberID . "/portfolioAttaches/" . $pfID . "/pf-cover.png"); $sql = "UPDATE `pfAttaches` SET `isCover` = 0 WHERE `attachID` = '{$attachID}'"; $db->query($sql); $response["result"] = "true"; $response["class"] = "glyphicon-star-empty"; } else { $path_parts = pathinfo(substr($ai->attachFilePath, 1)); if (make_thumb(substr($ai->attachFilePath, 1), "users/" . $member->memberID . "/portfolioAttaches/" . $pfID . "/pf-cover.png", "216", $path_parts['extension'])) { $sql = "UPDATE `pfAttaches` SET `isCover` = 1 WHERE `attachID` = '{$attachID}'"; $db->query($sql); $response["result"] = "true"; $response["class"] = "glyphicon-star"; } } } } header('Content-Type: application/json'); echo json_encode($response); exit; } ?> <script src="/js/jquery.form.js"></script> <div class="weedo-table">
<div class="gallery"> <?php $files = array(); foreach ($src_files as $file) { $ext = strrchr($file, '.'); if (in_array($ext, $extensions)) { array_push($files, $file); if (!is_dir($src_folder . '/thumbs')) { mkdir($src_folder . '/thumbs'); chmod($src_folder . '/thumbs', 0777); //chown($src_folder.'/thumbs', 'apache'); } $thumb = $src_folder . '/thumbs/' . $file; if (!file_exists($thumb)) { make_thumb($src_folder, $file, $thumb, $thumb_width); } } } if (count($files) == 0) { echo 'There are no photos in this album!'; } else { $numPages = ceil(count($files) / $itemsPerPage); if (isset($_GET['p'])) { $currentPage = $_GET['p']; if ($currentPage > $numPages) { $currentPage = $numPages; } } else { $currentPage = 1; }
//echo $imagename; $description = isset($_POST['description']) ? $_POST['description'] : ''; //echo $description; //echo "description: ".$description; if (!empty($filename)) { //make a loaction for storing images $location = "uploads/"; $img1_dest = $location . $filename; $img2_dest = $location . "medium" . $filename; $img3_dest = $location . "large" . $filename; //create 2 physical thumbnails and direct them into the file system $source_image = imagecreatefromjpeg($tmp_name); $desired_width1 = imagesx($source_image) * 1.5; $desired_width2 = imagesy($source_image) * 2; make_thumb($tmp_name, $img2_dest, $desired_width1); make_thumb($tmp_name, $img3_dest, $desired_width2); //finish creating thumbnails. They're supposed to be in their physical location //move the uploaded iamge into the file system $movefile = move_uploaded_file($tmp_name, $img1_dest); if ($movefile) { //now need to insert data into database $hsl = mysql_query("insert into image values('','{$imagename}','{$description}')"); if ($hsl) { echo "<script>alert('Insert to the database success!')</script>"; } else { echo "<script>alert('Error Table database')</script>"; } //display images display_image($img1_dest, $img2_dest, $img3_dest, $imagename, $description); } else { echo "upload directory is not writable";
function _upload_file() { $ret_info = array(); // 返回到客户端的信息 $file = $_FILES['Filedata']; if ($file['error'] == UPLOAD_ERR_NO_FILE) { $this->json_error('no_upload_file'); exit; } import('uploader.lib'); // 导入上传类 import('image.func'); $uploader = new Uploader(); $uploader->allowed_type(IMAGE_FILE_TYPE); // 限制文件类型 $uploader->allowed_size(2048000); // 限制单个文件大小2M $uploader->addFile($_FILES['Filedata']); if (!$uploader->file_info()) { $this->json_error($uploader->get_error()); exit; } /* 指定保存位置的根目录 */ $uploader->root_dir(ROOT_PATH); $filename = $uploader->random_filename(); /* 上传 */ $file_path = $uploader->save($this->save_path, $filename); // 保存到指定目录 if (!$file_path) { $this->json_error('file_save_error'); exit; } $thumbnail = dirname($file_path) . '/small_' . basename($file_path); make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $thumbnail, 810, "", 85); $file_type = $this->_return_mimetype($file_path); /* 文件入库 */ $data = array('store_id' => 0, 'file_type' => $file_type, 'file_size' => $file['size'], 'file_name' => $file['name'], 'thumb_nail' => $thumbnail, 'file_path' => $file_path, 'belong' => $this->belong, 'item_id' => $this->item_id, 'add_time' => gmtime()); $file_id = $this->mod_uploadedfile->add($data); if (!$file_id) { $this->json_error('file_add_error'); return false; } /* 返回客户端 */ if ($this->belong == BELONG_CHECK) { $ret_info = array('belong' => BELONG_CHECK, 'file_id' => $file_id, 'file_path' => $file_path); } else { $ret_info = array('file_id' => $file_id, 'file_path' => $file_path); } $this->json_result($ret_info); }
if ($rs) { $tmp_ext = $rs[file_extension] ? '.' . $rs[file_extension] : ''; $dir1 = PHPDISK_ROOT . 'system/cache/'; $dir2 = PHPDISK_ROOT . $settings[file_path] . '/' . $rs[file_store_path]; make_dir($dir2); $file = $dir1 . $rs[file_real_name] . $tmp_ext . '.phpdisk'; $file_real_name = md5(uniqid(mt_rand(), true) . microtime() . $uid); $file_dest = $dir2 . $file_real_name . get_real_ext($rs[file_extension]); //write_file(PHPDISK_ROOT.'system/s2.txt',$file.'|'.$file_dest.','); //if(@filesize($file)==(int)$rs[file_size]){ if (file_exists($file) && @rename($file, $file_dest)) { $file_real_path = PHPDISK_ROOT . '/' . $settings['file_path'] . '/'; $img_arr = getimagesize($file_dest); if ($img_arr[2] && @in_array($file_extension, array('jpg', 'jpeg', 'png', 'gif', 'bmp'))) { $is_image = 1; make_thumb($file_dest, $file_real_path . $rs[file_store_path] . $file_real_name . '_thumb.' . $file_extension, $settings['thumb_width'], $settings['thumb_height']); } else { $is_image = 0; } if ($configs[server_key]) { $server_oid = (int) @$db->result_first("select server_oid from {$tpf}servers where server_key='" . $db->escape($configs[server_key]) . "'"); } else { $server_oid = 0; } $ins = array('file_name' => $rs[file_name], 'file_key' => random(8), 'file_extension' => $rs[file_extension], 'is_image' => $is_image, 'file_mime' => 'application/octet-stream', 'file_description' => '', 'file_store_path' => $rs[file_store_path], 'file_real_name' => $file_real_name, 'file_md5' => '', 'server_oid' => (int) $server_oid, 'file_size' => $rs[file_size], 'file_time' => $timestamp, 'is_checked' => 1, 'in_share' => 0, 'userid' => $uid, 'folder_id' => $rs[folder_id], 'ip' => $onlineip); $db->query_unbuffered("insert into {$tpf}files set " . $db->sql_array($ins)); //$db->query_unbuffered("update {$tpf}uploadx_files set file_state=1 where id='{$rs[id]}'"); $db->query_unbuffered("delete from {$tpf}uploadx_files where id='{$rs[id]}'"); $str = '文件 ' . $rs[file_name] . $tmp_ext . ' 上传成功'; } else { $str = '文件 ' . $rs[file_name] . $tmp_ext . ' 上传失败,目录权限不足';
/** * 上传商品图片 * * @param int $goods_id * @return bool */ function _upload_image($goods_id) { import('image.func'); import('uploader.lib'); $uploader = new Uploader(); $uploader->allowed_type(IMAGE_FILE_TYPE); $uploader->allowed_size(SIZE_GOODS_IMAGE); // 400KB /* 取得剩余空间(单位:字节),false表示不限制 */ $store_mod =& m('store'); $settings = $store_mod->get_settings($this->_store_id); $upload_mod =& m('uploadedfile'); $remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $upload_mod->get_file_size($this->_store_id) : false; $files = $_FILES['new_file']; foreach ($files['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { /* 处理文件上传 */ $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key], 'error' => $files['error'][$key]); $uploader->addFile($file); if (!$uploader->file_info()) { $this->_error($uploader->get_error()); return false; } /* 判断能否上传 */ if ($remain !== false) { if ($remain < $file['size']) { $this->_error('space_limit_arrived'); return false; } else { $remain -= $file['size']; } } $uploader->root_dir(ROOT_PATH); $dirname = 'data/files/store_' . $this->_store_id . '/goods_' . time() % 200; $filename = $uploader->random_filename(); $file_path = $uploader->save($dirname, $filename); $thumbnail = dirname($file_path) . '/small_' . basename($file_path); make_thumb(ROOT_PATH . '/' . $file_path, ROOT_PATH . '/' . $thumbnail, THUMB_WIDTH, THUMB_HEIGHT, THUMB_QUALITY); /* 处理文件入库 */ $data = array('store_id' => $this->_store_id, 'file_type' => $file['type'], 'file_size' => $file['size'], 'file_name' => $file['name'], 'file_path' => $file_path, 'add_time' => gmtime()); $uf_mod =& m('uploadedfile'); $file_id = $uf_mod->add($data); if (!$file_id) { $this->_error($uf_mod->get_error()); return false; } /* 处理商品图片入库 */ $data = array('goods_id' => $goods_id, 'image_url' => $file_path, 'thumbnail' => $thumbnail, 'sort_order' => 255, 'file_id' => $file_id); if (!$this->_image_mod->add($data)) { $this->_error($this->_image_mod->get_error()); return false; } } } return true; }
function remote_image() { import('image.func'); import('uploader.lib'); $uploader = new Uploader(); $uploader->allowed_type(IMAGE_FILE_TYPE); $uploader->allowed_size(SIZE_GOODS_IMAGE); // 2M $upload_mod =& m('uploadedfile'); /* 取得剩余空间(单位:字节),false表示不限制 */ $store_mod =& m('store'); $settings = $store_mod->get_settings($this->store_id); $remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $upload_mod->get_file_size($this->store_id) : false; $uploader->root_dir(ROOT_PATH); $dirname = ''; $remote_url = trim($_POST['remote_url']); if (!empty($remote_url)) { if (preg_match("/^(http:\\/\\/){1,1}.+(gif|png|jpeg|jpg){1,1}\$/i", $remote_url)) { $result = $this->url_exist($remote_url, 2097152, $remain); if ($result === 1) { $this->view_remote(); $res = Lang::get("url_invalid"); echo "<script type='text/javascript'>alert('{$res}');</script>"; return false; } elseif ($result === 2) { $this->view_remote(); $res = Lang::get("not_allowed_size"); echo "<script type='text/javascript'>alert('{$res}');</script>"; return false; } elseif ($result === 3) { $this->view_remote(); $res = Lang::get("space_limit_arrived"); echo "<script type='text/javascript'>alert('{$res}');</script>"; return false; } $img_url = _at('file_get_contents', $remote_url); $dirname = ''; if ($this->belong == BELONG_GOODS) { $dirname = 'data/files/store_' . $this->visitor->get('manage_store') . '/goods_' . time() % 200; } elseif ($this->belong == BELONG_STORE) { $dirname = 'data/files/store_' . $this->visitor->get('manage_store') . '/other'; } elseif ($this->belong == BELONG_ARTICLE) { $dirname = 'data/files/mall/store_' . $this->visitor->get('manage_store') . '/article'; } $filename = $uploader->random_filename(); $new_url = $dirname . '/' . $filename . '.' . substr($remote_url, strrpos($remote_url, '.') + 1); ecm_mkdir(ROOT_PATH . '/' . $dirname); $fp = _at('fopen', ROOT_PATH . '/' . $new_url, "w"); _at('fwrite', $fp, $img_url); _at('fclose', $fp); if (!file_exists(ROOT_PATH . '/' . $new_url)) { $this->view_remote(); $res = Lang::get("system_error"); echo "<script type='text/javascript'>alert('{$res}');</script>"; return false; } /* 处理文件入库 */ $data = array('store_id' => $this->store_id, 'file_type' => $this->_return_mimetype(ROOT_PATH . '/' . $new_url), 'file_size' => filesize(ROOT_PATH . '/' . $new_url), 'file_name' => substr($remote_url, strrpos($remote_url, '/') + 1), 'file_path' => $new_url, 'belong' => $this->belong, 'item_id' => $this->id, 'add_time' => gmtime()); $file_id = $upload_mod->add($data); if (!$file_id) { $this->_error($uf_mod->get_error()); return false; } if ($this->instance == 'goods_image') { /* 生成缩略图 */ $thumbnail = dirname($new_url) . '/small_' . basename($new_url); make_thumb(ROOT_PATH . '/' . $new_url, ROOT_PATH . '/' . $thumbnail, THUMB_WIDTH, THUMB_HEIGHT, THUMB_QUALITY); /* 更新商品相册 */ $mod_goods_image =& m('goodsimage'); $goods_image = array('goods_id' => $this->id, 'image_url' => $new_url, 'thumbnail' => $thumbnail, 'sort_order' => 255, 'file_id' => $file_id); if (!$mod_goods_image->add($goods_image)) { $this->_error($this->mod_goods_imaged->get_error()); return false; } $data['thumbnail'] = $thumbnail; } $data['instance'] = $this->instance; $data['file_id'] = $file_id; $res = "{"; foreach ($data as $key => $val) { $res .= "\"{$key}\":\"{$val}\","; } $res = substr($res, 0, strrpos($res, ',')); $res .= '}'; $this->view_remote(); echo "<script type='text/javascript'>window.parent.add_uploadedfile({$res});</script>"; } else { $res = Lang::get('url_invalid'); $this->view_remote(); echo "<script type='text/javascript'>alert('{$res}');</script>"; return false; } } else { $res = Lang::get('remote_empty'); $this->view_remote(); echo "<script type='text/javascript'>alert('{$res}');</script>"; return false; } }
if (!$chunks || $chunk == $chunks - 1) { // Strip the temp .part suffix off rename("{$filePath}.part", $filePath); } if (isset($_POST["type_upload"]) && $_POST["type_upload"] == "import_items_from_csv") { rename($filePath, $targetDir . DIRECTORY_SEPARATOR . $_POST["csvFile"]); } else { if (isset($_POST["type_upload"]) && $_POST["type_upload"] == "import_items_from_keypass") { rename($filePath, $targetDir . DIRECTORY_SEPARATOR . $_POST["xmlFile"]); } else { if (isset($_POST["type_upload"]) && $_POST["type_upload"] == "upload_profile_photo") { $ext = pathinfo($filePath, PATHINFO_EXTENSION); rename($filePath, $targetDir . DIRECTORY_SEPARATOR . $_POST['newFileName'] . '.' . $ext); // make thumbnail require_once $_SESSION['settings']['cpassman_dir'] . '/sources/main.functions.php'; make_thumb($targetDir . DIRECTORY_SEPARATOR . $_POST['newFileName'] . '.' . $ext, $targetDir . DIRECTORY_SEPARATOR . $_POST['newFileName'] . "_thumb" . '.' . $ext, 40); //Connect to mysql server require_once '../../includes/settings.php'; require_once $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; DB::$host = $server; DB::$user = $user; DB::$password = $pass; DB::$dbName = $database; DB::$port = $port; DB::$encoding = $encoding; DB::$error_handler = 'db_error_handler'; $link = mysqli_connect($server, $user, $pass, $database, $port); $link->set_charset($encoding); // get current avatar and delete it $data = DB::queryFirstRow("SELECT avatar, avatar_thumb FROM " . $pre . "users WHERE id=%i", $_SESSION['user_id']); @unlink($targetDir . DIRECTORY_SEPARATOR . $data['avatar']);
$video_id = $video_id[1]; $thumb_url_start = '<a href="http://www.youtube.com/embed/' . $video_id . '?rel=0&wmode=transparent" title="' . $caption . '" class="albumpix vid">'; break; case "vimeo-": $video_id = explode('vimeo-', $prefix); $video_id = $video_id[1]; $thumb_url_start = '<a href="http://player.vimeo.com/video/' . $video_id . '" title="' . $caption . '" class="albumpix vid">'; break; default: $thumb_url_start = '<a href="' . $album . '/' . $files[$i] . '" title="' . $caption . '" class="albumpix">'; break; } if (in_array($ext, $extensions)) { $thumb = $album . '/thumbs/' . $files[$i]; if (!file_exists($thumb)) { make_thumb($album, $files[$i], $thumb, $thumb_width); } if ($i < $start || $i >= $start + $numPerPage) { ?> <div style="display:none;"><?php } ?> <div class="thumb-wrapper"> <div class="thumb"> <?php echo $thumb_url_start; ?> <img src="<?php echo $thumb; ?>
$upload_path_image = $path . $user_id . "/"; $upload_path_thumbnail = $upload_path_image . "/thumbnails/" . $user_id . "/"; if (!is_dir($upload_path_image)) { mkdir($upload_path_image, 0775, true); } if (!is_dir($upload_path_thumbnail)) { mkdir($upload_path_thumbnail, 0775, true); } $url = $upload_path_image . $file_name; // image location in store $url_thumb = $upload_path_thumbnail . $thumbnail_name; // thumbnail location in store // Save file move_uploaded_file($_FILES["file"]["tmp_name"], $url); // Create thumbnail image make_thumb($url, $url_thumb, WIDTH, HEIGHT); // Save image info $sXML = new SimpleXMLElement('uploaded.xml', null, true); // Load the entire xml // Check user has exists in XML foreach ($sXML as $user) { if ($user['uid'] == $user_id) { $image_id = $user->count() + 1; $newchild = $user->addChild("cover"); $newchild->addAttribute("pid", $user_id . $image_id); // string Id image = user_id + image_id in user $newchild->addChild("title", $title); $newchild->addChild("image_name", $file_name); $newchild->addChild("image_size", $image_size); $newchild->addChild("image_source", $url); $newchild->addChild("thumbnail_name", $thumbnail_name);
function maketable($dirname) { global $GDok, $IMGFOLDER, $IMGURL, $VIDEOICON, $AUDIOICON; $handle = opendir($dirname); $file_lista[] = array(); while ($file = readdir($handle)) { if ($file != '.' && $file != '..' && preg_match('/\\-l.jpg$/i', $file)) { $file_lista[] = $file; } } closedir($handle); $kepdb = -1; $coldb = 0; print '<table border="0" cellspacin="0" cellpadding="0"><tr>' . "\n"; if (count($file_lista) > 0) { for ($a = 0; $a < sizeof($file_lista); $a++) { $fnev = $dirname . "/" . $file_lista[$a]; if (!is_dir($fnev)) { if ((substr($fnev, -4) == ".jpg" || substr($fnev, -4) == ".gif" || substr($fnev, -4) == ".mpg" || substr($fnev, -4) == ".MPG" || substr($fnev, -4) == ".mpeg" || substr($fnev, -4) == ".MPEG" || substr($fnev, -4) == ".avi" || substr($fnev, -4) == ".AVI" || substr($fnev, -4) == ".wmv" || substr($fnev, -4) == ".WMV" || substr($fnev, -4) == ".mov" || substr($fnev, -4) == ".MOV" || substr($fnev, -4) == ".png" || substr($fnev, -4) == ".PNG" || substr($fnev, -4) == ".mp3" || substr($fnev, -4) == ".MP3" || substr($fnev, -4) == ".JPG" || substr($fnev, -4) == ".GIF") && $file_lista[$a] != 'index.gif' && $file_lista[$a] != 'index.gif' && !strpos($file_lista[$a], '_t.')) { $kepdb++; $coldb++; $picname = substr($file_lista[$a], 0, -4); $belyeg = $dirname . '/' . $picname . '_t' . substr($file_lista[$a], -4); $belyegurl = $IMGURL . '/' . rawurlencode($picname) . '_t' . substr($file_lista[$a], -4); if (substr($fnev, -4) == ".mpg" || substr($fnev, -4) == ".MPG" || substr($fnev, -4) == ".avi" || substr($fnev, -4) == ".AVI" || substr($fnev, -4) == ".wmv" || substr($fnev, -4) == ".WMV" || substr($fnev, -4) == ".mov" || substr($fnev, -4) == ".MOV") { $belyeg = './' . $VIDEOICON; $belyegurl = './' . $VIDEOICON; } if (substr($fnev, -4) == ".mp3" || substr($fnev, -4) == ".MP3") { $belyeg = './' . $AUDIOICON; $belyegurl = './' . $AUDIOICON; } // ha még nincsbélyegkép akkor létrehozni if (!file_exists($belyeg)) { if ($GDok) { make_thumb($fnev, $belyeg, 100, 100); } } if (!file_exists($belyeg)) { $belyeg = $dirname . '/' . $file_lista[$a]; $belyegurl = $IMGURL . '/' . rawurlencode($file_lista[$a]); } $x = -1; $y = -1; getimgsize($belyeg, $x, $y); print '<td width="110" height="110" onclick="parent.selectimg(' . $kepdb . ')" ' . 'align="center" valign="center" style="padding:5px; cursor:pointer;">' . "\n"; if ($x < 0) { print '<img src="' . $belyegurl . '" alt="' . $file_lista[$a] . '" width="100" height="100" id="' . $kepdb . '" />'; } else { if ($x > $y) { print '<img src="' . $belyegurl . '" alt="' . $file_lista[$a] . '" width="100" id="' . $kepdb . '" />'; } else { print '<img src="' . $belyegurl . '" alt="' . $file_lista[$a] . '" height="100" id="' . $kepdb . '" />'; } } print '</td>' . "\n"; if ($coldb == 3) { print '</tr><tr>' . "\n"; $coldb = 0; } } } } } print '</tr></table>' . "\n"; }
<?php if (!user()) { redirect('/login'); } $errormsg = array('', ''); if (isset($_GET['action'])) { if ($_GET['action'] == 'basic') { $uid = user('id'); if ($_FILES['avatar']['size'] > 0) { import('model/imgutil.php'); make_thumb($_FILES['avatar']['tmp_name'], "data/user/{$uid}/avatar.jpg", 90, 90); } global $_USER; $user = $_USER; unset($user['avatar']); unset($user['id']); $uname = trim($_POST['realname']); if (isset($uname[0])) { $user['name'] = iescape($uname); } $utitle = trim($_POST['title']); if ($user['verified'] && isset($utitle[0])) { $user['title'] = iescape($utitle); } data_save("user/{$uid}/info", json_encode($user)); redirect('/settings'); } elseif ($_GET['action'] == 'password') { function checkPwd() { if (!isset($_POST['password'][2])) {