Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fb6c62f19c | |||
| 54f056ca5f | |||
| ad47b58ad3 | |||
| 7f1c132eb7 | |||
| 53eb3983f7 | |||
| cb52c3e44b | |||
| 302efae864 | |||
| e48061c252 | |||
| eacb6dff58 | |||
| 6a1fca0765 | |||
| 503b8a256c | |||
| 2ceadbd287 | |||
| 7fc1a58c3f | |||
| e0f111b3b3 | |||
| b106942423 | |||
| 3fcf74f311 | |||
| 41c383ca5a | |||
| 5f36244db1 | |||
| 782ff9e69d | |||
| 64ea65deba | |||
| ae5d2e52aa | |||
| 52da2c79d6 | |||
| 3900dcda2a | |||
| a36c59f6fb | |||
| 287ec5c477 | |||
| 009d37569f | |||
| 6c99ed7544 | |||
| 9b0b99b12a | |||
| c1bfbcceca | |||
| d3c7ff924a |
22
.env.example
22
.env.example
@@ -68,13 +68,23 @@ DOLIBARR_URL=
|
||||
LIBARR_USERNAME=
|
||||
DOLIBARR_PWD=
|
||||
|
||||
MAIL_ISPAPI_URL=
|
||||
MAIL_ISPAPI_USERNAME=
|
||||
MAIL_ISPAPI_PWD=
|
||||
# ISPConfig Mail Server
|
||||
ISPCONFIG_MAIL_SOAP_LOCATION=
|
||||
ISPCONFIG_MAIL_SOAP_URI=
|
||||
ISPCONFIG_MAIL_USERNAME=
|
||||
ISPCONFIG_MAIL_PASSWORD=
|
||||
|
||||
HOSTING_ISPAPI_URL=
|
||||
HOSTING_ISPAPI_USERNAME=
|
||||
HOSTING_ISPAPI_PWD=
|
||||
# ISPConfig Web Server
|
||||
ISPCONFIG_WEB_SOAP_LOCATION=
|
||||
ISPCONFIG_WEB_SOAP_URI=
|
||||
ISPCONFIG_WEB_USERNAME=
|
||||
ISPCONFIG_WEB_PASSWORD=
|
||||
|
||||
# ISPConfig Test server
|
||||
ISPCONFIG_TEST_SOAP_LOCATION=
|
||||
ISPCONFIG_TEST_SOAP_URI=
|
||||
ISPCONFIG_TEST_USERNAME=
|
||||
ISPCONFIG_TEST_PASSWORD=
|
||||
|
||||
#NEXTCLOUD_API_ID=
|
||||
#NEXCLOUD_API_PWD=
|
||||
|
||||
142
.gitea/workflows/deploy-preprod.yml
Normal file
142
.gitea/workflows/deploy-preprod.yml
Normal file
@@ -0,0 +1,142 @@
|
||||
name: Deploy Roxane to Preprod
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: docker
|
||||
|
||||
container:
|
||||
image: nebulaed/php83-node22
|
||||
|
||||
steps:
|
||||
- name: Install network & SSH tools
|
||||
run: |
|
||||
set -e
|
||||
apt update
|
||||
apt install -y iproute2 iputils-ping openssh-client git
|
||||
|
||||
- name: Show IPv6 network
|
||||
run: |
|
||||
ip -6 addr
|
||||
ip -6 route
|
||||
|
||||
- name: Ping IPv6 preprod server
|
||||
run: |
|
||||
ping6 -c 3 2a01:e0a:bfe:a8a0::205
|
||||
|
||||
- name: Configure SSH
|
||||
env:
|
||||
SSH_HOST: ${{ vars.PREPROD_HOST }}
|
||||
SSH_PORT: ${{ vars.PREPROD_PORT }}
|
||||
run: |
|
||||
set -e
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
|
||||
ssh-keyscan -6 -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts
|
||||
|
||||
echo "SSH_HOST_SSH=$SSH_HOST" >> "$GITEA_ENV"
|
||||
|
||||
- name: Deploy Roxane to preprod
|
||||
env:
|
||||
SSH_USER: ${{ vars.PREPROD_USER }}
|
||||
SSH_PORT: ${{ vars.PREPROD_PORT }}
|
||||
PREPROD_PATH: ${{ vars.PREPROD_PATH }}
|
||||
GIT_REPO: ${{ vars.GIT_REPO }}
|
||||
run: |
|
||||
set -e
|
||||
|
||||
ssh -6 -o StrictHostKeyChecking=yes \
|
||||
-o ConnectTimeout=10 \
|
||||
-o ServerAliveInterval=60 \
|
||||
-p "$SSH_PORT" \
|
||||
"$SSH_USER@$SSH_HOST_SSH" bash -l -s <<'EOF' "$PREPROD_PATH" "$GIT_REPO"
|
||||
set -e
|
||||
|
||||
PREPROD_PATH="$1"
|
||||
GIT_REPO="$2"
|
||||
|
||||
# Vérifier si le dépôt existe, sinon le cloner
|
||||
if [ ! -d "$PREPROD_PATH/.git" ]; then
|
||||
echo "[!] Repository not found. Cloning from $GIT_REPO..."
|
||||
mkdir -p "$(dirname "$PREPROD_PATH")"
|
||||
git clone "$GIT_REPO" "$PREPROD_PATH"
|
||||
cd "$PREPROD_PATH"
|
||||
git checkout release
|
||||
else
|
||||
cd "$PREPROD_PATH"
|
||||
git config --global --add safe.directory "$PREPROD_PATH" 2>/dev/null || true
|
||||
|
||||
echo "[>>] Pulling latest Roxane release..."
|
||||
git fetch origin
|
||||
git checkout release
|
||||
git reset --hard origin/release
|
||||
git clean -fd # Nettoyer les fichiers non trackés
|
||||
fi
|
||||
|
||||
echo "[*] Installing Composer dependencies..."
|
||||
composer install --no-dev --optimize-autoloader --no-interaction --prefer-dist
|
||||
|
||||
echo "[~] Building frontend with Vite..."
|
||||
npm ci --prefer-offline
|
||||
npm run build
|
||||
|
||||
echo "[DB] Running database migrations..."
|
||||
php artisan migrate --force
|
||||
|
||||
echo "[++] Optimizing Roxane..."
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
php artisan event:cache
|
||||
|
||||
echo "[<>] Restarting queue workers..."
|
||||
php artisan queue:restart || true
|
||||
|
||||
echo "[OK] Roxane deployed successfully to preprod!"
|
||||
EOF
|
||||
|
||||
- name: Verify deployment
|
||||
if: success()
|
||||
env:
|
||||
SSH_USER: ${{ vars.PREPROD_USER }}
|
||||
SSH_PORT: ${{ vars.PREPROD_PORT }}
|
||||
PREPROD_PATH: ${{ vars.PREPROD_PATH }}
|
||||
run: |
|
||||
ssh -6 -o StrictHostKeyChecking=yes \
|
||||
-p "$SSH_PORT" \
|
||||
"$SSH_USER@$SSH_HOST_SSH" bash -l -s <<'EOF' "$PREPROD_PATH"
|
||||
set -e
|
||||
cd "$1"
|
||||
|
||||
echo "[?] Verifying deployment..."
|
||||
echo "Current branch: $(git branch --show-current)"
|
||||
echo "Last commit: $(git log -1 --oneline)"
|
||||
echo "Laravel version: $(php artisan --version)"
|
||||
EOF
|
||||
|
||||
- name: Cleanup on failure
|
||||
if: failure()
|
||||
env:
|
||||
SSH_USER: ${{ vars.PREPROD_USER }}
|
||||
SSH_PORT: ${{ vars.PREPROD_PORT }}
|
||||
PREPROD_PATH: ${{ vars.PREPROD_PATH }}
|
||||
run: |
|
||||
ssh -6 -o StrictHostKeyChecking=yes \
|
||||
-p "$SSH_PORT" \
|
||||
"$SSH_USER@$SSH_HOST_SSH" bash -l -s <<'EOF' "$PREPROD_PATH"
|
||||
cd "$1"
|
||||
|
||||
echo "[!!] Deployment failed. Rolling back optimizations..."
|
||||
php artisan config:clear || true
|
||||
php artisan route:clear || true
|
||||
php artisan view:clear || true
|
||||
php artisan cache:clear || true
|
||||
EOF
|
||||
89
app/Console/Commands/SyncISPConfigMailMembers.php
Normal file
89
app/Console/Commands/SyncISPConfigMailMembers.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\IspconfigType;
|
||||
use App\Models\IspconfigMember;
|
||||
use App\Models\Member;
|
||||
use App\Services\ISPConfig\ISPConfigMailService;
|
||||
use Illuminate\Console\Command;
|
||||
use function Laravel\Prompts\progress;
|
||||
|
||||
class SyncISPConfigMailMembers extends Command
|
||||
{
|
||||
protected $signature = 'sync:ispconfig-mail-members';
|
||||
protected $description = 'Synchronise les services MAIL ISPConfig des membres - Email Retzien';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Synchronisation ISPConfig MAIL');
|
||||
|
||||
$ispMail = new ISPConfigMailService();
|
||||
|
||||
//Récupération de tous les mail users
|
||||
$mailUsers = collect($ispMail->getAllMailUsers());
|
||||
|
||||
$progressBar = progress(label: 'ISPConfig Mail Members import', steps: $mailUsers->count());
|
||||
$progressBar->start();
|
||||
|
||||
$emailToMailUserId = $mailUsers
|
||||
->filter(fn ($u) => isset($u['email'], $u['mailuser_id']))
|
||||
->mapWithKeys(fn ($u) => [
|
||||
strtolower($u['email']) => (int) $u['mailuser_id'],
|
||||
]);
|
||||
|
||||
$synced = 0;
|
||||
|
||||
// Parcours des membres
|
||||
Member::whereNotNull('email')->chunk(100, function ($members) use (
|
||||
$progressBar,
|
||||
$emailToMailUserId,
|
||||
$ispMail,
|
||||
&$synced
|
||||
) {
|
||||
foreach ($members as $member) {
|
||||
$emails = array_map('trim', explode(';', $member->email));
|
||||
|
||||
$retzienEmail = collect($emails)
|
||||
->map(fn ($e) => strtolower($e))
|
||||
->first(fn ($e) => str_ends_with($e, '@retzien.fr'));
|
||||
|
||||
if (!$retzienEmail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mailUserId = $emailToMailUserId->get($retzienEmail);
|
||||
|
||||
if (!$mailUserId) {
|
||||
$this->warn("Aucun mail user ISPConfig pour {$retzienEmail}");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Récupération des données complètes de la boîte mail
|
||||
$mailUserData = $ispMail->getMailUserDetails($retzienEmail);
|
||||
|
||||
// Création / mise à jour
|
||||
IspconfigMember::updateOrCreate(
|
||||
[
|
||||
'member_id' => $member->id,
|
||||
//@todo : 'ispconfig_client_id' => ?,
|
||||
'type' => IspconfigType::MAIL,
|
||||
'email' => $retzienEmail,
|
||||
],
|
||||
[
|
||||
'ispconfig_service_user_id' => $mailUserId,
|
||||
'data' => [
|
||||
// @todo: traiter plus tard le cas de plusieurs mail pour un adhérent
|
||||
'mailuser' => [$mailUserData],
|
||||
],
|
||||
]
|
||||
);
|
||||
$synced++;
|
||||
$progressBar->advance();
|
||||
}
|
||||
});
|
||||
|
||||
$progressBar->finish();
|
||||
$this->info("{$synced} services mail synchronisés");
|
||||
}
|
||||
}
|
||||
226
app/Console/Commands/SyncISPConfigWebMembers.php
Normal file
226
app/Console/Commands/SyncISPConfigWebMembers.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\IspconfigType;
|
||||
use App\Models\IspconfigMember;
|
||||
use App\Models\Member;
|
||||
use App\Services\ISPConfig\ISPConfigWebService;
|
||||
use Illuminate\Console\Command;
|
||||
use function Laravel\Prompts\progress;
|
||||
|
||||
class SyncISPConfigWebMembers extends Command
|
||||
{
|
||||
protected $signature = 'sync:ispconfig-web-members {--refresh-cache : Vider le cache avant la synchronisation}';
|
||||
protected $description = 'Synchronise les services WEB ISPConfig des membres (via member->website_url)';
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//@todo: Retrouver le client_id pour chaque adhérent
|
||||
|
||||
$this->info('Synchronisation ISPConfig WEB (via member->website_url)');
|
||||
|
||||
$ispWeb = new ISPConfigWebService();
|
||||
|
||||
// Vider le cache si demandé
|
||||
if ($this->option('refresh-cache')) {
|
||||
$this->info('Vidage du cache ISPConfig...');
|
||||
$ispWeb->clearAllCache();
|
||||
}
|
||||
|
||||
// Récupération de toutes les données ISPConfig en une seule fois (avec cache)
|
||||
$this->info('Chargement des données ISPConfig...');
|
||||
$allWebsites = collect($ispWeb->getAllWebsites());
|
||||
$allDatabases = collect($ispWeb->getAllDatabases());
|
||||
$allFtpUsers = collect($ispWeb->getAllFtpUsers());
|
||||
$allShellUsers = collect($ispWeb->getAllShellUsers());
|
||||
$allDnsZones = collect($ispWeb->getAllDnsZones());
|
||||
|
||||
$progressBar = progress(
|
||||
label: 'ISPConfig Web Members import',
|
||||
steps: Member::whereNotNull('website_url')->count()
|
||||
);
|
||||
|
||||
$progressBar->start();
|
||||
|
||||
// Parcours des membres
|
||||
Member::whereNotNull('website_url')->chunk(100, function ($members) use (
|
||||
$allWebsites,
|
||||
$allDatabases,
|
||||
$allFtpUsers,
|
||||
$allShellUsers,
|
||||
$allDnsZones,
|
||||
$ispWeb,
|
||||
$progressBar
|
||||
) {
|
||||
foreach ($members as $member) {
|
||||
|
||||
// Extraction des domaines depuis website_url
|
||||
$memberDomains = collect(explode(';', $member->website_url))
|
||||
->map(fn($url) => $this->normalizeDomain($url))
|
||||
->filter()
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
if ($memberDomains->isEmpty()) {
|
||||
$progressBar->advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recherche des sites ISPConfig correspondants
|
||||
$matchedWebsites = $allWebsites->filter(function ($site) use ($memberDomains, $ispWeb) {
|
||||
$siteDomain = strtolower($site['domain']);
|
||||
|
||||
// Vérification du domaine principal
|
||||
if ($memberDomains->contains($siteDomain)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Récupération et vérification des alias (avec cache)
|
||||
$aliases = $ispWeb->getWebsiteAliases($site['domain_id']);
|
||||
foreach ($aliases as $alias) {
|
||||
if ($memberDomains->contains(strtolower($alias))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($matchedWebsites->isEmpty()) {
|
||||
$progressBar->advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Construction des données pour chaque site
|
||||
$sitesData = $matchedWebsites->map(function ($site) use (
|
||||
$allDatabases,
|
||||
$allFtpUsers,
|
||||
$allShellUsers,
|
||||
$allDnsZones,
|
||||
$ispWeb
|
||||
) {
|
||||
$domainId = $site['domain_id'];
|
||||
$sysGroupId = $site['sys_groupid'];
|
||||
$domain = $site['domain'];
|
||||
|
||||
// Récupération des alias (avec cache)
|
||||
$aliases = $ispWeb->getWebsiteAliases($domainId);
|
||||
|
||||
// Filtrage des bases de données pour ce site
|
||||
$databases = $allDatabases
|
||||
->filter(fn($db) => $db['sys_groupid'] == $sysGroupId)
|
||||
->map(fn($db) => [
|
||||
'database_id' => $db['database_id'],
|
||||
'database_name' => $db['database_name'],
|
||||
'database_user_id' => $db['database_user_id'],
|
||||
'database_type' => $db['type'],
|
||||
])
|
||||
->values();
|
||||
|
||||
// Filtrage des utilisateurs FTP pour ce site
|
||||
$ftpUsers = $allFtpUsers
|
||||
->filter(fn($ftp) => $ftp['parent_domain_id'] == $domainId)
|
||||
->map(fn($ftp) => [
|
||||
'ftp_user_id' => $ftp['ftp_user_id'],
|
||||
'username' => $ftp['username'],
|
||||
'dir' => $ftp['dir'],
|
||||
])
|
||||
->values();
|
||||
|
||||
// Filtrage des utilisateurs Shell pour ce site
|
||||
$shellUsers = $allShellUsers
|
||||
->filter(fn($shell) => $shell['parent_domain_id'] == $domainId)
|
||||
->map(fn($shell) => [
|
||||
'shell_user_id' => $shell['shell_user_id'],
|
||||
'username' => $shell['username'],
|
||||
'shell' => $shell['shell'],
|
||||
'chroot' => $shell['chroot'],
|
||||
])
|
||||
->values();
|
||||
|
||||
// Filtrage des zones DNS pour ce site
|
||||
// Le champ 'origin' de la zone DNS correspond au domaine avec un point final
|
||||
$dnsZones = $allDnsZones
|
||||
->filter(function ($zone) use ($domain, $aliases) {
|
||||
// Normalisation : retirer le point final de l'origin pour comparer
|
||||
$zoneOrigin = rtrim($zone['origin'], '.');
|
||||
|
||||
// Vérifier le domaine principal
|
||||
if (strtolower($zoneOrigin) === strtolower($domain)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Vérifier les alias
|
||||
foreach ($aliases as $alias) {
|
||||
if (strtolower($zoneOrigin) === strtolower($alias)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->map(fn($zone) => [
|
||||
'id' => $zone['id'],
|
||||
'origin' => $zone['origin'],
|
||||
'ns' => $zone['ns'],
|
||||
'active' => $zone['active'],
|
||||
'dnssec_wanted' => $zone['dnssec_wanted'] ?? null,
|
||||
'dnssec_initialized' => $zone['dnssec_initialized'] ?? null,
|
||||
])
|
||||
->values();
|
||||
|
||||
return [
|
||||
'domain_id' => $domainId,
|
||||
'domain' => $domain,
|
||||
'document_root' => $site['document_root'],
|
||||
'active' => $site['active'],
|
||||
'aliases' => $aliases,
|
||||
'databases' => $databases,
|
||||
'ftp_users' => $ftpUsers,
|
||||
'shell_users' => $shellUsers,
|
||||
'dns_zones' => $dnsZones,
|
||||
];
|
||||
});
|
||||
|
||||
// Création/mise à jour d'un enregistrement par site
|
||||
foreach ($sitesData as $siteData) {
|
||||
IspconfigMember::updateOrCreate(
|
||||
[
|
||||
'member_id' => $member->id,
|
||||
'type' => IspconfigType::WEB,
|
||||
'ispconfig_service_user_id' => $siteData['domain_id'],
|
||||
],
|
||||
[
|
||||
'data' => $siteData,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$progressBar->advance();
|
||||
}
|
||||
});
|
||||
|
||||
$progressBar->finish();
|
||||
$this->info('Synchronisation WEB terminée');
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalise une URL vers un domaine
|
||||
*/
|
||||
private function normalizeDomain(string $url): ?string
|
||||
{
|
||||
$url = trim($url);
|
||||
|
||||
if (!str_starts_with($url, 'http')) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
$host = parse_url($url, PHP_URL_HOST);
|
||||
|
||||
return $host ? strtolower($host) : null;
|
||||
}
|
||||
}
|
||||
19
app/Enums/IspconfigType.php
Normal file
19
app/Enums/IspconfigType.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum IspconfigType: string
|
||||
{
|
||||
case MAIL = 'mail';
|
||||
case WEB = 'web';
|
||||
case OTHER = 'other';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::MAIL => 'Email',
|
||||
self::WEB => 'Hébergement',
|
||||
self::OTHER => 'Autre',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\Layout\Split;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
|
||||
|
||||
class MemberForm
|
||||
{
|
||||
@@ -91,6 +91,41 @@ class MemberForm
|
||||
->label(Member::getAttributeLabel('country')),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Messagerie ISPConfig Retzien')
|
||||
->schema([
|
||||
TextEntry::make('isp_mail_email')
|
||||
->label('Adresse email')
|
||||
->state(fn (?Member $record) =>
|
||||
$record?->ispconfigMail()?->email ?? '—'
|
||||
),
|
||||
|
||||
TextEntry::make('isp_mail_user_id')
|
||||
->label('ID utilisateur ISPConfig (mailuser_id)')
|
||||
->state(fn (?Member $record) =>
|
||||
$record?->ispconfigMail()?->ispconfig_service_user_id ?? '—'
|
||||
),
|
||||
|
||||
TextEntry::make('isp_mail_quota')
|
||||
->label('Quota')
|
||||
->state(function (?Member $record) {
|
||||
$quota = $record?->ispconfigMail()?->data['mailuser']['quota'] ?? null;
|
||||
|
||||
return $quota
|
||||
? "{$quota} Mo"
|
||||
: 'Non défini';
|
||||
}),
|
||||
|
||||
TextEntry::make('isp_mail_domain')
|
||||
->label('Domaine')
|
||||
->state(fn (?Member $record) =>
|
||||
$record?->ispconfigMail()?->data['mailuser']['domain'] ?? 'retzien.fr'
|
||||
),
|
||||
])
|
||||
->columns(2)
|
||||
->visible(fn (?Member $record) =>
|
||||
$record?->ispconfigMail() !== null
|
||||
),
|
||||
])
|
||||
->columnSpan(3),
|
||||
Grid::make(1)
|
||||
|
||||
@@ -9,7 +9,7 @@ use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
|
||||
31
app/Models/IspconfigMember.php
Normal file
31
app/Models/IspconfigMember.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IspconfigType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class IspconfigMember extends Model
|
||||
{
|
||||
protected $table = 'ispconfigs_members';
|
||||
|
||||
protected $fillable = [
|
||||
'member_id',
|
||||
'ispconfig_client_id',
|
||||
'ispconfig_service_user_id',
|
||||
'email',
|
||||
'type',
|
||||
'data',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'type' => IspconfigType::class,
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
public function member(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Member::class);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IspconfigType;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -122,4 +123,23 @@ class Member extends Model
|
||||
{
|
||||
return $this->hasMany(Membership::class);
|
||||
}
|
||||
|
||||
public function ispconfigs(): HasMany
|
||||
{
|
||||
return $this->hasMany(IspconfigMember::class, 'member_id');
|
||||
}
|
||||
|
||||
public function ispconfigMail(): ?IspconfigMember
|
||||
{
|
||||
return $this->ispconfigs()
|
||||
->where('type', IspconfigType::MAIL)
|
||||
->first();
|
||||
}
|
||||
|
||||
public function ispconfigWeb(): ?IspconfigMember
|
||||
{
|
||||
return $this->ispconfigs()
|
||||
->where('type', IspconfigType::WEB)
|
||||
->first();
|
||||
}
|
||||
}
|
||||
|
||||
90
app/Services/ISPConfig/ISPConfigMailService.php
Normal file
90
app/Services/ISPConfig/ISPConfigMailService.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ISPConfig;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ISPConfigMailService extends ISPConfigService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('mail_server');
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère tous les domaines mail
|
||||
*/
|
||||
public function getAllMailDomains(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.mail.domains.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('mail_domain_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère tous les utilisateurs mail
|
||||
*/
|
||||
public function getAllMailUsers(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.mail.users.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('mail_user_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les domaines mail d'un client ISPConfig
|
||||
*/
|
||||
public function getMailDomainsForClient(int $ispConfigClientId): Collection
|
||||
{
|
||||
$allDomains = $this->getAllMailDomains();
|
||||
|
||||
return collect($allDomains)->filter(function ($domain) use ($ispConfigClientId) {
|
||||
return isset($domain['sys_groupid']) && $domain['sys_groupid'] == $ispConfigClientId;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les boîtes mail pour un domaine
|
||||
*/
|
||||
public function getMailUsersForDomain(string $domain): Collection
|
||||
{
|
||||
$allUsers = $this->getAllMailUsers();
|
||||
|
||||
return collect($allUsers)->filter(function ($user) use ($domain) {
|
||||
return str_ends_with($user['email'], '@' . $domain);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les détails d'une boîte mail
|
||||
*/
|
||||
public function getMailUserDetails(string $email): ?array
|
||||
{
|
||||
$allUsers = $this->getAllMailUsers();
|
||||
|
||||
$user = collect($allUsers)->firstWhere('email', $email);
|
||||
|
||||
if (!$user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'email' => $user['email'],
|
||||
'name' => $user['name'] ?? '',
|
||||
'quota' => (int) ($user['quota'] ?? 0),
|
||||
'usage' => (int) ($user['maildir_usage'] ?? 0),
|
||||
'usage_mb' => round(($user['maildir_usage'] ?? 0) / 1024 / 1024, 2),
|
||||
'active' => $user['postfix'] === 'y',
|
||||
'imap_enabled' => $user['disableimap'] === 'n',
|
||||
'pop3_enabled' => $user['disablepop3'] === 'n',
|
||||
'smtp_enabled' => $user['disablesmtp'] === 'n',
|
||||
'autoresponder' => $user['autoresponder'] === 'y',
|
||||
'spam_filter' => $user['move_junk'] === 'y',
|
||||
];
|
||||
}
|
||||
}
|
||||
139
app/Services/ISPConfig/ISPConfigService.php
Normal file
139
app/Services/ISPConfig/ISPConfigService.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ISPConfig;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use SoapClient;
|
||||
use SoapFault;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ISPConfigService
|
||||
{
|
||||
protected ?SoapClient $client = null;
|
||||
protected ?string $sessionId = null;
|
||||
protected array $config;
|
||||
protected string $serverType;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(string $serverType = 'mail_server')
|
||||
{
|
||||
$this->serverType = $serverType;
|
||||
$this->config = config("services.ispconfig.servers.{$serverType}");
|
||||
|
||||
if (!$this->config) {
|
||||
throw new Exception("ISPConfig server configuration not found for: {$serverType}");
|
||||
}
|
||||
}
|
||||
|
||||
protected function connect(): void
|
||||
{
|
||||
if ($this->client !== null && $this->sessionId !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->client = new SoapClient(null, [
|
||||
'location' => $this->config['soap_location'],
|
||||
'uri' => $this->config['soap_uri'],
|
||||
'trace' => 1,
|
||||
'exceptions' => 1,
|
||||
'stream_context' => stream_context_create([
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
]
|
||||
])
|
||||
]);
|
||||
|
||||
$this->sessionId = $this->client->login(
|
||||
$this->config['username'],
|
||||
$this->config['password']
|
||||
);
|
||||
|
||||
Log::info("ISPConfig connected", [
|
||||
'server' => $this->serverType,
|
||||
'session_id' => $this->sessionId
|
||||
]);
|
||||
|
||||
} catch (SoapFault $e) {
|
||||
Log::error("ISPConfig connection failed", [
|
||||
'server' => $this->serverType,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
throw new Exception("Failed to connect to ISPConfig: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function disconnect(): void
|
||||
{
|
||||
if ($this->client && $this->sessionId) {
|
||||
try {
|
||||
$this->client->logout($this->sessionId);
|
||||
Log::info("ISPConfig disconnected", ['server' => $this->serverType]);
|
||||
} catch (SoapFault $e) {
|
||||
Log::warning("ISPConfig logout failed", [
|
||||
'server' => $this->serverType,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
$this->sessionId = null;
|
||||
$this->client = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function call(string $method, array $params = []): mixed
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
try {
|
||||
array_unshift($params, $this->sessionId);
|
||||
|
||||
$result = $this->client->__soapCall($method, $params);
|
||||
|
||||
Log::debug("ISPConfig API call", [
|
||||
'method' => $method,
|
||||
'server' => $this->serverType,
|
||||
'success' => true
|
||||
]);
|
||||
|
||||
return $result;
|
||||
|
||||
} catch (SoapFault $e) {
|
||||
Log::error("ISPConfig API call failed", [
|
||||
'method' => $method,
|
||||
'server' => $this->serverType,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
throw new Exception("ISPConfig API call failed: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère tous les clients
|
||||
*/
|
||||
public function getAllClients(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.mail.clients.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('client_get_all')
|
||||
);
|
||||
}
|
||||
|
||||
public function getClientData(string $clientId): array
|
||||
{
|
||||
return $this->call('client_get', ['client_id' => $clientId]);
|
||||
}
|
||||
}
|
||||
266
app/Services/ISPConfig/ISPConfigWebService.php
Normal file
266
app/Services/ISPConfig/ISPConfigWebService.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ISPConfig;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ISPConfigWebService extends ISPConfigService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('web_server');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAllWebsites(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.websites.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('sites_web_domain_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAllDatabases(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.databases.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('sites_database_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAllFtpUsers(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.ftp.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('sites_ftp_user_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAllShellUsers(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.shell.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('sites_shell_user_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAllDnsZones(): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.dns-zones.all",
|
||||
config('services.ispconfig.cache_ttl'),
|
||||
fn() => $this->call('dns_zone_get', ['primary_id' => -1])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la liste des alias d'un site web
|
||||
*
|
||||
* @param int $domainId
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getWebsiteAliases(int $domainId): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.aliases.{$domainId}",
|
||||
config('services.ispconfig.cache_ttl', 3600),
|
||||
function () use ($domainId) {
|
||||
try {
|
||||
$siteInfo = $this->call('sites_web_domain_get', ['domain_id' => $domainId]);
|
||||
|
||||
if (empty($siteInfo)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$site = $siteInfo;
|
||||
|
||||
if (empty($site['alias'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$aliases = array_map('trim', explode(',', $site['alias']));
|
||||
return array_values(array_filter($aliases, fn($alias) => !empty($alias)));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Erreur lors de la récupération des alias pour le domaine {$domainId}: " . $e->getMessage());
|
||||
return [];
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la liste des bases de données d'un site en filtrant depuis toutes les BDD
|
||||
*
|
||||
* @param int $sysGroupId
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getWebsiteDatabases(int $sysGroupId): array
|
||||
{
|
||||
// Récupération de toutes les bases de données
|
||||
$allDatabases = $this->getAllDatabases();
|
||||
|
||||
// Filtrage par sys_groupid
|
||||
return collect($allDatabases)
|
||||
->filter(fn($db) => $db['sys_groupid'] == $sysGroupId)
|
||||
->map(fn($db) => [
|
||||
'database_id' => $db['database_id'],
|
||||
'database_name' => $db['database_name'],
|
||||
'database_user' => $db['database_user'],
|
||||
'database_type' => $db['type'],
|
||||
'active' => $db['active'],
|
||||
'remote_access' => $db['remote_access'],
|
||||
'remote_ips' => $db['remote_ips'] ?? ''
|
||||
])
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la liste des utilisateurs FTP d'un site en filtrant depuis tous les comptes FTP
|
||||
*
|
||||
* @param int $domainId
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getWebsiteFtpUsers(int $domainId): array
|
||||
{
|
||||
// Récupération de tous les utilisateurs FTP
|
||||
$allFtpUsers = $this->getAllFtpUsers();
|
||||
|
||||
// Filtrage par parent_domain_id
|
||||
return collect($allFtpUsers)
|
||||
->filter(fn($ftp) => $ftp['parent_domain_id'] == $domainId)
|
||||
->map(fn($ftp) => [
|
||||
'ftp_user_id' => $ftp['ftp_user_id'],
|
||||
'username' => $ftp['username'],
|
||||
'dir' => $ftp['dir'],
|
||||
'quota_size' => $ftp['quota_size'],
|
||||
'active' => $ftp['active'],
|
||||
'uid' => $ftp['uid'],
|
||||
'gid' => $ftp['gid']
|
||||
])
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la liste des utilisateurs Shell d'un site en filtrant depuis tous les comptes Shell
|
||||
*
|
||||
* @param int $domainId
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getWebsiteShellUsers(int $domainId): array
|
||||
{
|
||||
// Récupération de tous les utilisateurs Shell (avec cache)
|
||||
$allShellUsers = $this->getAllShellUsers();
|
||||
|
||||
// Filtrage par parent_domain_id
|
||||
return collect($allShellUsers)
|
||||
->filter(fn($shell) => $shell['parent_domain_id'] == $domainId)
|
||||
->map(fn($shell) => [
|
||||
'shell_user_id' => $shell['shell_user_id'],
|
||||
'username' => $shell['username'],
|
||||
'dir' => $shell['dir'],
|
||||
'shell' => $shell['shell'],
|
||||
'puser' => $shell['puser'],
|
||||
'pgroup' => $shell['pgroup'],
|
||||
'quota_size' => $shell['quota_size'],
|
||||
'active' => $shell['active'],
|
||||
'chroot' => $shell['chroot'],
|
||||
'ssh_rsa' => !empty($shell['ssh_rsa'])
|
||||
])
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère toutes les informations complètes d'un site (alias, BDD, FTP, Shell)
|
||||
*
|
||||
* @param int $domainId
|
||||
* @return array|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getWebsiteCompleteInfo(int $domainId): ?array
|
||||
{
|
||||
return Cache::remember(
|
||||
"ispconfig.web.complete.{$domainId}",
|
||||
config('services.ispconfig.cache_ttl', 3600),
|
||||
function () use ($domainId) {
|
||||
$siteInfo = $this->call('sites_web_domain_get', ['domain_id' => $domainId]);
|
||||
|
||||
if (empty($siteInfo)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$site = $siteInfo;
|
||||
|
||||
// Récupérer les alias
|
||||
$aliases = [];
|
||||
if (!empty($site['alias'])) {
|
||||
$aliases = array_values(array_filter(array_map('trim', explode(',', $site['alias']))));
|
||||
}
|
||||
|
||||
return [
|
||||
'domain_id' => $site['domain_id'],
|
||||
'domain' => $site['domain'],
|
||||
'document_root' => $site['document_root'],
|
||||
'active' => $site['active'],
|
||||
'sys_groupid' => $site['sys_groupid'],
|
||||
'aliases' => $aliases,
|
||||
'databases' => $this->getWebsiteDatabases($domainId, $site['sys_groupid']),
|
||||
'ftp_users' => $this->getWebsiteFtpUsers($domainId),
|
||||
'shell_users' => $this->getWebsiteShellUsers($domainId)
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vide le cache pour un domaine spécifique
|
||||
*
|
||||
* @param int $domainId
|
||||
* @return void
|
||||
*/
|
||||
public function clearDomainCache(int $domainId): void
|
||||
{
|
||||
Cache::forget("ispconfig.web.aliases.{$domainId}");
|
||||
Cache::forget("ispconfig.web.complete.{$domainId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Vide tout le cache ISPConfig Web
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clearAllCache(): void
|
||||
{
|
||||
Cache::forget("ispconfig.web.websites.all");
|
||||
Cache::forget("ispconfig.web.databases.all");
|
||||
Cache::forget("ispconfig.web.ftp.all");
|
||||
Cache::forget("ispconfig.web.shell.all");
|
||||
Cache::forget("ispconfig.web.dns-zones.all");
|
||||
Cache::forget("ispconfig.web.domain-alias.all");
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use SoapClient;
|
||||
use SoapFault;
|
||||
use Exception;
|
||||
|
||||
class ISPConfigService
|
||||
{
|
||||
protected ?SoapClient $client = null;
|
||||
protected ?string $sessionId = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* ISPConfig Login
|
||||
*/
|
||||
public function connect(string $type): void
|
||||
{
|
||||
// Type = 'hosting' or 'mailbox'
|
||||
$username = $username ?? config('services.ispconfig'.$type.'.username');
|
||||
$password = $password ?? config('services.ispconfig'.$type.'.password');
|
||||
|
||||
try {
|
||||
$this->client = new SoapClient(null, [
|
||||
'location' => config('services.ispconfig' . $type . '.base_url'),
|
||||
'trace' => true,
|
||||
'exceptions' => true,
|
||||
'stream_context' => stream_context_create([
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
]),
|
||||
]);
|
||||
|
||||
$this->sessionId = $this->client->login($username, $password);
|
||||
} catch (SoapFault $e) {
|
||||
throw new Exception("An error occurred : " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all clients
|
||||
*/
|
||||
public function getAllClients(string $username = null, string $password = null): array
|
||||
{
|
||||
if (!$this->sessionId) {
|
||||
$this->connect($username, $password);
|
||||
}
|
||||
|
||||
try {
|
||||
$clientIds = $this->client->client_get_all($this->sessionId);
|
||||
$clients = [];
|
||||
|
||||
foreach ($clientIds as $id) {
|
||||
$details = $this->client->client_get($this->sessionId, (int)$id);
|
||||
if (!empty($details)) {
|
||||
$clients[] = (array) $details;
|
||||
}
|
||||
}
|
||||
|
||||
return $clients;
|
||||
} catch (SoapFault $e) {
|
||||
throw new Exception("An error occurred : " . $e->getMessage());
|
||||
} finally {
|
||||
$this->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout
|
||||
*/
|
||||
public function disconnect(): void
|
||||
{
|
||||
if ($this->client && $this->sessionId) {
|
||||
try {
|
||||
$this->client->logout($this->sessionId);
|
||||
} catch (SoapFault $e) {
|
||||
Log::info('ISP Config logout succeeded');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,15 @@ use App\Events\MemberRegistered;
|
||||
use App\Models\Member;
|
||||
use App\Models\MemberGroup;
|
||||
use App\Models\Package;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class MemberService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// No repositories used in this project
|
||||
}
|
||||
|
||||
public function registerNewMember(array $data): Member
|
||||
{
|
||||
// Check if the member already exists
|
||||
$member = Member::where('email', $data['email'])->first();
|
||||
|
||||
if (! $member) {
|
||||
if (!$member) {
|
||||
// Create a new member
|
||||
$member = new Member();
|
||||
$member->status = 'pending';
|
||||
|
||||
@@ -41,18 +41,31 @@ return [
|
||||
'password' => env('DOLIBARR_PWD'),
|
||||
'api_key' => env('DOLIBARR_APIKEY')
|
||||
],
|
||||
|
||||
'ispconfig' => [
|
||||
'hosting' => [
|
||||
'base_url' => env('HOSTING_ISPAPI_URL'),
|
||||
'username' => env('HOSTING_ISPAPI_USERNAME'),
|
||||
'password' => env('HOSTING_ISPAPI_PWD'),
|
||||
'servers' => [
|
||||
'mail_server' => [
|
||||
'name' => 'ISP Config Mail',
|
||||
'soap_location' => env('ISPCONFIG_MAIL_SOAP_LOCATION'),
|
||||
'soap_uri' => env('ISPCONFIG_MAIL_SOAP_URI'),
|
||||
'username' => env('ISPCONFIG_MAIL_USERNAME'),
|
||||
'password' => env('ISPCONFIG_MAIL_PASSWORD'),
|
||||
],
|
||||
'web_server' => [
|
||||
'name' => 'ISP Config Web',
|
||||
'soap_location' => env('ISPCONFIG_WEB_SOAP_LOCATION'),
|
||||
'soap_uri' => env('ISPCONFIG_WEB_SOAP_URI'),
|
||||
'username' => env('ISPCONFIG_WEB_USERNAME'),
|
||||
'password' => env('ISPCONFIG_WEB_PASSWORD'),
|
||||
],
|
||||
'test_server' => [
|
||||
'name' => 'ISP Config TEST',
|
||||
'soap_location' => env('ISPCONFIG_TEST_SOAP_LOCATION'),
|
||||
'soap_uri' => env('ISPCONFIG_TEST_SOAP_URI'),
|
||||
'username' => env('ISPCONFIG_TEST_USERNAME'),
|
||||
'password' => env('ISPCONFIG_TEST_PASSWORD'),
|
||||
],
|
||||
],
|
||||
'cache_ttl' => env('ISPCONFIG_CACHE_TTL', 300), // 5 minutes
|
||||
],
|
||||
'mailbox' => [
|
||||
'base_url' => env('MAIL_ISPAPI_URL'),
|
||||
'username' => env('MAIL_ISPAPI_USERNAME'),
|
||||
'password' => env('MAIL_ISPAPI_PWD'),
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ispconfigs_members', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('member_id')->constrained('members')->onDelete('NO ACTION');
|
||||
$table->string('ispconfig_client_id')->nullable();
|
||||
$table->string('ispconfig_service_user_id')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->enum('type', ['mail', 'web', 'other']);
|
||||
$table->json('data')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ispconfigs_members');
|
||||
}
|
||||
};
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "roxane",
|
||||
"name": "app",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
29
resources/js/pages/maintenance.tsx
Normal file
29
resources/js/pages/maintenance.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
|
||||
export default function MaintenancePage() {
|
||||
const [dark, setDark] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (dark) {
|
||||
document.documentElement.classList.add("dark");
|
||||
} else {
|
||||
document.documentElement.classList.remove("dark");
|
||||
}
|
||||
}, [dark]);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col items-center justify-center bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 p-6 transition-colors duration-300">
|
||||
<button
|
||||
onClick={() => setDark(!dark)}
|
||||
className="absolute top-4 right-4 px-3 py-1 rounded-xl border border-gray-400 dark:border-gray-600 hover:bg-gray-200 dark:hover:bg-gray-800 transition"
|
||||
>
|
||||
{dark ? "☀️ Mode clair" : "🌙 Mode sombre"}
|
||||
</button>
|
||||
|
||||
<h1 className="text-4xl font-bold mb-4 text-center">Site en cours de construction</h1>
|
||||
<p className="text-lg text-center max-w-xl">
|
||||
Le Retzien Libre se refait une beauté. Le site sera visible très bientôt.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ logout.form = logoutForm
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
export const home = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
url: home.url(options),
|
||||
@@ -147,12 +147,12 @@ export const home = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
|
||||
home.definition = {
|
||||
methods: ["get","head"],
|
||||
url: '/',
|
||||
url: '/welcome',
|
||||
} satisfies RouteDefinition<["get","head"]>
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
home.url = (options?: RouteQueryOptions) => {
|
||||
return home.definition.url + queryParams(options)
|
||||
@@ -160,7 +160,7 @@ home.url = (options?: RouteQueryOptions) => {
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
home.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
url: home.url(options),
|
||||
@@ -169,7 +169,7 @@ home.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
home.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
|
||||
url: home.url(options),
|
||||
@@ -178,7 +178,7 @@ home.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
const homeForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
action: home.url(options),
|
||||
@@ -187,7 +187,7 @@ const homeForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
homeForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
action: home.url(options),
|
||||
@@ -196,7 +196,7 @@ homeForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
|
||||
/**
|
||||
* @see routes/web.php:6
|
||||
* @route '/'
|
||||
* @route '/welcome'
|
||||
*/
|
||||
homeForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
action: home.url({
|
||||
@@ -211,7 +211,81 @@ homeForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
home.form = homeForm
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
export const maintenance = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
url: maintenance.url(options),
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
maintenance.definition = {
|
||||
methods: ["get","head"],
|
||||
url: '/',
|
||||
} satisfies RouteDefinition<["get","head"]>
|
||||
|
||||
/**
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
maintenance.url = (options?: RouteQueryOptions) => {
|
||||
return maintenance.definition.url + queryParams(options)
|
||||
}
|
||||
|
||||
/**
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
maintenance.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
url: maintenance.url(options),
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
maintenance.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
|
||||
url: maintenance.url(options),
|
||||
method: 'head',
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
const maintenanceForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
action: maintenance.url(options),
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
maintenanceForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
action: maintenance.url(options),
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:10
|
||||
* @route '/'
|
||||
*/
|
||||
maintenanceForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
action: maintenance.url({
|
||||
[options?.mergeQuery ? 'mergeQuery' : 'query']: {
|
||||
_method: 'HEAD',
|
||||
...(options?.query ?? options?.mergeQuery ?? {}),
|
||||
}
|
||||
}),
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
maintenance.form = maintenanceForm
|
||||
|
||||
/**
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
export const dashboard = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
@@ -225,7 +299,7 @@ dashboard.definition = {
|
||||
} satisfies RouteDefinition<["get","head"]>
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
dashboard.url = (options?: RouteQueryOptions) => {
|
||||
@@ -233,7 +307,7 @@ dashboard.url = (options?: RouteQueryOptions) => {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
dashboard.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
@@ -242,7 +316,7 @@ dashboard.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
dashboard.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
|
||||
@@ -251,7 +325,7 @@ dashboard.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
const dashboardForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
@@ -260,7 +334,7 @@ const dashboardForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'>
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
dashboardForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
@@ -269,7 +343,7 @@ dashboardForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> =>
|
||||
})
|
||||
|
||||
/**
|
||||
* @see routes/web.php:11
|
||||
* @see routes/web.php:15
|
||||
* @route '/dashboard'
|
||||
*/
|
||||
dashboardForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
|
||||
|
||||
@@ -3,16 +3,41 @@
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inertia\Inertia;
|
||||
|
||||
Route::get('/', function () {
|
||||
Route::get('/welcome', function () {
|
||||
return Inertia::render('welcome');
|
||||
})->name('home');
|
||||
|
||||
Route::get('/', function () {
|
||||
return Inertia::render('maintenance');
|
||||
})->name('maintenance');
|
||||
|
||||
Route::middleware(['auth', 'verified'])->group(function () {
|
||||
Route::get('dashboard', function () {
|
||||
return Inertia::render('dashboard');
|
||||
})->name('dashboard');
|
||||
});
|
||||
|
||||
// TEST
|
||||
|
||||
Route::get('/test/sync-ispconfig', function () {
|
||||
|
||||
if (!app()->isLocal()) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
Artisan::call('sync:ispconfig-web-members');
|
||||
|
||||
return response()->json([
|
||||
'status' => 'ok',
|
||||
'output' => Artisan::output(),
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/test/isp-mails', function() {
|
||||
$ispService = new \App\Services\ISPConfig\ISPConfigMailService;
|
||||
|
||||
return $ispService->getAllMailDomains();
|
||||
});
|
||||
|
||||
require __DIR__.'/settings.php';
|
||||
require __DIR__.'/auth.php';
|
||||
|
||||
Reference in New Issue
Block a user