home.php 41 KB

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