home.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <?PHP
  2. $CURRENT_VIEW = PUBLIC_VIEW;
  3. chdir(APP_DATA_PATH);
  4. $lang = APP_DEF_LANG;
  5. $lang1 = substr(strip_tags(filter_input(INPUT_GET, "hl")??""), 0, 5);
  6. if ($lang1 !== PHP_STR) {
  7. $lang = $lang1;
  8. }
  9. $lang2 = substr(strip_tags(filter_input(INPUT_POST, "hl")??""), 0, 5);
  10. if ($lang2 !== PHP_STR) {
  11. $lang = $lang2;
  12. }
  13. $shortLang = getShortLang($lang);
  14. $userName = PHP_STR;
  15. $password = strip_tags(substr(filter_input(INPUT_POST, "password")??"",0,25));
  16. //if ($password!==PHP_STR) {
  17. $hash = hash("sha256", $password . APP_SALT, false);
  18. $ownerNickname="";
  19. foreach($CONFIG['AUTH'] as $key => $val) {
  20. $ownerNickname = $CONFIG['AUTH'][$key]['NICKNAME'];
  21. if ($password===PHP_STR) {
  22. $hash = "";
  23. break;
  24. }
  25. if ($CONFIG['AUTH'][$key]['HASH'] === $hash) {
  26. define('USER_NAME', $key);
  27. $NICKNAME = $CONFIG['AUTH'][$key]['NICKNAME'];
  28. $PROFILE_PIC = $CONFIG['AUTH'][$key]['PROFILE_PIC'];
  29. $USER_COLOR = $CONFIG['AUTH'][$key]['COLOR'];
  30. $USER_LOCALE = $CONFIG['AUTH'][$key]['LOCALE'];
  31. if ($lang === APP_DEF_LANG) {
  32. $lang = $USER_LOCALE;
  33. }
  34. $shortLang = getShortLang($lang);
  35. break;
  36. }
  37. break;
  38. }
  39. if (!defined("USER_NAME")) {
  40. $password=PHP_STR;
  41. }
  42. //}
  43. if ($password === PHP_STR) {
  44. $CURRENT_VIEW = PUBLIC_VIEW;
  45. } else {
  46. $CURRENT_VIEW = ADMIN_VIEW;
  47. }
  48. $disc = strip_tags(substr(filter_input(INPUT_POST, "disc")??"",0,35));
  49. $act = strip_tags(substr(filter_input(INPUT_POST, "act")??"",0,1));
  50. //echo("disc=".$disc."<br>");
  51. //echo("act=".$act."<br>");
  52. if ($password !== PHP_STR) {
  53. // ACTION PRESSED..
  54. if ($disc !== PHP_STR && $act !== PHP_STR) {
  55. if ($act === "u") {
  56. rename(APP_DATA_PATH . DIRECTORY_SEPARATOR .$disc, APP_DATA_PATH . DIRECTORY_SEPARATOR .substr($disc, 0, strlen($disc)-2));
  57. } else {
  58. if (substr($disc, strlen($disc)-2, 1) === "_") {
  59. rename(APP_DATA_PATH . DIRECTORY_SEPARATOR .$disc, APP_DATA_PATH . DIRECTORY_SEPARATOR .substr($disc, 0, strlen($disc)-2)."_$act");
  60. } else {
  61. rename(APP_DATA_PATH . DIRECTORY_SEPARATOR .$disc, APP_DATA_PATH . DIRECTORY_SEPARATOR .$disc."_$act");
  62. }
  63. }
  64. }
  65. }
  66. ?>
  67. <!DOCTYPE html>
  68. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  69. <head>
  70. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  71. <!--<?PHP echo(APP_LICENSE);?>-->
  72. <title><?PHP echo(APP_TITLE);?></title>
  73. <link rel="shortcut icon" href="/favicon.ico" />
  74. <meta name="description" content="Welcome to Msg! Let everyone have its msg."/>
  75. <meta name="keywords" content="msg,msgbox,voice,machine,on,premise,solution"/>
  76. <meta name="robots" content="index,follow"/>
  77. <meta name="author" content="5 Mode"/>
  78. <script src="/js/jquery-3.6.0.min.js" type="text/javascript"></script>
  79. <script src="/js/sha.js" type="text/javascript"></script>
  80. <script src="/js/common.js" type="text/javascript"></script>
  81. <style>
  82. .blocked {
  83. background-color: red;
  84. color: #FFFFFF;
  85. }
  86. .butAdmin {
  87. border-radius: 15%;
  88. }
  89. .enabled {
  90. background-color: yellow;
  91. color: #000000;
  92. }
  93. .deleted {
  94. background-color: darkgray;
  95. color: #FFFFFF;
  96. }
  97. .disabled {
  98. background-color: #FFFFFF;
  99. color: #000000;
  100. }
  101. #prex {
  102. margin:10px;
  103. margin-right:15px;
  104. width:96%;
  105. }
  106. .rowdisc1 {
  107. width: 100%;
  108. max-width:430px;
  109. height:50px;
  110. font-size: 15px;
  111. font-weight: 900;
  112. veritical-align: middle;
  113. background-color: #FFFFFF;
  114. border: 1px solid lightgray;
  115. color:#000000;
  116. margin-right:auto;
  117. }
  118. .rowdisc2 {
  119. width: 100%;
  120. max-width:430px;
  121. height:50px;
  122. font-size: 15px;
  123. font-weight: 900;
  124. veritical-align: middle;
  125. background-color: #91C1E0;
  126. border: 1px solid lightgray;
  127. color:#000000;
  128. margin-right:auto;
  129. }
  130. </style>
  131. <link href="/css/style.css?r=<?PHP echo(time());?>" type="text/css" rel="stylesheet">
  132. <link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet">
  133. </head>
  134. <body style="background:#FFFFFF;margin-top:0px;">
  135. <div id="header" class="header" style="margin-top:5px;margin-bottom:18px;">
  136. <a href="http://msg.yourname.com" target="_self" style="color:#000000; text-decoration: none;">&nbsp;<img src="/res/AFlogo.png" align="middle" style="position:relative;top:-5px;width:32px;">&nbsp;<img src="/res/msg-logo.png" height="14px" style="position:relative;top:0px;left:-3px;"></a>&nbsp;&nbsp;<a href="https://github.com/par7133/Msg" style="color:#000000;"><span style="color:#119fe2">on</span> github</a>&nbsp;&nbsp;</a>
  137. </div>
  138. <form id="frmUpload" action="/home?hl=<?PHP echo($lang);?>" method="post">
  139. <?PHP
  140. if ($CURRENT_VIEW === PUBLIC_VIEW): ?>
  141. <div class="rowdisc1" style="height:70px;margin-left:20px;margin-top:100px;padding:10px;">
  142. <?PHP echo(getResource0("PERSONAL MSGBOX", $lang));?><br>
  143. <?PHP echo(getResource0("This is the personal msgbox of", $lang));?>&nbsp;<?PHP echo($ownerNickname);?>
  144. </div>
  145. <?PHP else:
  146. $pattern = APP_DATA_PATH . DIRECTORY_SEPARATOR . "*";
  147. $aDisc = glob($pattern, GLOB_ONLYDIR);
  148. echo("<pre id='prex'>");
  149. $i=0;
  150. $s=0;
  151. for ($y=1;$y<=2;$y++):
  152. foreach($aDisc as $disc):
  153. if ($i%2===0) {
  154. $className = "rowdisc1";
  155. } else {
  156. $className = "rowdisc2";
  157. }
  158. $a = explode("/", $disc);
  159. $myDisc = $a[count($a)-1];
  160. $myDisc2 = $myDisc;
  161. if (right($myDisc2, 2) === "_a") {
  162. $myDisc2 = mb_substr($myDisc2, 0, strlen($myDisc2)-2);
  163. }
  164. if (right($myDisc2, 2) === "_b") {
  165. $myDisc2 = mb_substr($myDisc2, 0, strlen($myDisc2)-2);
  166. }
  167. if (right($myDisc2, 2) === "_d") {
  168. $myDisc2 = mb_substr($myDisc2, 0, strlen($myDisc2)-2);
  169. }
  170. $bUnauth = true;
  171. $bAuth = false;
  172. $bBlock = false;
  173. $bDelete = false;
  174. if (right($myDisc, 2) === "_a") {
  175. $bAuth = true;
  176. }
  177. if (right($myDisc, 2) === "_b") {
  178. $bBlock = true;
  179. }
  180. if (right($myDisc, 2) === "_d") {
  181. $bDelete = true;
  182. }
  183. if (!$bAuth && !$bBlock && !$bDelete) {
  184. $bUnauth = true;
  185. } else {
  186. $bUnauth = false;
  187. }
  188. if ($y === 1) {
  189. if (!$bUnauth) {
  190. //$i++;
  191. continue;
  192. }
  193. } else {
  194. if ($bUnauth) {
  195. //$i++;
  196. continue;
  197. }
  198. }
  199. $myDisc3 = strtoupper($myDisc2);
  200. if (!$bDelete) {
  201. echo("<div class=\"". $className ."\">");
  202. echo("<br>");
  203. if (!$bBlock && !$bDelete) {
  204. echo("&nbsp;&nbsp;<a href=\"" . $myDisc2 . "\" style=\"text-decoration:none;\">".str_pad($myDisc3, 25, ".")."</a>");
  205. } else {
  206. if ($bBlock) {
  207. echo("&nbsp;&nbsp;<span style=\"text-decoration:line-through red; color:#000000;\">".str_pad($myDisc3, 25, " ")."</span>");
  208. } else {
  209. echo("&nbsp;&nbsp;<span style=\"text-decoration:line-through darkgray; color:darkgray;\">".str_pad($myDisc3, 25, " ")."</span>");
  210. }
  211. }
  212. echo("&nbsp;&nbsp;");
  213. if ($CURRENT_VIEW === ADMIN_VIEW) {
  214. echo("<input type=\"button\" class=\"butAdmin " . ($bUnauth?"enabled":"disabled") . "\" onclick=\"$('#disc').val('".$myDisc."');$('#act').val('u');frmUpload.submit();\" value=\"U\" title=\"".getResource0("Unhandle", $lang)."\">");
  215. echo("&nbsp;");
  216. }
  217. echo("<input type=\"button\" class=\"butAdmin " . ($bAuth?"enabled":"disabled") . "\" onclick=\"$('#disc').val('".$myDisc."');$('#act').val('a');frmUpload.submit();\" value=\"A\" title=\"".getResource0("Approved", $lang)."\">");
  218. echo("&nbsp;");
  219. echo("<input type=\"button\" class=\"butAdmin " . ($bBlock?"blocked":"disabled") . "\" onclick=\"$('#disc').val('".$myDisc."');$('#act').val('b');frmUpload.submit();\" value=\"B\" title=\"".getResource0("Ban", $lang)."\">");
  220. echo("&nbsp;");
  221. echo("<input type=\"button\" class=\"butAdmin " . ($bDelete?"deleted":"disabled") . "\" onclick=\"$('#disc').val('".$myDisc."');$('#act').val('d');frmUpload.submit();\" value=\"D\" title=\"".getResource0("Delete", $lang)."\">");
  222. echo("</div>");
  223. $s++;
  224. }
  225. $i++;
  226. endforeach;
  227. endfor;
  228. if ($s === 0) {
  229. echo(getResource0("No message found.", $lang));
  230. }
  231. echo("</pre>");
  232. echo("<br>");
  233. echo("<div id =\"footerfaq\" style=\"position:relative;float:right;height:40px;font-weight:900;\"><a href=\"/faq.html\">FAQ</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
  234. ?>
  235. <input id="disc" name="disc" type="hidden" value="">
  236. <input id="act" name="act" type="hidden" value="">
  237. <?PHP endif; ?>
  238. <div id="passworddisplay">
  239. <br>
  240. &nbsp;&nbsp;<input id="Password" name="password" type="password" placeholder="password" value="<?PHP echo($password);?>" autocomplete="off">&nbsp;<input id="Go" type="submit" value="<?PHP echo(getResource0("Go", $lang));?>"><br>
  241. &nbsp;&nbsp;<input id="Salt" type="text" placeholder="salt" autocomplete="off">
  242. <div style="text-align:center;">
  243. <a id="hashMe" href="#" onclick="showEncodedPassword();"><?PHP echo(getResource0("Hash Me", $lang));?>!</a>
  244. </div>
  245. </div>
  246. <input type="hidden" name="hl" value="<?PHP echo($lang);?>">
  247. </form>
  248. <div id="footterCont">&nbsp;</div>
  249. <div id="footer" style="position:relative;;">
  250. <div style="float:left">
  251. <select id="cbLang" onchange="changeLang(this);">
  252. <option value="en-US" <?PHP echo(($lang==PHP_EN?"selected":""));?>>en</option>
  253. <option value="it-IT" <?PHP echo(($lang==PHP_IT?"selected":""));?>>it</option>
  254. <option value="zh-CN" <?PHP echo(($lang==PHP_CN?"selected":""));?>>cn</option>
  255. </select>
  256. </div>
  257. <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. CC</span></div>
  258. <script>
  259. function changeLang(tthis) {
  260. window.open("/?hl="+$(tthis).val(),"_self");
  261. }
  262. function showEncodedPassword() {
  263. if ($("#Password").val() === "") {
  264. $("#Password").addClass("emptyfield");
  265. return;
  266. }
  267. //if ($("#Salt").val() === "") {
  268. // $("#Salt").addClass("emptyfield");
  269. // return;
  270. //}
  271. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  272. msg = "Please set your hash in the config file with this value";
  273. alert(msg + "\n\n" + passw);
  274. }
  275. function setFooterPos() {
  276. if (document.getElementById("footerCont")) {
  277. tollerance = 16;
  278. //$("#footerfaq").css("top", parseInt( window.innerHeight - $("#footerfaq").height() - tollerance ) + "px");
  279. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  280. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  281. }
  282. }
  283. function setContentPos2() {
  284. h=parseInt(window.innerHeight);
  285. w=parseInt(window.innerWidth);
  286. mytop = parseInt(h - ($("#passworddisplay").height() + 80));
  287. $("#passworddisplay").css("top", mytop+"px");
  288. $("#passworddisplay").show();
  289. $("#prex").css("height", parseInt(h - 170) + "px");
  290. $("#frmUpload").css("height", parseInt(h - 230) + "px");
  291. }
  292. function hidePassword() {
  293. //$("#passworddisplay").css("visibility","hidden");
  294. $("#passworddisplay").hide();
  295. }
  296. window.addEventListener("load", function() {
  297. setTimeout("setContentPos2()", 200);
  298. //setTimeout("setFooterPos()", 200);
  299. setTimeout("hidePassword()", 12000);
  300. }, true);
  301. window.addEventListener("resize", function() {
  302. setTimeout("setContentPos2()", 200);
  303. //setTimeout("setFooterPos()", 200);
  304. setTimeout("hidePassword()", 12000);
  305. }, true);
  306. </script>
  307. </body>
  308. </html>