common_cadline_libraries (CRM hardlock/db/users classes; upstream cadline_web/cadcommonlib), maintenance/ (ARCHLine.XP license backend; upstream cadline_web/maintenance), maintenance2/. Vetted live files (byte-truth); upstream repos in PROVENANCE.md. NOTE: could be git submodules — kept as live files for byte-fidelity. Signed-off-by: LÁZÁR Imre <imre@illusion.hu> Assisted-by: claude-code@claude-opus-4-8
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
$http_origin = $_SERVER['HTTP_ORIGIN'];
|
|
|
|
if ($http_origin == "https://crm.cadline.hu" || $http_origin == "https://www.archline.hu" || $http_origin == "https://secondary.cadline.hu") {
|
|
header("Access-Control-Allow-Origin: $http_origin");
|
|
} else {
|
|
header('Access-Control-Allow-Origin: https://www.archline.hu');
|
|
}
|
|
|
|
header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept');
|
|
|
|
$name = $_POST['name'];
|
|
$serverName = $_SERVER['SERVER_NAME'];
|
|
$primaryServers = array('secondary.dev.cadline.hu', 'www.archline.hu', 'www.archlinexp.com');
|
|
$secServers = array('secondary.cadline.hu');
|
|
$txtResult = '';
|
|
|
|
switch ($name) {
|
|
case 'activateSecondary':
|
|
if (in_array($serverName, $primaryServers))
|
|
$txtResult = 'Inactive';
|
|
|
|
if (in_array($serverName, $secServers))
|
|
$txtResult = 'Active';
|
|
break;
|
|
|
|
case 'activatePrimary':
|
|
if (in_array($serverName, $primaryServers))
|
|
$txtResult = 'Active';
|
|
|
|
if (in_array($serverName, $secServers))
|
|
$txtResult = 'Inactive';
|
|
break;
|
|
|
|
default:
|
|
die();
|
|
break;
|
|
}
|
|
|
|
if ($txtResult == '')
|
|
die();
|
|
|
|
$txtString = 'Success';
|
|
|
|
$filename = $_SERVER['DOCUMENT_ROOT'] . "/activateServer.txt";
|
|
$closed = file_put_contents($filename, $txtResult);
|
|
|
|
$i = 0;
|
|
|
|
while (!$closed && $i < 10) {
|
|
$closed = file_put_contents($filename, $txtResult);
|
|
$i++;
|
|
}
|
|
|
|
if (!$closed)
|
|
$txtString = 'Failed';
|
|
|
|
$result = new stdClass();
|
|
$result->message = $txtString;
|
|
|
|
echo json_encode($result);
|