Permalink
Browse files

Start refactoring boot scripts (index, rest, dav, etc..).

Refactor upload action as preProcess/postProcess handlers need to use the new signature.
  • Loading branch information...
1 parent c4c1026 commit 2a27c1a25bde88be3c6d0418a002973187c74907 @cdujeu cdujeu committed May 9, 2016
Showing with 773 additions and 470 deletions.
  1. +3 −8 core/src/cmd.php
  2. +205 −75 core/src/core/src/pydio/Core/Controller/Controller.php
  3. +15 −5 core/src/core/src/pydio/Core/Controller/HTMLWriter.php
  4. +33 −1 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  5. +9 −2 core/src/core/src/pydio/Core/Services/ConfService.php
  6. +17 −16 core/src/core/src/pydio/Core/Utils/Utils.php
  7. +1 −1 core/src/core/tests/test.SSLEncryption.php
  8. +0 −3 core/src/dav.php
  9. +28 −110 core/src/index.php
  10. +4 −2 core/src/index_shared.php
  11. +0 −3 core/src/opencollab.php
  12. +205 −146 core/src/plugins/access.fs/class.fsAccessDriver.php
  13. +1 −1 core/src/plugins/access.fs/fsActions.xml
  14. +2 −2 core/src/plugins/action.quicksend/manifest.xml
  15. +0 −1 core/src/plugins/authfront.duosecurity/class.DuoSecurityFrontend.php
  16. +0 −2 core/src/plugins/authfront.session_login/class.SessionLoginFrontend.php
  17. +125 −0 core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
  18. +2 −2 core/src/plugins/gui.ajax/manifest.xml
  19. +14 −12 core/src/plugins/uploader.flex/class.FlexUploadProcessor.php
  20. +5 −1 core/src/plugins/uploader.flex/flash_tpl.html
  21. +1 −1 core/src/plugins/uploader.flex/manifest.xml
  22. +43 −29 core/src/plugins/uploader.html/class.SimpleUploadProcessor.php
  23. +40 −16 core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
  24. +6 −3 core/src/plugins/uploader.jumploader/jumploader_tpl.html
  25. +4 −0 core/src/plugins/uploader.plupload/pluploader_tpl.html
  26. +0 −2 core/src/publicLet.inc.php
  27. +10 −24 core/src/rest.php
  28. +0 −2 core/src/worker.php
View
@@ -46,11 +46,6 @@
ConfService::init();
ConfService::start();
-$confStorageDriver = ConfService::getConfStorageImpl();
-require_once($confStorageDriver->getUserClassFileName());
-//session_name("AjaXplorer");
-//session_start();
-
$optArgs = array();
$options = array();
@@ -231,22 +226,22 @@
if (!empty($nextUsers)) {
sleep(1);
$process = Controller::applyActionInBackground($options["r"], $optAction, $optArgs, $nextUsers, $optStatusFile);
- if ($process != null && is_a($process, "UnixProcess") && isSet($optStatusFile)) {
+ if ($process != null && is_a($process, "Pydio\\Core\\Utils\\UnixProcess") && isSet($optStatusFile)) {
file_put_contents($optStatusFile, "RUNNING:".$process->getPid());
}
}
if (!empty($optUserQueue)) {
sleep(1);
//echo("Should go to next with $optUserQueue");
$process = Controller::applyActionInBackground($options["r"], $optAction, $optArgs, "queue:".$optUserQueue, $optStatusFile);
- if ($process != null && is_a($process, "UnixProcess") && isSet($optStatusFile)) {
+ if ($process != null && is_a($process, "Pydio\\Core\\Utils\\UnixProcess") && isSet($optStatusFile)) {
file_put_contents($optStatusFile, "RUNNING:".$process->getPid());
}
}
if (!empty($nextRepositories)) {
sleep(1);
$process = Controller::applyActionInBackground($nextRepositories, $optAction, $optArgs, $originalOptUser, $optStatusFile);
- if ($process != null && is_a($process, "UnixProcess") && isSet($optStatusFile)) {
+ if ($process != null && is_a($process, "Pydio\\Core\\Utils\\UnixProcess") && isSet($optStatusFile)) {
file_put_contents($optStatusFile, "RUNNING:".$process->getPid());
}
}
Oops, something went wrong.
@@ -20,8 +20,7 @@
*/
namespace Pydio\Core\Controller;
-use Pydio\Core\Controller\XMLWriter;
-use Pydio\Core\Services\AuthService;
+use Psr\Http\Message\ResponseInterface;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\TextEncoder;
@@ -96,12 +95,23 @@ public static function writeI18nMessagesClass($mess)
* Send a simple Content-type header
* @static
*/
- public static function internetExplorerMainDocumentHeader()
+ public static function internetExplorerMainDocumentHeader(ResponseInterface &$response = null)
{
if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE 9.")) {
- header("X-UA-Compatible: IE=9");
+ if(isSet($response)){
+ $response = $response->withHeader("X-UA-Compatible", "IE=9");
+ }else{
+ header("X-UA-Compatible: IE=9");
+ }
} else if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE 10.")) {
- header("X-UA-Compatible: IE=Edge,chrome=1");
+ if(isSet($response)){
+ $response = $response->withHeader("X-UA-Compatible", "IE=Edge, chrome=1");
+ }else{
+ header("X-UA-Compatible: IE=Edge,chrome=1");
+ }
+ }
+ if(isSet($response)){
+ $response = $response->withHeader("Content-type", "text/html; charset=utf-8");
}
}
@@ -23,8 +23,8 @@
use Pydio\Access\Core\AJXP_Node;
use Pydio\Access\Core\IAjxpWrapperProvider;
use Pydio\Access\Core\Repository;
+use Pydio\Core\Exception\AuthRequiredException;
use Pydio\Core\Utils\Utils;
-use Pydio\Core\Controller\Controller;
use Pydio\Core\Exception\PydioPromptException;
use Pydio\Core\Services;
use Pydio\Core\Services\AuthService;
@@ -80,6 +80,28 @@ public static function close($docNode="tree")
print("</$docNode>");
}
+ public static function wrapDocument($content, $docNode = "tree", $attributes = array()){
+
+ if(self::$headerSent !== false && self::$headerSent == $docNode) {
+ return $content;
+ }
+ //header('Content-Type: text/xml; charset=UTF-8');
+ //header('Cache-Control: no-cache');
+ $buffer = '<?xml version="1.0" encoding="UTF-8"?>';
+ $attString = "";
+ if (count($attributes)) {
+ foreach ($attributes as $name=>$value) {
+ $attString.="$name=\"$value\" ";
+ }
+ }
+ self::$headerSent = $docNode;
+ $buffer .= "<$docNode $attString>";
+ $buffer .= $content;
+ $buffer .= "</$docNode>";
+ return $buffer;
+
+ }
+
/**
* @static
* @param string $data
@@ -294,6 +316,16 @@ public static function catchError($code, $message, $fichier, $ligne, $context)
*/
public static function catchException($exception)
{
+ if($exception instanceof AuthRequiredException){
+ XMLWriter::header();
+ $message = $exception->getMessage();
+ if(!empty($message)){
+ XMLWriter::sendMessage(null, $message);
+ }
+ XMLWriter::requireAuth();
+ XMLWriter::close();
+ return;
+ }
try {
XMLWriter::catchError($exception->getCode(), TextEncoder::fromUTF8($exception->getMessage()), $exception->getFile(), $exception->getLine(), $exception);
} catch (\Exception $innerEx) {
@@ -24,9 +24,7 @@
use Pydio\Access\Core\AbstractAccessDriver;
use Pydio\Access\Core\Repository;
use Pydio\Auth\Core\AbstractAuthDriver;
-use Pydio\Core\Services\AuthService;
use Pydio\Cache\Core\AbstractCacheDriver;
-use Pydio\Core\Services\CacheService;
use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Conf\Core\AbstractConfDriver;
use Pydio\Conf\Core\CoreConfLoader;
@@ -66,6 +64,13 @@ class ConfService
private $contextRepositoryId;
private $contextCharset;
+ public static function registerCatchAll(){
+ if (is_file(TESTS_RESULT_FILE)) {
+ set_error_handler(array("Pydio\\Core\\Controller\\XMLWriter", "catchError"), E_ALL & ~E_NOTICE & ~E_STRICT );
+ set_exception_handler(array("Pydio\\Core\\Controller\\XMLWriter", "catchException"));
+ }
+ }
+
/**
* @return AbstractConfDriver
*/
@@ -165,6 +170,8 @@ public static function start()
{
$inst = self::getInstance();
$inst->startInst();
+ $confStorageDriver = self::getConfStorageImpl();
+ require_once($confStorageDriver->getUserClassFileName());
}
/**
* Init CONF, AUTH drivers
@@ -20,17 +20,12 @@
*/
namespace Pydio\Core\Utils;
+use Psr\Http\Message\UploadedFileInterface;
use Pydio\Access\Core\Repository;
-use Pydio\Core\dibi;
-use Pydio\Core\DibiException;
-use Pydio\Core\HttpClient;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\Plugin;
use Pydio\Core\PluginFramework\PluginsService;
-use Pydio\Core\Utils\TextEncoder;
-use Pydio\Core\Utils\VarsFilter;
-use Pydio\Core\Utils\JSPacker;
use Pydio\Log\Core\AJXP_Logger;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -334,17 +329,23 @@ public static function parseCSL($string, $hash = false)
/**
* Parse the $fileVars[] PHP errors
* @static
- * @param $boxData
+ * @param array|UploadedFileInterface $boxData
* @param bool $throwException
* @return array|null
* @throws \Exception
*/
public static function parseFileDataErrors($boxData, $throwException=false)
{
$mess = ConfService::getMessages();
- $userfile_error = $boxData["error"];
- $userfile_tmp_name = $boxData["tmp_name"];
- $userfile_size = $boxData["size"];
+ if(is_array($boxData)){
+ $userfile_error = $boxData["error"];
+ $userfile_tmp_name = $boxData["tmp_name"];
+ $userfile_size = $boxData["size"];
+ }else{
+ $userfile_error = $boxData->getError();
+ $userfile_size = $boxData->getSize();
+ $userfile_tmp_name = "";
+ }
if ($userfile_error != UPLOAD_ERR_OK) {
$errorsArray = array();
$errorsArray[UPLOAD_ERR_FORM_SIZE] = $errorsArray[UPLOAD_ERR_INI_SIZE] = array(409, str_replace("%i", ini_get("upload_max_filesize"), $mess["537"]));
@@ -1905,21 +1906,21 @@ public static function runCreateTablesQuery($p, $file)
$allParts = array_merge($allParts, $parts);
}
}
- dibi::connect($p);
- dibi::begin();
+ \dibi::connect($p);
+ \dibi::begin();
foreach ($allParts as $createPart) {
$sqlPart = trim($createPart);
if (empty($sqlPart)) continue;
try {
- dibi::nativeQuery($sqlPart);
+ \dibi::nativeQuery($sqlPart);
$resKey = str_replace("\n", "", substr($sqlPart, 0, 50))."...";
$result[] = "OK: $resKey executed successfully";
- } catch (DibiException $e) {
+ } catch (\DibiException $e) {
$result[] = "ERROR! $sqlPart failed";
}
}
- dibi::commit();
- dibi::disconnect();
+ \dibi::commit();
+ \dibi::disconnect();
$message = implode("\n", $result);
if (strpos($message, "ERROR!")) return $message;
else return "SUCCESS:".$message;
@@ -39,7 +39,7 @@ public function doTest()
}
if (!$ssl) {
$this->failedLevel = "warning";
- $this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : if your server supports HTTPS, set the AJXP_FORCE_SSL_REDIRECT parameter in the <i>conf/bootstrap_conf.php</i> file.</p>";
+ $this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : if your server supports HTTPS, make sure to configure the automatic redirection from http to https.</p>";
return FALSE;
} else {
$this->failedInfo .= "Https protocol detected";
View
@@ -40,9 +40,6 @@
die('You are not allowed to access this service');
}
-$confStorageDriver = ConfService::getConfStorageImpl();
-require_once($confStorageDriver->getUserClassFileName());
-
PluginsService::getInstance()->initActivePlugins();
/**
Oops, something went wrong.

0 comments on commit 2a27c1a

Please sign in to comment.