<?php 
    $UploadMaxSize = Utils::convertBytes(ini_get('upload_max_filesize'));
    $confMaxSize = ConfService::getConf("UPLOAD_MAX_FILE");
    if($confMaxSize != 0 &&  $confMaxSize < $UploadMaxSize) $UploadMaxSize = $confMaxSize;
    $confTotalSize = ConfService::getConf("UPLOAD_MAX_TOTAL");
    $confTotalNumber = ConfService::getConf("UPLOAD_MAX_NUMBER");
    
	$FlashVar = '&fileTypes=*.*&fileTypeDescription=All%20files&totalUploadSize='.$confTotalSize.'&fileSizeLimit='.$UploadMaxSize.'&maxFileNumber='.$confTotalNumber;
?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
</head>
<body bgcolor="ffffff" onload="setReady();" style="padding: 0px; padding-left: 0px; margin: 0px; background-image: url('<?php print(CLIENT_RESOURCES_FOLDER);?>/images/strip.png');">
<div style="border: 0px solid #ccc; border-bottom: 0px; width: 422px; height:470px; padding: 0px 0px;">
<script language="javascript" type="text/javascript">
var jsReady = false;
function isReady(){
	return jsReady;
}
function setReady(){
	jsReady = true;
}
var messages = 
{
	MaxFileSizeLimit:252, 
	MaxFileSize:211, 
	HTTPError:253, 
	IOError:254, 
	SecurityError:255,
	Uploaded:256,
	Remove:257,
	Add:214,
	Clear:216,
	Upload:77,
	Cancel:232,
	TotalFile:258,
	SizeText:259,
	Byte:260, 
	existingFilesFound:262, 
	overwrite:263, 
	skip:264, 
	rename:6, 
	UploadLimitsTitle:281, 
	UploadLimitsSizePerFile:282, 
	UploadLimitsTotalSize:283, 
	UploadLimitsFilesNumber:284
};

function triggerFlashEvent(){
	if(arguments.length < 1) return;
	var eventType = arguments[0];
	switch(eventType){
		case "currentFiles":
			return parent.ajaxplorer.filesList.getFileNames("__AJXP_SEP__");
		break;
		case "currentFolder":
			var folder = parent.base64_encode(parent.ajaxplorer.filesList.getCurrentRep());
			return folder;
		break;	
		case "uploadComplete":
			parent.ajaxplorer.filesList.reload();
		break;
		case "getMessage":
			var messageId = arguments[1];
			if(parent && parent.window.MessageHash && messages){
				return parent.window.MessageHash[messages[messageId]];
			}
			return messageId;			
		break;
		default: 
		break;
	}
}


var url = '<?php print($_SERVER['SCRIPT_NAME']);?>?get_action=upload&ajxp_sessid=<?php echo session_id(); ?>';
/*
if(parent.ajaxplorer){
	url = url+'&dir='+escape(parent.ajaxplorer.filesList.getCurrentRep());
}
*/

var FlashObject = "<?php print(CLIENT_RESOURCES_FOLDER);?>/flash/FlashFileUpload.swf";
var FlashVarValue = "<?php echo $FlashVar; ?>" + "&uploadPage=" + escape(url) + "<?php echo (strlen(HTTPS_POLICY_FILE) > 0 ? "&policyFile=".HTTPS_POLICY_FILE : ""); ?>";

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="422" height="470" id="fileUpload" align="middle">\
<param name="allowScriptAccess" value="sameDomain" /> \
<param name="movie" value="'+FlashObject+'" /> \
<param name="quality" value="high" /> \
<param name="wmode" value="opaque"> \
<param name="FlashVars" value="' + FlashVarValue +'">\
<embed src="'+FlashObject+'" \
FlashVars="' + FlashVarValue + '" \
quality="high" wmode="transparent" width="422" height="470" name="fileUpload" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"\
pluginspage="http://www.macromedia.com/go/getflashplayer" />\
</object>');
</script>
</div>
</body>
</html>
