index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of www-conf-viewer.
  6. *
  7. * www-conf-viewer is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * www-conf-viewer is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with www-conf-viewer. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home.php
  21. *
  22. * www-conf-viewer home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2016, 2024, 5 Mode
  26. */
  27. // CONFIGURATION
  28. error_reporting(E_ALL | E_STRICT);
  29. ini_set('display_startup_errors',1);
  30. ini_set('display_errors',1);
  31. ini_set('log_errors',1);
  32. require "config.inc";
  33. define('PHP_BR', "<br>");
  34. define('PHP_SPACE', " ");
  35. define('PHP_STR', "");
  36. define("FUNCTIONS_PATH", APP_PATH . DIRECTORY_SEPARATOR . "CONFVW_func");
  37. require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.string.inc";
  38. require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.various.inc";
  39. $password = filter_input(INPUT_POST, "Password")??"";
  40. $password = strip_tags($password);
  41. if ($password !== PHP_STR) {
  42. $hash = hash("sha256", $password . APP_SALT, false);
  43. if ($hash !== APP_HASH) {
  44. $password=PHP_STR;
  45. }
  46. }
  47. if ($password == PHP_STR) {
  48. $NGINX_CONF_PATH = APP_EXAMPLE_PATH . DIRECTORY_SEPARATOR . "nginx.conf";
  49. $NGINX_SERVER_CONF_PATH = APP_EXAMPLE_PATH . DIRECTORY_SEPARATOR . "site.com.conf";
  50. $PHPFPM_CONF_PATH = APP_EXAMPLE_PATH . DIRECTORY_SEPARATOR . "php-fpm.conf";
  51. } else {
  52. $NGINX_CONF_PATH = APP_NGINX_CONF_PATH;
  53. $NGINX_SERVER_CONF_PATH = APP_NGINX_SERVER_CONF_PATH;
  54. $PHPFPM_CONF_PATH = APP_PHPFPM_CONF_PATH;
  55. }
  56. //echo("NGINX_CONF_PATH=$NGINX_CONF_PATH<br>");
  57. //echo("NGINX_SERVER_CONF_PATH=$NGINX_SERVER_CONF_PATH<br>");
  58. //echo("PHPFPM_CONF_PATH=$PHPFPM_CONF_PATH<br>");
  59. ?>
  60. <!DOCTYPE html>
  61. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  62. <head>
  63. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  64. <!--<?PHP echo(APP_LICENSE);?>-->
  65. <title><?PHP echo(APP_TITLE);?></title>
  66. <link rel="shortcut icon" href="/favicon.ico" />
  67. <meta name="description" content="Welcome to www-conf-viewer! Everyone its web config."/>
  68. <meta name="keywords" content="www-conf-viewer,web,configuration,viewer,on,premise,solution"/>
  69. <meta name="robots" content="index,follow"/>
  70. <meta name="author" content="5 Mode"/>
  71. <script src="/CONFVW_js/jquery-3.6.0.min.js" type="text/javascript"></script>
  72. <script src="/CONFVW_js/sha.js" type="text/javascript"></script>
  73. <script src="/CONFVW_js/common.js" type="text/javascript"></script>
  74. <link href="/CONFVW_css/style.css?r=<?PHP echo(time());?>" type="text/css" rel="stylesheet">
  75. </head>
  76. <body style="background:#dadada no-repeat; background-size: cover; background-attachment: fixed; background-position: center;">
  77. <div class="header" style="margin-top:18px;margin-bottom:18px;">
  78. <a href="http://www-conf-viewer.5mode-foss.eu" target="_self" style="color:#000000; text-decoration: none;">&nbsp;<img src="/CONFVW_res/logo.png" align="middle" style="position:relative;top:-5px;width:22px;">&nbsp;www-conf-viewer</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/par7133/www-conf-viewer" style="color:#000000;"><span style="color:#119fe2">on</span> github</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:posta@elettronica.lol" style="color:#000000;"><span style="color:#119fe2">for</span> feedback</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="tel:+39-331-4029415" style="font-size:13px;background-color:lightcyan;border:2px solid lightcyan;color:#000000;height:27px;text-decoration:none;">&nbsp;&nbsp;get support&nbsp;&nbsp;</a>
  79. </div>
  80. <form id="frmUpload" role="form" method="post" action="/" target="_self" enctype="multipart/form-data">
  81. <?PHP if (!MAX_SECURITY || (MAX_SECURITY && ($password != PHP_STR))) :?>
  82. <table style="width:100%">
  83. <tr>
  84. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  85. <div style="float:left;font-weight:900;font-size:12px;">NGINX (Core configuration)</div>
  86. <div style="float:right"><img src="/CONFVW_res/nginx.png" style="width:48px;" slt="Nginx logo"></div>
  87. </td>
  88. </tr>
  89. <?PHP
  90. $aNginxConf = file($NGINX_CONF_PATH, FILE_SKIP_EMPTY_LINES);
  91. if (!empty($aNginxConf)) {
  92. $nested = false;
  93. foreach($aNginxConf as $line) {
  94. $line = trim($line, " \n\r\t\v\x00");
  95. $line = trim($line, "\x00..\x1F");
  96. if (((mb_strlen($line) < 4) && ($line!="}")) || (left($line,1)=="#")) {
  97. continue;
  98. }
  99. $directive = explode(PHP_SPACE, $line)[0]??null;
  100. if (isset($directive) && strtolower(left($directive,4)=="http")) {
  101. break;
  102. }
  103. if (right($line,1)=="{") { ?>
  104. <tr>
  105. <td class="td-caption" colspan="2">
  106. <?PHP echo($directive); ?><br>
  107. <span id="directive-desc2">
  108. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  109. </span>
  110. </td>
  111. <td class="td-full-opts">
  112. &nbsp;
  113. </td>
  114. </tr>
  115. <?PHP $nested = true;
  116. continue;
  117. }
  118. if ($directive=="}") {
  119. $nested = false;
  120. continue;
  121. }
  122. if (isset($directive) && (left($directive,1)!="#") && ($directive!="}")) {
  123. $fullopts = substr($line, mb_strlen($directive)+1);
  124. $fullopts = rtrim($fullopts,";") ?? PHP_STR;
  125. ?>
  126. <tr>
  127. <?PHP if ($nested): ?>
  128. <!--<td class="td-tab">
  129. &nbsp;
  130. </td> -->
  131. <td class="td-caption2" colspan="2">
  132. <?PHP else: ?>
  133. <td class="td-caption" colspan="2">
  134. <?PHP endif; ?>
  135. <span id="directive"><?PHP echo($directive); ?></span><br>
  136. <span id="directive-desc">
  137. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  138. </span>
  139. </td>
  140. <td class="td-full-opts">
  141. <?PHP echo($fullopts); ?>
  142. </td>
  143. </tr>
  144. <?PHP
  145. }
  146. }
  147. }
  148. ?>
  149. <tr>
  150. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  151. <div style="float:left;font-weight:900;font-size:12px;">This is www-conf-viewer, a 5 Mode software.<br>Copyright 2021, 2024 5 Mode - GPL License<br>Authors: Daniele Bonini</div>
  152. <div style="float:right"><a href="https://5mode.com"><img src="/CONFVW_res/5mode.png" style="width:48px;" alt="5 Mode"></a>&nbsp;&nbsp;&nbsp;</div>
  153. </td>
  154. </tr>
  155. </table>
  156. <br><br>
  157. <table style="width:100%">
  158. <tr>
  159. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  160. <div style="float:left;font-weight:900;font-size:12px;">NGINX (HTTP configuration)</div>
  161. <div style="float:right"><img src="/CONFVW_res/nginx.png" style="width:48px;" slt="Nginx logo"></div>
  162. </td>
  163. </tr>
  164. <?PHP
  165. //$aNginxConf = file($NGINX_CONF_PATH, FILE_SKIP_EMPTY_LINES);
  166. if (!empty($aNginxConf)) {
  167. $found_http = false;
  168. $line_buff = "";
  169. $nested = false;
  170. foreach($aNginxConf as $line) {
  171. $line = trim($line, " \n\r\t\v\x00");
  172. $line = trim($line, "\x00..\x1F");
  173. if (((mb_strlen($line) < 4) && ($line!="}")) || (left($line,1)=="#")) {
  174. continue;
  175. }
  176. $directive = explode(PHP_SPACE, $line)[0]??null;
  177. // searching the initial token 'http'..
  178. if (isset($directive) && (strtolower($directive)!="http")) {
  179. if (!$found_http) {
  180. continue;
  181. }
  182. } else {
  183. $found_http = true;
  184. continue;
  185. }
  186. // exiting on the server token..
  187. if (isset($directive) && (strtolower($directive)=="map")) {
  188. break;
  189. }
  190. // exiting on the server token..
  191. if (isset($directive) && (strtolower($directive)=="server")) {
  192. break;
  193. }
  194. //echo("<tr><td>$directive (debug)</td><td>$line</td></tr>");
  195. if (right($line,1)!=";") {
  196. $line_buff .= $line . "|||||";
  197. continue;
  198. } else {
  199. if ($line_buff!=PHP_STR) {
  200. $line_buff .= $line . "|||||";
  201. $directive = explode(PHP_SPACE, $line_buff)[0]??null;
  202. }
  203. }
  204. if (right($line,1)=="{" || ($line_buff!=PHP_STR && !$nested)) { ?>
  205. <tr>
  206. <td class="td-caption" colspan="2">
  207. <?PHP echo($directive); ?><br>
  208. <span id="directive-desc2">
  209. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  210. </span>
  211. </td>
  212. <td class="td-full-opts">
  213. &nbsp;
  214. </td>
  215. </tr>
  216. <?PHP $nested = true;
  217. if ($line_buff==PHP_STR) {
  218. continue;
  219. }
  220. }
  221. if ($line_buff!=PHP_STR && $nested) {
  222. $ipos = stripos($line_buff, PHP_SPACE);
  223. $s = substr($line_buff,$ipos+1);
  224. $buffLines = explode("|||||", $s);
  225. foreach($buffLines as $buffLine) {
  226. if ($buffLine==PHP_STR) {
  227. continue;
  228. }
  229. ?>
  230. <tr>
  231. <td class="td-caption2" colspan="2">
  232. <span id="directive">&nbsp;</span>
  233. </td>
  234. <td class="td-full-opts">
  235. <?PHP echo(trim($buffLine,";")); ?>
  236. </td>
  237. </tr>
  238. <?PHP
  239. }
  240. $nested = false;
  241. $line_buff = PHP_STR;
  242. } else {
  243. if ($directive=="}") {
  244. $nested = false;
  245. continue;
  246. }
  247. if (isset($directive) && (left($directive,1)!="#") && ($directive!="}")) {
  248. $fullopts = substr($line, mb_strlen($directive)+1);
  249. $fullopts = rtrim($fullopts,";") ?? PHP_STR;
  250. ?>
  251. <tr>
  252. <?PHP if ($nested): ?>
  253. <td class="td-caption2" colspan="2">
  254. <?PHP else: ?>
  255. <td class="td-caption" colspan="2">
  256. <?PHP endif; ?>
  257. <span id="directive"><?PHP echo($directive); ?></span><br>
  258. <span id="directive-desc">
  259. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  260. </span>
  261. </td>
  262. <td class="td-full-opts">
  263. <?PHP echo($fullopts); ?>
  264. </td>
  265. </tr>
  266. <?PHP
  267. }
  268. }
  269. }
  270. }
  271. ?>
  272. <tr>
  273. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  274. <div style="float:left;font-weight:900;font-size:12px;">This is www-conf-viewer, a 5 Mode software.<br>Copyright 2021, 2024 5 Mode - GPL License<br>Authors: Daniele Bonini</div>
  275. <div style="float:right"><a href="https://5mode.com"><img src="/CONFVW_res/5mode.png" style="width:48px;" alt="5 Mode"></a>&nbsp;&nbsp;&nbsp;</div>
  276. </td>
  277. </tr>
  278. </table>
  279. <br><br>
  280. <table style="width:100%">
  281. <tr>
  282. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  283. <div style="float:left;font-weight:900;font-size:12px;">NGINX (SERVER configuration)</div>
  284. <div style="float:right"><img src="/CONFVW_res/nginx.png" style="width:48px;" slt="Nginx logo"></div>
  285. </td>
  286. </tr>
  287. <?PHP
  288. $serverConf = file($NGINX_SERVER_CONF_PATH);
  289. ?>
  290. <tr>
  291. <td class="td-server-spec" style="white-space:pre;">
  292. <?PHP
  293. $blank_lines = 0;
  294. foreach($serverConf as $line) {
  295. $sample = left($line,10);
  296. $sample = ltrim($sample);
  297. if ((mb_strlen(trim($line))<3) && (trim($line)!="}")) {
  298. $blank_lines++;
  299. continue;
  300. }
  301. if (left($sample, 1) != "#") {
  302. if ($blank_lines>0) {
  303. echo("\n");
  304. }
  305. echo(HTMLencode($line, true));
  306. $blank_lines = 0;
  307. }
  308. }
  309. ?>
  310. </td>
  311. </tr>
  312. <tr>
  313. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  314. <div style="float:left;font-weight:900;font-size:12px;">This is www-conf-viewer, a 5 Mode software.<br>Copyright 2021, 2024 5 Mode - GPL License<br>Authors: Daniele Bonini</div>
  315. <div style="float:right"><a href="https://5mode.com"><img src="/CONFVW_res/5mode.png" style="width:48px;" alt="5 Mode"></a>&nbsp;&nbsp;&nbsp;</div>
  316. </td>
  317. </tr>
  318. </table>
  319. <br><br>
  320. <table style="width:100%">
  321. <tr>
  322. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  323. <div style="float:left;font-weight:900;font-size:12px;">PHPFPM</div>
  324. <div style="float:right"><img src="/CONFVW_res/php.png" style="width:48px;" slt="Nginx logo"></div>
  325. </td>
  326. </tr>
  327. <?PHP
  328. if ($PHPFPM_CONF_PATH != PHP_STR) {
  329. $serverConf = file($PHPFPM_CONF_PATH);
  330. } else {
  331. $serverConf = [PHP_STR];
  332. }
  333. ?>
  334. <tr>
  335. <td class="td-server-spec-php" style="white-space:pre;">
  336. <?PHP
  337. $blank_lines = 0;
  338. foreach($serverConf as $line) {
  339. $sample = left($line,10);
  340. $sample = ltrim($sample);
  341. if ((mb_strlen(trim($line))<3) && (trim($line)!="}")) {
  342. $blank_lines++;
  343. continue;
  344. }
  345. if (left($sample, 1) != "#") {
  346. if ($blank_lines>0) {
  347. echo("\n");
  348. }
  349. echo(HTMLencode($line, true));
  350. $blank_lines = 0;
  351. }
  352. }
  353. ?>
  354. </td>
  355. </tr>
  356. <tr>
  357. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  358. <div style="float:left;font-weight:900;font-size:12px;">This is www-conf-viewer, a 5 Mode software.<br>Copyright 2021, 2024 5 Mode - GPL License<br>Authors: Daniele Bonini</div>
  359. <div style="float:right"><a href="https://5mode.com"><img src="/CONFVW_res/5mode.png" style="width:48px;" alt="5 Mode"></a>&nbsp;&nbsp;&nbsp;</div>
  360. </td>
  361. </tr>
  362. </table>
  363. <?PHP else:
  364. echo("<div style='width:250px;padding-top:250px;font-weight:400;margin:auto;text-align:center;'>Login required.</div>");
  365. endif; ?>
  366. <br><br>
  367. <div id="passworddisplay">
  368. <br>
  369. &nbsp;&nbsp;<input type="password" id="Password" name="Password" placeholder="password" value="<?php echo($password);?>" autocomplete="off">&nbsp;<input type="submit" value="Go" style="text-align:left;width:25%;color:#000000;"><br>
  370. &nbsp;&nbsp;<input type="text" id="Salt" placeholder="salt" autocomplete="off"><br>
  371. <div style="text-align:center;">
  372. <a id="hashMe" href="#" onclick="showEncodedPassword();">Hash Me!</a>
  373. </div>
  374. </div>
  375. </form>
  376. <div id="footerCont">&nbsp;</div>
  377. <div id="footer"><span style="background:#FFFFFF; opacity:0.7;">&nbsp;&nbsp;A <a href="http://5mode.com" class="aaa">5 Mode</a> project and <a href="http://demo.5mode.com" class="aaa">WYSIWYG</a> system. Some rights reserved.</span></div>
  378. <script src="/CONFVW_js/home.js" type="text/javascript"></script>
  379. <!-- METRICS CODE -->
  380. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  381. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html"); ?>
  382. <?php endif; ?>
  383. </body>
  384. </html>