namespace App\Models;
use Cubist\Backpack\Magic\Fields\Checkbox;
+use Cubist\Backpack\Magic\Fields\Table;
use Cubist\Backpack\Magic\Fields\Text;
use Cubist\Backpack\Magic\Models\ExternalServer;
use Cubist\Net\Transfer\Local;
+use Cubist\Util\Files\Files;
+use Cubist\Util\Json;
+
// __('!! Serveurs externes')
class FluidbookExternalInstallServer extends ExternalServer
{
public function setFields()
{
parent::setFields();
+ $this->addField('redirections', Table::class, __('Redirections'), ['entity_singular' => __('redirection'), 'columns' => ['from' => __('De'), 'to' => __('Vers')], 'when' => ['protocol' => 'hosting']]);
$this->addField('allows_root', Checkbox::class, __('Autoriser le chargement à la racine (sur le chemin de base)'), ['default' => false]);
}
+ public function onSaved(): bool
+ {
+ $this->updateHtaccess();
+ return parent::onSaved();
+ }
+
+ protected function updateHtaccess()
+ {
+ if ($this->getProtocol() === 'hosting') {
+
+ $redirections = Json::isJson($this->redirections) ? json_decode($this->redirections, true) : $this->redirections;
+
+ $content = '<IfModule mod_rewrite.c>
+ <IfModule mod_negotiation.c>
+ Options -MultiViews -Indexes
+ </IfModule>
+ RewriteEngine On
+ # Handle Authorization Header
+ RewriteCond %{HTTP:Authorization} .
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+';
+ foreach ($redirections as $redirection) {
+ $content .= ' RewriteRule ' . $redirection['from'] . ' /' . ltrim($redirection['to'], '/') . " [R=308,L]\n";
+ }
+ $content .= '</IfModule>' . "\n";
+ $tmp = Files::tempnam();
+ file_put_contents($tmp, $content);
+ $this->getTransferDriver()->copyFile($tmp, '.htaccess');
+ unlink($tmp);
+ }
+ }
+
public function getProtocols()
{
return parent::getProtocols() + ['hosting' => 'Hosting'];
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/cubist_net.git",
- "reference": "f0203ae9addff45df5811cd5d68d64b77de829da"
+ "reference": "a67603800a93bde7294c450a99a862d2f51b219a"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-52aa4b.tar",
- "reference": "f0203ae9addff45df5811cd5d68d64b77de829da",
- "shasum": "1fc86d55ae26e48ea286a4fa0ac6e82cd1a09e0a"
+ "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-b429cc.tar",
+ "reference": "a67603800a93bde7294c450a99a862d2f51b219a",
+ "shasum": "f2a91449c8b133fc14b1130d4b7c1c55482c6bf0"
},
"require": {
"cubist/util": "dev-master",
}
],
"description": "net cubist composer package",
- "time": "2023-04-19T09:17:27+00:00"
+ "time": "2023-11-07T11:19:05+00:00"
},
{
"name": "cubist/pdf",
},
{
"name": "league/flysystem",
- "version": "3.18.0",
+ "version": "3.19.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
- "reference": "015633a05aee22490495159237a5944091d8281e"
+ "reference": "1b2aa10f2326e0351399b8ce68e287d8e9209a83"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/015633a05aee22490495159237a5944091d8281e",
- "reference": "015633a05aee22490495159237a5944091d8281e",
+ "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1b2aa10f2326e0351399b8ce68e287d8e9209a83",
+ "reference": "1b2aa10f2326e0351399b8ce68e287d8e9209a83",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
- "source": "https://github.com/thephpleague/flysystem/tree/3.18.0"
+ "source": "https://github.com/thephpleague/flysystem/tree/3.19.0"
},
"funding": [
{
"type": "github"
}
],
- "time": "2023-10-20T17:59:40+00:00"
+ "time": "2023-11-07T09:04:28+00:00"
},
{
"name": "league/flysystem-local",
- "version": "3.18.0",
+ "version": "3.19.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-local.git",
- "reference": "e7381ef7643f658b87efb7dbe98fe538fb1bbf32"
+ "reference": "8d868217f9eeb4e9a7320db5ccad825e9a7a4076"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e7381ef7643f658b87efb7dbe98fe538fb1bbf32",
- "reference": "e7381ef7643f658b87efb7dbe98fe538fb1bbf32",
+ "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/8d868217f9eeb4e9a7320db5ccad825e9a7a4076",
+ "reference": "8d868217f9eeb4e9a7320db5ccad825e9a7a4076",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/thephpleague/flysystem-local/issues",
- "source": "https://github.com/thephpleague/flysystem-local/tree/3.18.0"
+ "source": "https://github.com/thephpleague/flysystem-local/tree/3.19.0"
},
"funding": [
{
"type": "github"
}
],
- "time": "2023-10-19T20:07:13+00:00"
+ "time": "2023-11-06T20:35:28+00:00"
},
{
"name": "league/glide",
"ext-zlib": "*"
},
"platform-dev": [],
- "plugin-api-version": "2.6.0"
+ "plugin-api-version": "2.1.0"
}