index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. if ($password !== PHP_STR) {
  41. $hash = hash("sha256", $password . APP_SALT, false);
  42. if ($hash !== APP_HASH) {
  43. $password=PHP_STR;
  44. }
  45. }
  46. if ($password == PHP_STR) {
  47. $NGINX_CONF_PATH = APP_EXAMPLE_PATH . DIRECTORY_SEPARATOR . "nginx.conf";
  48. $NGINX_SERVER_CONF_PATH = APP_EXAMPLE_PATH . DIRECTORY_SEPARATOR . "site.com.conf";
  49. $PHPFPM_CONF_PATH = APP_EXAMPLE_PATH . DIRECTORY_SEPARATOR . "php-fpm.conf";
  50. } else {
  51. $NGINX_CONF_PATH = APP_NGINX_CONF_PATH;
  52. $NGINX_SERVER_CONF_PATH = APP_NGINX_SERVER_CONF_PATH;
  53. $PHPFPM_CONF_PATH = APP_PHPFPM_CONF_PATH;
  54. }
  55. //echo("NGINX_CONF_PATH=$NGINX_CONF_PATH<br>");
  56. //echo("NGINX_SERVER_CONF_PATH=$NGINX_SERVER_CONF_PATH<br>");
  57. //echo("PHPFPM_CONF_PATH=$PHPFPM_CONF_PATH<br>");
  58. ?>
  59. <!DOCTYPE html>
  60. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  61. <head>
  62. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  63. <!--<?PHP echo(APP_LICENSE);?>-->
  64. <title><?PHP echo(APP_TITLE);?></title>
  65. <link rel="shortcut icon" href="/favicon.ico" />
  66. <meta name="description" content="Welcome to www-conf-viewer! Everyone its web config."/>
  67. <meta name="keywords" content="www-conf-viewer,web,configuration,viewer,on,premise,solution"/>
  68. <meta name="robots" content="index,follow"/>
  69. <meta name="author" content="5 Mode"/>
  70. <script src="/CONFVW_js/jquery-3.6.0.min.js" type="text/javascript"></script>
  71. <script src="/CONFVW_js/sha.js" type="text/javascript"></script>
  72. <script src="/CONFVW_js/common.js" type="text/javascript"></script>
  73. <link href="/CONFVW_css/style.css?r=<?PHP echo(time());?>" type="text/css" rel="stylesheet">
  74. </head>
  75. <body style="background:#dadada no-repeat; background-size: cover; background-attachment: fixed; background-position: center;">
  76. <div class="header" style="margin-top:18px;margin-bottom:18px;">
  77. <a href="http://www-conf-viewer.5mode-lab.com" 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:my25mb@aol.com" 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>
  78. </div>
  79. <form id="frmUpload" role="form" method="post" action="/" target="_self" enctype="multipart/form-data">
  80. <?PHP if (!MAX_SECURITY || (MAX_SECURITY && ($password != PHP_STR))) :?>
  81. <table style="width:100%">
  82. <tr>
  83. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  84. <div style="float:left;font-weight:900;font-size:12px;">NGINX (Core configuration)</div>
  85. <div style="float:right"><img src="/CONFVW_res/nginx.png" style="width:48px;" slt="Nginx logo"></div>
  86. </td>
  87. </tr>
  88. <?PHP
  89. $aNginxConf = file($NGINX_CONF_PATH, FILE_SKIP_EMPTY_LINES);
  90. if (!empty($aNginxConf)) {
  91. $nested = false;
  92. foreach($aNginxConf as $line) {
  93. $line = trim($line, " \n\r\t\v\x00");
  94. $line = trim($line, "\x00..\x1F");
  95. if (((mb_strlen($line) < 4) && ($line!="}")) || (left($line,1)=="#")) {
  96. continue;
  97. }
  98. $directive = explode(PHP_SPACE, $line)[0]??null;
  99. if (isset($directive) && strtolower(left($directive,4)=="http")) {
  100. break;
  101. }
  102. if (right($line,1)=="{") { ?>
  103. <tr>
  104. <td class="td-caption" colspan="2">
  105. <?PHP echo($directive); ?><br>
  106. <span id="directive-desc2">
  107. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  108. </span>
  109. </td>
  110. <td class="td-full-opts">
  111. &nbsp;
  112. </td>
  113. </tr>
  114. <?PHP $nested = true;
  115. continue;
  116. }
  117. if ($directive=="}") {
  118. $nested = false;
  119. continue;
  120. }
  121. if (isset($directive) && (left($directive,1)!="#") && ($directive!="}")) {
  122. $fullopts = substr($line, mb_strlen($directive)+1);
  123. $fullopts = rtrim($fullopts,";") ?? PHP_STR;
  124. ?>
  125. <tr>
  126. <?PHP if ($nested): ?>
  127. <!--<td class="td-tab">
  128. &nbsp;
  129. </td> -->
  130. <td class="td-caption2" colspan="2">
  131. <?PHP else: ?>
  132. <td class="td-caption" colspan="2">
  133. <?PHP endif; ?>
  134. <span id="directive"><?PHP echo($directive); ?></span><br>
  135. <span id="directive-desc">
  136. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  137. </span>
  138. </td>
  139. <td class="td-full-opts">
  140. <?PHP echo($fullopts); ?>
  141. </td>
  142. </tr>
  143. <?PHP
  144. }
  145. }
  146. }
  147. ?>
  148. <tr>
  149. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  150. <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>
  151. <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>
  152. </td>
  153. </tr>
  154. </table>
  155. <br><br>
  156. <table style="width:100%">
  157. <tr>
  158. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  159. <div style="float:left;font-weight:900;font-size:12px;">NGINX (HTTP configuration)</div>
  160. <div style="float:right"><img src="/CONFVW_res/nginx.png" style="width:48px;" slt="Nginx logo"></div>
  161. </td>
  162. </tr>
  163. <?PHP
  164. //$aNginxConf = file($NGINX_CONF_PATH, FILE_SKIP_EMPTY_LINES);
  165. if (!empty($aNginxConf)) {
  166. $found_http = false;
  167. $line_buff = "";
  168. $nested = false;
  169. foreach($aNginxConf as $line) {
  170. $line = trim($line, " \n\r\t\v\x00");
  171. $line = trim($line, "\x00..\x1F");
  172. if (((mb_strlen($line) < 4) && ($line!="}")) || (left($line,1)=="#")) {
  173. continue;
  174. }
  175. $directive = explode(PHP_SPACE, $line)[0]??null;
  176. // searching the initial token 'http'..
  177. if (isset($directive) && (strtolower($directive)!="http")) {
  178. if (!$found_http) {
  179. continue;
  180. }
  181. } else {
  182. $found_http = true;
  183. continue;
  184. }
  185. // exiting on the server token..
  186. if (isset($directive) && (strtolower($directive)=="map")) {
  187. break;
  188. }
  189. // exiting on the server token..
  190. if (isset($directive) && (strtolower($directive)=="server")) {
  191. break;
  192. }
  193. //echo("<tr><td>$directive (debug)</td><td>$line</td></tr>");
  194. if (right($line,1)!=";") {
  195. $line_buff .= $line . "|||||";
  196. continue;
  197. } else {
  198. if ($line_buff!=PHP_STR) {
  199. $line_buff .= $line . "|||||";
  200. $directive = explode(PHP_SPACE, $line_buff)[0]??null;
  201. }
  202. }
  203. if (right($line,1)=="{" || ($line_buff!=PHP_STR && !$nested)) { ?>
  204. <tr>
  205. <td class="td-caption" colspan="2">
  206. <?PHP echo($directive); ?><br>
  207. <span id="directive-desc2">
  208. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  209. </span>
  210. </td>
  211. <td class="td-full-opts">
  212. &nbsp;
  213. </td>
  214. </tr>
  215. <?PHP $nested = true;
  216. if ($line_buff==PHP_STR) {
  217. continue;
  218. }
  219. }
  220. if ($line_buff!=PHP_STR && $nested) {
  221. $ipos = stripos($line_buff, PHP_SPACE);
  222. $s = substr($line_buff,$ipos+1);
  223. $buffLines = explode("|||||", $s);
  224. foreach($buffLines as $buffLine) {
  225. if ($buffLine==PHP_STR) {
  226. continue;
  227. }
  228. ?>
  229. <tr>
  230. <td class="td-caption2" colspan="2">
  231. <span id="directive">&nbsp;</span>
  232. </td>
  233. <td class="td-full-opts">
  234. <?PHP echo(trim($buffLine,";")); ?>
  235. </td>
  236. </tr>
  237. <?PHP
  238. }
  239. $nested = false;
  240. $line_buff = PHP_STR;
  241. } else {
  242. if ($directive=="}") {
  243. $nested = false;
  244. continue;
  245. }
  246. if (isset($directive) && (left($directive,1)!="#") && ($directive!="}")) {
  247. $fullopts = substr($line, mb_strlen($directive)+1);
  248. $fullopts = rtrim($fullopts,";") ?? PHP_STR;
  249. ?>
  250. <tr>
  251. <?PHP if ($nested): ?>
  252. <td class="td-caption2" colspan="2">
  253. <?PHP else: ?>
  254. <td class="td-caption" colspan="2">
  255. <?PHP endif; ?>
  256. <span id="directive"><?PHP echo($directive); ?></span><br>
  257. <span id="directive-desc">
  258. <?PHP echo($NGINX_DIRECTIVES[$directive]??PHP_STR);?>
  259. </span>
  260. </td>
  261. <td class="td-full-opts">
  262. <?PHP echo($fullopts); ?>
  263. </td>
  264. </tr>
  265. <?PHP
  266. }
  267. }
  268. }
  269. }
  270. ?>
  271. <tr>
  272. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  273. <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>
  274. <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>
  275. </td>
  276. </tr>
  277. </table>
  278. <br><br>
  279. <table style="width:100%">
  280. <tr>
  281. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  282. <div style="float:left;font-weight:900;font-size:12px;">NGINX (SERVER configuration)</div>
  283. <div style="float:right"><img src="/CONFVW_res/nginx.png" style="width:48px;" slt="Nginx logo"></div>
  284. </td>
  285. </tr>
  286. <?PHP
  287. $serverConf = file($NGINX_SERVER_CONF_PATH);
  288. ?>
  289. <tr>
  290. <td class="td-server-spec" style="white-space:pre;">
  291. <?PHP
  292. $blank_lines = 0;
  293. foreach($serverConf as $line) {
  294. $sample = left($line,10);
  295. $sample = ltrim($sample);
  296. if ((mb_strlen(trim($line))<3) && (trim($line)!="}")) {
  297. $blank_lines++;
  298. continue;
  299. }
  300. if (left($sample, 1) != "#") {
  301. if ($blank_lines>0) {
  302. echo("\n");
  303. }
  304. echo(HTMLencode($line, true));
  305. $blank_lines = 0;
  306. }
  307. }
  308. ?>
  309. </td>
  310. </tr>
  311. <tr>
  312. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  313. <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>
  314. <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>
  315. </td>
  316. </tr>
  317. </table>
  318. <br><br>
  319. <table style="width:100%">
  320. <tr>
  321. <td colspan="3" style="width:100%;padding:10px;padding-bottom:7px;">
  322. <div style="float:left;font-weight:900;font-size:12px;">PHPFPM</div>
  323. <div style="float:right"><img src="/CONFVW_res/php.png" style="width:48px;" slt="Nginx logo"></div>
  324. </td>
  325. </tr>
  326. <?PHP
  327. if ($PHPFPM_CONF_PATH != PHP_STR) {
  328. $serverConf = file($PHPFPM_CONF_PATH);
  329. } else {
  330. $serverConf = [PHP_STR];
  331. }
  332. ?>
  333. <tr>
  334. <td class="td-server-spec-php" style="white-space:pre;">
  335. <?PHP
  336. $blank_lines = 0;
  337. foreach($serverConf as $line) {
  338. $sample = left($line,10);
  339. $sample = ltrim($sample);
  340. if ((mb_strlen(trim($line))<3) && (trim($line)!="}")) {
  341. $blank_lines++;
  342. continue;
  343. }
  344. if (left($sample, 1) != "#") {
  345. if ($blank_lines>0) {
  346. echo("\n");
  347. }
  348. echo(HTMLencode($line, true));
  349. $blank_lines = 0;
  350. }
  351. }
  352. ?>
  353. </td>
  354. </tr>
  355. <tr>
  356. <td colspan="3" style="width:100%;padding:8px;padding-top:12px;border-top: 1px dotted gray;">
  357. <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>
  358. <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>
  359. </td>
  360. </tr>
  361. </table>
  362. <?PHP else:
  363. echo("<div style='width:250px;padding-top:250px;font-weight:400;margin:auto;text-align:center;'>Login required.</div>");
  364. endif; ?>
  365. <br><br>
  366. <div id="passworddisplay">
  367. <br>
  368. &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>
  369. &nbsp;&nbsp;<input type="text" id="Salt" placeholder="salt" autocomplete="off"><br>
  370. <div style="text-align:center;">
  371. <a id="hashMe" href="#" onclick="showEncodedPassword();">Hash Me!</a>
  372. </div>
  373. </div>
  374. </form>
  375. <div id="footerCont">&nbsp;</div>
  376. <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>
  377. <script src="/CONFVW_js/home.js" type="text/javascript"></script>
  378. <!-- METRICS CODE -->
  379. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  380. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html"); ?>
  381. <?php endif; ?>
  382. </body>
  383. </html>