diff options
author | Minteck <nekostarfan@gmail.com> | 2021-08-24 15:38:16 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-08-24 15:38:16 +0200 |
commit | 529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105 (patch) | |
tree | 8a50c30271b9b328cde0d907b1441f2dabdc341b /Neutron-trunk/api/admin/appearance.php | |
parent | 15e4724761c50b30803df1811a525c85058f70bf (diff) | |
download | electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.tar.gz electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.tar.bz2 electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.zip |
Update
Diffstat (limited to 'Neutron-trunk/api/admin/appearance.php')
-rw-r--r-- | Neutron-trunk/api/admin/appearance.php | 194 |
1 files changed, 194 insertions, 0 deletions
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 @@ +<?php require_once "../../resources/private/relative.php"; getRelativeDetails("api"); ?> +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php"; + +if (isset($_COOKIE['_NEUTRON_ADMIN_TOKEN']) && $_COOKIE['_NEUTRON_ADMIN_TOKEN'] != "." && $_COOKIE['_NEUTRON_ADMIN_TOKEN'] != ".." && $_COOKIE['_NEUTRON_ADMIN_TOKEN'] != "/") { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $_COOKIE['_NEUTRON_ADMIN_TOKEN'])) { +if (isset($_POST['sitename'])) { + if (trim($_POST['sitename']) == "") { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["sitenamenone"]); + } + if (strpos($_POST['sitename'], '<') !== false || strpos($_POST['sitename'], '>') !== 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 |