home.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of Homomm.
  6. *
  7. * Homomm 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. * Homomm 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 Homomm. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home.php
  21. *
  22. * Homomm home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2021, 2024, 5 Mode
  26. */
  27. $msgHistory = [];
  28. $cmd = PHP_STR;
  29. $opt = PHP_STR;
  30. $param1 = PHP_STR;
  31. $param2 = PHP_STR;
  32. $param3 = PHP_STR;
  33. $user = PHP_STR;
  34. $userName = PHP_STR;
  35. $chatHint = PHP_STR;
  36. $chatHintResolved = PHP_STR;
  37. $picPath = PHP_STR;
  38. $curPicture = PHP_STR;
  39. $curLocale = APP_LOCALE;
  40. $lastMessage = PHP_STR;
  41. function showHistory() {
  42. global $msgHistory;
  43. global $user;
  44. global $curPath;
  45. global $picPath;
  46. global $CONFIG;
  47. global $curLocale;
  48. global $LOCALE;
  49. global $EMOTICONS;
  50. global $lastMessage;
  51. $i = 1;
  52. $totMsgs = count($msgHistory);
  53. $oldDate = "";
  54. $m = 1;
  55. foreach($msgHistory as $val) {
  56. $delFunc = false;
  57. if ((mb_stripos($val, "-master") !== false) && ($user == "MASTER")) {
  58. $float = "right";
  59. $bgcolor = "#E3FAE3";
  60. } else if ((mb_stripos($val, "-master") === false) && ($user != "MASTER")) {
  61. $float = "right";
  62. $bgcolor = "#E3FAE3";
  63. } else {
  64. $float = "left";
  65. $bgcolor = "#FFFFFF";
  66. }
  67. echo("<div style='width:100%;height:auto;border:0px solid red;margin-bottom:12px;'>");
  68. $val = rtrim($val,"\n");
  69. // grab the date converting to the given time zone..
  70. //$dateori = left($val, 8);
  71. $dated = new DateTime(left($val,4)."-".substr($val,4,2)."-".substr($val,6,2)." ".substr($val,9,2).":".substr($val,11,2).":".substr($val,13,2));
  72. $dated = date_add1("H", ltrim($CONFIG['AUTH'][$user]['TIMEZONE'],"+")-APP_SERVER_TIMEZONE, $dated);
  73. $date = $dated->format("l j F");
  74. //$date = date("l j F", mktime(0,0,0,substr($dateori,4,2),right($dateori,2),left($dateori,4)));
  75. if (in_array($curLocale, ["CN", "JP", "KR"])) {
  76. $date = str_phrase_reverse($date);
  77. }
  78. $date = getResource($date, $curLocale);
  79. if ($date!=$oldDate) {
  80. echo("<div style='text-align:center;'><span style='background-color:gray;color:#FFFFFF'>$date</span></div><br>");
  81. $oldDate = $date;
  82. }
  83. // grab the time
  84. //preg_match('/^.+-(\d{6})-/i', $val, $matches);
  85. //$timereg = $matches[1];
  86. //$time = ltrim(left($timereg,2),"0") . ":" . substr($timereg,2,2);
  87. $time = $dated->format("H:i");
  88. // Checking for del functionality..
  89. // If it is one of the logged user msg..
  90. if ((($m==$totMsgs) || ($m==$totMsgs-1)) && ($float === "right")) {
  91. // file date
  92. //$origin = new DateTime(left($dateori,4) ."-". substr($dateori,4,2) ."-". right($dateori,2) . " " . left($timereg,2) .":". substr($timereg,2,2) .":". "00");
  93. //echo($dated->format("YMd H:i:s"));
  94. // current date
  95. $target = new DateTime();
  96. $interval = $dated->diff($target);
  97. $minInterval = $interval->format("%i");
  98. if ($minInterval<2) {
  99. $delFunc = true;
  100. }
  101. }
  102. if (is_image($val)) {
  103. // display the img
  104. $img = substr($picPath, strlen(APP_PATH)) . DIRECTORY_SEPARATOR . $val;
  105. $deldiv=PHP_STR;
  106. if ($delFunc) {
  107. $deldiv = "<div style='float:right;width:17px;position:relative;top:-4px;height:11px;cursor:pointer' onclick=\"deletePic('$val')\"><img src='/res/del.png' style='width:11px;'></div>";
  108. }
  109. echo("<div style='background-color:$bgcolor;float:$float;padding:5px;max-width:300px;min-width:260px;border-radius:2px;cursor:pointer;' onclick=\"openPic('$val')\"><img src='$img' style='width:100%;'><div style='float:right;font-size:9px;'>$time</div>$deldiv</div><br><br><br>");
  110. } else {
  111. // display the msg
  112. $msg = HTMLencode(file_get_contents($curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . $val));
  113. $msg = enableEmails($msg);
  114. $msg = enableLinks($msg);
  115. $msg = enableEmoticons($msg);
  116. $deldiv=PHP_STR;
  117. if ($delFunc) {
  118. $deldiv = "<div style='float:right;width:17px;position:relative;top:-4px;height:11px;cursor:pointer' onclick=\"deleteMsg('$val')\"><img src='/res/del.png' style='width:11px;'></div>";
  119. }
  120. echo("<div style='background-color:$bgcolor;float:$float;padding:5px;max-width:300px;min-width:260px;border-radius:2px;white-space:normal;'>".str_replace("\n", "<br>", $msg)."<div style='float:right;font-size:9px;'>$time</div>$deldiv</div><br><br><br>");
  121. }
  122. echo("<div style='clear:both;'></div>");
  123. echo("</div>");
  124. $lastMessage = hash("sha256", $val . APP_SALT, false);
  125. $m++;
  126. }
  127. }
  128. function updateHistory(&$update, $maxItems) {
  129. global $msgHistory;
  130. global $curPath;
  131. global $picPath;
  132. // Making enough space in $msgHistory for the update..
  133. $shift = (count($msgHistory) + count($update)) - $maxItems;
  134. if ($shift > 0) {
  135. $msgHistory = array_slice($msgHistory, $shift, $maxItems);
  136. }
  137. // Adding $msgHistory update..
  138. if (count($update) > $maxItems) {
  139. $beginUpd = count($update) - ($maxItems-1);
  140. } else {
  141. $beginUpd = 0;
  142. }
  143. $update = array_slice($update, $beginUpd, $maxItems);
  144. foreach($update as $val) {
  145. $msgHistory[] = $val;
  146. }
  147. // Deleting unused message files..
  148. foreach (glob($curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . "*.msg") as $msgFilePath) {
  149. $msgFileName = basename($msgFilePath);
  150. if (!in_array($msgFileName."\n", $msgHistory)) {
  151. unlink($curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . $msgFileName);
  152. }
  153. }
  154. // Deleting unused pic files..
  155. foreach (glob($picPath . DIRECTORY_SEPARATOR . "*") as $imgFilePath) {
  156. $imgFileName = basename($imgFilePath);
  157. if (!in_array($imgFileName."\n", $msgHistory)) {
  158. unlink($picPath . DIRECTORY_SEPARATOR . $imgFileName);
  159. }
  160. }
  161. // Writing out $msgHistory on disk..
  162. $filepath = $curPath . DIRECTORY_SEPARATOR . ".HMM_history";
  163. file_put_contents($filepath, implode('', $msgHistory));
  164. }
  165. function parseCommand() {
  166. global $command;
  167. global $cmd;
  168. global $opt;
  169. global $param1;
  170. global $param2;
  171. global $param3;
  172. $str = trim($command);
  173. $ipos = stripos($str, PHP_SPACE);
  174. if ($ipos > 0) {
  175. $cmd = left($str, $ipos);
  176. $str = substr($str, $ipos+1);
  177. } else {
  178. $cmd = $str;
  179. return;
  180. }
  181. if (left($str, 1) === "-") {
  182. $ipos = stripos($str, PHP_SPACE);
  183. if ($ipos > 0) {
  184. $opt = left($str, $ipos);
  185. $str = substr($str, $ipos+1);
  186. } else {
  187. $opt = $str;
  188. return;
  189. }
  190. }
  191. if (left($str, 1) === "'") {
  192. $ipos = stripos($str, "'", 1);
  193. if ($ipos > 0) {
  194. $param1 = substr($str, 0, $ipos+1);
  195. $str = substr($str, $ipos+1);
  196. } else {
  197. $param1 = $str;
  198. return;
  199. }
  200. } else {
  201. $ipos = stripos($str, PHP_SPACE);
  202. if ($ipos > 0) {
  203. $param1 = left($str, $ipos);
  204. $str = substr($str, $ipos+1);
  205. } else {
  206. $param1 = $str;
  207. return;
  208. }
  209. }
  210. $ipos = stripos($str, PHP_SPACE);
  211. if ($ipos > 0) {
  212. $param2 = left($str, $ipos);
  213. $str = substr($str, $ipos+1);
  214. } else {
  215. $param2 = $str;
  216. return;
  217. }
  218. $ipos = stripos($str, PHP_SPACE);
  219. if ($ipos > 0) {
  220. $param3 = left($str, $ipos);
  221. $str = substr($str, $ipos+1);
  222. } else {
  223. $param3 = $str;
  224. return;
  225. }
  226. }
  227. function upload() {
  228. global $curPath;
  229. global $user;
  230. global $userName;
  231. global $picPath;
  232. global $msgSign;
  233. //if (!empty($_FILES['files'])) {
  234. if (!empty($_FILES['files']['tmp_name'][0])) {
  235. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  236. //no file uploaded
  237. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  238. echo("WARNING: No file uploaded.");
  239. return;
  240. }
  241. $google = "abcdefghijklmnopqrstuvwxyz";
  242. if (count($uploads)>strlen($google)) {
  243. echo("WARNING: Too many uploaded files.");
  244. return;
  245. }
  246. // Checking for repeated upload cause ie. caching prb..
  247. $duplicateMsgs = glob($picPath . DIRECTORY_SEPARATOR . date("Ymd-H") . "*-$msgSign*.*");
  248. if (!empty($duplicateMsgs)) {
  249. echo("WARNING: destination already exists");
  250. return;
  251. }
  252. $i=1;
  253. foreach($uploads as &$upload) {
  254. switch ($upload['error']) {
  255. case PHP_UPLOAD_ERR_OK:
  256. break;
  257. case PHP_UPLOAD_ERR_NO_FILE:
  258. echo("WARNING: One or more uploaded files are missing.");
  259. return;
  260. case PHP_UPLOAD_ERR_INI_SIZE:
  261. echo("WARNING: File exceeded INI size limit.");
  262. return;
  263. case PHP_UPLOAD_ERR_FORM_SIZE:
  264. echo("WARNING: File exceeded form size limit.");
  265. return;
  266. case PHP_UPLOAD_ERR_PARTIAL:
  267. echo("WARNING: File only partially uploaded.");
  268. return;
  269. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  270. echo("WARNING: TMP dir doesn't exist.");
  271. return;
  272. case PHP_UPLOAD_ERR_CANT_WRITE:
  273. echo("WARNING: Failed to write to the disk.");
  274. return;
  275. case PHP_UPLOAD_ERR_EXTENSION:
  276. echo("WARNING: A PHP extension stopped the file upload.");
  277. return;
  278. default:
  279. echo("WARNING: Unexpected error happened.");
  280. return;
  281. }
  282. if (!is_uploaded_file($upload['tmp_name'])) {
  283. echo("WARNING: One or more file have not been uploaded.");
  284. return;
  285. }
  286. // name
  287. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  288. if ($name == PHP_STR) {
  289. echo("WARNING: Invalid file name: " . $name);
  290. return;
  291. }
  292. $upload['name'] = $name;
  293. // fileType
  294. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  295. $upload['type'] = $fileType;
  296. // tmp_name
  297. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  298. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  299. echo("WARNING: Invalid file temp path: " . $tmp_name);
  300. return;
  301. }
  302. $upload['tmp_name'] = $tmp_name;
  303. //size
  304. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  305. if ($size == "") {
  306. echo("WARNING: Invalid file size.");
  307. return;
  308. }
  309. $upload["size"] = $size;
  310. $tmpFullPath = $upload["tmp_name"];
  311. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  312. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  313. $fileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  314. $date = date("Ymd-His");
  315. $rnd = $msgSign;
  316. if ($originalFileExt!==PHP_STR) {
  317. if ($user == "MASTER") {
  318. $destFileName = $date . "-" . $rnd . substr($google, $i-1, 1) . "-master.$fileExt";
  319. } else {
  320. $destFileName = $date . "-" . $rnd . substr($google, $i-1, 1) . "-$userName.$fileExt";
  321. }
  322. } else {
  323. return;
  324. }
  325. $destFullPath = $picPath . DIRECTORY_SEPARATOR . $destFileName;
  326. if (file_exists($destFullPath)) {
  327. echo("WARNING: destination already exists");
  328. return;
  329. }
  330. copy($tmpFullPath, $destFullPath);
  331. // Updating history..
  332. $output = [];
  333. $output[] = $destFileName . "\n";
  334. updateHistory($output, HISTORY_MAX_ITEMS);
  335. // Cleaning up..
  336. // Delete the tmp file..
  337. unlink($tmpFullPath);
  338. $i++;
  339. }
  340. }
  341. }
  342. function myExecSendMessage() {
  343. global $curPath;
  344. global $message;
  345. global $user;
  346. global $userName;
  347. global $sendSMS;
  348. global $CONFIG;
  349. global $chatHintResolved;
  350. global $msgSign;
  351. $date = date("Ymd-His");
  352. $rnd = $msgSign;
  353. $duplicateMsgs = glob($curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . date("Ymd-H") . "*-$msgSign*.msg");
  354. if (!empty($duplicateMsgs)) {
  355. return;
  356. }
  357. if (!empty($message)) {
  358. if ($user == "MASTER") {
  359. $fileName = $date . "-" . $rnd . "-master.msg";
  360. } else {
  361. $fileName = $date . "-" . $rnd . "-$userName.msg";
  362. }
  363. $msg = $message;
  364. if (right($msg,1)!="\n") {
  365. $msg = $msg . "\n";
  366. }
  367. // Creating the msg file..
  368. file_put_contents($curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . $fileName, $msg);
  369. // Updating message history..
  370. $output = [];
  371. $output[] = $fileName . "\n";
  372. updateHistory($output, HISTORY_MAX_ITEMS);
  373. if ($user == "MASTER") {
  374. $smsUser = $chatHintResolved;
  375. } else {
  376. $smsUser = "MASTER";
  377. }
  378. // Sending out the sms notifcation..
  379. if ($sendSMS && SMS_USERNAME!=PHP_STR) {
  380. $message = array(
  381. 'To'=>$CONFIG['AUTH'][$smsUser]['PHONE'],
  382. 'MessagingServiceSid'=>SMS_MESSAGING_SERVICE,
  383. 'Body'=>SMS_BODY
  384. );
  385. sendSMS($message, SMS_API_URL, SMS_USERNAME, SMS_PASSWORD);
  386. }
  387. }
  388. }
  389. function delMsgParamValidation()
  390. {
  391. global $curPath;
  392. global $opt;
  393. global $param1;
  394. global $param2;
  395. global $param3;
  396. //opt!=""
  397. if ($opt!==PHP_STR) {
  398. //updateHistoryWithErr("invalid options");
  399. return false;
  400. }
  401. //param1!="" and isword
  402. if (($param1===PHP_STR) || !is_word($param1)) {
  403. //updateHistoryWithErr("invalid msg file");
  404. return false;
  405. }
  406. //param2==""
  407. if ($param2!==PHP_STR) {
  408. //updateHistoryWithErr("invalid parameters");
  409. return false;
  410. }
  411. //param3==""
  412. if ($param3!==PHP_STR) {
  413. //updateHistoryWithErr("invalid parameters");
  414. return false;
  415. }
  416. //param1 exist
  417. $path = $curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . $param1;
  418. if (!file_exists($path)) {
  419. //updateHistoryWithErr("file must exists");
  420. return false;
  421. }
  422. //param1 is_file
  423. if (!is_file($path)) {
  424. //updateHistoryWithErr("invalid msg file");
  425. return false;
  426. }
  427. //param1 file extension == msg
  428. if (!is_msg($param1)) {
  429. //updateHistoryWithErr("invalid msg file");
  430. return false;
  431. }
  432. // Checking file date
  433. // grab date
  434. $dateori = left($param1, 8);
  435. // grab time
  436. preg_match('/^.+-(\d{6})-/i', $param1, $matches);
  437. $timereg = $matches[1];
  438. $origin = new DateTime(left($dateori,4) ."-". substr($dateori,4,2) ."-". right($dateori,2) . " " . left($timereg,2) .":". substr($timereg,2,2) .":". right($timereg,2));
  439. //echo($origin->format("YMd H:i:s"));
  440. // current date
  441. $target = new DateTime();
  442. $interval = $origin->diff($target);
  443. $minInterval = $interval->format("%i");
  444. if ($minInterval>=2) {
  445. return false;
  446. }
  447. return true;
  448. }
  449. function myExecDelMsgCommand() {
  450. global $curPath;
  451. global $param1;
  452. global $msgHistory;
  453. // searching the file name in the msgHsitory
  454. $msgkey = array_search($param1."\n", $msgHistory);
  455. if ($msgkey !== false) {
  456. // Clearing out the msg from the history..
  457. unset($msgHistory[$msgkey]);
  458. $hpath = $curPath . DIRECTORY_SEPARATOR . ".HMM_history";
  459. file_put_contents($hpath, implode('', $msgHistory));
  460. // Deleting the msg file..
  461. $msgpath = $curPath . DIRECTORY_SEPARATOR . "msgs" . DIRECTORY_SEPARATOR . $param1;
  462. if (file_exists($msgpath)) {
  463. unlink($msgpath);
  464. }
  465. }
  466. }
  467. function delPicParamValidation()
  468. {
  469. global $picPath;
  470. global $opt;
  471. global $param1;
  472. global $param2;
  473. global $param3;
  474. //opt!=""
  475. if ($opt!==PHP_STR) {
  476. //updateHistoryWithErr("invalid options");
  477. return false;
  478. }
  479. //param1!="" and isword
  480. if (($param1===PHP_STR) || !is_word($param1)) {
  481. //updateHistoryWithErr("invalid pic file");
  482. return false;
  483. }
  484. //param2==""
  485. if ($param2!==PHP_STR) {
  486. //updateHistoryWithErr("invalid parameters");
  487. return false;
  488. }
  489. //param3==""
  490. if ($param3!==PHP_STR) {
  491. //updateHistoryWithErr("invalid parameters");
  492. return false;
  493. }
  494. //param1 exist
  495. $path = $picPath . DIRECTORY_SEPARATOR . $param1;
  496. if (!file_exists($path)) {
  497. //updateHistoryWithErr("pic must exists");
  498. return false;
  499. }
  500. //param1 is_file
  501. if (!is_file($path)) {
  502. //updateHistoryWithErr("invalid pic file");
  503. return false;
  504. }
  505. //param1 is_image
  506. if (!is_image($param1)) {
  507. //updateHistoryWithErr("invalid pic file");
  508. return false;
  509. }
  510. // Checking file date
  511. // grab date
  512. $dateori = left($param1, 8);
  513. // grab time
  514. preg_match('/^.+-(\d{6})-/i', $param1, $matches);
  515. $timereg = $matches[1];
  516. $origin = new DateTime(left($dateori,4) ."-". substr($dateori,4,2) ."-". right($dateori,2) . " " . left($timereg,2) .":". substr($timereg,2,2) .":". right($timereg,2));
  517. //echo($origin->format("YMd H:i:s"));
  518. // current date
  519. $target = new DateTime();
  520. $interval = $origin->diff($target);
  521. $minInterval = $interval->format("%i");
  522. if ($minInterval>=2) {
  523. return false;
  524. }
  525. return true;
  526. }
  527. function myExecDelPicCommand() {
  528. global $picPath;
  529. global $curPath;
  530. global $param1;
  531. global $msgHistory;
  532. // searching the file name in the msgHistory
  533. $msgkey = array_search($param1."\n", $msgHistory);
  534. if ($msgkey !== false) {
  535. // Clearing out the msg from the history..
  536. unset($msgHistory[$msgkey]);
  537. $hpath = $curPath . DIRECTORY_SEPARATOR . ".HMM_history";
  538. file_put_contents($hpath, implode('', $msgHistory));
  539. // Deleting the pic file..
  540. $picpath = $picPath . DIRECTORY_SEPARATOR . $param1;
  541. if (file_exists($picpath)) {
  542. unlink($picpath);
  543. }
  544. }
  545. }
  546. function openPicParamValidation()
  547. {
  548. global $picPath;
  549. global $opt;
  550. global $param1;
  551. global $param2;
  552. global $param3;
  553. //opt!=""
  554. if ($opt!==PHP_STR) {
  555. //updateHistoryWithErr("invalid options");
  556. return false;
  557. }
  558. //param1!="" and isword
  559. if (($param1===PHP_STR) || !is_word($param1)) {
  560. //updateHistoryWithErr("invalid pic file");
  561. return false;
  562. }
  563. //param2==""
  564. if ($param2!==PHP_STR) {
  565. //updateHistoryWithErr("invalid parameters");
  566. return false;
  567. }
  568. //param3==""
  569. if ($param3!==PHP_STR) {
  570. //updateHistoryWithErr("invalid parameters");
  571. return false;
  572. }
  573. //param1 exist
  574. $path = $picPath . DIRECTORY_SEPARATOR . $param1;
  575. if (!file_exists($path)) {
  576. //updateHistoryWithErr("pic must exists");
  577. return false;
  578. }
  579. //param1 is_file
  580. if (!is_file($path)) {
  581. //updateHistoryWithErr("invalid pic file");
  582. return false;
  583. }
  584. //param1 is_image
  585. if (!is_image($param1)) {
  586. //updateHistoryWithErr("invalid pic file");
  587. return false;
  588. }
  589. return true;
  590. }
  591. function myExecOpenPicCommand() {
  592. global $picPath;
  593. global $curPicture;
  594. global $param1;
  595. $curPicture = substr($picPath.DIRECTORY_SEPARATOR.$param1, strlen(dirname(APP_PIC_PATH)));
  596. }
  597. $password = filter_input(INPUT_POST, "Password")??"";
  598. $password = strip_tags($password);
  599. if ($password==PHP_STR) {
  600. $password = filter_input(INPUT_POST, "Password2")??"";
  601. $password = strip_tags($password);
  602. }
  603. $command = filter_input(INPUT_POST, "CommandLine")??"";
  604. $command = strip_tags($command);
  605. $message = filter_input(INPUT_POST, "MessageLine")??"";
  606. $message = strip_tags($message);
  607. $sendSMS1 = filter_input(INPUT_POST, "chkSMS")??"";
  608. $sendSMS1 = strip_tags($sendSMS1);
  609. $oldMsgSign = filter_input(INPUT_POST, "old-msg-sign")??"";
  610. $oldMsgSign = strip_tags($oldMsgSign);
  611. $msgSign = filter_input(INPUT_POST, "msg-sign")??"";
  612. $msgSign = strip_tags($msgSign);
  613. if ($sendSMS1!=PHP_STR) {
  614. $sendSMS = true;
  615. } else {
  616. $sendSMS = false;
  617. }
  618. $pwd = PHP_STR;
  619. $chatHint = filter_input(INPUT_POST, "chatHint")??"";
  620. $chatHint = strip_tags($chatHint);
  621. // chat validation
  622. $chatHintResolved = PHP_STR;
  623. if ($chatHint!=PHP_STR) {
  624. $found=false;
  625. foreach ($CONFIG['AUTH'] as $key => $val) {
  626. if ($chatHint==$val['USERNAME']) {
  627. $chatHintResolved = $key;
  628. $found=true;
  629. break;
  630. }
  631. }
  632. if (!$found) {
  633. die("Invalid chat!");
  634. }
  635. }
  636. //echo ("chatHint*=".$chatHint."<br>");
  637. //echo ("chatHintResolved*=".$chatHintResolved."<br>");
  638. $hideSplash = filter_input(INPUT_POST, "hideSplash")??"";
  639. $hideSplash = strip_tags($hideSplash);
  640. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash")??"";
  641. $hideHCSplash = strip_tags($hideHCSplash);
  642. //echo "password=*$password*<br>";
  643. if ($password != PHP_STR) {
  644. $hash = hash("sha256", $password . APP_SALT, false);
  645. $found=false;
  646. foreach ($CONFIG['AUTH'] as $key => $val) {
  647. //echo ("username=".$val['USERNAME']."<br>");
  648. if ($hash==$val['HASH']) {
  649. $user = $key;
  650. if ($chatHintResolved==PHP_STR) {
  651. $chatHint=$val['USERNAME'];
  652. $chatHintResolved = $key;
  653. } else {
  654. if ($user != "MASTER") {
  655. if ($user != $chatHintResolved) {
  656. $found=false;
  657. break;
  658. }
  659. }
  660. }
  661. $found=true;
  662. //echo ("user=".$user."<br>");
  663. //echo ("chatHint**=".$chatHint."<br>");
  664. //echo ("chatHintResolved**=".$chatHintResolved."<br>");
  665. break;
  666. }
  667. }
  668. if (!$found) {
  669. $password=PHP_STR;
  670. }
  671. if ($password != PHP_STR) {
  672. $userName = $CONFIG['AUTH'][$user]['USERNAME'];
  673. // xxx
  674. //$pwd = APP_REPO_PATH . DIRECTORY_SEPARATOR . $CONFIG['AUTH'][$chatHintResolved]['REPO_FOLDER'];
  675. $pwd = $CONFIG['AUTH'][$chatHintResolved]['REPO_FOLDER'];
  676. $picPath = APP_PIC_PATH . DIRECTORY_SEPARATOR . $CONFIG['AUTH'][$chatHintResolved]['PIC_FOLDER'];
  677. $curLocale = $CONFIG['AUTH'][$user]['LOCALE'];
  678. }
  679. }
  680. $curPath = APP_REPO_PATH;
  681. if ($pwd!=PHP_STR) {
  682. //if (left($pwd, strlen(APP_REPO_PATH)) === APP_REPO_PATH) {
  683. // $curPath = $pwd;
  684. if (file_exists(APP_REPO_PATH . DIRECTORY_SEPARATOR . $pwd)) {
  685. $curPath = APP_REPO_PATH . DIRECTORY_SEPARATOR . $pwd;
  686. chdir($curPath);
  687. if (!file_exists($curPath . DIRECTORY_SEPARATOR . ".HMM_history")) {
  688. $output = [];
  689. file_put_contents($curPath . DIRECTORY_SEPARATOR . ".HMM_history", $output);
  690. }
  691. if (!file_exists($curPath . DIRECTORY_SEPARATOR . "msgs")) {
  692. mkdir("msgs", 0777);
  693. }
  694. } else {
  695. // xxx
  696. $password = PHP_STR;
  697. }
  698. } else {
  699. // xxx
  700. $password = PHP_STR;
  701. }
  702. $ipos = strripos($curPath, PHP_SLASH);
  703. $curDir = substr($curPath, $ipos);
  704. if ($password != PHP_STR) {
  705. $msgHistory = file($curPath . DIRECTORY_SEPARATOR . ".HMM_history");
  706. parseCommand($command);
  707. //echo("cmd=" . $cmd . "<br>");
  708. //echo("opt=" . $opt . "<br>");
  709. //echo("param1=" . $param1 . "<br>");
  710. //echo("param2=" . $param2 . "<br>");
  711. //upload();
  712. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  713. if ($command === "sendmsg") {
  714. if (trim($message,"\n")!==PHP_STR) {
  715. myExecSendMessage();
  716. upload();
  717. }
  718. } else if ($command === "refreshbrd") {
  719. // refreshing Msg Board..
  720. }
  721. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  722. if ($cmd === "delmsg") {
  723. if (delMsgParamValidation()) {
  724. myExecDelMsgCommand();
  725. }
  726. } else if ($cmd === "delpic") {
  727. if (delPicParamValidation()) {
  728. myExecDelPicCommand();
  729. }
  730. } else if ($cmd === "openpic") {
  731. if (openPicParamValidation()) {
  732. myExecOpenPicCommand();
  733. }
  734. }
  735. } else {
  736. // if I'm not saving data..
  737. //if (empty($editBoardParams) || $editBoardParams[0]['location']===PHP_STR) {
  738. // if (empty($_FILES['files']['tmp_name'][0])) {
  739. // updateHistoryWithErr("invalid command");
  740. // }
  741. //}
  742. }
  743. } else {
  744. $msgHistory = [];
  745. }
  746. ?>
  747. <!DOCTYPE html>
  748. <head>
  749. <meta charset="UTF-8"/>
  750. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  751. <!--
  752. Copyright 2021, 2024 5 Mode
  753. This file is part of Homomm.
  754. Homomm is free software: you can redistribute it and/or modify
  755. it under the terms of the GNU General Public License as published by
  756. the Free Software Foundation, either version 3 of the License, or
  757. (at your option) any later version.
  758. Homomm is distributed in the hope that it will be useful,
  759. but WITHOUT ANY WARRANTY; without even the implied warranty of
  760. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  761. GNU General Public License for more details.
  762. You should have received a copy of the GNU General Public License
  763. along with Homomm. If not, see <https://www.gnu.org/licenses/>.
  764. -->
  765. <title>Homomm: every person its messages..</title>
  766. <link rel="shortcut icon" href="/favicon.ico?v=<?php echo(time()); ?>" />
  767. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  768. <meta name="author" content="5 Mode"/>
  769. <meta name="robots" content="noindex"/>
  770. <script src="/js/jquery-3.6.0.min.js" type="text/javascript"></script>
  771. <script src="/js/common.js" type="text/javascript"></script>
  772. <script src="/js/bootstrap.min.js" type="text/javascript"></script>
  773. <script src="/js/sha.js" type="text/javascript"></script>
  774. <script src="/js/home.js?v=<?php echo(time()); ?>" type="text/javascript" defer></script>
  775. <link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet">
  776. <link href="/css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  777. </head>
  778. <body>
  779. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "jscheck.html")): ?>
  780. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "jscheck.html"); ?>
  781. <?php endif; ?>
  782. <?php
  783. // Sorting friend list..
  784. function sort_friends_coll($a, $b)
  785. {
  786. return strcmp($a["USERNAME"], $b["USERNAME"]);
  787. }
  788. $AUTH = $CONFIG['AUTH'];
  789. usort($AUTH, "sort_friends_coll");
  790. //print_r($AUTH);
  791. ?>
  792. <div id="HCsplash" style="padding-top: 160px; text-align:center;color:#ffffff;display:none;">
  793. <div id="myh1"><H1>Homomm</H1></div><br>
  794. <img src="/res/HMMlogo2.png" style="width:310px;">
  795. </div>
  796. <?php
  797. if ($curPicture != PHP_STR) {
  798. $apic = glob($picPath . DIRECTORY_SEPARATOR . "*");
  799. $i=0;
  800. foreach($apic as &$path) {
  801. $fileName = basename($path);
  802. if (is_file($picPath . DIRECTORY_SEPARATOR . $fileName)) {
  803. $path=$fileName;
  804. } else {
  805. unset($apic[$i]);
  806. }
  807. $i++;
  808. }
  809. $i=array_search(basename($curPicture), $apic);
  810. // if the only one
  811. if (count($apic)==1) {
  812. $prevPicture = basename($apic[0]);
  813. $nextPicture = basename($apic[0]);
  814. // if first
  815. } else if ($i==0) {
  816. $prevPicture = basename($apic[count($apic)-1]);
  817. $nextPicture = basename($apic[1]);
  818. // if last
  819. } else if ($i==(count($apic)-1)) {
  820. $prevPicture = basename($apic[$i-1]);
  821. $nextPicture = basename($apic[0]);
  822. } else {
  823. $prevPicture = basename($apic[$i-1]);
  824. $nextPicture = basename($apic[$i+1]);
  825. }
  826. $hidePlayer = "0";
  827. } else {
  828. $hidePlayer = "1";
  829. }
  830. ?>
  831. <div id="picPlayer" style="width:100%;height:1900px;vertical-align:middle;text-align:center;background:#000000;display:<?php echo(($hidePlayer==="1"? "none": "inline"));?>;">
  832. <div id="closePlayer" style="position: absolute; top:20px; left:20px; cursor:pointer;" onclick="closePlayer()"><img src="/res/parent.png" style="width:64px;"></div>
  833. <div id="myPicCont" style="width:100%;max-width:100%;clear:both;margin:auto;vertical-align:middle;background:#000000;"><img id="myPic" src="<?php echo($curPicture);?>" style="width:100%;vertical-align:middle;display:none;;background:#000000;"></div>
  834. <div id="navPlayer1" style="position:absolute;top:3000px;width:175px;cursor:pointer;overflow-x:hidden;border:0px solid red;" onclick="openPic('<?php echo($prevPicture);?>')"><img src="/res/picPrev.png" style="width:200px;position:relative;left:-125px;"></div>
  835. <div id="navPlayer2" style="position:absolute;top:3000px;width:175px;cursor:pointer;overflow-x:hidden;border:0px solid red;" onclick="openPic('<?php echo($nextPicture);?>')"><img src="/res/picNext.png" style="width:200px;position:relative;left:+100px;"></div>
  836. </div>
  837. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data" style="display:<?php echo((($hideHCSplash == "1") && ($hidePlayer == "1")? "inline": "none"));?>;">
  838. <div class="header">
  839. <a id="burger-menu" href="#" style="display:none;"><img src="/res/burger-menu2.png" style="width:58px;"></a><a id="ahome" href="http://homomm.5mode-foss.eu" target="_blank" style="color:black; text-decoration: none;"><img id="logo-hmm" src="/res/HMMlogo2.png" style="width:48px;">&nbsp;Homomm</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="agithub" href="https://github.com/par7133/Homomm" 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="<?php echo($password);?>" autocomplete="off"></div>
  840. </div>
  841. <div style="clear:both;"></div>
  842. <table class="friend-header" style="width:100%;border:3px solid #e4f5f7;display:none;">
  843. <tr>
  844. <td style="width:100%;background:#e4f5f7;">
  845. <?php if ($user!="MASTER"): ?>
  846. <div class="friend-header-ve" style="float:left;width:31%;font-size:14px;padding:4px;border:3px solid #e4f5f7;margin-top:2px;margin-right:2px;margin-bottom:2px;text-align:left;cursor:pointer;">&nbsp;&nbsp;<a href="https://github.com/par7133/Homomm" style="text-decoration:none;color:black;">on github</a></div>
  847. <div class="friend-header-ve" style="float:left;width:31%;font-size:14px;padding:4px;border:3px solid #e4f5f7;margin-top:2px;margin-right:2px;margin-bottom:2px;text-align:left;cursor:pointer;">&nbsp;&nbsp;<a href="mailto:posta@elettronica.lol" style="text-decoration:none;color:black;">for feedback</a></div>
  848. <div class="friend-header-ve" style="float:left;width:31%;font-size:14px;padding:4px;border:3px solid #e4f5f7;margin-top:2px;margin-right:2px;margin-bottom:2px;text-align:left;cursor:pointer;">&nbsp;&nbsp;<a href="tel:+39-331-0812391" style="text-decoration:none;color:black;">get support</a></div>
  849. <?php else: ?>
  850. <?php foreach($AUTH as $key => $val):
  851. $myusername = $val['USERNAME'];
  852. $currentChatClass = PHP_STR;
  853. if ($myusername == $chatHint) {
  854. $currentChatClass = "friend-header-ve-selected";
  855. }
  856. echo("<div class=\"friend-header-ve $currentChatClass\" onclick=\"changeChat('$myusername')\" style=\"float:left;width:31%;border:3px solid #e4f5f7;font-size:14px;padding:4px;margin-top:2px;margin-right:2px;margin-bottom:2px;text-align:left;cursor:pointer;\">&nbsp;&nbsp;$myusername</div>");
  857. endforeach; ?>
  858. <?php endif; ?>
  859. </td>
  860. </tr>
  861. </table>
  862. <div style="clear:both;"></div>
  863. <div id="sidebar" style="clear:both; float:left; padding:8px; width:25%; max-width:250px; height:100%; text-align:center; border-right: 1px solid #2c2f34;">
  864. <?php if ($user!="MASTER"): ?>
  865. <br><br>
  866. <img src="/res/HMMgenius.png" alt="HMM Genius" title="HMM Genius" style="position:relative; left:+6px; width:90%; border: 1px dashed #EEEEEE;">
  867. <?php else: ?>
  868. <div style="text-align:left;">&nbsp;<?php echo(getResource("Friends", $curLocale));?></div><br>
  869. <div style="position:relative;top:-10px;left:+6px; width:90%; overflow-y:auto; height:244px; border: 1px dashed #EEEEEE;">
  870. <?php foreach($AUTH as $key => $val):
  871. $myusername = $val['USERNAME'];
  872. $currentChatClass = PHP_STR;
  873. if ($myusername == $chatHint) {
  874. $currentChatClass = "friend-selected";
  875. }
  876. echo("<div class=\"friend $currentChatClass\" onclick=\"changeChat('$myusername')\" style=\"padding:10px;text-align:left;font-size:14px;cursor:pointer;\">&nbsp;&nbsp;$myusername</div>");
  877. endforeach; ?>
  878. </div>
  879. <?php endif; ?>
  880. <div id="upload-cont"><input id="files" name="files[]" type="file" accept=".gif,.png,.jpg,.jpeg" style="visibility: hidden;" multiple></div>
  881. &nbsp;<br><br>
  882. <div style="text-align:left;white-space:nowrap;">
  883. &nbsp;&nbsp;<input type="password" id="Password" name="Password" placeholder="password" style="font-size:13px; background:#393939; color:#ffffff; width: 60%; border-radius:3px;" value="<?php echo($password);?>" autocomplete="off">&nbsp;<input type="submit" value="<?php echo(getResource("Go", $curLocale));?>" style="text-align:left;width:25%;"><br>
  884. &nbsp;&nbsp;<input type="text" id="Salt" placeholder="salt" style="position:relative; top:+5px; font-size:13px; background:#393939; color:#ffffff; width: 90%; border-radius:3px;" autocomplete="off"><br>
  885. <div style="text-align:center;">
  886. <a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; color:#000000; font-size:12px;"><?php echo(getResource("Hash Me", $curLocale));?>!</a>
  887. <br><br><br>
  888. <audio id="mybeep" preload="auto">
  889. <source src="/media/R2D2-hey-you.mp3" type="audio/mpeg">
  890. Maybe doesn't support the audio..
  891. </audio>
  892. <input type="button" id="myPlayButton" onclick="playmybeep()" value="<?php echo(getResource("Try the Beep", $curLocale));?>">
  893. <script>
  894. function playmybeep() {
  895. document.getElementById("mybeep").volume = 1;
  896. document.getElementById("mybeep").play();
  897. }
  898. </script>
  899. </div>
  900. </div>
  901. </div>
  902. <div id="messagebar" style="float:left; width:75%; max-width:950px; height:600px; padding:8px; border:0px solid red;">
  903. <?php if (APP_SPLASH): ?>
  904. <?php if ($hideSplash !== PHP_STR): ?>
  905. <div id="splash" style="border-radius:20px; position:relative; left:+3px; width:98%; background-color: #33aced; padding: 20px; margin-bottom:8px;">
  906. <button type="button" class="close" aria-label="Close" onclick="closeSplash();" style="position:relative; left:-10px;">
  907. <span aria-hidden="true">&times;</span>
  908. </button>
  909. Hello and welcome to Homomm!<br><br>
  910. Homomm is a light and simple software on premise to exchange multimedia messages with friends.<br><br>
  911. Homomm is released under GPLv3 license, it is supplied AS-IS and we do not take any responsibility for its misusage.<br><br>
  912. Homomm name comes from the two words: "homines" meaning our choise to give chance to the human beings to come first
  913. and "mm" for "multimedia messaging".<br><br>
  914. Homomm doesn't want to be a replacement of Whats App, Telegram, Wechat, etc. but their alter ago.<br><br>
  915. First step, use the left side panel password and salt fields to create the hash to insert in the config file for every user. Remember to manually set there also the salt value.<br><br>
  916. As you are going to run Homomm in the PHP process context, using a limited web server or phpfpm user, you must follow some simple directives for an optimal first setup:<br>
  917. <ol>
  918. <li>Check the permissions of your "Repo" folder in your web app private path; and set its path in the config file.</li>
  919. <li>In the Repo path create a "user" folder for each user and give to this folder the write permission. Set it appropriately in the config file.</li>
  920. <li>Check the permissions of your "hmm-img" folder in your web app public path; and set its path in the config file.</li>
  921. <li>In hmm-img path create a "user" folder for each user and give to this folder the write permission. Set it appropriately in the config file.</li>
  922. <li>In the config file, set every "user" information appropriately like in the examples given.</li>
  923. <li>Configure your <a href="http://twilio.com" style="color:#e6d236;">Twilio</a> account information appropriately to send out sms notification.</li>
  924. <li>Configure the server pushing interval to be notified on new chat messages.</li>
  925. <li>Configure the max history items as required (default: 50).</li>
  926. </ol>
  927. <br>
  928. Hope you can enjoy it and let us know about any feedback: <a href="mailto:posta@elettronica.lol" style="color:#e6d236;">posta@elettronica.lol</a>
  929. </div>
  930. <?php endif; ?>
  931. <?php endif; ?>
  932. &nbsp;<?php echo(getResource("Message board", $curLocale));?>&nbsp;<a href="#" onclick="refresh();"><img src="/res/refresh.png" style="position:relative;top:+0px;"></a><br>
  933. <div id="Console" style="float:left; width:100%; height:288px; min-height:288px; overflow-y:auto; background:url('/res/console-bg.png'); background-size:cover; margin-top:10px; border:0px solid red;">
  934. <div id="Consolep" style="min-height:433px;margin-left:5px;padding:10px;border:0px solid green; color: #000000;">
  935. <?php showHistory($msgHistory); ?>
  936. </div>
  937. </div>
  938. <div id="Messagep" style="float:left; width:100%;min-height:105px;position:relative;top:-1px;margin-left:0px;padding:10px;padding-top:0px;border:0px solid red;background:url('/res/console-bg.png'); background-size:cover; color: #000000;">
  939. <div id="MessageL" style="width:100%;position:relative;white-space:nowrap;top:-23px;border:0px solid black;"><div id="MessageK" style="float:left;width:93%;background:#FFFFFF;;white-space:nowrap;position:relative; top:+40px;border:0px solid red;"><textarea id="MessageLine" name="MessageLine" type="text" autocomplete="off" rows="3" placeholder="<?php echo(getResource("Message", $curLocale));?>" style="float:left;position:relative;top:+1px;width:75%;resize:none; background-color:white; color:black; border:0px; border-bottom: 1px dashed #EEEEEE;font-weight:900;"></textarea><div id="sendOptions" style="float:left;position:relative;top:+1px;left:+2px;background-color:#FFFFFF;width:105px;max-width:105px;height:59px;white-space:nowrap;padding:3px;font-weight:900;"><div id="pop-icons" style="float:left;text-align:center;margin:3px;margin-top:0px;width:30px;cursor:pointer;border:0px solid black;">&#128578;</div><div style="float:right;position:relative:top:-2px;border:0px solid blue;"><input type="checkbox" name="chkSMS" value="sms" style="font-size:10px;vertical-align:middle;">&nbsp;SMS&nbsp;</div><br><div onclick="upload();" style="float:right;position:relative;top:+5px;left:0px;cursor:pointer;border:0px solid red;"><img src="/res/upload.png" style="width:26px;"></div><div id="del-attach" onclick="clearUpload()" style="float:left; position:relative;top:-8px;left:-60px;display:none;cursor:pointer;"><img src="/res/del-attach.png" style="width:48px;"></div></div></div><div id="MessageS" style="float:left;width:7%;position:relative;top:+40px;cursor:pointer;border:0px solid green;" onclick="sendMessage()"><img src="/res/send.png" style="float:left;height:100%;width:63px;"></div></div>
  940. <div style="clear:both"></div>
  941. <div id="emoticons" style="position:absolute; width: 130px; height:69px; background-color:#FFFFFF; border:1px solid black;display:none;">
  942. <?php foreach ($EMOTICONS as $key => $val): ?>
  943. <div style="float:left;width:30px;cursor:pointer;" onclick="insertEmotIcon('<?php echo($key);?>');"><?php echo($val);?></div>
  944. <?php endforeach; ?>
  945. </div>
  946. <div style="clear:both"></div>
  947. </div>
  948. </div>
  949. <input type="hidden" id="CommandLine" name="CommandLine">
  950. <input type="hidden" id="chatHint" name="chatHint" value="<?php echo($chatHint); ?>">
  951. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  952. <input type="hidden" name="hideHCSplash" value="1">
  953. <input type="hidden" name="msg-sign" value="<?php echo(mt_rand(1000000, 9999999)); ?>">
  954. <input type="hidden" id="last_message" value="<?php echo($lastMessage); ?>">
  955. </form>
  956. <div class="footer">
  957. <div id="footerCont">&nbsp;</div>
  958. <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://demo.5mode.com">WYSIWYG</a> system</span>. Some rights reserved.</span></div>
  959. </div>
  960. <script>
  961. if (document.getElementsByClassName("friend-selected")[0]) {
  962. document.getElementsByClassName("friend-selected")[0].scrollIntoView();
  963. }
  964. function upload() {
  965. <?PHP if ($password!==PHP_STR): ?>
  966. $("input#files").click();
  967. <?PHP endif; ?>
  968. }
  969. function setPPlayer() {
  970. $("#picPlayer").css("height", parseInt(window.innerHeight)+"px");
  971. $("#myPicCont").css("height", parseInt(window.innerHeight)+"px");
  972. $("#myPicCont").css("max-width", parseInt(window.innerWidth)+"px");
  973. $("#closePlayer").css("left", "10px");
  974. $("#navPlayer1").css("top", parseInt((window.innerHeight-200)/2)+"px");
  975. $("#navPlayer2").css("top", parseInt((window.innerHeight-200)/2)+"px");
  976. $("#navPlayer2").css("left", parseInt(window.innerWidth-175)+"px");
  977. if (document.getElementById("myPic").src!="") {
  978. if ($("#myPic").width() > $("#myPic").height()) {
  979. f = $("#myPic").width() / $("#myPic").height();
  980. $("#myPic").css("padding-top", parseInt((window.innerHeight - $("#myPic").height()) / 2)+"px");
  981. $("#myPic").css("width", "100%"); //parseInt(window.innerWidth)+"px");
  982. $("#myPic").css("height", "");
  983. $("#myPic").css("max-height", parseInt(window.innerHeight)+"px");
  984. } else {
  985. $("#myPic").css("width", "");
  986. $("#myPic").css("max-width", parseInt(window.innerWidth)+"px");
  987. $("#myPic").css("height", "100%"); //parseInt(window.innerHeight)+"px");
  988. $("#myPicCont").css("max-width", parseInt(window.innerWidth)+"px");
  989. }
  990. $("#myPic").css("display", "inline");
  991. }
  992. $(document.body).css("overflow-x","hidden");
  993. }
  994. function hideTitle() {
  995. $("#myh1").hide("slow");
  996. }
  997. function startApp() {
  998. $("#HCsplash").hide("slow");
  999. $(document.body).css("background","#ffffff");
  1000. $("#frmHC").show();
  1001. <?php if (APP_SPLASH): ?>
  1002. $(document.body).css("overflow-y","auto");
  1003. <?php endif; ?>
  1004. }
  1005. <?php if($hideHCSplash!=="1"): ?>
  1006. window.addEventListener("load", function() {
  1007. //$("#HCsplash").show();
  1008. //setTimeout("startApp()", 5000);
  1009. $(document.body).css("background","#000000");
  1010. $("#HCsplash").show("slow");
  1011. setTimeout("hideTitle()", 2000);
  1012. setTimeout("startApp()", 4000);
  1013. }, true);
  1014. <?php else: ?>
  1015. window.addEventListener("load", function() {
  1016. startApp();
  1017. });
  1018. <?php endif; ?>
  1019. window.addEventListener("load", function() {
  1020. <?php if ($hideHCSplash != "1" || $hidePlayer != "1"): ?>
  1021. $(document.body).css("backgrond","#000000");
  1022. <?php else: ?>
  1023. $(document.body).css("backgrond","#FFFFFF");
  1024. <?php endif; ?>
  1025. });
  1026. window.addEventListener("load", function() {
  1027. <?php if($password===PHP_STR):?>
  1028. $("#Password").addClass("emptyfield");
  1029. <?php endif; ?>
  1030. readyToType();
  1031. document.getElementById("MessageLine").focus();
  1032. }, true);
  1033. window.addEventListener("load", function() {
  1034. <?php if ($hidePlayer == "0"): ?>
  1035. setPPlayer();
  1036. <?php endif; ?>
  1037. <?php if ($password != PHP_STR): ?>
  1038. setInterval("checkServer()", <?php echo(APP_PUSH_INTERVAL);?>);
  1039. <?PHP endif; ?>
  1040. }, true);
  1041. window.addEventListener("resize", function() {
  1042. <?php if ($hidePlayer == "0"): ?>
  1043. setPPlayer();
  1044. <?php endif; ?>
  1045. }, true);
  1046. </script>
  1047. </body>
  1048. </html>