index.php 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  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,19);
  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, $val);
  87. $mydate = $aFields[0]??PHP_STR;
  88. $mytime = $aFields[1]??PHP_STR;
  89. //$mydesc = $aFields[2]??PHP_STR;
  90. $myid = $mydate . 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 . "|" . $time . "|" . $s . "|u\n";
  224. updateHistory($output, HISTORY_MAX_ITEMS);
  225. echo("<script>");
  226. echo("window.open('/','_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 . "|" . $time . "|" . $s . "|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('/','_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. $str = trim($command);
  348. $ipos = stripos($str, PHP_SPACE);
  349. if ($ipos > 0) {
  350. $cmd = left($str, $ipos);
  351. $str = substr($str, $ipos+1);
  352. } else {
  353. $cmd = $str;
  354. return;
  355. }
  356. if (left($str, 1) === "-") {
  357. $ipos = stripos($str, PHP_SPACE);
  358. if ($ipos > 0) {
  359. $opt = left($str, $ipos);
  360. $str = substr($str, $ipos+1);
  361. } else {
  362. $opt = $str;
  363. return;
  364. }
  365. }
  366. if (left($str, 1) === "'") {
  367. $ipos = stripos($str, "'", 1);
  368. if ($ipos > 0) {
  369. $param1 = substr($str, 0, $ipos+1);
  370. $str = substr($str, $ipos+1);
  371. } else {
  372. $param1 = $str;
  373. return;
  374. }
  375. } else {
  376. $ipos = stripos($str, PHP_SPACE);
  377. if ($ipos > 0) {
  378. $param1 = left($str, $ipos);
  379. $str = substr($str, $ipos+1);
  380. } else {
  381. $param1 = $str;
  382. return;
  383. }
  384. }
  385. $ipos = stripos($str, PHP_SPACE);
  386. if ($ipos > 0) {
  387. $param2 = left($str, $ipos);
  388. $str = substr($str, $ipos+1);
  389. } else {
  390. $param2 = $str;
  391. return;
  392. }
  393. $ipos = stripos($str, PHP_SPACE);
  394. if ($ipos > 0) {
  395. $param3 = left($str, $ipos);
  396. $str = substr($str, $ipos+1);
  397. } else {
  398. $param3 = $str;
  399. return;
  400. }
  401. }
  402. function signParamValidation() {
  403. global $opt;
  404. global $param1;
  405. global $param2;
  406. global $param3;
  407. global $date;
  408. global $hour;
  409. global $min;
  410. global $desc;
  411. global $captchacount;
  412. global $captchasign;
  413. global $captchaHistory;
  414. //opt!=""
  415. if ($opt!==PHP_STR) {
  416. echo("WARNING: invalid options<br>");
  417. return false;
  418. }
  419. //param1==""
  420. if ($param1!==PHP_STR) {
  421. echo("WARNING: invalid parameters<br>");
  422. return false;
  423. }
  424. //param2==""
  425. if ($param2!==PHP_STR) {
  426. echo("WARNING: invalid parameters<br>");
  427. return false;
  428. }
  429. //param3==""
  430. if ($param3!==PHP_STR) {
  431. echo("WARNING: invalid parameters<br>");
  432. return false;
  433. }
  434. //date!=""
  435. if ($date===PHP_STR || strlen($date)<4) {
  436. //echo("WARNING: invalid date<br>");
  437. return false;
  438. }
  439. /*
  440. if (APP_MODE == CALENDAR_MODE_TYPE) {
  441. if ($hour===PHP_STR || strlen($hour)>2) {
  442. //echo("WARNING: invalid hour<br>");
  443. return false;
  444. }
  445. if ($min===PHP_STR || strlen($min)>2) {
  446. //echo("WARNING: invalid min<br>");
  447. return false;
  448. }
  449. }
  450. */
  451. //place!=""
  452. if ($desc===PHP_STR || strlen($desc)<4) {
  453. //echo("WARNING: invalid desc<br>");
  454. return false;
  455. }
  456. $rescaptcha1=$captchacount>=4;
  457. $rescaptcha2=count(array_filter($captchaHistory, "odd")) > (APP_MAX_FROM_IP - 1);
  458. //if ($rescaptcha1) {
  459. // echo("WARNING: captcha expired #1<br>");
  460. //}
  461. //if ($rescaptcha2) {
  462. // echo("WARNING: captcha expired #2<br>");
  463. //}
  464. ///if ($rescaptcha1 || $rescaptcha2) {
  465. //if ($rescaptcha1) {
  466. // return false;
  467. //}
  468. return true;
  469. }
  470. function odd($val) {
  471. global $captchasign;
  472. return rtrim($val,"\n") == $captchasign;
  473. }
  474. function myExecSignCommanddis() {
  475. global $date;
  476. global $hour;
  477. global $min;
  478. global $desc;
  479. global $curPath;
  480. global $lastMessage;
  481. global $captchacount;
  482. global $captchasign;
  483. global $captchaHistory;
  484. /*
  485. if (APP_MODE == EVENTS_MODE_TYPE) {
  486. $newSign = HTMLencodeF($date,false) . "|" . HTMLencodeF($desc,false) . "|u";
  487. } else {
  488. $newSign = HTMLencodeF($date,false) . "|" . HTMLencodeF($hour.":".((strlen($min)==1)?"0".$min:$min)) . "|" . HTMLencodeF($desc,false) . "|u";
  489. }
  490. */
  491. //echo("array_filter=".count(array_filter($captchaHistory, "odd"))."<br>");
  492. //echo("new_sign?=".((hash("sha256", $newSign . APP_SALT, false) !== $lastMessage)?"true":"false")."<br>");
  493. if (hash("sha256", $newSign . APP_SALT, false) !== $lastMessage) {
  494. // Updating message history..
  495. $output = [];
  496. $output[] = $newSign . "\n";
  497. updateHistory($output, HISTORY_MAX_ITEMS);
  498. // Updating captcha history..
  499. $output = [];
  500. $output[] = $captchasign . "\n";
  501. updatecaptchaHistory($output);
  502. $lastMessage = hash("sha256", $newSign . APP_SALT, false);
  503. }
  504. }
  505. function confParamValidation() {
  506. global $opt;
  507. global $param1;
  508. global $param2;
  509. global $param3;
  510. global $signHistory;
  511. global $signHistoryDateTime;
  512. //opt!=""
  513. if ($opt!==PHP_STR) {
  514. echo("WARNING: invalid options<br>");
  515. return false;
  516. }
  517. $myval = trim($param1,"'");
  518. //param1!=""
  519. if ($myval===PHP_STR) {
  520. echo("WARNING: invalid parameters<br>");
  521. return false;
  522. }
  523. //param1 in $signHistory
  524. //if (!in_array($myval."\n",$signHistory)) {
  525. if (!in_array($myval,$signHistoryDateTime)) {
  526. echo("WARNING: invalid parameters<br>");
  527. return false;
  528. }
  529. //param2==""
  530. if ($param2!==PHP_STR) {
  531. echo("WARNING: invalid parameters<br>");
  532. return false;
  533. }
  534. //param3==""
  535. if ($param3!==PHP_STR) {
  536. echo("WARNING: invalid parameters<br>");
  537. return false;
  538. }
  539. return true;
  540. }
  541. /*
  542. function myExecConfSignCommand() {
  543. global $param1;
  544. global $signHistory;
  545. global $curPath;
  546. $mysign = trim($param1,"'");
  547. if ($signHistory) {
  548. //echo("inside myExecConfSignCommand()");
  549. $newval = left($mysign, strlen($mysign)-2) . "|v";
  550. $key = array_search($mysign."\n", $signHistory);
  551. if ($key !== false) {
  552. $signHistory[$key] = $newval . "\n";
  553. // Writing out $signHistory on disk..
  554. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  555. file_put_contents($filepath, implode('', $signHistory));
  556. }
  557. }
  558. }
  559. */
  560. function myExecConfSignCommand() {
  561. global $param1;
  562. global $signHistory;
  563. global $curPath;
  564. global $signHistoryDateTime;
  565. $mysign = trim($param1,"'");
  566. if ($signHistory) {
  567. //echo("inside myExecConfSignCommand()");
  568. //$newval = left($mysign, strlen($mysign)-2) . "|v";
  569. $key = array_search($mysign, $signHistoryDateTime);
  570. if ($key !== false) {
  571. $newval = left($signHistory[$key], strlen($signHistory[$key])-3) . "|v";
  572. $signHistory[$key] = $newval . "\n";
  573. // Writing out $signHistory on disk..
  574. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  575. file_put_contents($filepath, implode('', $signHistory));
  576. }
  577. }
  578. }
  579. function delParamValidation() {
  580. global $opt;
  581. global $param1;
  582. global $param2;
  583. global $param3;
  584. global $signHistory;
  585. global $signHistoryDateTime;
  586. //opt!=""
  587. if ($opt!==PHP_STR) {
  588. echo("WARNING: invalid options<br>");
  589. return false;
  590. }
  591. $myval = trim($param1,"'");
  592. //param1!=""
  593. if ($myval===PHP_STR) {
  594. echo("WARNING: invalid parameters<br>");
  595. return false;
  596. }
  597. //param1 in $signHistory
  598. //if (!in_array($myval."\n",$signHistory)) {
  599. if (!in_array($myval,$signHistoryDateTime)) {
  600. echo("WARNING: invalid parameters1$myval<br>");
  601. return false;
  602. }
  603. //param2==""
  604. if ($param2!==PHP_STR) {
  605. echo("WARNING: invalid parameters<br>");
  606. return false;
  607. }
  608. //param3==""
  609. if ($param3!==PHP_STR) {
  610. echo("WARNING: invalid parameters<br>");
  611. return false;
  612. }
  613. return true;
  614. }
  615. /*
  616. function myExecDelSignCommand() {
  617. global $param1;
  618. global $signHistory;
  619. global $curPath;
  620. $mysign = trim($param1,"'");
  621. if ($signHistory) {
  622. //echo("inside myExecDelSignCommand()");
  623. $newval = left($mysign, strlen($mysign)-2) . "|u";
  624. $key = array_search($mysign."\n", $signHistory);
  625. if ($key !== false) {
  626. $signHistory[$key] = $newval . "\n";
  627. // Writing out $signHistory on disk..
  628. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  629. file_put_contents($filepath, implode('', $signHistory));
  630. }
  631. }
  632. }
  633. */
  634. function myExecDelSignCommand() {
  635. global $param1;
  636. global $signHistory;
  637. global $curPath;
  638. global $signHistoryDateTime;
  639. $mysign = trim($param1,"'");
  640. if ($signHistory) {
  641. //echo("inside myExecDelSignCommand()");
  642. //$newval = left($mysign, strlen($mysign)-2) . "|u";
  643. $key = array_search($mysign, $signHistoryDateTime);
  644. if ($key !== false) {
  645. $newval = left($signHistory[$key], strlen($signHistory[$key])-3) . "|u";
  646. $signHistory[$key] = $newval . "\n";
  647. // Writing out $signHistory on disk..
  648. $filepath = $curPath . DIRECTORY_SEPARATOR . ".DI_history";
  649. file_put_contents($filepath, implode('', $signHistory));
  650. }
  651. }
  652. }
  653. $password = filter_input(INPUT_POST, "Password")??"";
  654. $password = strip_tags($password);
  655. if ($password==PHP_STR) {
  656. $password = filter_input(INPUT_POST, "Password2")??"";
  657. $password = strip_tags($password);
  658. }
  659. $command = filter_input(INPUT_POST, "CommandLine")??"";
  660. $command = strip_tags($command);
  661. //$pwd = filter_input(INPUT_POST, "pwd");
  662. $hideSplash = filter_input(INPUT_POST, "hideSplash")??"";
  663. $hideSplash = strip_tags($hideSplash);
  664. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash")??"";
  665. $hideHCSplash = strip_tags($hideHCSplash);
  666. $date = filter_input(INPUT_POST, "date")??"";
  667. $date = strip_tags($date);
  668. $hour = filter_input(INPUT_POST, "hour")??"";
  669. $hour = strip_tags($hour);
  670. $min = filter_input(INPUT_POST, "min")??"";
  671. $min = strip_tags($min);
  672. $desc = filter_input(INPUT_POST, "desc")??"";
  673. $desc = strip_tags($desc);
  674. $captchasign = hash("sha256", $_SERVER["REMOTE_ADDR"] . date("Y") . APP_SALT, false);
  675. $lastMessage = filter_input(INPUT_POST, "last_message")??"";
  676. $lastMessage = strip_tags($lastMessage);
  677. $totsigns = count($signHistory);
  678. //print_r($totsigns);
  679. //exit(0);
  680. if ($totsigns > 0) {
  681. $lastMessage = hash("sha256", rtrim($signHistory[$totsigns-1],"\n") . APP_SALT, false);
  682. }
  683. $captchacount = (int)filter_input(INPUT_POST, "captcha_count")??"";
  684. $captchacount = strip_tags($captchacount);
  685. //if ($captchacount === 0) {
  686. // $captchacount = 1;
  687. //}
  688. if ($password !== PHP_STR) {
  689. $hash = hash("sha256", $password . APP_SALT, false);
  690. if ($hash !== APP_HASH) {
  691. $password=PHP_STR;
  692. }
  693. }
  694. parseCommand($command);
  695. //echo("cmd=" . $cmd . "<br>");
  696. //echo("opt=" . $opt . "<br>");
  697. //echo("param1=" . $param1 . "<br>");
  698. //echo("param2=" . $param2 . "<br>");
  699. if ($password !== PHP_STR) {
  700. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  701. if ($cmd === "sign") {
  702. $captchacount = $captchacount + 1;
  703. if (signParamValidation()) {
  704. myExecSignCommand();
  705. }
  706. } else if ($command === "refresh") {
  707. // refreshing Msg Board..
  708. }
  709. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  710. if ($cmd === "del") {
  711. if (delParamValidation()) {
  712. myExecDelSignCommand();
  713. }
  714. } else if ($cmd === "conf") {
  715. if (confParamValidation()) {
  716. myExecConfSignCommand();
  717. }
  718. }
  719. } else {
  720. }
  721. $contextType = PERSONAL_CONTEXT_TYPE;
  722. } else {
  723. /*
  724. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  725. if ($cmd === "sign") {
  726. $captchacount = $captchacount + 1;
  727. if (signParamValidation()) {
  728. myExecSignCommand();
  729. }
  730. }
  731. }*/
  732. }
  733. ?>
  734. <!DOCTYPE html>
  735. <head>
  736. <meta charset="UTF-8"/>
  737. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  738. <!--
  739. Copyright 2021, 2024 5 Mode
  740. This file is part of Homolog.
  741. Homolog is free software: you can redistribute it and/or modify
  742. it under the terms of the GNU General Public License as published by
  743. the Free Software Foundation, either version 3 of the License, or
  744. (at your option) any later version.
  745. Homolog is distributed in the hope that it will be useful,
  746. but WITHOUT ANY WARRANTY; without even the implied warranty of
  747. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  748. GNU General Public License for more details.
  749. You should have received a copy of the GNU General Public License
  750. along with Homologs. If not, see <https://www.gnu.org/licenses/>.
  751. -->
  752. <title><?php echo(APP_TITLE); ?></title>
  753. <link rel="shortcut icon" href="/favicon.ico?v=<?php echo(time()); ?>>" />
  754. <meta name="description" content="<?php echo(APP_DESCRIPTION); ?>"/>
  755. <meta name="keywords" content="<?php echo(APP_KEYWORDS); ?>"/>
  756. <meta name="author" content="5 Mode"/>
  757. <meta name="robots" content="index,follow"/>
  758. <script src="/DI_js/jquery-3.6.0.min.js" type="text/javascript"></script>
  759. <script src="/DI_js/common.js" type="text/javascript"></script>
  760. <script src="/DI_js/bootstrap.min.js" type="text/javascript"></script>
  761. <script src="/DI_js/index-js.php" type="text/javascript" defer></script>
  762. <link href="/DI_css/bootstrap.min.css" type="text/css" rel="stylesheet">
  763. <link href="/DI_css/style.css?r=<?PHP echo(time());?>" type="text/css" rel="stylesheet">
  764. <style>
  765. @import url('https://fonts.googleapis.com/css2?family=<?php echo(str_ireplace(" ","+",DISPLAY_DATE_FONT));?>');
  766. </style>
  767. </head>
  768. <body>
  769. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "jscheck.html")): ?>
  770. <?php include("jscheck.html"); ?>
  771. <?php endif; ?>
  772. <form id="frmDI" method="POST" action="/" target="_self" enctype="multipart/form-data">
  773. <?php if(APP_USE === "PRIVATE"): ?>
  774. <div class="header">
  775. <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:posta@elettronica.lol" 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>
  776. </div>
  777. <?php else: ?>
  778. <div class="header2">
  779. <?php echo(APP_CUSTOM_HEADER); ?>
  780. </div>
  781. <?php endif; ?>
  782. <div style="clear:both;margin:auto">&nbsp;</div>
  783. <?php
  784. $callSideBarTOP = 1;
  785. if(APP_USE === "PRIVATE") {
  786. $callSideBarTOP = 65;
  787. }
  788. ?>
  789. <div id="call-sidebar" style="top:<?php echo($callSideBarTOP);?>px;">
  790. &nbsp;
  791. </div>
  792. <div id="sidebar">
  793. <button id="sidebar-close" type="button" class="close" aria-label="Close" onclick="closeSideBar();">
  794. <span aria-hidden="true">&times;</span>
  795. </button>
  796. <br><br>
  797. <img id="genius" src="/DI_res/HLgenius.png" alt="HL Genius" title="HL Genius">
  798. &nbsp;<br><br>
  799. <div style="text-align:left;white-space:nowrap;">
  800. &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>
  801. &nbsp;<input id="Salt" class="sidebarcontrol" type="text" placeholder="salt" autocomplete="off"><br>
  802. <div style="text-align:center;">
  803. <a id="butHashMe" href="#" onclick="showEncodedPassword();"><?php echo(getResource("Hash Me", $curLocale));?>!</a>
  804. <br><br><br>
  805. </div>
  806. </div>
  807. </div>
  808. <div id="content-bar">
  809. <div style="width:100%; padding: 8px; text-align:center; font-size:26px; border:0px solid red;">
  810. <br>
  811. <?php if (APP_DEFAULT_CONTEXT === "PRIVATE"): ?>
  812. <div id="content-header">
  813. <?php if ($contextType === PUBLIC_CONTEXT_TYPE): ?>
  814. <div id="guest-msg"><h1><?php echo(APP_GUEST_MSG??"&nbsp;"); ?></h1></div>
  815. <?php else: ?>
  816. <div class="dragover" dropzone="copy" style="min-width:630px;">
  817. <div id="drop-img">
  818. <div id="fireupload" onclick="$('#files').click()">
  819. <img src="/DI_res/dnd2.gif">
  820. </div>
  821. </div>
  822. <div id="template-img">
  823. <div id="templated">
  824. <a href="/template.txt"><img src="/DI_res/template.png"></a>
  825. </div>
  826. </div>
  827. <input id="files" name="files[]" type="file" accept=".txt" style="visibility: hidden;" multiple>
  828. <input type="hidden" id="t" name="t">
  829. <div id="welcome-msg"><h1><?php echo(APP_WELCOME_MSG??"&nbsp;"); ?></h1></div>
  830. <div style="clear:both;margin:auto;"><br></div>
  831. <!-- <input type="hidden" name="msg-sign" value="<?php echo(mt_rand(1000000, 9999999)); ?>"> -->
  832. <input type="hidden" name="msg-sign" value="<?php echo($gdate . "|" . $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:60%;">
  844. <tr>
  845. <td id="fullExerpt" style="100%;white-space:pre;text-align:left;padding:30px;padding-top:5px;">
  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="visibility: hidden;" multiple>
  873. <input type="hidden" id="t" name="t">
  874. <div id="welcome-msg"><h1><?php echo(APP_WELCOME_MSG??"&nbsp;"); ?></h1></div>
  875. <div style="clear:both;margin:auto;"><br></div>
  876. <!-- <input type="hidden" name="msg-sign" value="<?php echo(mt_rand(1000000, 9999999)); ?>"> -->
  877. <input type="hidden" name="msg-sign" value="<?php echo($gdate . "|" . $gtime); ?>">
  878. <hr>
  879. <div style="clear:both;float:right;margin-right:120px;margin-bottom:30px;">
  880. <input id="txtSearch" name="q" type="text" class="search-control" value="<?PHP echo($q); ?>">
  881. &nbsp;&nbsp;
  882. <select id="cbCat" name="cat" class="search-control" onchange="reload();">
  883. <option value=""></option>
  884. <?PHP foreach ($aCats as $vcat): ?>
  885. <option value="<?PHP echo($vcat); ?>" <?PHP echo(($cat===$vcat)?"selected":"");?>><?PHP echo($vcat);?></option>
  886. <?PHP endforeach;?>
  887. </select>
  888. </div>
  889. </div>
  890. <br><br><br><br>
  891. <?php showHistory(); ?>
  892. <button id="modalButtonNew" type="button" class="btn btn-primary" style="display:none;" data-toggle="modal" data-target="#modalNew">Button #1</button>
  893. <div class="modal" tabindex="-1" role="dialog" id="modalNew">
  894. <div class="modal-dialog modal-lg my-modal-dialog" style="left:10%;" role="document">
  895. <div class="modal-content my-modal-content" style="height:550px;border:3px solid #000000; overflow:scroll;">
  896. <img src="/DI_res/pxl.png" style="width:98%; vertical-align:top; opacity:0.2">
  897. <div style="position:absolute; top:10px; width:100%;padding:50px;">
  898. <table style="width:60%;">
  899. <tr>
  900. <td id="fullExerpt" style="100%;white-space:pre;text-align:left;padding:30px;padding-top:5px;">
  901. &nbsp;
  902. </td>
  903. </tr>
  904. </table>
  905. </div>
  906. </div>
  907. <div class="modal-toolbox my-modal-toolbox" style="float:left;">
  908. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  909. </div>
  910. </div>
  911. </div>
  912. <?php else: ?>
  913. <div class="dragover" dropzone="copy" style="min-width:630px;">
  914. <div id="drop-img">
  915. <div id="fireupload" onclick="$('#files').click()">
  916. <img src="/DI_res/dnd2.gif">
  917. </div>
  918. </div>
  919. <div id="template-img">
  920. <div id="templated">
  921. <a href="/template.txt"><img src="/DI_res/template.png"></a>
  922. </div>
  923. </div>
  924. <input id="files" name="files[]" type="file" accept=".txt" style="visibility: hidden;" multiple>
  925. <input type="hidden" id="t" name="t">
  926. <div id="welcome-msg"><h1><?php echo(APP_WELCOME_MSG??"&nbsp;"); ?></h1></div>
  927. <div style="clear:both;margin:auto;"><br></div>
  928. <!-- <input type="hidden" name="msg-sign" value="<?php echo(mt_rand(1000000, 9999999)); ?>"> -->
  929. <input type="hidden" name="msg-sign" value="<?php echo($gdate . "|" . $gtime); ?>">
  930. <hr>
  931. <br>
  932. </div>
  933. <?php showHistory(); ?>
  934. <button id="modalButtonNew" type="button" class="btn btn-primary" style="display:none;" data-toggle="modal" data-target="#modalNew">Button #1</button>
  935. <div class="modal" tabindex="-1" role="dialog" id="modalNew">
  936. <div class="modal-dialog modal-lg my-modal-dialog" style="left:10%;" role="document">
  937. <div class="modal-content my-modal-content" style="height:550px;border:3px solid #000000; overflow:scroll;">
  938. <img src="/DI_res/pxl.png" style="width:98%; vertical-align:top; opacity:0.2">
  939. <div style="position:absolute; top:10px; width:100%;padding:50px;">
  940. <table style="width:60%;">
  941. <tr>
  942. <td id="fullExerpt" style="100%;white-space:pre;text-align:left;padding:30px;padding-top:5px;">
  943. &nbsp;
  944. </td>
  945. </tr>
  946. </table>
  947. </div>
  948. </div>
  949. <div class="modal-toolbox my-modal-toolbox" style="float:left;">
  950. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  951. </div>
  952. </div>
  953. </div>
  954. <?php endif; ?>
  955. <?php endif; ?>
  956. <div style="clear:both;margin:auto;"><br><br><br><br><br></div>
  957. <?php if(APP_USE === "BUSINESS"): ?>
  958. <div id="footer2">
  959. <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>
  960. </div>
  961. <?php endif; ?>&nbsp;
  962. </div>
  963. </div>
  964. <input type="hidden" id="CommandLine" name="CommandLine">
  965. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  966. <input type="hidden" name="hideHCSplash" value="1">
  967. <input type="hidden" name="captcha_count" value="<?php echo($captchacount); ?>">
  968. <input type="hidden" name="last_message" value="<?php echo($lastMessage); ?>">
  969. </form>
  970. <!--
  971. <div class="footer">
  972. <div id="footerCont">&nbsp;</div>
  973. <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>. Some rights reserved.</span></div>
  974. </div>
  975. -->
  976. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  977. <?php include("skinner.html"); ?>
  978. <?php endif; ?>
  979. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  980. <?php include("metrics.html"); ?>
  981. <?php endif; ?>
  982. </body>
  983. </html>