Permalink
Browse files

Fix some extensions issues. Move methods from Utils and ConfService t…

…o new StatHelper class. Utils should be broken down further.
  • Loading branch information...
1 parent b2bf0a8 commit dd1972169d8cee77d3c9732a0918204fc1cfc1f4 @cdujeu cdujeu committed Jun 20, 2016
Showing with 473 additions and 453 deletions.
  1. +21 −12 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  2. +15 −2 core/src/core/src/pydio/Core/Http/Middleware/SecureTokenMiddleware.php
  3. +3 −2 core/src/core/src/pydio/Core/Http/Response/FileReaderResponse.php
  4. +1 −64 core/src/core/src/pydio/Core/Services/ConfService.php
  5. +356 −0 core/src/core/src/pydio/Core/Utils/StatHelper.php
  6. +1 −313 core/src/core/src/pydio/Core/Utils/Utils.php
  7. +2 −1 core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
  8. +3 −1 core/src/plugins/access.ajxp_home/res/react/WelcomeComponents.js
  9. +10 −9 core/src/plugins/access.fs/class.fsAccessDriver.php
  10. +6 −2 core/src/plugins/access.imap/class.imapAccessDriver.php
  11. +2 −6 core/src/plugins/access.inbox/class.inboxAccessDriver.php
  12. +3 −2 core/src/plugins/access.mysql/class.mysqlAccessDriver.php
  13. +2 −2 core/src/plugins/action.antivirus/class.AntivirusScanner.php
  14. +2 −1 core/src/plugins/conf.sql/class.sqlConfDriver.php
  15. +6 −5 core/src/plugins/core.access/src/AbstractAccessDriver.php
  16. +3 −2 core/src/plugins/core.access/src/Model/Repository.php
  17. +3 −3 core/src/plugins/core.conf/class.AbstractConfDriver.php
  18. +2 −1 core/src/plugins/core.index/class.AbstractSearchEngineIndexer.php
  19. +2 −1 core/src/plugins/core.notifications/class.AJXP_Notification.php
  20. +4 −4 core/src/plugins/core.notifications/class.AJXP_NotificationCenter.php
  21. +3 −3 core/src/plugins/core.uploader/class.CoreUploaderLoader.php
  22. +5 −5 core/src/plugins/editor.diaporama/class.ImagePreviewer.php
  23. +5 −4 core/src/plugins/meta.comments/class.CommentsMetaManager.php
  24. +6 −3 core/src/plugins/meta.git/class.GitManager.php
  25. +3 −3 core/src/plugins/meta.quota/class.QuotaComputer.php
  26. +2 −1 core/src/plugins/uploader.http/class.HttpDownloader.php
  27. +2 −1 core/src/plugins/uploader.jumploader/class.JumploaderProcessor.php
@@ -22,19 +22,13 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\IAjxpWrapperProvider;
-use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
-use Pydio\Core\Model\RepositoryInterface;
-use Pydio\Core\Model\UserInterface;
-use Pydio\Core\Serializer\RepositoryXML;
use Pydio\Core\Services\LocaleService;
-use Pydio\Core\Services\UsersService;
+use Pydio\Core\Utils\StatHelper;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Services;
-use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Core\Services\ConfService;
-use Pydio\Core\PluginFramework\PluginsService;
-use Pydio\Core\Utils\TextEncoder;
+
defined('AJXP_EXEC') or die( 'Access not allowed');
@@ -88,6 +82,13 @@ public static function close($docNode="tree", $print = true)
}
}
+ /**
+ * Wrap xml inside a <tree>...</tree> document, including <?xml> declaration.
+ * @param $content
+ * @param string $docNode
+ * @param array $attributes
+ * @return string
+ */
public static function wrapDocument($content, $docNode = "tree", $attributes = array()){
if(self::$headerSent !== false && self::$headerSent == $docNode) {
@@ -259,10 +260,10 @@ public static function replaceAjxpXmlKeywords($xml, $stripSpaces = false)
$xml = str_replace("AJXP_SERVER_ACCESS", AJXP_SERVER_ACCESS, $xml);
}
$xml = str_replace("AJXP_APPLICATION_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $xml);
- $xml = str_replace("AJXP_MIMES_EDITABLE", Utils::getAjxpMimes("editable"), $xml);
- $xml = str_replace("AJXP_MIMES_IMAGE", Utils::getAjxpMimes("image"), $xml);
- $xml = str_replace("AJXP_MIMES_AUDIO", Utils::getAjxpMimes("audio"), $xml);
- $xml = str_replace("AJXP_MIMES_ZIP", Utils::getAjxpMimes("zip"), $xml);
+ $xml = str_replace("AJXP_MIMES_EDITABLE", StatHelper::getAjxpMimes("editable"), $xml);
+ $xml = str_replace("AJXP_MIMES_IMAGE", StatHelper::getAjxpMimes("image"), $xml);
+ $xml = str_replace("AJXP_MIMES_AUDIO", StatHelper::getAjxpMimes("audio"), $xml);
+ $xml = str_replace("AJXP_MIMES_ZIP", StatHelper::getAjxpMimes("zip"), $xml);
$authDriver = ConfService::getAuthDriverImpl();
if ($authDriver != NULL) {
$loginRedirect = $authDriver->getLoginRedirect();
@@ -415,6 +416,14 @@ public static function triggerBgAction($actionName, $parameters, $messageId, $pr
return $data;
}
+ /**
+ * Send directly JavaScript code to the client
+ * @param $jsCode
+ * @param $messageId
+ * @param bool $print
+ * @param int $delay
+ * @return string
+ */
public static function triggerBgJSAction($jsCode, $messageId, $print=true, $delay = 0)
{
$data = XMLWriter::write("<trigger_bg_action name=\"javascript_instruction\" messageId=\"$messageId\" delay=\"$delay\">", $print);
@@ -24,12 +24,17 @@
use Psr\Http\Message\ServerRequestInterface;
use Pydio\Core\Exception\PydioException;
use Pydio\Core\Http\Server;
-use Pydio\Core\Services\ConfService;
+use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Utils\Utils;
defined('AJXP_EXEC') or die('Access not allowed');
+/**
+ * Class SecureTokenMiddleware
+ * CSRF Prevention
+ * @package Pydio\Core\Http\Middleware
+ */
class SecureTokenMiddleware
{
@@ -43,7 +48,15 @@ class SecureTokenMiddleware
*/
public static function handleRequest(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface $responseInterface, callable $next = null){
- $pluginsUnSecureActions = ConfService::getDeclaredUnsecureActions();
+ $pluginsUnSecureActions = PluginsService::searchManifestsWithCache("//action[@skipSecureToken]", function($nodes){
+ $res = array();
+ /** @var \DOMElement $node */
+ foreach ($nodes as $node) {
+ $res[] = $node->getAttribute("name");
+ }
+ return $res;
+ });
+
$pluginsUnSecureActions[] = "get_secure_token";
if (!in_array($requestInterface->getAttribute("action"), $pluginsUnSecureActions) && self::getSecureToken()) {
$params = $requestInterface->getParsedBody();
@@ -25,6 +25,7 @@
use Pydio\Access\Driver\StreamProvider\FS\fsAccessWrapper;
use Pydio\Core\Controller\HTMLWriter;
use Pydio\Core\Services\ConfService;
+use Pydio\Core\Utils\StatHelper;
use Pydio\Core\Utils\TextEncoder;
use Pydio\Core\Utils\Utils;
use Pydio\Log\Core\AJXP_Logger;
@@ -191,7 +192,7 @@ public function readFile($node = null, $filePath = null, $data = null, $headerTy
} else if ($headerType == "image") {
- header("Content-Type: ".Utils::getImageMimeType(basename($filePathOrData))."; name=\"".$localName."\"");
+ header("Content-Type: ". StatHelper::getImageMimeType(basename($filePathOrData)) ."; name=\"".$localName."\"");
header("Content-Length: ".$size);
header('Cache-Control: public');
@@ -219,7 +220,7 @@ public function readFile($node = null, $filePath = null, $data = null, $headerTy
$mimeType = trim($splitChar[0]);
$this->logDebug("Detected mime $mimeType for $realfile");
} else {
- $mimeType = Utils::getStreamingMimeType(basename($filePathOrData));
+ $mimeType = StatHelper::getStreamingMimeType(basename($filePathOrData));
}
header('Content-type: '.$mimeType);
}
@@ -21,17 +21,12 @@
namespace Pydio\Core\Services;
-use Pydio\Access\Core\AbstractAccessDriver;
-use Pydio\Access\Core\AJXP_MetaStreamWrapper;
-use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Auth\Core\AbstractAuthDriver;
use Pydio\Cache\Core\AbstractCacheDriver;
-use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Conf\Core\AbstractConfDriver;
use Pydio\Core\Model\Context;
-use Pydio\Core\Model\UserInterface;
use Pydio\Core\PluginFramework\CoreInstanceProvider;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Utils\VarsFilter;
@@ -327,65 +322,7 @@ public static function zipCreationEnabled()
if(!self::zipEnabled()) return false;
return ConfService::getCoreConf("ZIP_CREATION");
}
-
-
- /**
- * MISC CONFS
- */
- /**
- * Get all registered extensions, from both the conf/extensions.conf.php and from the plugins
- * @static
- * @return
- */
- public static function getRegisteredExtensions()
- {
- return self::getInstance()->getRegisteredExtensionsInst();
- }
- /**
- * See static method
- * @return
- */
- public function getRegisteredExtensionsInst()
- {
- if (!isSet($this->configs["EXTENSIONS"])) {
- $EXTENSIONS = array();
- $RESERVED_EXTENSIONS = array();
- include_once(AJXP_CONF_PATH."/extensions.conf.php");
- $EXTENSIONS = array_merge($RESERVED_EXTENSIONS, $EXTENSIONS);
- foreach ($EXTENSIONS as $key => $value) {
- unset($EXTENSIONS[$key]);
- $EXTENSIONS[$value[0]] = $value;
- }
- $nodes = PluginsService::getInstance(Context::emptyContext())->searchAllManifests("//extensions/extension", "nodes", true);
- $res = array();
- /** @var \DOMElement $node */
- foreach ($nodes as $node) {
- $res[$node->getAttribute("mime")] = array($node->getAttribute("mime"), $node->getAttribute("icon"), $node->getAttribute("messageId"));
- }
- if (count($res)) {
- $EXTENSIONS = array_merge($EXTENSIONS, $res);
- }
- $this->configs["EXTENSIONS"] = $EXTENSIONS;
- }
- return $this->configs["EXTENSIONS"];
- }
- /**
- * Get the actions that declare to skip the secure token in the plugins
- * @static
- * @return array
- */
- public static function getDeclaredUnsecureActions()
- {
- return PluginsService::searchManifestsWithCache("//action[@skipSecureToken]", function($nodes){
- $res = array();
- /** @var \DOMElement $node */
- foreach ($nodes as $node) {
- $res[] = $node->getAttribute("name");
- }
- return $res;
- });
- }
-
+
/**
* Get a config by its name
* @static
Oops, something went wrong.

0 comments on commit dd19721

Please sign in to comment.