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/admin/appearance.php | 194 +++++++++++++++++++++ Neutron-trunk/api/admin/cache_content_reset.php | 14 ++ Neutron-trunk/api/admin/cache_pages_update.php | 72 ++++++++ Neutron-trunk/api/admin/calendar_create.php | 155 ++++++++++++++++ Neutron-trunk/api/admin/calendar_delete.php | 64 +++++++ Neutron-trunk/api/admin/calendar_nextevents.php | 36 ++++ Neutron-trunk/api/admin/create_page.php | 90 ++++++++++ Neutron-trunk/api/admin/customization_colors.php | 32 ++++ Neutron-trunk/api/admin/customization_theme.php | 32 ++++ Neutron-trunk/api/admin/delete_page.php | 47 +++++ Neutron-trunk/api/admin/edit_page.php | 42 +++++ Neutron-trunk/api/admin/flag_disable.php | 43 +++++ Neutron-trunk/api/admin/flag_enable.php | 43 +++++ Neutron-trunk/api/admin/footer.php | 33 ++++ Neutron-trunk/api/admin/galery_create_category.php | 47 +++++ Neutron-trunk/api/admin/galery_delete_category.php | 52 ++++++ Neutron-trunk/api/admin/galery_delete_image.php | 40 +++++ Neutron-trunk/api/admin/galery_label_picture.php | 38 ++++ Neutron-trunk/api/admin/galery_publish_photo.php | 120 +++++++++++++ Neutron-trunk/api/admin/galery_toggle_state.php | 40 +++++ .../api/admin/instant_language_change.php | 33 ++++ Neutron-trunk/api/admin/login.php | 52 ++++++ Neutron-trunk/api/admin/password.php | 73 ++++++++ Neutron-trunk/api/admin/rename_page.php | 75 ++++++++ Neutron-trunk/api/admin/reset.php | 87 +++++++++ Neutron-trunk/api/admin/save_advanced.php | 46 +++++ Neutron-trunk/api/admin/widgets.php | 64 +++++++ 27 files changed, 1664 insertions(+) create mode 100644 Neutron-trunk/api/admin/appearance.php create mode 100644 Neutron-trunk/api/admin/cache_content_reset.php create mode 100644 Neutron-trunk/api/admin/cache_pages_update.php create mode 100644 Neutron-trunk/api/admin/calendar_create.php create mode 100644 Neutron-trunk/api/admin/calendar_delete.php create mode 100644 Neutron-trunk/api/admin/calendar_nextevents.php create mode 100644 Neutron-trunk/api/admin/create_page.php create mode 100644 Neutron-trunk/api/admin/customization_colors.php create mode 100644 Neutron-trunk/api/admin/customization_theme.php create mode 100644 Neutron-trunk/api/admin/delete_page.php create mode 100644 Neutron-trunk/api/admin/edit_page.php create mode 100644 Neutron-trunk/api/admin/flag_disable.php create mode 100644 Neutron-trunk/api/admin/flag_enable.php create mode 100644 Neutron-trunk/api/admin/footer.php create mode 100644 Neutron-trunk/api/admin/galery_create_category.php create mode 100644 Neutron-trunk/api/admin/galery_delete_category.php create mode 100644 Neutron-trunk/api/admin/galery_delete_image.php create mode 100644 Neutron-trunk/api/admin/galery_label_picture.php create mode 100644 Neutron-trunk/api/admin/galery_publish_photo.php create mode 100644 Neutron-trunk/api/admin/galery_toggle_state.php create mode 100644 Neutron-trunk/api/admin/instant_language_change.php create mode 100644 Neutron-trunk/api/admin/login.php create mode 100644 Neutron-trunk/api/admin/password.php create mode 100644 Neutron-trunk/api/admin/rename_page.php create mode 100644 Neutron-trunk/api/admin/reset.php create mode 100644 Neutron-trunk/api/admin/save_advanced.php create mode 100644 Neutron-trunk/api/admin/widgets.php (limited to 'Neutron-trunk/api/admin') diff --git a/Neutron-trunk/api/admin/appearance.php b/Neutron-trunk/api/admin/appearance.php new file mode 100644 index 0000000..28ebe74 --- /dev/null +++ b/Neutron-trunk/api/admin/appearance.php @@ -0,0 +1,194 @@ + +') !== 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($lang["api"]["sitenameinvalid"]); + } + if (strlen($_POST['sitename']) > 75) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["sitenamelong"]); + } +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["sitenamerecv"]); +} + +if (isset($_POST['alwaysmenu'])) { + (string)$am = $_POST['alwaysmenu']; +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["awmnone"]); +} + +if (isset($_POST['oldrenderer'])) { + (string)$or = $_POST['oldrenderer']; +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["olrnone"]); +} + +if (isset($_POST['showpages'])) { + (integer)$sp = $_POST['showpages']; +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["swpnone"]); +} + +if ($am == "true") { + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/alwaysmenu")) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/alwaysmenu", ""); + } +} else { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/alwaysmenu")) { + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/alwaysmenu"); + } +} +// var_dump($or);require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit(); +if ($or == "true") { + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/oldRenderer")) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/oldRenderer", ""); + } +} else { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/oldRenderer")) { + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/oldRenderer"); + } +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagesInMenuBar", $sp); + +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") . " - API/" . $_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") . " - API/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); +} + +if (isset($_FILES['icon'])) { + if ($_FILES['icon']['error'] == 1) { + $maxsize = ini_get('upload_max_filesize'); + if ($maxsize > 1000) { + if ($maxsize > 1000000) { + $maxsizestr = round($maxsize / 1000000, 2) . " " . $lang["sizes"]["mib"]; + } else { + $maxsizestr = round($maxsize / 1000, 2) . " " . $lang["sizes"]["kib"]; + } + } else { + $maxsizestr = $maxsize . " " . $lang["sizes"]["bytes"]; + } + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filesize"] . " ({$maxsizestr})"); + } + if ($_FILES['icon']['error'] == 2) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileform"]); + } + if ($_FILES['icon']['error'] == 3) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileincomplete"]); + } + if ($_FILES['icon']['error'] == 4) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filenotfound"]); + } + if ($_FILES['icon']['error'] == 6) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filenotempdir"]); + } + if ($_FILES['icon']['error'] == 7) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filewriterror"]); + } + if ($_FILES['icon']['error'] == 8) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileint"]); + } + if ($_FILES['icon']['type'] != "image/png" && $_FILES['icon']['type'] != "image/jpeg" && $_FILES['icon']['type'] != "image/gif") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filemime2"]); + } + if ($_FILES['icon']['error'] == 0) { + imagepng(imagecreatefromstring(file_get_contents($_FILES['icon']['tmp_name'])), $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/siteicon.png"); + if ($_FILES['icon']['type'] == "image/png") { + copy($_FILES['icon']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/siteicon-uncomp.png"); + } else { + copy($_SERVER['DOCUMENT_ROOT'] . "/resources/upload/siteicon.png", $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/siteicon-uncomp.png"); + } + require_once $_SERVER['DOCUMENT_ROOT'] . "/api/engine-cyclic/components/favicon.php"; + unlink($_FILES['icon']['tmp_name']); + } +} + +if (isset($_FILES['banner'])) { + if ($_FILES['banner']['error'] == 1) { + $maxsize = ini_get('upload_max_filesize'); + if ($maxsize > 1000) { + if ($maxsize > 1000000) { + $maxsizestr = round($maxsize / 1000000, 2) . " " . $lang["sizes"]["mib"]; + } else { + $maxsizestr = round($maxsize / 1000, 2) . " " . $lang["sizes"]["kib"]; + } + } else { + $maxsizestr = $maxsize . " " . $lang["sizes"]["bytes"]; + } + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filesize"] . " ({$maxsizestr})"); + } + if ($_FILES['banner']['error'] == 2) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileform"]); + } + if ($_FILES['banner']['error'] == 3) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileincomplete"]); + } + if ($_FILES['banner']['error'] == 4) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filenotfound"]); + } + if ($_FILES['banner']['error'] == 6) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filenotempdir"]); + } + if ($_FILES['banner']['error'] == 7) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filewriterror"]); + } + if ($_FILES['banner']['error'] == 8) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileint"]); + } + if ($_FILES['banner']['type'] != "image/png" && $_FILES['banner']['type'] != "image/jpeg" && $_FILES['banner']['type'] != "image/gif") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filemime2"]); + } + if ($_FILES['banner']['error'] == 0) { + imagejpeg(imagecreatefromstring(file_get_contents($_FILES['banner']['tmp_name'])), $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/banner.jpg"); + $img = imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'] . "/resources/upload/banner.jpg"); + $width = imagesx($img); + $height = imagesy($img); + $x_step = intval($width/$num_samples); + $y_step = intval($height/$num_samples); + $total_lum = 0; + $sample_no = 1; + for ($x=0; $x<$width; $x+=$x_step) { + for ($y=0; $y<$height; $y+=$y_step) { + $rgb = imagecolorat($img, $x, $y); + $r = ($rgb >> 16) & 0xFF; + $g = ($rgb >> 8) & 0xFF; + $b = $rgb & 0xFF; + $lum = ($r+$r+$b+$g+$g+$g)/6; + $total_lum += $lum; + $sample_no++; + } + } + $avg_lum = $total_lum / $sample_no; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/banner.mtd", ($avg_lum / 255) * 100); + unlink($_FILES['banner']['tmp_name']); + } +} + +$sitename = str_replace('>', '>', $_POST['sitename']); +$sitename = str_replace('<', '<', $sitename); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/sitename", $sitename); +require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php"; +echo("ok"); +} else { + 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") . " - APIDENY/" . $_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") . " - APIDENY/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); + } +} +} else { + 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") . " - APIDENY/" . $_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") . " - APIDENY/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); + } +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/cache_content_reset.php b/Neutron-trunk/api/admin/cache_content_reset.php new file mode 100644 index 0000000..6e9e02b --- /dev/null +++ b/Neutron-trunk/api/admin/cache_content_reset.php @@ -0,0 +1,14 @@ +hiddenPages))) { + append("\n{$page}|" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")); + $index++; + } +} +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) { + append("\n@galery|" . $lang["viewer"]["galery"]); +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/pagelist.mtd", $cache); + +$cache = ""; +$index = 0; +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {$index = 1;} +append("@home|@indexHomeIcon"); +foreach ($pages as $page) { + if ((($page != ".." && $page != ".")) && (is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $page)) && (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")) && (!in_array($page, $customSettings->hiddenPages))) { + append("\n{$page}|" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")); + $index++; + } +} +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) { + append("\n@galery|" . $lang["viewer"]["galery"]); +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/pagelist-full.mtd", $cache); + +/* --------------------------- */ +// Backwards compatibility with the old engine-cyclic +$cache = ""; + +$pages = scandir($_SERVER['DOCUMENT_ROOT']); +uasort($pages, 'compareASCII'); +foreach ($pages as $page) { + if ($page != ".." && $page != ".") { + if (is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $page)) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")) { + if (!in_array($page, $customSettings->hiddenPages)) { + append("" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename") . ""); + } + } + } + } +} +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {append("" . $lang["viewer"]["galery"] . "");} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/pagelist-old.mtd", $cache); \ No newline at end of file diff --git a/Neutron-trunk/api/admin/calendar_create.php b/Neutron-trunk/api/admin/calendar_create.php new file mode 100644 index 0000000..eff4682 --- /dev/null +++ b/Neutron-trunk/api/admin/calendar_create.php @@ -0,0 +1,155 @@ + +', '>', $name); + $name = str_replace('<', '<', $name); + if (strlen($name) > 75) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["calnamelong"]); + } + if (trim($name) == "") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["calnamenone"]); + } + $desc = str_replace('>', '>', $desc); + $desc = str_replace('<', '<', $desc); + if ($day == "1") { + $daystr = $lang["api"]["calordinal"]; + } else { + $daystr = $day; + } + if ($month == "01") { + $monthstr = $lang["api"]["calminmonths"][0]; + } + if ($month == "02") { + $monthstr = $lang["api"]["calminmonths"][1]; + } + if ($month == "03") { + $monthstr = $lang["api"]["calminmonths"][2]; + } + if ($month == "04") { + $monthstr = $lang["api"]["calminmonths"][3]; + } + if ($month == "05") { + $monthstr = $lang["api"]["calminmonths"][4]; + } + if ($month == "06") { + $monthstr = $lang["api"]["calminmonths"][5]; + } + if ($month == "07") { + $monthstr = $lang["api"]["calminmonths"][6]; + } + if ($month == "08") { + $monthstr = $lang["api"]["calminmonths"][7]; + } + if ($month == "09") { + $monthstr = $lang["api"]["calminmonths"][8]; + } + if ($month == "10") { + $monthstr = $lang["api"]["calminmonths"][9]; + } + if ($month == "11") { + $monthstr = $lang["api"]["calminmonths"][10]; + } + if ($month == "12") { + $monthstr = $lang["api"]["calminmonths"][11]; + } + $json = json_decode($jsonraw); + foreach($json->events as $event) { + if (isset($event->timestamp)) { + if ($event->timestamp == $year . date('m', $date) . date('d', $date)) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["calsameday"]); + } + } + } + $pos = count($json->events); + $json->events[$pos] = new stdClass(); + $json->events[$pos]->timestamp = $year . date('m', $date) . date('d', $date); + $json->events[$pos]->name = $name; + $json->events[$pos]->description = $desc; + if (substr($link, 0, 4) == "http") { + $json->events[$pos]->link = $link; + } else { + $json->events[$pos]->link = "http://" . $link; + } + $json->events[$pos]->datestr = $daystr . " " . $monthstr . " " . $year; + $newjsonraw = json_encode($json, JSON_PRETTY_PRINT); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json", $newjsonraw); + require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php"; + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["calerror"]); +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/calendar_delete.php b/Neutron-trunk/api/admin/calendar_delete.php new file mode 100644 index 0000000..edeb86d --- /dev/null +++ b/Neutron-trunk/api/admin/calendar_delete.php @@ -0,0 +1,64 @@ + +events as $stdClass) { + $pos = $pos + 1; + if (isset($stdClass->timestamp)) { + if ($stdClass->timestamp == $id) { + unset($json->events[$pos]->timestamp); + unset($json->events[$pos]->datestr); + unset($json->events[$pos]->name); + unset($json->events[$pos]->description); + } + } + } + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json", json_encode($json, JSON_PRETTY_PRINT)); + require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php"; + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("CalDb1: ParseError: Unable to open database, JSON parse failed. Data might be corrupted"); +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/calendar_nextevents.php b/Neutron-trunk/api/admin/calendar_nextevents.php new file mode 100644 index 0000000..6dc0cae --- /dev/null +++ b/Neutron-trunk/api/admin/calendar_nextevents.php @@ -0,0 +1,36 @@ + + +', '>', $title); +$title = str_replace('<', '<', $title); +if (substr($title, 0, 1) == " " || substr($title, 0, 1) == "-" || substr($title, 0, 1) == " " || substr($title, 0, 1) == "_" || substr($title, 0, 1) == "@" || substr($title, 0, 1) == "|" || substr($title, 0, 1) == "'" || substr($title, 0, 1) == "\"" || substr($title, 0, 1) == "~" || substr($title, 0, 1) == "&" || substr($title, 0, 1) == "=") { + $prefixed = true; +} else { + $prefixed = false; +} +$type = $_POST['type']; +$content = $_POST['content']; + +$slug = preg_replace("/[^0-9a-zA-Z ]/m", "", $title ); +$slug = str_replace(" ", "-", $slug); +$slug = strtolower($slug); + +if ($prefixed) { + $slug = "-" . $slug; +} + +if (trim($title) == "") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgtitleempty"]); +} + +if ($slug == "api" || $slug == "cms-special" || $slug == "galery" || $slug == "cms-unrelated" || $slug == "vendor" || $slug == "data" || $slug == "resources" || $slug == "widgets" || $slug == "-htaccess" || $slug == "index" || $slug == "index-php") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameinternal"]); +} + +if (strlen($slug) > 70) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnamelong"]); +} + +if ($type != "0" && $type != "1") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgtypenone"]); +} + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $slug)) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameexists"]); +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $slug, $content); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $slug, $type); +mkdir($_SERVER['DOCUMENT_ROOT'] . "/" . $slug); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $slug . "/index.php", ''); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $slug . "/pagename", $title); +require_once $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_pages_update.php"; +require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php"; +require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); \ No newline at end of file diff --git a/Neutron-trunk/api/admin/customization_colors.php b/Neutron-trunk/api/admin/customization_colors.php new file mode 100644 index 0000000..9e650e8 --- /dev/null +++ b/Neutron-trunk/api/admin/customization_colors.php @@ -0,0 +1,32 @@ + + + + + + + + +', '>', $category); + $category = str_replace('<', '<', $category); +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["mkcatnoname"]); +} + +$slug = preg_replace("/[^0-9a-zA-Z ]/m", "", $category ); +$slug = str_replace(" ", "-", $slug); +$slug = strtolower($slug); + +if ($slug == "unclassed") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameinternal"]); +} + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/categories/" . $slug)) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["mkcatexists"]); +} else { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/categories/" . $slug, $category); + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/galery_delete_category.php b/Neutron-trunk/api/admin/galery_delete_category.php new file mode 100644 index 0000000..603a5d0 --- /dev/null +++ b/Neutron-trunk/api/admin/galery_delete_category.php @@ -0,0 +1,52 @@ + + + + + 1000) { + if ($maxsize > 1000000) { + $maxsizestr = round($maxsize / 1000000, 2) . " " . $lang["sizes"]["mib"]; + } else { + $maxsizestr = round($maxsize / 1000, 2) . " " . $lang["sizes"]["kib"]; + } + } else { + $maxsizestr = $maxsize . " " . $lang["sizes"]["bytes"]; + } + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filesize"] . " ({$maxsizestr})"); + } + if ($_FILES['file']['error'] == 2) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileform"]); + } + if ($_FILES['file']['error'] == 3) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileincomplete"]); + } + if ($_FILES['file']['error'] == 4) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filenotfound"]); + } + if ($_FILES['file']['error'] == 6) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filenotempdir"]); + } + if ($_FILES['file']['error'] == 7) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["filewriteerror"]); + } + if ($_FILES['file']['error'] == 8) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["fileint"]); + } + 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($file["api"]["filemime"] . " " . strtoupper(str_ireplace("image/", "", $_FILES['file']['type'])) . "."); + } + if ($_FILES['file']['error'] == 0) { + // if (/*!*//* <-- Fonction de test, décommentez le "!" pour forcer l'affichage de ce message */file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/pictures/" . $uuid)) { + // echo("Vous êtes tombé sur une erreur très rare, bravo à vous !\n\nPrenez rapidement ce message en capture d'écran et transmettez le aux développeurs de Neutron.\n\nVous pouvez leur donner cette adresse de galerie Neutron comme preuve :\nmpcms-gallery://" . $uuid . "@"); + // if (isset($_SERVER['HTTP_HOST'])) { + // echo($_SERVER['HTTP_HOST']); + // } else { + // if (isset($_SERVER['SERVER_NAME'])) { + // echo($_SERVER['SERVER_NAME']); + // } else { + // echo("unknown"); + // } + // } + // echo("\n\nVotre site doit être publiquement accessible et vous ne devez pas avoir modifié Neutron pour que votre trouvaille soit référencée."); + // exit; + // } + imagejpeg(imagecreatefromstring(file_get_contents($_FILES['file']['tmp_name'])), $_SERVER['DOCUMENT_ROOT'] . "/resources/upload/" . $uuid . ".jpg"); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/pictures/" . $uuid, "/resources/upload/" . $uuid . ".jpg" . "|" . $_POST['category']); + unlink($_FILES['file']['tmp_name']); + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/picdb.json")) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/picdb.json", "{\"" . $_POST['category'] . "\":[\"" . $uuid . "\"]}"); + } + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); + } +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/galery_toggle_state.php b/Neutron-trunk/api/admin/galery_toggle_state.php new file mode 100644 index 0000000..582faa9 --- /dev/null +++ b/Neutron-trunk/api/admin/galery_toggle_state.php @@ -0,0 +1,40 @@ + + + + 12,]), PASSWORD_BCRYPT, ['cost' => 12,])); + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/tokens")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens"); + } + $tokens = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens"); + foreach ($tokens as $deltoken) { + if ($deltoken == "." || $deltoken == "..") {} else { + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $deltoken); + } + } + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $token, ""); + header("Set-Cookie: _NEUTRON_ADMIN_TOKEN={$token}; Path=/; Http-Only; SameSite=Strict"); + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); + return; + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["keyinvalid"]); + } + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["keynone"]); + } + } else { // Use regular password + if (password_verify($_POST['password'], file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/password"))) { + $token = str_ireplace("/", "-", password_hash(password_hash(rand(0, 999999) + rand(0, 999999) + rand(0, 999999) + rand(0, 999999) + rand(0, 999999), PASSWORD_BCRYPT, ['cost' => 12,]), PASSWORD_BCRYPT, ['cost' => 12,])); + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/tokens")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens"); + } + $tokens = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens"); + foreach ($tokens as $atoken) { + if ($atoken == "." || $atoken == "..") {} else { + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $atoken); + } + } + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $token, ""); + header("Set-Cookie: _NEUTRON_ADMIN_TOKEN={$token}; Path=/; Http-Only; SameSite=Strict"); + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); + return; + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["lgpassinvalid"]); + } + } +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["lgpassnone"]); +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/password.php b/Neutron-trunk/api/admin/password.php new file mode 100644 index 0000000..a823721 --- /dev/null +++ b/Neutron-trunk/api/admin/password.php @@ -0,0 +1,73 @@ + + 12,])); +require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); \ No newline at end of file diff --git a/Neutron-trunk/api/admin/rename_page.php b/Neutron-trunk/api/admin/rename_page.php new file mode 100644 index 0000000..4091940 --- /dev/null +++ b/Neutron-trunk/api/admin/rename_page.php @@ -0,0 +1,75 @@ + +', '>', $newname); + $newname = str_replace('<', '<', $newname); + if (trim($newname) == "") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameempty"]); + } + $newslug = preg_replace("/[^0-9a-zA-Z ]/m", "", $newname ); + $newslug = str_replace(" ", "-", $newslug); + $newslug = strtolower($newslug); + if ($newslug == "api" || $newslug == "cms-special" || $newslug == "galery" || $newslug == "vendor" || $newslug == "cms-unrelated" || $newslug == "data" || $newslug == "resources" || $newslug == "widgets" || $newslug == "-htaccess" || $newslug == "index" || $newslug == "index-php") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameinternal"]); + } + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $newslug)) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameexists"]); + } + if (strlen($newslug) > 70) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnamelong"]); + } + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $newslug, file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $oldslug)); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $newslug, file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $oldslug)); + mkdir($_SERVER['DOCUMENT_ROOT'] . "/" . $newslug); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $newslug . "/index.php", ''); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $newslug . "/pagename", $newname); + unlink($_SERVER['DOCUMENT_ROOT'] . "/" . $oldslug . "/index.php"); + unlink($_SERVER['DOCUMENT_ROOT'] . "/" . $oldslug . "/pagename"); + rmdir($_SERVER['DOCUMENT_ROOT'] . "/" . $oldslug); + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $oldslug); + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $oldslug); + require_once $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_pages_update.php"; + require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php"; + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnamenone"]); + } + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnotfound"]); + } +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnone"]); +} \ No newline at end of file diff --git a/Neutron-trunk/api/admin/reset.php b/Neutron-trunk/api/admin/reset.php new file mode 100644 index 0000000..7c67207 --- /dev/null +++ b/Neutron-trunk/api/admin/reset.php @@ -0,0 +1,87 @@ + + + +list; + +if ($_POST['value'] == "true") { + if (array_search($_POST['element'], $array) === false) { + array_push($array, $_POST['element']); + } +} + +if ($_POST['value'] == "false") { + if (array_search($_POST['element'], $array) !== false) { + unset($array[array_search($_POST['element'], $array)]); + sort($array); + } +} +$settings->list = $array; + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/widgets.json", json_encode($settings, JSON_PRETTY_PRINT)); + +require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php"; +require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok"); \ No newline at end of file -- cgit