Skip to content
Snippets Groups Projects
Verified Commit ba9e465b authored by Damien's avatar Damien
Browse files

FEAT #13694 TIME 1:10 Migrate custom xml

parent ba4d51bf
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
php ./migrateModulesConfig.php
php ./migrateNotificationsProperties.php
php ./migrateCustomXml.php # mettre en dernier
<?php
require '../../vendor/autoload.php';
chdir('../..');
$file = 'custom/custom.xml';
if (is_file($file)) {
if (!is_readable($file) || !is_writable($file)) {
printf("File custom/custom.xml is not readable or not writable.\n");
exit;
}
$loadedXml = simplexml_load_file($file);
$jsonFile = [];
if ($loadedXml) {
foreach ($loadedXml->custom as $value) {
$jsonFile[] = [
'id' => (string)$value->custom_id,
'ip' => (string)$value->ip,
'externalDomain' => (string)$value->external_domain,
'domain' => (string)$value->domain,
'path' => (string)$value->path
];
}
$jsonFile = json_encode($jsonFile);
file_put_contents('custom/custom.json', $jsonFile);
}
unlink($file);
printf("Fichier custom/custom.xml migré en fichier json.\n");
}
......@@ -31,7 +31,7 @@ class CoreConfigModel
return $customId;
}
if (!file_exists('custom/custom.xml') || empty($_SERVER['SCRIPT_NAME']) || empty($_SERVER['SERVER_ADDR'])) {
if (!is_file('custom/custom.json') || empty($_SERVER['SCRIPT_NAME']) || empty($_SERVER['SERVER_ADDR'])) {
$customId = '';
return $customId;
}
......@@ -40,16 +40,17 @@ class CoreConfigModel
$path = $explodeUrl[count($explodeUrl) - 3];
$xmlfile = simplexml_load_file('custom/custom.xml');
foreach ($xmlfile->custom as $value) {
if (!empty($value->path) && $value->path == $path) {
$customId = (string)$value->custom_id;
$jsonFile = file_get_contents('custom/custom.json');
$jsonFile = json_decode($jsonFile, true);
foreach ($jsonFile as $value) {
if (!empty($value['path']) && $value['path'] == $path) {
$customId = $value['id'];
return $customId;
} elseif ($value->ip == $_SERVER['SERVER_ADDR']) {
$customId = (string)$value->custom_id;
} elseif ($value['ip'] == $_SERVER['SERVER_ADDR']) {
$customId = $value['id'];
return $customId;
} elseif ($value->external_domain == $_SERVER['HTTP_HOST'] || $value->domain == $_SERVER['HTTP_HOST']) {
$customId = (string)$value->custom_id;
} elseif ($value['externalDomain'] == $_SERVER['HTTP_HOST'] || $value['domain'] == $_SERVER['HTTP_HOST']) {
$customId = $value['id'];
return $customId;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment