function add_file_counter($files_sn = "") { global $xoopsDB; $file = upfile::get_one_file($files_sn); $file_type = $file['file_type']; $file_size = $file['file_size']; $real_filename = $file['description']; $sql = "update " . $xoopsDB->prefix("tad_web_files_center") . " set `counter`=`counter`+1 where `files_sn`='{$files_sn}'"; $xoopsDB->queryF($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); if ($file['kind'] == "img") { //header("location:"._FILES_CENTER_IMAGE_URL."/{$file['file_name']}"); $file_saved = _FILES_CENTER_IMAGE_URL . "/{$file['file_name']}"; } else { //header("location:"._FILES_CENTER_URL."/{$file['file_name']}"); $file_saved = _FILES_CENTER_URL . "/{$file['file_name']}"; } $file_display = mb_convert_encoding($real_filename, "BIG-5", "UTF-8"); $mimetype = $file_type; if (function_exists('mb_http_output')) { mb_http_output('pass'); } header('Expires: 0'); header('Content-Type: ' . $mimetype); if (preg_match("/MSIE ([0-9]\\.[0-9]{1,2})/", $HTTP_USER_AGENT)) { header('Content-Disposition: inline; filename="' . $file_display . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $file_display . '"'); header('Pragma: no-cache'); } header("Content-Type: application/force-download"); header("Content-Transfer-Encoding: binary"); $handle = fopen($file_saved, "rb"); while (!feof($handle)) { $buffer = fread($handle, 4096); echo $buffer; } fclose($handle); }
/** * 处理文件上传 * */ function action_upload() { global $config; global $data; global $tUser; $config["use_layout"] = false; $kv = new kv("sys"); $up = new upfile(UP_PATH . date("Ym"), explode(",", "doc,docx,xls,xlsx,txt,zip,rar,gif,bmp,jpg,png")); $ups = $up->upload($_FILES["up"]); foreach ($ups as $file) { $kv->push("sys.files", $file, $file); $kv->push("user.{$tUser}.files", $file, $file); } $kv->restat_keys("sys.files"); $kv->restat_keys("user.{$tUser}.files"); header("Location:?act=files"); }
<?php require_once './common.inc.php'; require_once '../' . $met_adminfile . '/include/upfile.class.php'; header("Content-type: image/jpeg"); //$thumb_src.'dir=原图路径&x=长&y=宽' $ext1 = explode("/", $dir); $count = count($ext1); $count1 = $ext1[$count - 1]; $ext2 = explode(".", $count1); $ext3 = $ext2[1]; $path1 = $ext2[0]; $dir1 = '../upload/thumb_src/' . $x . '_' . $y . '/' . $path1 . '.' . $ext3; if (file_exists($dir1)) { readfile("{$dir1}"); } else { $f = new upfile(); $imgurls = $f->createthumb($dir, $x, $y); readfile($imgurls); }
if ($_FILES['Filedata']['name'] != '') { $met_upsql = $f->upload('Filedata', $filenamearray[0]); } include "pclzip.lib.php"; $archive = new PclZip('../databack/sql/' . 'metinfo_' . $filenamearray[0] . '.zip'); $archive->add('../databack/' . $filenamearray[0] . '.sql', PCLZIP_OPT_REMOVE_PATH, '../databack/'); $metinfo = '1$' . '../databack/' . $filenamearray[0] . '.sql'; } else { $filetype = explode('.', $_FILES['Filedata']['name']); if ($filetype[count($filetype) - 1] == 'zip') { if (stristr($met_file_format, 'zip') === false) { echo $lang_jsx36; die; } $filenamearray = explode('.zip', $_FILES['Filedata']['name']); $f = new upfile('sql,zip', '../databack/sql/', '', ''); if ($f->get_error()) { echo $f->get_errorcode(); die; } if (file_exists('../databack/sql/' . $filenamearray[0] . '.zip')) { $filenamearray[0] = 'metinfo' . $filenamearray[0]; } if ($_FILES['Filedata']['name'] != '') { $met_upsql = $f->upload('Filedata', $filenamearray[0]); } include "pclzip.lib.php"; $archive = new PclZip('../databack/sql/' . $filenamearray[0] . '.zip'); if ($archive->extract(PCLZIP_OPT_PATH, '../databack') == 0) { $metinfo = $archive->errorInfo(true); } else {
} } } /*缩略图*/ if ($met_thumb_wate == 1 && $val['imgurls'] != '') { $imgurls = $depth . '../' . $val['imgurls']; if ($met_big_img == '') { $imgurl = $val['imgurl']; if (!stristr($val['imgurl'], 'watermark')) { $setimgurl = explode("/", $imgurl); $imgurl = $setimgurl[0] . "/" . $setimgurl[1] . "/" . $setimgurl[2] . "/watermark/" . $setimgurl[3]; } $met_big_img = str_ireplace("/watermark", "", $val['imgurl']); } $setthumb = explode("/", $met_big_img); $f = new upfile($met_img_type, "../../../upload/{$setthumb['2']}/", $met_img_maxsize, '', 1); $f->savename = $setthumb[3]; $met_bigthumb_img = $depth . "../" . $met_big_img; $met_big_img_iconv = stristr(PHP_OS, "WIN") ? @iconv("utf-8", "gbk", $met_bigthumb_img) : $met_bigthumb_img; if (file_exists($met_big_img_iconv)) { //列表和首页缩略图 if ($met_big_img == str_ireplace("/thumb", "", $val['imgurls'])) { $met_img_x = ''; $met_img_y = ''; if ($met_img_style == 1) { imgstyle($module); } $met_thumb_img = $depth . "../" . $met_big_img; $imgurls = $f->createthumb($met_thumb_img, $met_img_x, $met_img_y); if ($met_wate_class == 2) { $img->met_image_name = $depth . $met_wate_img;
$sql1 = $save_type == 2 ? " and id!={$id}" : ''; $filenameok = $db->get_one("SELECT * FROM {$met_news} WHERE ({$sql}) {$sql1} and filename='{$filename}'"); if ($filenameok) { metsave('-1', $lang_modFilenameok, $depth); } } if (!$imgurl && !$imgurls) { $imgauto = preg_match('/<img.*src=\\\\"(.*?)\\\\".*?>/i', $content, $out); $filenameimg = explode("images/", $out[1]); $filenameimg = $filenameimg[count($filenameimg) - 1]; $new_big_img = '../../../upload/images/' . $filenameimg; $new_big_img = str_ireplace("/watermark", "", $new_big_img); $new_big_img_iconv = stristr(PHP_OS, "WIN") ? @iconv("utf-8", "gbk", $new_big_img) : $new_big_img; if ($filenameimg && file_exists($new_big_img_iconv)) { require_once ROOTPATH_ADMIN . 'include/upfile.class.php'; $f = new upfile($met_img_type, "../../../upload/images/", $met_img_maxsize, '', 1); $f->savename = str_ireplace("watermark/", "", $filenameimg); $imgurls = $f->createthumb($new_big_img, $met_newsimg_x, $met_newsimg_y); if ($met_thumb_wate == 1) { require_once ROOTPATH_ADMIN . 'include/watermark.class.php'; $img = new Watermark(); if ($met_wate_class == 2) { $img->met_image_pos = $met_watermark; $img->met_image_name = $depth . $met_wate_img; } else { $img->met_text = $met_text_wate; $img->met_text_color = $met_text_color; $img->met_text_angle = $met_text_angle; $img->met_text_pos = $met_watermark; $img->met_text_font = $depth . $met_text_fonts; $img->met_text_size = $met_text_size;
$img->save_file = $imgurls; $img->create(); } } } /*չʾͼƬ*/ if ($val['displayimg']) { $displayurl = explode("|", $val['displayimg']); foreach ($displayurl as $key1 => $val1) { $displayurls[] = explode("*", $val1); } foreach ($displayurls as $key2 => $val2) { $met_bigdisplay_img = str_ireplace("/watermark", "", $val2[1]); //ÄÚÈÝÒ³ËõÂÔͼ $setthumb = explode("/", $met_bigdisplay_img); $f = new upfile($met_img_type, "../../../upload/{$setthumb['2']}/", $met_img_maxsize, '', 1); $f->savename = $setthumb[3]; $met_dis_img = $depth . "../" . $met_bigdisplay_img; $met_bigdisplay_img_iconv = stristr(PHP_OS, "WIN") ? @iconv("utf-8", "gbk", $met_dis_img) : $met_dis_img; if (file_exists($met_bigdisplay_img_iconv)) { $met_img_x = ''; $met_img_y = ''; if ($mou == 3) { $met_img_x = $met_productdetail_x; $met_img_y = $met_productdetail_y; } if ($mou == 5) { $met_img_x = $met_imgdetail_x; $met_img_y = $met_imgdetail_y; } $imgurls = $f->createthumb($met_dis_img, $met_img_x, $met_img_y, 'thumb_dis/');
require_once './common.inc.php'; require_once '../' . $met_adminfile . '/include/upfile.class.php'; header("Content-type: image/jpeg"); //$thumb_src.'dir=原图路径&x=长&y=宽' $dir = '../' . str_replace('../', '', $dir); if (is_numeric($x) && is_numeric($y)) { $ext1 = explode("/", $dir); $count = count($ext1); $count1 = $ext1[$count - 1]; $ext2 = explode(".", $count1); $ext3 = $ext2[1]; $path1 = $ext2[0]; $dir1 = '../upload/thumb_src/' . $x . '_' . $y . '/' . $path1 . '.' . $ext3; if (strtolower($ext3) == 'jpg' || strtolower($ext3) == 'jpeg' || strtolower($ext3) == 'bmp' || strtolower($ext3) == 'png' || strtolower($ext3) == 'gif') { if (stristr(PHP_OS, "WIN")) { $dir1 = @iconv("utf-8", "GBK", $dir1); } if (file_exists($dir1)) { readfile("{$dir1}"); } else { $f = new upfile($met_img_type, '../upload/thumb_src/', $met_img_maxsize, '', 1); $f->savename = $path1 . '.' . $ext3; $imgurls = $f->createthumb($dir, $x, $y, $x . '_' . $y . '/'); if (stristr(PHP_OS, "WIN")) { $imgurls = @iconv("utf-8", "GBK", $imgurls); } readfile($imgurls); } } }
// FileName: card_img.php // Summary: 信用卡图片管理 // Author: millken(迷路林肯) // LastModifed:2008-7-3 // copyright (c)2008 millken@gmail.com //==================================================== session_start(); if (!$_SESSION['webmaster']) { header("location:login.php"); } include '../common.inc.php'; include ROOT_PATH . 'include/upfile.class.php'; if (in_array($do, array('add', 'hide', 'del', 'recommend'))) { switch ($do) { case 'add': $up = new upfile(ROOT_PATH . 'data/' . date("Ym", time()), array('gif', 'jpg', 'jpeg'), true); $fileimg = $up->upload($_FILES['img']); $img = empty($fileimg) ? '' : 'data/' . date("Ym", time()) . "/" . basename($fileimg[0]); $sql = "INSERT INTO `{$tablepre}productpic` (pid,img,url) VALUES ('{$pid}','{$img}','{$url}')"; $db->query($sql); refer("添加图片成功"); break; case 'hide': $db->query("UPDATE `{$tablepre}productpic` SET hide=abs(hide-1) WHERE pid='{$pid}'"); refer("更新状态成功"); break; case 'recommend': $db->query("UPDATE `{$tablepre}productpic` SET recommend=abs(recommend-1) WHERE pid='{$pid}'"); refer("更新状态成功"); break; case 'del':