Permalink
Browse files

Various fixes for shares.

Make WEBDAV and PUBLIC routes configurable, clear route file when clearing all caches
  • Loading branch information...
1 parent cf73c5d commit a34063a18b0b3317b741ae58435590ba63465239 @cdujeu cdujeu committed Sep 2, 2016
@@ -25,6 +25,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Pydio\Core\Exception\PydioException;
+use Pydio\Core\Services\ConfService;
use Zend\Diactoros\ServerRequestFactory;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -46,14 +47,16 @@ class TopLevelRouter
private $base = "";
+ const ROUTE_CACHE_FILENAME = "plugins_toplevel_routes.php";
+
/**
* TopLevelRouter constructor.
* @param array $cacheOptions
*/
public function __construct($cacheOptions = []){
$this->cacheOptions = array_merge([
"cacheDisabled" => AJXP_SKIP_CACHE,
- "cacheFile" => AJXP_DATA_PATH."/cache/plugins_toplevel_routes.php"
+ "cacheFile" => AJXP_CACHE_DIR."/".TopLevelRouter::ROUTE_CACHE_FILENAME
], $cacheOptions);
}
@@ -65,11 +68,11 @@ public function __construct($cacheOptions = []){
public function configureRoutes($base, RouteCollector &$r){
$allMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'CONNECT', 'PATCH', 'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'LOCK', 'UNLOCK'];
- $file = AJXP_DATA_PATH."/".AJXP_PLUGINS_FOLDER."/boot.conf/routes.json";
- if(!file_exists($file)){
- $file = AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/core.ajaxplorer/routes.json";
- }
- $routes = json_decode(file_get_contents($file), true);
+ $file = AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/core.ajaxplorer/routes.json";
+ $textContent = file_get_contents($file);
+ $textContent = str_replace("%PUBLIC_BASEURI%", ConfService::getGlobalConf("PUBLIC_BASEURI"), $textContent);
+ $textContent = str_replace("%WEBDAV_BASEURI%", ConfService::getGlobalConf("WEBDAV_BASEURI"), $textContent);
+ $routes = json_decode($textContent, true);
foreach ($routes as $short => $data){
$methods = $data["methods"] == "*" ? $allMethods : $data["methods"];
foreach($data["routes"] as $route){
@@ -121,8 +124,10 @@ public function route(){
break;
case Dispatcher::NOT_FOUND:
default:
- throw new PydioException("Oups, could not find any valid route for ".$uri.", method was was ".$httpMethod);
- break;
+ //throw new PydioException("Oups, could not find any valid route for ".$uri.", method was was ".$httpMethod);
+ header("HTTP/1.0 404 Not Found");
+ echo file_get_contents(AJXP_INSTALL_PATH . "/plugins/gui.ajax/res/html/404.html");
+ die();
}
}
@@ -29,6 +29,7 @@
use Pydio\Core\Exception\PydioException;
use Pydio\Core\Exception\PydioUserAlertException;
use Pydio\Core\Exception\RepositoryLoadException;
+use Pydio\Core\Http\TopLevelRouter;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
@@ -105,6 +106,7 @@ public static function clearPluginsCache(){
@unlink(AJXP_PLUGINS_REQUIRES_FILE);
@unlink(AJXP_PLUGINS_QUERIES_CACHE);
@unlink(AJXP_PLUGINS_BOOTSTRAP_CACHE);
+ @unlink(AJXP_CACHE_DIR."/".TopLevelRouter::ROUTE_CACHE_FILENAME);
if(@unlink(AJXP_PLUGINS_REPOSITORIES_CACHE)){
$content = "<?php \n";
$boots = glob(AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/*/repositories.php");
@@ -153,7 +153,7 @@ public static function instanciatePluginFromGlobalParams($globalsArray, $interfa
$globalsArray = array("instance_name" => $globalsArray);
}
- if (!isSet($globalsArray["instance_name"]) && isSet($globalsArray["group_switch_value"])){
+ if (is_array($globalsArray) && !isSet($globalsArray["instance_name"]) && isSet($globalsArray["group_switch_value"])){
$globalsArray["instance_name"] = $globalsArray["group_switch_value"];
}
@@ -246,7 +246,7 @@ public static function publicRoute($serverBase, $route, $params){
}
ConfService::getAuthDriverImpl();
- $minisiteServer = new MinisiteServer($serverBase, $hash, isSet($params["download_file"]));
+ $minisiteServer = new MinisiteServer($serverBase, $hash, isSet($params["optional"]));
$minisiteServer->registerCatchAll();
$minisiteServer->listen();
@@ -75,7 +75,7 @@ public function buildPublicDlURL()
}
} else {
$fullUrl = ApplicationState::detectServerURL(true);
- return str_replace("\\", "/", rtrim($fullUrl, "/")."/".trim(ConfService::getGlobalConf("PUBLIC_BASE_URI"), "/"));
+ return str_replace("\\", "/", rtrim($fullUrl, "/")."/".trim(ConfService::getGlobalConf("PUBLIC_BASEURI"), "/"));
}
}
@@ -19,7 +19,7 @@
<global_param name="APPLICATION_TITLE" group="CONF_MESSAGE[Main]" type="string" label="CONF_MESSAGE[App Title]" description="CONF_MESSAGE[Your application title]" mandatory="true" default="Pydio" expose="true"/>
<global_param name="DEFAULT_LANGUAGE" group="CONF_MESSAGE[Main]" type="select" choices="AJXP_AVAILABLE_LANGUAGES" label="CONF_MESSAGE[Default Language]" description="CONF_MESSAGE[Default language when a user does not have set his/her own.]" mandatory="true" default="en"/>
<global_param name="SERVER_URL" group="CONF_MESSAGE[Main]" type="string" label="CONF_MESSAGE[Server URL]" description="CONF_MESSAGE[Server URL used to build share links and notifications. It will be detected if empty.]" mandatory="false"/>
- <global_param name="PUBLIC_BASE_URI" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Public Base URI]" description="CONF_MESSAGE[URI where to serve the public links]" mandatory="true" default="/public"/>
+ <global_param name="PUBLIC_BASEURI" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Public Base URI]" description="CONF_MESSAGE[URI where to serve the public links]" mandatory="true" default="/public"/>
<global_param name="PUBLIC_DOWNLOAD_FOLDER" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Download Folder (Legacy)]" description="CONF_MESSAGE[Absolute path to the public folder where temporary download links will be created. This is used for legacy purpose, newly created links do not use it anymore, but use the Base URI instead.]" mandatory="false" default="AJXP_INSTALL_PATH/data/public"/>
<!-- MAKE SURE NOT TO CHANGE ORDER OF name AND default ATTRIBUTES, CAN BE REPLACED BY INSTALLERS -->
<global_param name="PUBLIC_DOWNLOAD_URL" default="" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Download URL]" description="CONF_MESSAGE[If not inferred directly from the current pydio URL plus the public base URI, replace the public access URL here.]" mandatory="false"/>
@@ -23,10 +23,10 @@
"class": "Pydio\\Core\\Http\\Base",
"method": "handleRoute"
},
- "/shares": {
+ "%WEBDAV_BASEURI%": {
"methods": "*",
"routes": [
- "/shares[{optional:.+}]"
+ "%WEBDAV_BASEURI%[{optional:.+}]"
],
"class": "Pydio\\Core\\Http\\Dav\\DAVServer",
"method": "handleRoute"
@@ -47,12 +47,12 @@
"class": "Pydio\\OCS\\OCSPlugin",
"method": "startServer"
},
- "/public":{
+ "%PUBLIC_BASEURI%":{
"methods": "*",
"routes": [
- "/public/{hash}/dl/[{optional:.+}]",
- "/public/{hash}",
- "/public[{optional:.+}]"
+ "%PUBLIC_BASEURI%/{hash}/dl/[{optional:.+}]",
+ "%PUBLIC_BASEURI%/{hash}",
+ "%PUBLIC_BASEURI%[{optional:.+}]"
],
"class": "Pydio\\Share\\ShareCenter",
"path" : "plugins/action.share/src/ShareCenter.php",
@@ -0,0 +1,31 @@
+<style>
+ body, html{
+ width: 100%;
+ height: 90%;
+ font-family: Roboto, Arial, sans-serif;
+ }
+ .Aligner {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+ width: 100%;
+ }
+
+ .Aligner-item {
+ max-width: 90%;
+ font-size: 2em;
+ color: rgba(0,0,0,0.73);
+ text-align: center;
+ }
+</style>
+<head>
+ <title>Page not found!</title>
+</head>
+<body>
+ <div class="Aligner">
+ <div class="Aligner-item">
+ Oups, cannot find this page!
+ </div>
+ </div>
+</body>

0 comments on commit a34063a

Please sign in to comment.