source/include/upload.php
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
class upload_file {
public $attach = array();
public $allow_type = array('bmp', 'gif', 'jpg', 'png');
public $allow_size = 10485760;
public $error_code = 0;
public function init($attach, $savepath) {
if (!is_array($attach) || empty($attach) || !$this->is_upload_file($attach['tmp_name']) || trim($attach['name']) == '' || $attach['size'] == 0) {
$this->attach = array();
$this->error_code = -101;
return false;
} else {
$attach['name'] = trim($attach['name']);
$attach['size'] = intval($attach['size']);
$attach['ext'] = $this->get_ext($attach['name']);
$attach['path'] = $savepath.$this->make_filename($attach['name']).'.'.$attach['ext'];
$this->attach = & $attach;
$this->error_code = 0;
}
}
public function save_file() {
if (empty($this->attach) || empty($this->attach['tmp_name']) || empty($this->attach['path'])) {
$this->error_code = -101;
return false;
} elseif ($this->check_filetype($this->attach['ext'])) {
$this->error_code = -102;
return false;
} elseif (!$this->check_filesize($this->attach['size'])) {
$this->error_code = -103;
return false;
} elseif (!$this->save_to_local($this->attach['tmp_name'], $this->attach['path'])) {
$this->error_code = -104;
return false;
} else {
$this->error_code = 0;
return true;
}
}
public function save_to_local($source, $target) {
if (!$this->is_upload_file($source)) {
$succeed = false;
} elseif (function_exists('move_uploaded_file') && @move_uploaded_file($source, $target)) {
$succeed = true;
} elseif (@copy($source, $target)) {
$succeed = true;
} elseif (@is_readable($source) && (@$fp_s = fopen($source, 'rb')) && (@$fp_t = fopen($target, 'wb'))) {
while (!feof($fp_s)) {
$s_data = @fread($fp_s, @filesize($source));
@fwrite($fp_t, $s_data);
}
fclose($fp_s);
fclose($fp_t);
$succeed = true;
}
if ($succeed) {
后面还有 57 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
