Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix iFrame-based uploaders : get_template action was remove, implemen…
Browse files Browse the repository at this point in the history
…t custom action for each.
  • Loading branch information
cdujeu committed Jun 21, 2016
1 parent d298520 commit 15bfe29
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 77 deletions.
31 changes: 31 additions & 0 deletions core/src/plugins/uploader.flex/class.FlexUploadProcessor.php
Expand Up @@ -22,7 +22,9 @@
use Pydio\Core\Controller\Controller;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\PluginFramework\Plugin;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Services\UsersService;
use Pydio\Core\Utils\StatHelper;

defined('AJXP_EXEC') or die( 'Access not allowed');

Expand All @@ -35,6 +37,30 @@ class FlexUploadProcessor extends Plugin
{
private static $active = false;

/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
*/
public function getTemplate(\Psr\Http\Message\ServerRequestInterface &$request, \Psr\Http\Message\ResponseInterface &$response){

$confMaxSize = StatHelper::convertBytes(ConfService::getCoreConf("UPLOAD_MAX_SIZE", "uploader"));
$UploadMaxSize = min(StatHelper::convertBytes(ini_get('upload_max_filesize')), StatHelper::convertBytes(ini_get('post_max_size')));
if($confMaxSize != 0) $UploadMaxSize = min ($UploadMaxSize, $confMaxSize);
$confTotalNumber = ConfService::getCoreConf("UPLOAD_MAX_NUMBER", "uploader");
$confTotalSize = ConfService::getCoreConf("UPLOAD_MAX_SIZE_TOTAL", "uploader");
$confTotalNumber = ConfService::getCoreConf("UPLOAD_MAX_NUMBER", "uploader");
$maxLength = ConfService::getCoreConf("NODENAME_MAX_LENGTH");

$FlashVar = '&totalUploadSize='.$confTotalSize.'&fileSizeLimit='.$UploadMaxSize.'&maxFileNumber='.$confTotalNumber.'&maxFilenameLength='.$maxLength;
$pluginConfigs = $this->getConfigs();
include($this->getBaseDir()."/flash_tpl.html");

}

/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
*/
public function preProcess(\Psr\Http\Message\ServerRequestInterface &$request, \Psr\Http\Message\ResponseInterface &$response)
{
/** @var ContextInterface $ctx */
Expand Down Expand Up @@ -69,6 +95,11 @@ public function preProcess(\Psr\Http\Message\ServerRequestInterface &$request, \
}
}

/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @throws Exception
*/
public function postProcess(\Psr\Http\Message\ServerRequestInterface &$request, \Psr\Http\Message\ResponseInterface &$response)
{
if (!self::$active) {
Expand Down
16 changes: 0 additions & 16 deletions core/src/plugins/uploader.flex/flash_tpl.html
@@ -1,19 +1,3 @@
<?php
use Pydio\Core\Utils\Utils as AJXP_Utils;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\PluginsService as AJXP_PluginsService;

$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);
$confTotalNumber = ConfService::getCoreConf("UPLOAD_MAX_NUMBER", "uploader");
$confTotalSize = ConfService::getCoreConf("UPLOAD_MAX_SIZE_TOTAL", "uploader");
$confTotalNumber = ConfService::getCoreConf("UPLOAD_MAX_NUMBER", "uploader");
$maxLength = ConfService::getCoreConf("NODENAME_MAX_LENGTH");

$FlashVar = '&totalUploadSize='.$confTotalSize.'&fileSizeLimit='.$UploadMaxSize.'&maxFileNumber='.$confTotalNumber.'&maxFilenameLength='.$maxLength;
$pluginConfigs = AJXP_PluginsService::getInstance()->findPlugin("uploader", "flex")->getConfigs();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Expand Down
7 changes: 6 additions & 1 deletion core/src/plugins/uploader.flex/manifest.xml
Expand Up @@ -11,6 +11,11 @@
</server_settings>
<registry_contributions>
<actions>
<action name="flex_tpl">
<processing>
<serverCallback methodName="getTemplate"/>
</processing>
</action>
<action name="upload">
<pre_processing>
<serverCallback methodName="preProcess"/>
Expand All @@ -35,7 +40,7 @@
</div>
]]></clientForm>
<dialogOnOpen><![CDATA[
var src = window.ajxpServerAccessPath + '&get_action=get_template&template_name=flash_tpl.html&pluginName=uploader.flex&encode=false';
var src = window.ajxpServerAccessPath + '&get_action=flex_tpl&encode=false';
modal.getForm().down('#flashframe').src = src;
]]></dialogOnOpen>
<activeCondition><![CDATA[
Expand Down
Expand Up @@ -22,6 +22,7 @@
use Pydio\Access\Core\AJXP_MetaStreamWrapper;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\UserSelection;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Utils\StatHelper;
Expand All @@ -41,13 +42,47 @@ class JumploaderProcessor extends Plugin
/**
* Handle UTF8 Decoding
*
* @var unknown_type
* @var bool
*/
private static $skipDecoding = false;
private static $remote = false;
private static $wrapperIsRemote = false;
private static $partitions = array();

/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
*/
public function getTemplate(\Psr\Http\Message\ServerRequestInterface &$request, \Psr\Http\Message\ResponseInterface &$response){

/** @var ContextInterface $ctx */
$ctx = $request->getAttribute("ctx");
$confMaxSize = StatHelper::convertBytes(ConfService::getCoreConf("UPLOAD_MAX_SIZE", "uploader"));
$UploadMaxSize = min(StatHelper::convertBytes(ini_get('upload_max_filesize')), StatHelper::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 = $ctx->getRepository();
$accessType = $repository->getAccessType();

$partitionLength = $UploadMaxSize - 1000;

if($accessType == "remotefs"){
$maxFileLength = $UploadMaxSize;
}else if($accessType == "ftp"){
$partitionLength = $UploadMaxSize - 1000;
}

include($this->getBaseDir()."/jumploader_tpl.html");

}

/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @throws Exception
*/
public function preProcess(\Psr\Http\Message\ServerRequestInterface &$request, \Psr\Http\Message\ResponseInterface &$response)
{
$httpVars = $request->getParsedBody();
Expand Down Expand Up @@ -464,6 +499,10 @@ public function postProcess(\Psr\Http\Message\ServerRequestInterface &$request,
}
}

/**
* @param $params
* @return string
*/
public function jumploaderInstallApplet($params)
{
if (is_file($this->getBaseDir()."/jumploader_z.jar")) {
Expand Down
23 changes: 0 additions & 23 deletions core/src/plugins/uploader.jumploader/jumploader_tpl.html
@@ -1,26 +1,3 @@
<?php
use Pydio\Core\Utils\Utils;
use Pydio\Core\Services\ConfService;

$confMaxSize = Utils::convertBytes(ConfService::getCoreConf("UPLOAD_MAX_SIZE", "uploader"));
$UploadMaxSize = min(Utils::convertBytes(ini_get('upload_max_filesize')), 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();

$partitionLength = $UploadMaxSize - 1000;

if($accessType == "remotefs"){
$maxFileLength = $UploadMaxSize;
}else if($accessType == "ftp"){
$partitionLength = $UploadMaxSize - 1000;
}


?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Expand Down
10 changes: 9 additions & 1 deletion core/src/plugins/uploader.jumploader/manifest.xml
Expand Up @@ -11,6 +11,11 @@
</server_settings>
<registry_contributions>
<actions>
<action name="jumploader_tpl">
<processing>
<serverCallback methodName="getTemplate"/>
</processing>
</action>
<action name="upload">
<pre_processing>
<serverCallback methodName="preProcess"/>
Expand All @@ -35,8 +40,11 @@
</div>
]]></clientForm>
<dialogOnOpen><![CDATA[
var src = window.ajxpServerAccessPath + '&get_action=get_template&template_name=jumploader_tpl.html&pluginName=uploader.jumploader&encode=false';
var src = window.ajxpServerAccessPath + '&get_action=jumploader_tpl&encode=false';
modal.getForm().down('#jumpframe').src = src;
]]></dialogOnOpen>
<activeCondition><![CDATA[
return navigator.javaEnabled();
]]></activeCondition>
</processing>
</uploader>
53 changes: 49 additions & 4 deletions core/src/plugins/uploader.plupload/class.PluploadProcessor.php
Expand Up @@ -38,20 +38,65 @@
use Pydio\Access\Core\Model\UserSelection;

use Pydio\Core\Controller\Controller;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\StatHelper;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Controller\XMLWriter;
use Pydio\Core\PluginFramework\Plugin;

defined('AJXP_EXEC') or die( 'Access not allowed');

/**
* Class PluploadProcessor
*/
class PluploadProcessor extends Plugin
{
// 15 minutes execution time
//@set_time_limit(15 * 60);
/**
* @param \Psr\Http\Message\ServerRequestInterface $requestInterface
* @param \Psr\Http\Message\ResponseInterface $responseInterface
*/
public function getTemplate(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface){

/** @var \Pydio\Core\Model\ContextInterface $ctx */
$ctx = $requestInterface->getAttribute("ctx");
$UploadMaxSize = StatHelper::convertBytes(ini_get('upload_max_filesize'));
$UploadMaxPostSize = StatHelper::convertBytes(ini_get('post_max_size'));
if($UploadMaxPostSize > 0 && $UploadMaxPostSize < $UploadMaxSize) $UploadMaxSize = $UploadMaxPostSize;
$confMaxSize = ConfService::getConf("UPLOAD_MAX_FILE");
if($confMaxSize != 0 && $confMaxSize < $UploadMaxSize) $UploadMaxSize = $confMaxSize;

$pluginConfigs = $this->getConfigs();
$confTotalSize = ConfService::getConf("UPLOAD_MAX_TOTAL");
$confTotalNumber = ConfService::getConf("UPLOAD_MAX_NUMBER");

$repository = $ctx->getRepository();
$accessType = $repository->getAccessType();
if($accessType == "fs"){
$partitionLength = $UploadMaxSize - 1000;
}else if($accessType == "remotefs"){
$maxFileLength = $UploadMaxSize;
}else if($accessType == "ftp"){
$maxFileLength = $UploadMaxSize;
}

$minisite_session = "";
if(strpos(session_name(), "AjaXplorer_Shared") === 0) {
$minisite_session = "&minisite_session=" . substr(session_name(), strlen("AjaXplorer_Shared"));
}
$secureToken = $requestInterface->getParsedBody()["secure_token"];
include($this->getBaseDir()."/pluploader_tpl.html");

// Uncomment this one to fake upload time
// usleep(5000);
}

/**
* @param $action
* @param $httpVars
* @param $fileVars
* @param \Pydio\Core\Model\ContextInterface $ctx
* @throws Exception
* @throws \Pydio\Core\Exception\ActionNotFoundException
* @throws \Pydio\Core\Exception\AuthRequiredException
*/
public function unifyChunks($action, &$httpVars, &$fileVars, \Pydio\Core\Model\ContextInterface $ctx)
{

Expand Down
7 changes: 6 additions & 1 deletion core/src/plugins/uploader.plupload/manifest.xml
Expand Up @@ -23,6 +23,11 @@
<serverCallback methodName="unifyChunks"/>
</processing>
</action>
<action name="plupload_tpl">
<processing>
<serverCallback methodName="getTemplate"/>
</processing>
</action>
</actions>
</registry_contributions>
<dependencies>
Expand All @@ -39,7 +44,7 @@
</div>
]]></clientForm>
<dialogOnOpen><![CDATA[
var src = window.ajxpServerAccessPath + '&get_action=get_template&template_name=pluploader_tpl.html&pluginName=uploader.plupload&encode=false';
var src = window.ajxpServerAccessPath + '&get_action=plupload_tpl&encode=false';
modal.getForm().down('#pluploadframe').src = src;
]]></dialogOnOpen>
</processing>
Expand Down
31 changes: 1 addition & 30 deletions core/src/plugins/uploader.plupload/pluploader_tpl.html
@@ -1,32 +1,3 @@
<?php
use Pydio\Core\Utils\Utils as AJXP_Utils;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\PluginsService as AJXP_PluginsService;

$UploadMaxSize = AJXP_Utils::convertBytes(ini_get('upload_max_filesize'));
$UploadMaxPostSize = AJXP_Utils::convertBytes(ini_get('post_max_size'));
if($UploadMaxPostSize > 0 && $UploadMaxPostSize < $UploadMaxSize) $UploadMaxSize = $UploadMaxPostSize;
$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");
$pluginConfigs = AJXP_PluginsService::getInstance()->findPlugin("uploader", "plupload")->getConfigs();

$repository = ConfService::getRepository();
$accessType = $repository->getAccessType();
if($accessType == "fs"){
$partitionLength = $UploadMaxSize - 1000;
}else if($accessType == "remotefs"){
$maxFileLength = $UploadMaxSize;
}else if($accessType == "ftp"){
$maxFileLength = $UploadMaxSize;
}

$minisite_session = "";
if(strpos(session_name(), "AjaXplorer_Shared") === 0){
$minisite_session = "&minisite_session=".substr(session_name(), strlen("AjaXplorer_Shared"));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
Expand All @@ -53,7 +24,7 @@

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

var uploadUrl = '<?php print($_SERVER["SCRIPT_NAME"]); ?>?get_action=upload_chunks_unify_plupload&secure_token=<?php echo $httpVars["secure_token"];?>&ajxp_sessid=<?php echo session_id().$minisite_session; ?>';
var uploadUrl = '<?php print($_SERVER["SCRIPT_NAME"]); ?>?get_action=upload_chunks_unify_plupload&secure_token=<?php echo $secureToken;?>&ajxp_sessid=<?php echo session_id().$minisite_session; ?>';

var maxFileSize = '<?PHP echo ($UploadMaxSize/1048576) . "mb"; ?>';
var maxHTML4 = '<?PHP echo $UploadMaxSize; ?>';
Expand Down

0 comments on commit 15bfe29

Please sign in to comment.