<?php
/**
#	Project: PHPDISK File Storage Solution
#	This is NOT a freeware, use is subject to license terms.
#
#	Site: http://www.phpdisk.com
#
#	Author: Along ( admin@phpdisk.com )
#
#	$Id: upload.inc.php 10 2024-07-17 12:55:08Z along $
#
#	Copyright (C) 2008-2083 PHPDisk Team. All Rights Reserved.
#
*/


if(!defined('IN_DISCUZ')){
	exit('Access Denied');
}
require 'includes/commons.inc.php';
login_auth($_G['uid']);

$uid = (int)gpc('uid','GP',0);
$uid = $uid ? $uid : (int)$_G['uid'];
$job = trim(gpc('job','G',''));

$folder_id = 0;
if($settings['h5_upload_ext']){
	$up_mimeTypes = '';
	$arr = explode(',', $settings['h5_upload_ext']);
	for($i = 0; $i < count($arr); $i ++){
		$up_mimeTypes .= ".{$arr[$i]},";
	}
	$up_mimeTypes = $up_mimeTypes ? substr($up_mimeTypes, 0,-1): '';
	$up_extensions = $settings['h5_upload_ext'];
}else{
	$up_extensions = $up_mimeTypes = '';
}
if($settings['max_file_size']){
	$up_fileSingleSizeLimit = get_byte_value($settings['max_file_size']);
}else{
	$up_fileSingleSizeLimit = get_byte_value('4g'); //default 
}

if($settings['h5_upload_ext']){
	$h5_upload_ext = '';
	$arr = explode(',',$settings['h5_upload_ext']);
	for ($i=0;$i<count($arr);$i++){
		$h5_upload_ext .= "'.$arr[$i]',";
	}
	$h5_upload_ext = $h5_upload_ext ? substr($h5_upload_ext,0,-1) : '';
}

$sign = md5($uid.$settings['encrypt_key'].date('Ymd'));
$action = 'doupload';
$server_oid = 0;
//$max_file_queue = 30;
if($auth['pd_auth'] && $settings['open_multi_server']){
	$rs = DB::fetch_first("select * from phpdisk_mini_servers where is_default=1 limit 1");
	$server_oid = (int)$rs['server_oid'];
	$token = md5(md5($_G['uid'].$action.$server_oid.$settings['encrypt_key'].$rs['server_key']));
	$rc_upload_url = $rs['server_host'].'rc_upload.php';
}else{
	$token = md5(md5($uid.$action.$settings['encrypt_key']));
	$rc_upload_url = 'plugin.php?id=phpdisk_mini:rc_upload';
}

include template('phpdisk_mini:default/upload');

?>
