<commit_before><?php 
    $confMaxSize = AJXP_Utils::convertBytes(ConfService::getCoreConf("UPLOAD_MAX_SIZE", "uploader"));
	$UploadMaxSize = min(AJXP_Utils::convertBytes(ini_get('upload_max_filesize')), AJXP_Utils::convertBytes(ini_get('post_max_size')));
	if($confMaxSize != 0) $UploadMaxSize = min ($UploadMaxSize, $confMaxSize);
    $confTotalSize = ConfService::getCoreConf("UPLOAD_MAX_SIZE_TOTAL", "uploader");
    $confTotalNumber = ConfService::getCoreConf("UPLOAD_MAX_NUMBER", "uploader");
    
	$repository = ConfService::getRepository();
	$accessType = $repository->getAccessType();
	if($accessType == "fs"){
		$partitionLength = $UploadMaxSize - 1000;	
	}else if($accessType == "remotefs"){
		$maxFileLength = $UploadMaxSize;
	}else if($accessType == "ftp"){
		$maxFileLength = $UploadMaxSize;
		/*
		// Here we could switch to FTP, but that would mean, by a way or another,
		// to display in clear the ftp credentials... 
		// Also, beware the ftp_z.jar is needed for this to work.
		$ftpWrapper = new ftpAccessWrapper();
		$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
		$streamData = $plugin->detectStreamWrapper(true);		
    	$destStreamURL = $streamData["protocol"]."://".$repository->getId()."/";
    	// Not working now, as ftpAccessWrapper::buildRealUrl is in fact protected
    	$ftpURL = $ftpWrapper->buildRealUrl($destStreamURL);
    	// Then pass this URL to the javascript uploadUrl => to the applet.
    	*/
	}
	

?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
</head>
<body bgcolor="ffffff" style="overflow:hidden; padding: 0px; padding-left: 0px; margin: 0px;">
<script language="javascript" type="text/javascript">

var clientId = '<?php echo session_id(); ?>';

var partitionLength = <?php echo ($partitionLength?$partitionLength:-1); ?>;
var maxFileLength = <?php echo ($maxFileLength?$maxFileLength:-1); ?>;
var ftpUrl = '<?php echo ($ftpURL?$ftpURL:""); ?>';

function appletInitialized(uploader){	
	var applet = document.getElementById('jumpLoaderApplet');
	var origUrl = applet.getUploaderConfig().getUploadUrl();
	var currentFolder = parent.base64_encode(parent.ajaxplorer.getUserSelection().getContextNode().getPath());
	applet.getUploaderConfig().setUploadUrl(origUrl + "&dir=" + currentFolder + "&ajxp_sessid=" + clientId);
	applet.getUploaderConfig().setPartitionLength(partitionLength);
	applet.getUploaderConfig().setMaxFileLength(maxFileLength);
    parent.document.fire("ajaxplorer:longtask_starting");
}

function uploaderStatusChanged(uploader){
	var applet = document.getElementById('jumpLoaderApplet');
	// 1 = uploading, 0 is back to normal => we assume "uploaded"
	if(uploader.getStatus() == 0){
		parent.ajaxplorer.fireContextRefresh();
        parent.document.fire("ajaxplorer:longtask_finished");
	}
}


/*
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,<commit_msg>Jumploader : use uploader passed as argument, may solve FF random problems?<commit_after><?php 
    $confMaxSize = AJXP_Utils::convertBytes(ConfService::getCoreConf("UPLOAD_MAX_SIZE", "uploader"));
	$UploadMaxSize = min(AJXP_Utils::convertBytes(ini_get('upload_max_filesize')), AJXP_Utils::convertBytes(ini_get('post_max_size')));
	if($confMaxSize != 0) $UploadMaxSize = min ($UploadMaxSize, $confMaxSize);
    $confTotalSize = ConfService::getCoreConf("UPLOAD_MAX_SIZE_TOTAL", "uploader");
    $confTotalNumber = ConfService::getCoreConf("UPLOAD_MAX_NUMBER", "uploader");
    
	$repository = ConfService::getRepository();
	$accessType = $repository->getAccessType();
	if($accessType == "fs"){
		$partitionLength = $UploadMaxSize - 1000;	
	}else if($accessType == "remotefs"){
		$maxFileLength = $UploadMaxSize;
	}else if($accessType == "ftp"){
		$maxFileLength = $UploadMaxSize;
		/*
		// Here we could switch to FTP, but that would mean, by a way or another,
		// to display in clear the ftp credentials... 
		// Also, beware the ftp_z.jar is needed for this to work.
		$ftpWrapper = new ftpAccessWrapper();
		$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
		$streamData = $plugin->detectStreamWrapper(true);		
    	$destStreamURL = $streamData["protocol"]."://".$repository->getId()."/";
    	// Not working now, as ftpAccessWrapper::buildRealUrl is in fact protected
    	$ftpURL = $ftpWrapper->buildRealUrl($destStreamURL);
    	// Then pass this URL to the javascript uploadUrl => to the applet.
    	*/
	}
	

?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
</head>
<body bgcolor="ffffff" style="overflow:hidden; padding: 0px; padding-left: 0px; margin: 0px;">
<script language="javascript" type="text/javascript">

var clientId = '<?php echo session_id(); ?>';

var partitionLength = <?php echo ($partitionLength?$partitionLength:-1); ?>;
var maxFileLength = <?php echo ($maxFileLength?$maxFileLength:-1); ?>;
var ftpUrl = '<?php echo ($ftpURL?$ftpURL:""); ?>';

function appletInitialized(uploader){
	var origUrl = uploader.getUploaderConfig().getUploadUrl();
	var currentFolder = parent.base64_encode(parent.ajaxplorer.getUserSelection().getContextNode().getPath());
    uploader.getUploaderConfig().setUploadUrl(origUrl + "&dir=" + currentFolder + "&ajxp_sessid=" + clientId);
    uploader.getUploaderConfig().setPartitionLength(partitionLength);
    uploader.getUploaderConfig().setMaxFileLength(maxFileLength);
    parent.document.fire("ajaxplorer:longtask_starting");
}

function uploaderStatusChanged(uploader){
	// 1 = uploading, 0 is back to normal => we assume "uploaded"
	if(uploader.getStatus() == 0){
		parent.ajaxplorer.fireContextRefresh();
        parent.document.fire("ajaxplorer:longtask_finished");
	}
}


/*
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,
{'fraction_non_alphanumeric': 0.15436351706036747, 'fraction_numerical': 0.017716535433070866, 'mean_word_length': 5.835201793721973, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6983926', 'n_tokens_mistral': 2142, 'n_tokens_neox': 1992, 'n_words': 391}