index.php 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of DropIn.
  6. *
  7. * DropIn 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. * DropIn 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 DropIn. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * index.php
  21. *
  22. * DropIn home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2021, 2024, 5 Mode
  26. */
  27. require "init.inc";
  28. $contextType = PUBLIC_CONTEXT_TYPE;
  29. $signHistory = [];
  30. $cmd = PHP_STR;
  31. $opt = PHP_STR;
  32. $param1 = PHP_STR;
  33. $param2 = PHP_STR;
  34. $param3 = PHP_STR;
  35. $curLocale = APP_LOCALE;
  36. $lastSign = PHP_STR;
  37. $msgSign = filter_input(INPUT_POST, "msg-sign")??"";
  38. $msgSign = strip_tags($msgSign);
  39. $q = filter_input(INPUT_POST, "q")??"";
  40. $q = strip_tags($q);
  41. $aCats = explode("|", trim(APP_CATS,"()"));
  42. $cat = filter_input(INPUT_POST, "cat")??"";
  43. $cat = strip_tags($cat);
  44. $curPath = APP_DATA_PATH;
  45. chdir($curPath);
  46. $gdate = date("Y-m-d");
  47. $gtime = date("H:i:s");
  48. $signHistory = file($curPath . DIRECTORY_SEPARATOR . ".DI_history");
  49. $signHistoryDateTime = $signHistory;
  50. foreach($signHistoryDateTime as &$el) {
  51. $el = left($el,21);
  52. }
  53. $captchaHistory = file($curPath . DIRECTORY_SEPARATOR . ".DI_captchahistory");
  54. function colorCats($s) {
  55. $pattern = '/' . APP_CATS . '/';
  56. $rep = '<span style="color:red">${1}</span>';
  57. return preg_replace($pattern, $rep, $s);
  58. }
  59. function showHistory() {
  60. global $signHistory;
  61. global $curPath;
  62. global $CONFIG;
  63. global $curLocale;
  64. global $LOCALE;
  65. global $lastSign;
  66. global $password;
  67. global $contextType;
  68. global $cat;
  69. global $q;
  70. $signHistoryCopy = $signHistory;
  71. rsort($signHistoryCopy);
  72. echo("<div id='events'>");
  73. $m = 1;
  74. foreach($signHistoryCopy as $val) {
  75. $val = rtrim($val, "\n");
  76. $mydate = PHP_STR;
  77. $mytime = PHP_STR;
  78. $mydesc = PHP_STR;
  79. $myflag = PHP_STR;
  80. // spec desc (field separator: ~~):
  81. // #title:
  82. // #desc:
  83. // #tags:
  84. // #cats:
  85. // text (separator: @@@)
  86. $aFields = explode(PHP_PIPE . PHP_PIPE. PHP_PIPE, $val);
  87. $mydate = $aFields[0]??PHP_STR;
  88. $mytime = $aFields[1]??PHP_STR;
  89. //$mydesc = $aFields[2]??PHP_STR;
  90. $myid = $mydate . PHP_PIPE . PHP_PIPE . PHP_PIPE . $mytime;
  91. $mytitle = str_replace("#title: ", PHP_STR, explode("~~", $aFields[2])[0]??PHP_STR);
  92. $mycat = str_replace("#cat: ", PHP_STR,explode("~~", $aFields[2])[3]??PHP_STR);
  93. if ($cat!=="") {
  94. if ($mycat!==$cat) {
  95. continue;
  96. }
  97. }
  98. $myheader = (explode("~~", $aFields[2])[0]??PHP_STR) . PHP_EOL . (explode("~~", $aFields[2])[1]??PHP_STR) . PHP_EOL . (explode("~~", $aFields[2])[2]??PHP_STR) . PHP_EOL . (explode("~~", $aFields[2])[3]??PHP_STR) . PHP_EOL;
  99. $mydesc = str_replace("@@@", PHP_EOL, explode("~~", $aFields[2])[4]??PHP_STR);
  100. if ($q!=="") {
  101. if (mb_stripos($myheader, $q) === false && mb_stripos($mydesc, $q) === false) {
  102. continue;
  103. }
  104. }
  105. $myflag = $aFields[3]??PHP_STR;
  106. if ($mydate==PHP_STR && $mydesc==PHP_STR) {
  107. continue;
  108. }
  109. //$mydesc = enableLinks($mydesc);
  110. // If I'm in admin
  111. if ($contextType === PERSONAL_CONTEXT_TYPE) {
  112. $adminFnc = PHP_STR;
  113. if ($myflag === "u") {
  114. $adminFnc = "<a href='#' onclick=\"confSign('" . $myid . "')\"><img src='/DI_res/confirm.png' style='width:36px;'></a>";
  115. } else {
  116. $adminFnc = "<a href='#' onclick=\"delSign('" . $myid . "')\"><img src='/DI_res/del.png' style='width:36px;'></a>";
  117. }
  118. echo("<table class='table-event' align='center'>");
  119. echo("<tr>");
  120. echo("<td class='td-data-date'>");
  121. echo("<span class='data-date' style='font-family:".DISPLAY_DATE_FONT.";'>".$mydate."</span>");
  122. echo("</td>");
  123. echo("<td class='td-data-time'>");
  124. echo("<span class='data-time' style='font-family:".DISPLAY_DATE_FONT.";'>".$mytime."</span>");
  125. echo("</td>");
  126. echo("<td class='td-data-title'>");
  127. echo("<span class='data-title' onclick='openEx(\"" . $m . "\");'>".$mytitle."</span>");
  128. echo("<div id='hheader".$m."' class='exerpt'>".colorCats(HTMLencode($myheader, true))."</div>");
  129. echo("<div id='eexerpt".$m."' class='exerpt'>".HTMLencode($mydesc, true)."</div>");
  130. echo("</td>");
  131. echo("<td class='td-admin'>");
  132. echo($adminFnc);
  133. echo("</td>");
  134. echo("</tr>");
  135. echo("</table>");
  136. // If I'm not in admin
  137. } else {
  138. if ($myflag !== "u") {
  139. echo("<div id='res".$m."' class='res'>");
  140. echo("<span class='resli' onclick='openEx(\"" . $m . "\");'>");
  141. echo("<span class='this-title'>".$mytitle."&nbsp;<span class='tag'>[$mycat]</span></span>");
  142. if (DISPLAY_SHOW_DATETIME) {
  143. echo("<br>");
  144. echo("<span class='data-date' style='font-family:".DISPLAY_DATE_FONT.";'>".$mydate."</span>");
  145. echo("&nbsp;");
  146. echo("<span class='data-time' style='font-family:".DISPLAY_DATE_FONT.";'>".$mytime."</span>");
  147. }
  148. echo("</span>");
  149. echo("<div id='hheader".$m."' class='exerpt'>".colorCats(HTMLencode($myheader, true))."</div>");
  150. echo("<div id='eexerpt".$m."' class='exerpt'>".HTMLencode($mydesc, true)."</div>");
  151. echo("</div>");
  152. }
  153. }
  154. $m++;
  155. }
  156. echo("</div>");
  157. }
  158. function updateHistory(&$update, $maxItems) {
  159. global $signHistory;
  160. global $curPath;
  161. // Making enough space in $signHistory for the update..
  162. $shift = (count($signHistory) + count($update)) - $maxItems;
  163. if ($shift > 0) {
  164. $signHistory = array_slice($signHistory, $shift, $maxItems);
  165. }
  166. // Adding $signHistory update..
  167. if (count($update) > $maxItems) {
  168. $beginUpd = count($update) - ($maxItems-1);
  169. } else {
  170. $beginUpd = 0;
  171. }
  172. $update = array_slice($update, $beginUpd, $maxItems);
  173. foreach($update as $val) {
  174. $signHistory[] = $val;
  175. }
  176. // Writing out $signHistory on disk..
  177. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  178. file_put_contents($filepath, implode('', $signHistory));
  179. }
  180. function updatecaptchaHistory(&$update) {
  181. global $captchaHistory;
  182. global $curPath;
  183. foreach($update as $val) {
  184. $captchaHistory[] = $val;
  185. }
  186. // Writing out $captchaHistory on disk..
  187. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_captchahistory";
  188. file_put_contents($filepath, implode('', $captchaHistory));
  189. }
  190. function upload() {
  191. global $curPath;
  192. global $signHistory;
  193. global $signHistoryDateTime;
  194. global $msgSign;
  195. $t = filter_input(INPUT_POST, "t")??"";
  196. $t = strip_tags($t);
  197. // Checking for repeated upload cause ie. caching prb..
  198. //$duplicateMsgs = glob($picPath . DIRECTORY_SEPARATOR . date("Ymd-H") . "*-$msgSign*.*");
  199. //if (!empty($duplicateMsgs)) {
  200. // echo("WARNING: destination already exists");
  201. // return;
  202. //}
  203. if (in_array($msgSign,$signHistoryDateTime)) {
  204. echo("WARNING: destination already exists");
  205. return;
  206. }
  207. if ($t !==PHP_STR) {
  208. $date = date("Y-m-d");
  209. $time = date("H:i:s");
  210. $fileContent = explode(PHP_EOL,$t);
  211. if (left($fileContent[0],8) !== "#title: ") {
  212. return;
  213. }
  214. // Updating history..
  215. $output = [];
  216. $s = PHP_STR;
  217. $s = rtrim($fileContent[0]) . "~~" . rtrim($fileContent[1]) . "~~" . rtrim($fileContent[2]) . "~~" . rtrim($fileContent[3]) . "~~" ;
  218. $d = PHP_STR;
  219. for ($i=4;$i<count($fileContent);$i++) {
  220. $d = $d . rtrim($fileContent[$i]) ."@@@";
  221. }
  222. $s = $s . "@@@" . $d;
  223. $output[] = $date . PHP_PIPE . PHP_PIPE . PHP_PIPE . $time . PHP_PIPE . PHP_PIPE . PHP_PIPE . $s . PHP_PIPE . PHP_PIPE . PHP_PIPE . "u\n";
  224. updateHistory($output, HISTORY_MAX_ITEMS);
  225. echo("<script>");
  226. echo("window.open('/?up=1','_self')");
  227. echo("</script>");
  228. exit;
  229. }
  230. if (!empty($_FILES['files']['tmp_name'][0]) || !empty($_FILES['filesdd']['tmp_name'][0])) {
  231. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  232. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  233. $uploads = (array)fixMultipleFileUpload($_FILES['filesdd']);
  234. }
  235. //no file uploaded
  236. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  237. echo("WARNING: No file uploaded.");
  238. return;
  239. }
  240. $google = "abcdefghijklmnopqrstuvwxyz";
  241. if (count($uploads)>strlen($google)) {
  242. echo("WARNING: Too many uploaded files.");
  243. return;
  244. }
  245. $i=1;
  246. foreach($uploads as &$upload) {
  247. switch ($upload['error']) {
  248. case PHP_UPLOAD_ERR_OK:
  249. break;
  250. case PHP_UPLOAD_ERR_NO_FILE:
  251. echo("WARNING: One or more uploaded files are missing.");
  252. return;
  253. case PHP_UPLOAD_ERR_INI_SIZE:
  254. echo("WARNING: File exceeded INI size limit.");
  255. return;
  256. case PHP_UPLOAD_ERR_FORM_SIZE:
  257. echo("WARNING: File exceeded form size limit.");
  258. return;
  259. case PHP_UPLOAD_ERR_PARTIAL:
  260. echo("WARNING: File only partially uploaded.");
  261. return;
  262. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  263. echo("WARNING: TMP dir doesn't exist.");
  264. return;
  265. case PHP_UPLOAD_ERR_CANT_WRITE:
  266. echo("WARNING: Failed to write to the disk.");
  267. return;
  268. case PHP_UPLOAD_ERR_EXTENSION:
  269. echo("WARNING: A PHP extension stopped the file upload.");
  270. return;
  271. default:
  272. echo("WARNING: Unexpected error happened.");
  273. return;
  274. }
  275. if (!is_uploaded_file($upload['tmp_name'])) {
  276. echo("WARNING: One or more file have not been uploaded.");
  277. return;
  278. }
  279. // name
  280. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  281. if ($name == PHP_STR) {
  282. echo("WARNING: Invalid file name: " . $name);
  283. return;
  284. }
  285. $upload['name'] = $name;
  286. // fileType
  287. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  288. $upload['type'] = $fileType;
  289. // tmp_name
  290. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  291. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  292. echo("WARNING: Invalid file temp path: " . $tmp_name);
  293. return;
  294. }
  295. $upload['tmp_name'] = $tmp_name;
  296. //size
  297. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  298. if ($size == "") {
  299. echo("WARNING: Invalid file size.");
  300. return;
  301. }
  302. $upload["size"] = $size;
  303. $tmpFullPath = $upload["tmp_name"];
  304. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  305. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  306. $fileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  307. if ($fileExt != "txt") {
  308. echo("WARNING: Invalid file extension.");
  309. return;
  310. }
  311. $date = date("Y-m-d");
  312. $time = date("H:i:s");
  313. $fileContent = file($tmpFullPath);
  314. if (left($fileContent[0],8) !== "#title: ") {
  315. return;
  316. }
  317. // Updating history..
  318. $output = [];
  319. $s = PHP_STR;
  320. $s = rtrim($fileContent[0]) . "~~" . rtrim($fileContent[1]) . "~~" . rtrim($fileContent[2]) . "~~" . rtrim($fileContent[3]) . "~~" ;
  321. $d = PHP_STR;
  322. for ($i=4;$i<count($fileContent);$i++) {
  323. $d = $d . rtrim($fileContent[$i]) ."@@@";
  324. }
  325. $s = $s . "@@@" . $d;
  326. $output[] = $date . PHP_PIPE . PHP_PIPE . PHP_PIPE . $time . PHP_PIPE . PHP_PIPE . PHP_PIPE . $s . PHP_PIPE . PHP_PIPE . PHP_PIPE ."u\n";
  327. updateHistory($output, HISTORY_MAX_ITEMS);
  328. // Cleaning up..
  329. // Delete the tmp file..
  330. unlink($tmpFullPath);
  331. $i++;
  332. }
  333. echo("<script>");
  334. echo("window.open('/?up=1','_self')");
  335. echo("</script>");
  336. exit;
  337. }
  338. }
  339. upload();
  340. function parseCommand() {
  341. global $command;
  342. global $cmd;
  343. global $opt;
  344. global $param1;
  345. global $param2;
  346. global $param3;
  347. //echo($command ."<br>");
  348. $str = trim($command);
  349. $ipos = stripos($str, PHP_SPACE);
  350. if ($ipos > 0) {
  351. $cmd = left($str, $ipos);
  352. $str = substr($str, $ipos+1);
  353. } else {
  354. $cmd = $str;
  355. return;
  356. }
  357. if (left($str, 1) === "-") {
  358. $ipos = stripos($str, PHP_SPACE);
  359. if ($ipos > 0) {
  360. $opt = left($str, $ipos);
  361. $str = substr($str, $ipos+1);
  362. } else {
  363. $opt = $str;
  364. return;
  365. }
  366. }
  367. if (left($str, 1) === "'") {
  368. $ipos = stripos($str, "'", 1);
  369. if ($ipos > 0) {
  370. $param1 = substr($str, 0, $ipos+1);
  371. $str = substr($str, $ipos+1);
  372. } else {
  373. $param1 = $str;
  374. return;
  375. }
  376. } else {
  377. $ipos = stripos($str, PHP_SPACE);
  378. if ($ipos > 0) {
  379. $param1 = left($str, $ipos);
  380. $str = substr($str, $ipos+1);
  381. } else {
  382. $param1 = $str;
  383. return;
  384. }
  385. }
  386. $ipos = stripos($str, PHP_SPACE);
  387. if ($ipos > 0) {
  388. $param2 = left($str, $ipos);
  389. $str = substr($str, $ipos+1);
  390. } else {
  391. $param2 = $str;
  392. return;
  393. }
  394. $ipos = stripos($str, PHP_SPACE);
  395. if ($ipos > 0) {
  396. $param3 = left($str, $ipos);
  397. $str = substr($str, $ipos+1);
  398. } else {
  399. $param3 = $str;
  400. return;
  401. }
  402. }
  403. function signParamValidation() {
  404. global $opt;
  405. global $param1;
  406. global $param2;
  407. global $param3;
  408. global $date;
  409. global $hour;
  410. global $min;
  411. global $desc;
  412. global $captchacount;
  413. global $captchasign;
  414. global $captchaHistory;
  415. //opt!=""
  416. if ($opt!==PHP_STR) {
  417. echo("WARNING: invalid options<br>");
  418. return false;
  419. }
  420. //param1==""
  421. if ($param1!==PHP_STR) {
  422. echo("WARNING: invalid parameters<br>");
  423. return false;
  424. }
  425. //param2==""
  426. if ($param2!==PHP_STR) {
  427. echo("WARNING: invalid parameters<br>");
  428. return false;
  429. }
  430. //param3==""
  431. if ($param3!==PHP_STR) {
  432. echo("WARNING: invalid parameters<br>");
  433. return false;
  434. }
  435. //date!=""
  436. if ($date===PHP_STR || strlen($date)<4) {
  437. //echo("WARNING: invalid date<br>");
  438. return false;
  439. }
  440. /*
  441. if (APP_MODE == CALENDAR_MODE_TYPE) {
  442. if ($hour===PHP_STR || strlen($hour)>2) {
  443. //echo("WARNING: invalid hour<br>");
  444. return false;
  445. }
  446. if ($min===PHP_STR || strlen($min)>2) {
  447. //echo("WARNING: invalid min<br>");
  448. return false;
  449. }
  450. }
  451. */
  452. //place!=""
  453. if ($desc===PHP_STR || strlen($desc)<4) {
  454. //echo("WARNING: invalid desc<br>");
  455. return false;
  456. }
  457. $rescaptcha1=$captchacount>=4;
  458. $rescaptcha2=count(array_filter($captchaHistory, "odd")) > (APP_MAX_FROM_IP - 1);
  459. //if ($rescaptcha1) {
  460. // echo("WARNING: captcha expired #1<br>");
  461. //}
  462. //if ($rescaptcha2) {
  463. // echo("WARNING: captcha expired #2<br>");
  464. //}
  465. ///if ($rescaptcha1 || $rescaptcha2) {
  466. //if ($rescaptcha1) {
  467. // return false;
  468. //}
  469. return true;
  470. }
  471. function odd($val) {
  472. global $captchasign;
  473. return rtrim($val,"\n") == $captchasign;
  474. }
  475. function myExecSignCommanddis() {
  476. global $date;
  477. global $hour;
  478. global $min;
  479. global $desc;
  480. global $curPath;
  481. global $lastMessage;
  482. global $captchacount;
  483. global $captchasign;
  484. global $captchaHistory;
  485. /*
  486. if (APP_MODE == EVENTS_MODE_TYPE) {
  487. $newSign = HTMLencodeF($date,false) . "|" . HTMLencodeF($desc,false) . "|u";
  488. } else {
  489. $newSign = HTMLencodeF($date,false) . "|" . HTMLencodeF($hour.":".((strlen($min)==1)?"0".$min:$min)) . "|" . HTMLencodeF($desc,false) . "|u";
  490. }
  491. */
  492. //echo("array_filter=".count(array_filter($captchaHistory, "odd"))."<br>");
  493. //echo("new_sign?=".((hash("sha256", $newSign . APP_SALT, false) !== $lastMessage)?"true":"false")."<br>");
  494. if (hash("sha256", $newSign . APP_SALT, false) !== $lastMessage) {
  495. // Updating message history..
  496. $output = [];
  497. $output[] = $newSign . "\n";
  498. updateHistory($output, HISTORY_MAX_ITEMS);
  499. // Updating captcha history..
  500. $output = [];
  501. $output[] = $captchasign . "\n";
  502. updatecaptchaHistory($output);
  503. $lastMessage = hash("sha256", $newSign . APP_SALT, false);
  504. }
  505. }
  506. function confParamValidation() {
  507. global $opt;
  508. global $param1;
  509. global $param2;
  510. global $param3;
  511. global $signHistory;
  512. global $signHistoryDateTime;
  513. //opt!=""
  514. if ($opt!==PHP_STR) {
  515. echo("WARNING: invalid options<br>");
  516. return false;
  517. }
  518. $myval = trim($param1,"'");
  519. //param1!=""
  520. if ($myval===PHP_STR) {
  521. echo("WARNING: invalid parameters<br>");
  522. return false;
  523. }
  524. //param1 in $signHistory
  525. //if (!in_array($myval."\n",$signHistory)) {
  526. if (!in_array($myval,$signHistoryDateTime)) {
  527. echo("WARNING: invalid parameters<br>");
  528. return false;
  529. }
  530. //param2==""
  531. if ($param2!==PHP_STR) {
  532. echo("WARNING: invalid parameters<br>");
  533. return false;
  534. }
  535. //param3==""
  536. if ($param3!==PHP_STR) {
  537. echo("WARNING: invalid parameters<br>");
  538. return false;
  539. }
  540. return true;
  541. }
  542. /*
  543. function myExecConfSignCommand() {
  544. global $param1;
  545. global $signHistory;
  546. global $curPath;
  547. $mysign = trim($param1,"'");
  548. if ($signHistory) {
  549. //echo("inside myExecConfSignCommand()");
  550. $newval = left($mysign, strlen($mysign)-3) . PHP_PIPE. PHP_PIPE ."v";
  551. $key = array_search($mysign."\n", $signHistory);
  552. if ($key !== false) {
  553. $signHistory[$key] = $newval . "\n";
  554. // Writing out $signHistory on disk..
  555. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  556. file_put_contents($filepath, implode('', $signHistory));
  557. }
  558. }
  559. }
  560. */
  561. function myExecConfSignCommand() {
  562. global $param1;
  563. global $signHistory;
  564. global $curPath;
  565. global $signHistoryDateTime;
  566. $mysign = trim($param1,"'");
  567. if ($signHistory) {
  568. //echo("inside myExecConfSignCommand()");
  569. //$newval = left($mysign, strlen($mysign)-3) . PHP_PIPE . PHP_PIPE . PHP_PIPE . "v";
  570. $key = array_search($mysign, $signHistoryDateTime);
  571. if ($key !== false) {
  572. $newval = left($signHistory[$key], strlen($signHistory[$key])-5) . PHP_PIPE . PHP_PIPE . PHP_PIPE ."v";
  573. $signHistory[$key] = $newval . "\n";
  574. // Writing out $signHistory on disk..
  575. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  576. file_put_contents($filepath, implode('', $signHistory));
  577. }
  578. }
  579. }
  580. function delParamValidation() {
  581. global $opt;
  582. global $param1;
  583. global $param2;
  584. global $param3;
  585. global $signHistory;
  586. global $signHistoryDateTime;
  587. //opt!=""
  588. if ($opt!==PHP_STR) {
  589. echo("WARNING: invalid options<br>");
  590. return false;
  591. }
  592. $myval = trim($param1,"'");
  593. //param1!=""
  594. if ($myval===PHP_STR) {
  595. echo("WARNING: invalid parameters<br>");
  596. return false;
  597. }
  598. //param1 in $signHistory
  599. //if (!in_array($myval."\n",$signHistory)) {
  600. if (!in_array($myval,$signHistoryDateTime)) {
  601. echo("WARNING: invalid parameters<br>");
  602. return false;
  603. }
  604. //param2==""
  605. if ($param2!==PHP_STR) {
  606. echo("WARNING: invalid parameters<br>");
  607. return false;
  608. }
  609. //param3==""
  610. if ($param3!==PHP_STR) {
  611. echo("WARNING: invalid parameters<br>");
  612. return false;
  613. }
  614. return true;
  615. }
  616. /*
  617. function myExecDelSignCommand() {
  618. global $param1;
  619. global $signHistory;
  620. global $curPath;
  621. $mysign = trim($param1,"'");
  622. if ($signHistory) {
  623. //echo("inside myExecDelSignCommand()");
  624. $newval = left($mysign, strlen($mysign)-2) . "|u";
  625. $key = array_search($mysign."\n", $signHistory);
  626. if ($key !== false) {
  627. $signHistory[$key] = $newval . "\n";
  628. // Writing out $signHistory on disk..
  629. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  630. file_put_contents($filepath, implode('', $signHistory));
  631. }
  632. }
  633. }
  634. */
  635. function myExecDelSignCommand() {
  636. global $param1;
  637. global $signHistory;
  638. global $curPath;
  639. global $signHistoryDateTime;
  640. $mysign = trim($param1,"'");
  641. if ($signHistory) {
  642. //echo("inside myExecDelSignCommand()");
  643. //$newval = left($mysign, strlen($mysign)-2) . "|u";
  644. $key = array_search($mysign, $signHistoryDateTime);
  645. if ($key !== false) {
  646. $newval = left($signHistory[$key], strlen($signHistory[$key])-5) . PHP_PIPE . PHP_PIPE . PHP_PIPE ."u";
  647. $signHistory[$key] = $newval . "\n";
  648. // Writing out $signHistory on disk..
  649. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  650. file_put_contents($filepath, implode('', $signHistory));
  651. }
  652. }
  653. }
  654. $password = filter_input(INPUT_POST, "Password")??"";
  655. $password = strip_tags($password);
  656. if ($password==PHP_STR) {
  657. $password = filter_input(INPUT_POST, "Password2")??"";
  658. $password = strip_tags($password);
  659. }
  660. $command = filter_input(INPUT_POST, "CommandLine")??"";
  661. $command = strip_tags($command);
  662. //$pwd = filter_input(INPUT_POST, "pwd");
  663. $hideSplash = filter_input(INPUT_POST, "hideSplash")??"";
  664. $hideSplash = strip_tags($hideSplash);
  665. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash")??"";
  666. $hideHCSplash = strip_tags($hideHCSplash);
  667. $date = filter_input(INPUT_POST, "date")??"";
  668. $date = strip_tags($date);
  669. $hour = filter_input(INPUT_POST, "hour")??"";
  670. $hour = strip_tags($hour);
  671. $min = filter_input(INPUT_POST, "min")??"";
  672. $min = strip_tags($min);
  673. $desc = filter_input(INPUT_POST, "desc")??"";
  674. $desc = strip_tags($desc);
  675. $captchasign = hash("sha256", $_SERVER["REMOTE_ADDR"] . date("Y") . APP_SALT, false);
  676. $lastMessage = filter_input(INPUT_POST, "last_message")??"";
  677. $lastMessage = strip_tags($lastMessage);
  678. $totsigns = count($signHistory);
  679. //print_r($totsigns);
  680. //exit(0);
  681. if ($totsigns > 0) {
  682. $lastMessage = hash("sha256", rtrim($signHistory[$totsigns-1],"\n") . APP_SALT, false);
  683. }
  684. $captchacount = (int)filter_input(INPUT_POST, "captcha_count")??"";
  685. $captchacount = strip_tags($captchacount);
  686. //if ($captchacount === 0) {
  687. // $captchacount = 1;
  688. //}
  689. if ($password !== PHP_STR) {
  690. $hash = hash("sha256", $password . APP_SALT, false);
  691. if ($hash !== APP_HASH) {
  692. $password=PHP_STR;
  693. }
  694. }
  695. parseCommand($command);
  696. //echo("cmd=" . $cmd . "<br>");
  697. //echo("opt=" . $opt . "<br>");
  698. //echo("param1=" . $param1 . "<br>");
  699. //echo("param2=" . $param2 . "<br>");
  700. if ($password !== PHP_STR) {
  701. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  702. if ($cmd === "sign") {
  703. $captchacount = $captchacount + 1;
  704. if (signParamValidation()) {
  705. myExecSignCommand();
  706. }
  707. } else if ($command === "refresh") {
  708. // refreshing Msg Board..
  709. }
  710. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  711. if ($cmd === "del") {
  712. if (delParamValidation()) {
  713. myExecDelSignCommand();
  714. }
  715. } else if ($cmd === "conf") {
  716. if (confParamValidation()) {
  717. myExecConfSignCommand();
  718. }
  719. }
  720. } else {
  721. }
  722. $contextType = PERSONAL_CONTEXT_TYPE;
  723. } else {
  724. /*
  725. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  726. if ($cmd === "sign") {
  727. $captchacount = $captchacount + 1;
  728. if (signParamValidation()) {
  729. myExecSignCommand();
  730. }
  731. }
  732. }*/
  733. }
  734. ?>
  735. <!DOCTYPE html>
  736. <head>
  737. <meta charset="UTF-8"/>
  738. <meta name="viewport" content="width=device-width, initial-scale=0.8"/>
  739. <!--
  740. Copyright 2021, 2024 5 Mode
  741. This file is part of DropIn.
  742. DropIn is free software: you can redistribute it and/or modify
  743. it under the terms of the GNU General Public License as published by
  744. the Free Software Foundation, either version 3 of the License, or
  745. (at your option) any later version.
  746. DropIn is distributed in the hope that it will be useful,
  747. but WITHOUT ANY WARRANTY; without even the implied warranty of
  748. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  749. GNU General Public License for more details.
  750. You should have received a copy of the GNU General Public License
  751. along with DropIn. If not, see <https://www.gnu.org/licenses/>.
  752. -->
  753. <title><?php echo(APP_TITLE); ?></title>
  754. <link rel="shortcut icon" href="/favicon.ico?v=<?php echo(time()); ?>>" />
  755. <meta name="description" content="<?php echo(APP_DESCRIPTION); ?>"/>
  756. <meta name="keywords" content="<?php echo(APP_KEYWORDS); ?>"/>
  757. <meta name="author" content="5 Mode"/>
  758. <meta name="robots" content="index,follow"/>
  759. <script src="/DI_js/jquery-3.6.0.min.js" type="text/javascript"></script>
  760. <script src="/DI_js/common.js" type="text/javascript"></script>
  761. <script src="/DI_js/bootstrap.min.js" type="text/javascript"></script>
  762. <script src="/DI_js/index-js.php" type="text/javascript" defer></script>
  763. <link href="/DI_css/bootstrap.min.css" type="text/css" rel="stylesheet">
  764. <link href="/DI_css/style.css?r=<?PHP echo(time());?>" type="text/css" rel="stylesheet">
  765. <style>
  766. @import url('https://fonts.googleapis.com/css2?family=<?php echo(str_ireplace(" ","+",DISPLAY_DATE_FONT));?>');
  767. </style>
  768. </head>
  769. <body>
  770. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "jscheck.html")): ?>
  771. <?php include("jscheck.html"); ?>
  772. <?php endif; ?>
  773. <form id="frmDI" method="POST" action="/" target="_self" enctype="multipart/form-data">
  774. <?php if(APP_USE === "PRIVATE"): ?>
  775. <div class="header">
  776. <a id="ahome" href="http://dropin.5mode-foss.eu" target="_blank" style="color:black; text-decoration: none;"><img id="logo-hmm" src="/DI_res/DIlogo.png" style="width:32px;">&nbsp;DropIn</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="agithub" href="https://github.com/par7133/DropIn" style="color:#000000"><span style="color:#119fe2">on</span> github</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="afeedback" href="mailto:code@gaox.io" style="color:#000000"><span style="color:#119fe2">for</span> feedback</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="asupport" href="tel:+39-378-0812391" style="font-size:13px;background-color:#15c60b;border:2px solid #15c60b;color:black;height:27px;text-decoration:none;">&nbsp;&nbsp;get support&nbsp;&nbsp;</a><div id="pwd2" style="float:right;position:relative;top:+13px;display:none"><input type="password" id="Password2" name="Password2" placeholder="password" style="font-size:13px; background:#393939; color:#ffffff; width: 125px; border-radius:3px;" value="" autocomplete="off"></div>
  777. </div>
  778. <?php else: ?>
  779. <div class="header2">
  780. <?php echo(APP_CUSTOM_HEADER); ?>
  781. </div>
  782. <?php endif; ?>
  783. <div style="clear:both;margin:auto">&nbsp;</div>
  784. <?php
  785. $callSideBarTOP = 1;
  786. if(APP_USE === "PRIVATE") {
  787. $callSideBarTOP = 65;
  788. }
  789. ?>
  790. <div id="call-sidebar" style="top:<?php echo($callSideBarTOP);?>px;">
  791. &nbsp;
  792. </div>
  793. <div id="sidebar">
  794. <button id="sidebar-close" type="button" class="close" aria-label="Close" onclick="closeSideBar();">
  795. <span aria-hidden="true">&times;</span>
  796. </button>
  797. <br><br>
  798. <img id="genius" src="/DI_res/HLgenius.png" alt="HL Genius" title="HL Genius">
  799. &nbsp;<br><br>
  800. <div style="text-align:left;white-space:nowrap;">
  801. &nbsp;<input id="Password" name="Password" class="sidebarcontrol" type="password" placeholder="password" value="<?php echo($password);?>" autocomplete="off">&nbsp;<input type="submit" class="sidebarcontrol" value="<?php echo(getResource("Go", $curLocale));?>" style="width:24%; height: 25px;background-color:lightgray;color:#000000;"><br>
  802. &nbsp;<input id="Salt" class="sidebarcontrol" type="text" placeholder="salt" autocomplete="off"><br>
  803. <div style="text-align:center;">
  804. <a id="butHashMe" href="#" onclick="showEncodedPassword();"><?php echo(getResource("Hash Me", $curLocale));?>!</a>
  805. <br><br><br>
  806. </div>
  807. </div>
  808. </div>
  809. <div id="content-bar">
  810. <div style="width:100%; padding: 8px; text-align:center; font-size:26px; border:0px solid red;">
  811. <br>
  812. <?php if (APP_DEFAULT_CONTEXT === "PRIVATE"): ?>
  813. <div id="content-header">
  814. <?php if ($contextType === PUBLIC_CONTEXT_TYPE): ?>
  815. <div id="guest-msg"><h1><?php echo(APP_GUEST_MSG??"&nbsp;"); ?></h1></div>
  816. <?php else: ?>
  817. <div class="dragover" dropzone="copy" style="min-width:630px;">
  818. <div id="drop-img">
  819. <div id="fireupload" onclick="$('#files').click()">
  820. <img src="/DI_res/dnd2.gif">
  821. </div>
  822. </div>
  823. <div id="template-img">
  824. <div id="templated">
  825. <a href="/template.txt"><img src="/DI_res/template.png"></a>
  826. </div>
  827. </div>
  828. <input id="files" name="files[]" type="file" accept=".txt" style="display:none;" multiple>
  829. <input type="hidden" id="t" name="t">
  830. <div id="welcome-msg"><h1><span id="page-title"><?php echo(APP_WELCOME_MSG??"&nbsp;"); ?></span></h1></div>
  831. <div style="clear:both;margin:auto;"><br></div>
  832. <input type="hidden" name="msg-sign" value="<?php echo($gdate . PHP_PIPE . PHP_PIPE . PHP_PIPE . $gtime); ?>">
  833. <hr>
  834. <br>
  835. </div>
  836. <?php showHistory(); ?>
  837. <button id="modalButtonNew" type="button" class="btn btn-primary" style="display:none;" data-toggle="modal" data-target="#modalNew">Button #1</button>
  838. <div class="modal" tabindex="-1" role="dialog" id="modalNew">
  839. <div class="modal-dialog modal-lg my-modal-dialog" style="left:10%;" role="document">
  840. <div class="modal-content my-modal-content" style="height:550px;border:3px solid #000000; overflow:scroll;">
  841. <img src="/DI_res/pxl.png" style="width:98%; vertical-align:top; opacity:0.2">
  842. <div style="position:absolute; top:10px; width:100%;padding:50px;">
  843. <table style="width:100%;">
  844. <tr>
  845. <td id="fullExerpt">
  846. &nbsp;
  847. </td>
  848. </tr>
  849. </table>
  850. </div>
  851. </div>
  852. <div class="modal-toolbox my-modal-toolbox" style="float:left;">
  853. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  854. </div>
  855. </div>
  856. </div>
  857. <?php endif; ?>
  858. <?php else: ?>
  859. <div id="content-header">
  860. <?php if ($contextType === PUBLIC_CONTEXT_TYPE): ?>
  861. <div class="dragover" dropzone="copy" style="min-width:630px;">
  862. <div id="drop-img">
  863. <div id="fireupload" onclick="$('#files').click()">
  864. <img src="/DI_res/dnd2.gif">
  865. </div>
  866. </div>
  867. <div id="template-img">
  868. <div id="templated">
  869. <a href="/template.txt"><img src="/DI_res/template.png"></a>
  870. </div>
  871. </div>
  872. <input id="files" name="files[]" type="file" accept=".txt" style="display:none;" multiple>
  873. <input type="hidden" id="t" name="t">
  874. <div id="welcome-msg"><br><h1><span id="page-title"><?php echo(APP_WELCOME_MSG??"&nbsp;"); ?></span></h1></div>
  875. <div style="clear:both;margin:auto;"><br></div>
  876. <input type="hidden" name="msg-sign" value="<?php echo($gdate . PHP_PIPE . PHP_PIPE . PHP_PIPE . $gtime); ?>">
  877. <hr>
  878. <div style="clear:both;float:right;margin-right:5%;margin-bottom:30px;">
  879. <input id="txtSearch" name="q" type="text" class="search-control" value="<?PHP echo($q); ?>">
  880. &nbsp;
  881. <select id="cbCat" name="cat" class="search-control" onchange="reload();">
  882. <option value=""></option>
  883. <?PHP foreach ($aCats as $vcat): ?>
  884. <option value="<?PHP echo($vcat); ?>" <?PHP echo(($cat===$vcat)?"selected":"");?>><?PHP echo($vcat);?></option>
  885. <?PHP endforeach;?>
  886. </select>
  887. </div>
  888. </div>
  889. <br><br><br><br>
  890. <?php showHistory(); ?>
  891. <button id="modalButtonNew" type="button" class="btn btn-primary" style="display:none;" data-toggle="modal" data-target="#modalNew">Button #1</button>
  892. <div class="modal" tabindex="-1" role="dialog" id="modalNew">
  893. <div class="modal-dialog modal-lg my-modal-dialog" style="left:10%;" role="document">
  894. <div class="modal-content my-modal-content" style="height:550px;border:3px solid #000000; overflow:scroll;">
  895. <img src="/DI_res/pxl.png" style="width:98%; vertical-align:top; opacity:0.2">
  896. <div style="position:absolute; top:10px; width:100%;padding:50px;">
  897. <table style="width:100%;">
  898. <tr>
  899. <td id="fullExerpt">
  900. &nbsp;
  901. </td>
  902. </tr>
  903. </table>
  904. </div>
  905. </div>
  906. <div class="modal-toolbox my-modal-toolbox" style="float:left;">
  907. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  908. </div>
  909. </div>
  910. </div>
  911. <?php else: ?>
  912. <div class="dragover" dropzone="copy" style="min-width:630px;">
  913. <div id="drop-img">
  914. <div id="fireupload" onclick="$('#files').click()">
  915. <img src="/DI_res/dnd2.gif">
  916. </div>
  917. </div>
  918. <div id="template-img">
  919. <div id="templated">
  920. <a href="/template.txt"><img src="/DI_res/template.png"></a>
  921. </div>
  922. </div>
  923. <input id="files" name="files[]" type="file" accept=".txt" style="display:none;" multiple>
  924. <input type="hidden" id="t" name="t">
  925. <div id="welcome-msg"><h1><span id="page-title"><?php echo(APP_WELCOME_MSG??"&nbsp;"); ?></span></h1></div>
  926. <div style="clear:both;margin:auto;"><br></div>
  927. <input type="hidden" name="msg-sign" value="<?php echo($gdate . PHP_PIPE . PHP_PIPE . PHP_PIPE . $gtime); ?>">
  928. <hr>
  929. <br>
  930. </div>
  931. <?php showHistory(); ?>
  932. <button id="modalButtonNew" type="button" class="btn btn-primary" style="display:none;" data-toggle="modal" data-target="#modalNew">Button #1</button>
  933. <div class="modal" tabindex="-1" role="dialog" id="modalNew">
  934. <div class="modal-dialog modal-lg my-modal-dialog" style="left:10%;" role="document">
  935. <div class="modal-content my-modal-content" style="height:550px;border:3px solid #000000; overflow:scroll;">
  936. <img src="/DI_res/pxl.png" style="width:98%; vertical-align:top; opacity:0.2">
  937. <div style="position:absolute; top:10px; width:100%;padding:50px;">
  938. <table style="width:100%;">
  939. <tr>
  940. <td id="fullExerpt">
  941. &nbsp;
  942. </td>
  943. </tr>
  944. </table>
  945. </div>
  946. </div>
  947. <div class="modal-toolbox my-modal-toolbox" style="float:left;">
  948. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  949. </div>
  950. </div>
  951. </div>
  952. <?php endif; ?>
  953. <?php endif; ?>
  954. <div style="clear:both;margin:auto;"><br><br><br><br><br></div>
  955. <?php if(APP_USE === "BUSINESS"): ?>
  956. <div id="footer2">
  957. <a id="ahome" href="http://dropin.5mode-foss.eu" target="_blank" style="color:black;"><img id="logo-hl" src="/DI_res/DIlogo.png">Powered by DropIn</a>
  958. </div>
  959. <?php endif; ?>&nbsp;
  960. </div>
  961. </div>
  962. <input type="hidden" id="CommandLine" name="CommandLine">
  963. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  964. <input type="hidden" name="hideHCSplash" value="1">
  965. <input type="hidden" name="captcha_count" value="<?php echo($captchacount); ?>">
  966. <input type="hidden" name="last_message" value="<?php echo($lastMessage); ?>">
  967. </form>
  968. <div class="footer">
  969. <div id="footerCont">&nbsp;</div>
  970. <div id="footer"><span style="background:#FFFFFF;opacity:1.0;margin-right:10px;">&nbsp;&nbsp;A <a href="http://5mode.com">5 Mode</a> project <span class="no-sm">and <a href="http://wysiwyg.systems">WYSIWYG</a> system</span>. CC&nbsp;&nbsp;</span></div>
  971. </div>
  972. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  973. <?php include("skinner.html"); ?>
  974. <?php endif; ?>
  975. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  976. <?php include("metrics.html"); ?>
  977. <?php endif; ?>
  978. </body>
  979. </html>