?? upload.inc.php
字號:
<?php
if(!defined('IN_DISCUZ')) {
exit('Access Deined');
}
//設定$maxattachsize和圖片文件保存路徑$attachdir
//縮略圖的寬度$thumbwidth和高度$thumbheight
$thumbwidth = 180;
$thumbheight = 180;
$filename = daddslashes($attach['name']);
$attach['ext'] = $extension = strtolower(fileext($attach['name']));
$attach['name'] = dhtmlspecialchars($attach['name']);
$attach['thumb'] = 0;
if(strlen($attach['name']) > 90) {
$attach['name'] = 'abbr_'.md5($attach['name']).'.'.$extension;
}
if(empty($attach['size'])) {
showmessage('post_attachment_size_invalid');
}
/*
if($maxattachsize && $attach['size'] > $maxattachsize) {
showmessage('post_attachment_toobig');
}
*/
if($attachsave) {
switch($attachsave) {
case 1: $attach_subdir = 'forumid_'.$GLOBALS['fid']; break;
case 2: $attach_subdir = 'ext_'.$extension; break;
case 3: $attach_subdir = 'month_'.date('ym'); break;
case 4: $attach_subdir = 'day_'.date('ymd'); break;
case 5: $attach_subdir = 'blcar'; break;
}
$attach_dir = $attachdir.'/'.$attach_subdir;
if(!is_dir($attach_dir)) {
mkdir($attach_dir, 0777);
fclose(fopen($attach_dir.'/index.htm', 'w'));
}
$attach['attachment'] = $attach_subdir.'/';
} else {
$attach['attachment'] = '';
}
$attach['attachment'] .= preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\.|$)/i", "_\\1\\2",
date('Ymd').'_'.substr(md5($filename.microtime()), 12).random(12).'.'.$extension);
$target = $attachdir.'/'.$attach['attachment'];
if(@copy($attach['tmp_name'], $target) || (function_exists('move_uploaded_file') && @move_uploaded_file($attach['tmp_name'], $target))) {
@unlink($attach['tmp_name']);
$attach_saved = true;
}
if(!$attach_saved && @is_readable($attach['tmp_name'])) {
@$fp = fopen($attach['tmp_name'], 'rb');
@flock($fp, 2);
@$attachedfile = fread($fp, $attach['size']);
@fclose($fp);
@$fp = fopen($target, 'wb');
@flock($fp, 2);
if(@fwrite($fp, $attachedfile)) {
@unlink($attach['tmp_name']);
$attach_saved = true;
}
@fclose($fp);
}
if($attach_saved) {
@chmod($target, 0644);
if(!in_array($attach['ext'], array('jpg', 'jpeg', 'gif', 'png')) && function_exists('getimagesize') && !@getimagesize($target)) {
@unlink($target);
showmessage('post_attachment_ext_notallowed');
} else {
require_once DISCUZ_ROOT.'./include/image.class.php';
$image = new Image($attachedfile, $target, $attach);
if($image->imagecreatefromfunc && $image->imagefunc) {
$image->Thumb($thumbwidth, $thumbheight);
$image->Watermark();
$attach = $image->attach;
}
}
}
else {
showmessage('post_attachment_save_error');
}
?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -