From 529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105 Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 24 Aug 2021 15:38:16 +0200 Subject: Update --- Neutron-trunk/api/setup/check.php | 30 ++++++++ Neutron-trunk/api/setup/defaultHomepage.html | 1 + Neutron-trunk/api/setup/push.php | 105 +++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 Neutron-trunk/api/setup/check.php create mode 100644 Neutron-trunk/api/setup/defaultHomepage.html create mode 100644 Neutron-trunk/api/setup/push.php (limited to 'Neutron-trunk/api/setup') diff --git a/Neutron-trunk/api/setup/check.php b/Neutron-trunk/api/setup/check.php new file mode 100644 index 0000000..d3eb831 --- /dev/null +++ b/Neutron-trunk/api/setup/check.php @@ -0,0 +1,30 @@ + +GD Support enabled ') !== false || strpos($data, 'GD Support => enabled') !== false) {} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("The GD2 library is not installed or enabled"); +} + +if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Unsupported browser, please use Chrome, Chrome-based or Firefox"); +} + +require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); diff --git a/Neutron-trunk/api/setup/defaultHomepage.html b/Neutron-trunk/api/setup/defaultHomepage.html new file mode 100644 index 0000000..88da957 --- /dev/null +++ b/Neutron-trunk/api/setup/defaultHomepage.html @@ -0,0 +1 @@ +
Neutron

Edit the homepage to start your website...
Modifiez la page d'accueil pour commencer votre site...
Edite la página de inicio para iniciar su sitio web...
Modifica la home page per avviare il tuo sito Web...
Bearbeiten Sie die Homepage, um Ihre Website zu starten...
Bewerk de startpagina om uw website te starten...
Отредактируйте домашнюю страницу, чтобы начать свой сайт ...
编辑首页以启动您的网站...
ホームページを編集してウェブサイトを開始...

\ No newline at end of file diff --git a/Neutron-trunk/api/setup/push.php b/Neutron-trunk/api/setup/push.php new file mode 100644 index 0000000..20d8898 --- /dev/null +++ b/Neutron-trunk/api/setup/push.php @@ -0,0 +1,105 @@ + +') !== false || strpos($_POST['sitename'], '{') !== false || strpos($_POST['sitename'], '}') !== false || strpos($_POST['sitename'], '@') !== false || strpos($_POST['sitename'], '#') !== false || strpos($_POST['sitename'], '|') !== false) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Le nom du site contient des caractères invalides"); + } + if (strlen($_POST['sitename']) > 75) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Le nom du site est trop long"); + } +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Aucun nom n'a été spécifié pour le site"); +} + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/resources/i18n/" . $_POST['language'])) { + $lang = $_POST['language']; +} else { + $lang = "fr"; +} + +if (isset($_FILES['file'])) { + if ($_FILES['file']['error'] == 1) { + $maxsize = ini_get('upload_max_filesize'); + if ($maxsize > 1000) { + if ($maxsize > 1000000) { + $maxsizestr = round($maxsize / 1000000, 2) . " Mio"; + } else { + $maxsizestr = round($maxsize / 1000, 2) . " Kio"; + } + } else { + $maxsizestr = $maxsize . " octets"; + } + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("La taille du fichier d'icône dépasse la taille maximale imposée par le serveur ({$maxsizestr})"); + } + if ($_FILES['file']['error'] == 2) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("La taille maximale du fichier de formulaire à été dépassée"); + } + if ($_FILES['file']['error'] == 3) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Le fichier d'icône est incomplet (n'a pas été transmis entièrement)"); + } + if ($_FILES['file']['error'] == 4) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Le fichier est renseigné au serveur, mais il n'a pas été transmis"); + } + if ($_FILES['file']['error'] == 6) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Aucun dossier temporaire présent sur le serveur"); + } + if ($_FILES['file']['error'] == 7) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Impossible d'écrire sur le disque"); + } + if ($_FILES['file']['error'] == 8) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Un autre programme à interrompu la transmission du fichier"); + } + if ($_FILES['file']['type'] != "image/png" && $_FILES['file']['type'] != "image/jpeg" && $_FILES['file']['type'] != "image/gif") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("Ce type de fichier n'est pas supporté"); + } + if ($_FILES['file']['error'] == 0) { + imagepng(imagecreatefromstring(file_get_contents($_FILES['file']['tmp_name'])), $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/siteicon.png"); + unlink($_FILES['file']['tmp_name']); + } +} else { + copy($_SERVER['DOCUMENT_ROOT'] . "/resources/image/siteicon.png", $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/siteicon.png"); +} + +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent"); +} + +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages"); +} + +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes"); +} + +$password = password_hash("MPCMS-usr-motdepasse", PASSWORD_BCRYPT, ['cost' => 12,]); + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/index", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/setup/defaultHomepage.html")); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/index", "0"); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/lang", $lang); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/footer", "Copyright © Votre nom ici
Tous droits réservés"); +$sitename = str_replace('>', '>', $_POST['sitename']); +$sitename = str_replace('<', '<', $sitename); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/sitename", $sitename); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/widgets.json", "{\"list\": [\"test\"]}"); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json", "{\"events\":[{}]}"); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/password", $password); +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log")) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log") . date("d/m/Y H:i:s") . " - SETUP/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); +} else { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", date("d/m/Y H:i:s") . " - SETUP/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); +} + +require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); \ No newline at end of file -- cgit