目录source/class/discuz/discuz_upload.php
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: discuz_upload.php 34648 2014-06-18 02:53:07Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
Class discuz_upload{
var $attach = array();
var $type = '';
var $extid = 0;
var $errorcode = 0;
var $forcename = '';
public function __construct() {
}
function init($attach, $type = 'temp', $extid = 0, $forcename = '') {
if(!is_array($attach) || empty($attach) || !$this->is_upload_file($attach['tmp_name']) || trim($attach['name']) == '' || $attach['size'] == 0) {
$this->attach = array();
$this->errorcode = -1;
return false;
} else {
$this->type = $this->check_dir_type($type);
$this->extid = intval($extid);
$this->forcename = $forcename;
$attach['size'] = intval($attach['size']);
$attach['name'] = trim($attach['name']);
$attach['thumb'] = '';
$attach['ext'] = $this->fileext($attach['name']);
$attach['name'] = dhtmlspecialchars($attach['name'], ENT_QUOTES);
if(strlen($attach['name']) > 90) {
$attach['name'] = cutstr($attach['name'], 80, '').'.'.$attach['ext'];
}
$attach['isimage'] = $this->is_image_ext($attach['ext']);
$attach['extension'] = $this->get_target_extension($attach['ext']);
$attach['attachdir'] = $this->get_target_dir($this->type, $extid);
$attach['attachment'] = $attach['attachdir'].$this->get_target_filename($this->type, $this->