home.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of Homogram.
  6. *
  7. * Homogram 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. * Homogram 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 Homogram. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home.php
  21. *
  22. * Homogram home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2021, 2024, 5 Mode
  26. */
  27. $contextType = PUBLIC_CONTEXT_TYPE;
  28. $cmd = PHP_STR;
  29. $opt = PHP_STR;
  30. $param1 = PHP_STR;
  31. $param2 = PHP_STR;
  32. $param3 = PHP_STR;
  33. function myExecPrivatifyCommand() {
  34. global $param1;
  35. global $curPath;
  36. $privateData = [];
  37. $curFile = substr($curPath, strlen(APP_REPO_PATH)) . DIRECTORY_SEPARATOR . $param1;
  38. //echo "curFile=$curFile";
  39. // Update .private file
  40. $privateFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".private";
  41. //echo "curFile=$privateFile";
  42. if (file_exists($privateFile)) {
  43. $privateData = file($privateFile);
  44. }
  45. if (!in_array($curFile . "\n", $privateData)) {
  46. $privateData[] = $curFile . "\n";
  47. file_put_contents($privateFile, implode('', $privateData));
  48. }
  49. }
  50. function myExecDelCommand() {
  51. global $param1;
  52. global $curPath;
  53. $curFile = $curPath . DIRECTORY_SEPARATOR . $param1;
  54. unlink($curFile);
  55. }
  56. function myExecPublicifyCommand() {
  57. global $param1;
  58. global $curPath;
  59. $privateData = [];
  60. $curFile = substr($curPath, strlen(APP_REPO_PATH)) . DIRECTORY_SEPARATOR . $param1;
  61. //echo "curFile=$curFile";
  62. // Update .private file
  63. $privateFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".private";
  64. //echo "curFile=$privateFile";
  65. if (file_exists($privateFile)) {
  66. $privateData = file($privateFile);
  67. }
  68. $key = array_search($curFile . "\n", $privateData);
  69. if ($key!==false) {
  70. unset($privateData[$key]);
  71. file_put_contents($privateFile, implode('', $privateData));
  72. }
  73. }
  74. function myExecMakeDirCommand() {
  75. global $param1;
  76. global $curPath;
  77. $newpath = $curPath . DIRECTORY_SEPARATOR . $param1;
  78. mkdir($newpath, 0777);
  79. }
  80. function parseCommand() {
  81. global $command;
  82. global $cmd;
  83. global $opt;
  84. global $param1;
  85. global $param2;
  86. global $param3;
  87. $str = trim($command);
  88. $ipos = stripos($str, PHP_SPACE);
  89. if ($ipos > 0) {
  90. $cmd = left($str, $ipos);
  91. $str = substr($str, $ipos+1);
  92. } else {
  93. $cmd = $str;
  94. return;
  95. }
  96. if (left($str, 1) === "-") {
  97. $ipos = stripos($str, PHP_SPACE);
  98. if ($ipos > 0) {
  99. $opt = left($str, $ipos);
  100. $str = substr($str, $ipos+1);
  101. } else {
  102. $opt = $str;
  103. return;
  104. }
  105. }
  106. $ipos = stripos($str, PHP_SPACE);
  107. if ($ipos > 0) {
  108. $param1 = left($str, $ipos);
  109. $str = substr($str, $ipos+1);
  110. } else {
  111. $param1 = $str;
  112. return;
  113. }
  114. $ipos = stripos($str, PHP_SPACE);
  115. if ($ipos > 0) {
  116. $param2 = left($str, $ipos);
  117. $str = substr($str, $ipos+1);
  118. } else {
  119. $param2 = $str;
  120. return;
  121. }
  122. $ipos = stripos($str, PHP_SPACE);
  123. if ($ipos > 0) {
  124. $param3 = left($str, $ipos);
  125. $str = substr($str, $ipos+1);
  126. } else {
  127. $param3 = $str;
  128. return;
  129. }
  130. }
  131. function is_subfolderdest(string $path): bool
  132. {
  133. global $curPath;
  134. $ret=false;
  135. if ($path === "../") {
  136. return $ret;
  137. }
  138. if ($path!=PHP_STR) {
  139. $folderName = left($path, strlen($path)-1);
  140. if (!is_word($folderName)) {
  141. return $ret;
  142. }
  143. if (is_dir($curPath . PHP_SLASH . $folderName) && (right($path,1)==="/")) {
  144. $ret=true;
  145. }
  146. }
  147. return $ret;
  148. }
  149. function privatifyparamValidation() {
  150. global $curPath;
  151. global $opt;
  152. global $param1;
  153. global $param2;
  154. global $param3;
  155. //opt!=""
  156. if ($opt!==PHP_STR) {
  157. //updateHistoryWithErr("invalid options");
  158. return false;
  159. }
  160. //param1!="" and isword
  161. if (($param1===PHP_STR) || !is_word($param1)) {
  162. //updateHistoryWithErr("invalid image file");
  163. return false;
  164. }
  165. //param2==""
  166. if ($param2!==PHP_STR) {
  167. //updateHistoryWithErr("invalid parameters");
  168. return false;
  169. }
  170. //param3==""
  171. if ($param3!==PHP_STR) {
  172. //updateHistoryWithErr("invalid parameters");
  173. return false;
  174. }
  175. //param1 exist
  176. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  177. if (!file_exists($path)) {
  178. //updateHistoryWithErr("file must exists");
  179. return false;
  180. }
  181. //param1 is_file
  182. if (!is_file($path)) {
  183. //updateHistoryWithErr("invalid inventory file");
  184. return false;
  185. }
  186. //param1 file extension == gif | png | jpg | jpeg
  187. $fileExt = strtolower(pathinfo($param1, PATHINFO_EXTENSION));
  188. if ($fileExt !== "gif" && $fileExt !== "png" && $fileExt !== "jpg" && $fileExt !== "jpeg") {
  189. //updateHistoryWithErr("invalid inventory file");
  190. return false;
  191. }
  192. return true;
  193. }
  194. function publicifyparamValidation() {
  195. global $curPath;
  196. global $opt;
  197. global $param1;
  198. global $param2;
  199. global $param3;
  200. //opt!=""
  201. if ($opt!==PHP_STR) {
  202. //updateHistoryWithErr("invalid options");
  203. return false;
  204. }
  205. //param1!="" and isword
  206. if (($param1===PHP_STR) || !is_word($param1)) {
  207. //updateHistoryWithErr("invalid image file");
  208. return false;
  209. }
  210. //param2==""
  211. if ($param2!==PHP_STR) {
  212. //updateHistoryWithErr("invalid parameters");
  213. return false;
  214. }
  215. //param3==""
  216. if ($param3!==PHP_STR) {
  217. //updateHistoryWithErr("invalid parameters");
  218. return false;
  219. }
  220. //param1 exist
  221. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  222. if (!file_exists($path)) {
  223. //updateHistoryWithErr("file must exists");
  224. return false;
  225. }
  226. //param1 is_file
  227. if (!is_file($path)) {
  228. //updateHistoryWithErr("invalid inventory file");
  229. return false;
  230. }
  231. //param1 file extension == gif | png | jpg | jpeg
  232. $fileExt = strtolower(pathinfo($param1, PATHINFO_EXTENSION));
  233. if ($fileExt !== "gif" && $fileExt !== "png" && $fileExt !== "jpg" && $fileExt !== "jpeg") {
  234. //updateHistoryWithErr("invalid inventory file");
  235. return false;
  236. }
  237. return true;
  238. }
  239. function delparamValidation() {
  240. global $curPath;
  241. global $opt;
  242. global $param1;
  243. global $param2;
  244. global $param3;
  245. //opt!=""
  246. if ($opt!==PHP_STR) {
  247. //updateHistoryWithErr("invalid options");
  248. return false;
  249. }
  250. //param1!="" and isword
  251. if (($param1===PHP_STR) || !is_word($param1)) {
  252. //updateHistoryWithErr("invalid image file");
  253. return false;
  254. }
  255. //param2==""
  256. if ($param2!==PHP_STR) {
  257. //updateHistoryWithErr("invalid parameters");
  258. return false;
  259. }
  260. //param3==""
  261. if ($param3!==PHP_STR) {
  262. //updateHistoryWithErr("invalid parameters");
  263. return false;
  264. }
  265. //param1 exist
  266. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  267. if (!file_exists($path)) {
  268. //updateHistoryWithErr("file must exists");
  269. return false;
  270. }
  271. //param1 is_file
  272. if (!is_file($path)) {
  273. //updateHistoryWithErr("invalid inventory file");
  274. return false;
  275. }
  276. //param1 file extension == gif | png | jpg | jpeg
  277. $fileExt = strtolower(pathinfo($param1, PATHINFO_EXTENSION));
  278. if ($fileExt !== "gif" && $fileExt !== "png" && $fileExt !== "jpg" && $fileExt !== "jpeg") {
  279. //updateHistoryWithErr("invalid inventory file");
  280. return false;
  281. }
  282. return true;
  283. }
  284. function makedirparamValidation() {
  285. global $curPath;
  286. global $opt;
  287. global $param1;
  288. global $param2;
  289. global $param3;
  290. //opt!=""
  291. if ($opt!==PHP_STR) {
  292. //updateHistoryWithErr("invalid options");
  293. return false;
  294. }
  295. //param1!="" and isword
  296. if (($param1===PHP_STR) || !is_word($param1)) {
  297. //updateHistoryWithErr("invalid folder name");
  298. return false;
  299. }
  300. //param2==""
  301. if ($param2!==PHP_STR) {
  302. //updateHistoryWithErr("invalid parameters");
  303. return false;
  304. }
  305. //param3==""
  306. if ($param3!==PHP_STR) {
  307. //updateHistoryWithErr("invalid parameters");
  308. return false;
  309. }
  310. //param1 exist
  311. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  312. if (file_exists($path)) {
  313. //updateHistoryWithErr("file must not exists");
  314. return false;
  315. }
  316. //param1 file extension != gif | png | jpg | jpeg
  317. $fileExt = strtolower(pathinfo($param1, PATHINFO_EXTENSION));
  318. if ($fileExt === "gif" || $fileExt === "png" || $fileExt === "jpg" || $fileExt === "jpeg") {
  319. //updateHistoryWithErr("invalid inventory file");
  320. return false;
  321. }
  322. return true;
  323. }
  324. function upload() {
  325. global $curPath;
  326. global $prompt;
  327. //if (!empty($_FILES['files'])) {
  328. if (!empty($_FILES['files']['tmp_name'][0])) {
  329. // Updating history..
  330. //$output = [];
  331. //$output[] = $prompt . " " . "File upload" . "\n";
  332. //updateHistory($output, HISTORY_MAX_ITEMS);
  333. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  334. //no file uploaded
  335. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  336. //updateHistoryWithErr("No file uploaded.", false);
  337. return;
  338. }
  339. foreach($uploads as &$upload) {
  340. switch ($upload['error']) {
  341. case PHP_UPLOAD_ERR_OK:
  342. break;
  343. case PHP_UPLOAD_ERR_NO_FILE:
  344. //updateHistoryWithErr("One or more uploaded files are missing.", false);
  345. return;
  346. case PHP_UPLOAD_ERR_INI_SIZE:
  347. //updateHistoryWithErr("File exceeded INI size limit.", false);
  348. return;
  349. case PHP_UPLOAD_ERR_FORM_SIZE:
  350. //updateHistoryWithErr("File exceeded form size limit.", false);
  351. return;
  352. case PHP_UPLOAD_ERR_PARTIAL:
  353. //updateHistoryWithErr("File only partially uploaded.", false);
  354. return;
  355. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  356. //updateHistoryWithErr("TMP dir doesn't exist.", false);
  357. return;
  358. case PHP_UPLOAD_ERR_CANT_WRITE:
  359. //updateHistoryWithErr("Failed to write to the disk.", false);
  360. return;
  361. case PHP_UPLOAD_ERR_EXTENSION:
  362. //updateHistoryWithErr("A PHP extension stopped the file upload.", false);
  363. return;
  364. default:
  365. //updateHistoryWithErr("Unexpected error happened.", false);
  366. return;
  367. }
  368. if (!is_uploaded_file($upload['tmp_name'])) {
  369. //updateHistoryWithErr("One or more file have not been uploaded.", false);
  370. return;
  371. }
  372. // name
  373. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  374. if ($name == PHP_STR) {
  375. //updateHistoryWithErr("Invalid file name: " . $name, false);
  376. return;
  377. }
  378. $upload['name'] = $name;
  379. // fileType
  380. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  381. $upload['type'] = $fileType;
  382. // tmp_name
  383. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  384. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  385. //updateHistoryWithErr("Invalid file temp path: " . $tmp_name, false);
  386. return;
  387. }
  388. $upload['tmp_name'] = $tmp_name;
  389. //size
  390. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  391. if ($size == "") {
  392. //updateHistoryWithErr("Invalid file size.", false);
  393. return;
  394. }
  395. $upload["size"] = $size;
  396. $tmpFullPath = $upload["tmp_name"];
  397. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  398. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  399. $FileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  400. if ($originalFileExt!==PHP_STR) {
  401. $destFileName = $originalFilename . "." . $originalFileExt;
  402. } else {
  403. $destFileName = $originalFilename;
  404. }
  405. $destFullPath = $curPath . DIRECTORY_SEPARATOR . $destFileName;
  406. if (file_exists($destFullPath)) {
  407. //updateHistoryWithErr("destination already exists", false);
  408. return;
  409. }
  410. copy($tmpFullPath, $destFullPath);
  411. // Updating history..
  412. //$output = [];
  413. //$output[] = $destFileName . " " . "uploaded" . "\n";
  414. //updateHistory($output, HISTORY_MAX_ITEMS);
  415. // Cleaning up..
  416. // Delete the tmp file..
  417. unlink($tmpFullPath);
  418. }
  419. }
  420. }
  421. function showImages() {
  422. global $curPath;
  423. global $contextType;
  424. $privateData = [];
  425. $privateFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".private";
  426. if (file_exists($privateFile)) {
  427. $privateData = file($privateFile);
  428. }
  429. ///$root = "img";
  430. $root = APP_REPO_PATH;
  431. //subpath
  432. ///$subpath = mb_substr((string)filter_input(INPUT_GET, "path", FILTER_SANITIZE_STRING), 0, 500);
  433. $subpath = $curPath;
  434. if ($subpath!=="" && is_dir($subpath)) {
  435. $path = $subpath;
  436. } else {
  437. $path = $root;
  438. }
  439. /*
  440. * Display Link to Home
  441. */
  442. if ($path!==$root) {
  443. $title = "Parent";
  444. $ipos = mb_strripos($subpath, "/");
  445. $parentPath = substr($subpath, 0, $ipos);
  446. $relPath = substr($parentPath, strlen(APP_REPO_PATH));
  447. $cdate = date("d-m-Y", filectime($parentPath));
  448. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  449. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  450. echo "<tr><td style='padding:3px;'><a href='#' onclick='changePath(\"{$relPath}\")'><img src='/res/folder-home.png' width='100%' height='200px'></a></td><tr>";
  451. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  452. echo "</table>";
  453. } else {
  454. $title = "Parent";
  455. $cdate = date("d-m-Y", filectime($root));
  456. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  457. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  458. echo "<tr><td style='padding:3px;'><img src='/res/folder-home-dis.png' width='100%' height='200px'></td><tr>";
  459. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  460. echo "</table>";
  461. }
  462. if ($contextType === PERSONAL_CONTEXT_TYPE) {
  463. $title = "New folder";
  464. $cdate = date("d-m-Y");
  465. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  466. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  467. echo "<tr><td style='padding:3px;cursor:pointer;' onclick='makeNewFolder()'><img src='/res/new-folder.png' width='100%' height='200px'></td><tr>";
  468. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  469. echo "</table>";
  470. }
  471. $pattern = $path . "/*";
  472. /*
  473. * Display subfolders
  474. */
  475. $aDirs = glob($pattern, GLOB_ONLYDIR);
  476. sort($aDirs);
  477. foreach ($aDirs as &$fsEntry) {
  478. $relPath = substr($fsEntry, strlen(APP_REPO_PATH));
  479. $ipos = mb_strripos($fsEntry, "/");
  480. $title = substr($fsEntry, $ipos+1);
  481. $cdate = date("d-m-Y", filectime($fsEntry));
  482. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  483. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  484. //echo "<tr><td style='padding:3px;'><a href='/index.php?path={$relPath}'><img src='/res/folder.png' width='100%' height='200px'></a></td><tr>";
  485. echo "<tr><td style='padding:3px;'><a href='#' onclick='changePath(\"{$relPath}\")'><img src='/res/folder.png' width='100%' height='200px'></a></td><tr>";
  486. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  487. echo "</table>";
  488. }
  489. $aImages = glob($pattern);
  490. sort($aImages);
  491. $i=1;
  492. foreach ($aImages as &$fsEntry) {
  493. if (!is_dir($fsEntry)) {
  494. $relPath = "/" . substr(APP_REPO_PATH, strlen(APP_PATH)+1) . substr($fsEntry, strlen(APP_REPO_PATH));
  495. $fileName = basename($fsEntry);
  496. $curFile = substr($curPath, strlen(APP_REPO_PATH)) . DIRECTORY_SEPARATOR . $fileName;
  497. $isPrivateFile = false;
  498. $imgLock = "/res/public.png";
  499. if (in_array($curFile . "\n",$privateData)) {
  500. $isPrivateFile = true;
  501. $imgLock = "/res/private.png";
  502. }
  503. $ipos = mb_strripos($fsEntry, "/");
  504. $title = substr($fsEntry, $ipos+1);
  505. $ipos = mb_stripos($title, ".");
  506. $title = substr($title, 0, $ipos);
  507. $cdate = date("d-m-Y", filectime($fsEntry));
  508. if ((!$isPrivateFile && ($contextType === PUBLIC_CONTEXT_TYPE)) || ($contextType === PERSONAL_CONTEXT_TYPE)) {
  509. echo "<div style='float:left;width:235px'>";
  510. echo "<table style='width:235px;height:230px;margin-top:5px;margin-right:4px;background-color:#e1e1e1;border:1px solid #D2D2D2'>";
  511. echo "<tr>";
  512. if ($contextType === PERSONAL_CONTEXT_TYPE) {
  513. echo "<td style='width:23px;cursor:pointer; vertical-align:bottom;' ondblclick='delImg(\"{$i}\",\"{$fileName}\")'><img id='del-{$i}' class='imgdel' src='/res/del.png' style='height:19px;'></td>";
  514. echo "<td style='width:45px;cursor:pointer' ondblclick='changeVisibility(\"{$i}\",\"{$fileName}\")'><img id='lock-{$i}' class='imglock' src='{$imgLock}' style='height:23px;'></td>";
  515. } else {
  516. echo "<td style='width:23px;cursor:pointer; vertical-align:bottom;'><img id='del-{$i}' class='imgdel' src='/res/pxl.gif' style='height:19px;'></td>";
  517. echo "<td style='width:45px;cursor:pointer'><img id='lock-{$i}' class='imglock' src='/res/pxl.gif' style='height:23px;'></td>";
  518. }
  519. echo "<td style='height:23px;text-align:center;font-size:11px;'>{$title}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
  520. echo "<tr>";
  521. echo "<tr><td style='padding:3px;height:200px;background-image:url({$relPath});background-size:235px 200px;cursor:zoom-in;' colspan='3' onclick='openLink(\"{$relPath}\",\"_blank\")'>&nbsp;</td><tr>";
  522. echo "<tr><td style='text-align:left;font-size:11px' colspan='3'>&nbsp;{$cdate}</td><tr>";
  523. echo "</table>";
  524. echo "<div style='position:relative;top:-35px;text-align:right;padding-right:1.5px;'>";
  525. echo "<a href=\"https://www.facebook.com/sharer/sharer.php?u=http://homogram.com{$relPath}&t=\" onclick=\"javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;\" target=\"_blank\" title=\"Share on Facebook\"><img src='/res/fb.png'></a>";
  526. echo "<a href=\"https://twitter.com/share?url=http://homogram.com{$relPath}&text=\" onclick=\"javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;\" target=\"_blank\" title=\"Share on Twitter\"><img src='/res/twitter.png'></a>";
  527. echo "<a href=\"whatsapp://send?text=http://homogram.com{$relPath}\" data-action=\"share/whatsapp/share\" onClick=\"javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;\" target=\"_blank\" title=\"Share on whatsapp\"><img src='/res/whatsapp.png'></a>";
  528. echo "</div>";
  529. echo "</div>";
  530. }
  531. $i++;
  532. }
  533. }
  534. }
  535. $password = filter_input(INPUT_POST, "Password");
  536. $command = filter_input(INPUT_POST, "CommandLine");
  537. $pwd = filter_input(INPUT_POST, "pwd");
  538. $hideSplash = filter_input(INPUT_POST, "hideSplash");
  539. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash");
  540. if ($password !== PHP_STR) {
  541. $hash = hash("sha256", $password . APP_SALT, false);
  542. if ($hash !== APP_HASH) {
  543. $password=PHP_STR;
  544. }
  545. }
  546. $curPath = APP_REPO_PATH;
  547. if ($pwd!==PHP_STR) {
  548. ///if (left($pwd, strlen(APP_REPO_PATH)) === APP_REPO_PATH) {
  549. if (file_exists(APP_REPO_PATH . $pwd) && is_dir(APP_REPO_PATH . $pwd)) {
  550. $curPath = APP_REPO_PATH . $pwd;
  551. }
  552. }
  553. chdir($curPath);
  554. $ipos = strripos($curPath, PHP_SLASH);
  555. $curDir = substr($curPath, $ipos);
  556. if ($password !== PHP_STR) {
  557. parseCommand($command);
  558. //echo("cmd=" . $cmd . "<br>");
  559. //echo("opt=" . $opt . "<br>");
  560. //echo("param1=" . $param1 . "<br>");
  561. //echo("param2=" . $param2 . "<br>");
  562. upload();
  563. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  564. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  565. if ($cmd === "privatify") {
  566. if (privatifyparamValidation()) {
  567. myExecPrivatifyCommand();
  568. }
  569. } else if ($cmd === "publicify") {
  570. if (publicifyparamValidation()) {
  571. myExecPublicifyCommand();
  572. }
  573. } else if ($cmd === "del") {
  574. if (delparamValidation()) {
  575. myExecDelCommand();
  576. }
  577. } else if ($cmd === "makedir") {
  578. if (makedirparamValidation()) {
  579. myExecMakeDirCommand();
  580. }
  581. }
  582. } else {
  583. }
  584. $contextType = PERSONAL_CONTEXT_TYPE;
  585. } else {
  586. }
  587. ?>
  588. <!DOCTYPE html>
  589. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  590. <head>
  591. <meta charset="UTF-8"/>
  592. <meta name="style" content="day1"/>
  593. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  594. <!--
  595. Copyright 2021, 2024 5 Mode
  596. This file is part of Homogram.
  597. Homogram is free software: you can redistribute it and/or modify
  598. it under the terms of the GNU General Public License as published by
  599. the Free Software Foundation, either version 3 of the License, or
  600. (at your option) any later version.
  601. Homogram is distributed in the hope that it will be useful,
  602. but WITHOUT ANY WARRANTY; without even the implied warranty of
  603. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  604. GNU General Public License for more details.
  605. You should have received a copy of the GNU General Public License
  606. along with Homogram. If not, see <https://www.gnu.org/licenses/>.
  607. -->
  608. <title>Homogram: every person its pictures..</title>
  609. <link rel="shortcut icon" href="./res/favicon.ico?v=<?php echo(time()); ?>" />
  610. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  611. <meta name="author" content="5 Mode"/>
  612. <meta name="robots" content="index,follow"/>
  613. <script src="./js/jquery-3.1.0.min.js" type="text/javascript"></script>
  614. <script src="./js/common.js" type="text/javascript"></script>
  615. <script src="./js/bootstrap.min.js" type="text/javascript"></script>
  616. <script src="./js/sha.js" type="text/javascript"></script>
  617. <script src="./js/home.js" type="text/javascript" defer></script>
  618. <link href="./css/bootstrap.min.css" type="text/css" rel="stylesheet">
  619. <link href="./css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  620. <script>
  621. $(document).ready(function() {
  622. $("#Password").on("keydown",function(e){
  623. key = e.which;
  624. //alert(key);
  625. if (key===13) {
  626. e.preventDefault();
  627. frmHC.submit();
  628. } else {
  629. //e.preventDefault();
  630. }
  631. });
  632. });
  633. window.addEventListener("load", function() {
  634. <?php if($password===PHP_STR):?>
  635. $("#Password").addClass("emptyfield");
  636. <?php endif; ?>
  637. //maxY = document.getElementById("Console").scrollHeight;
  638. //alert(maxY);
  639. }, true);
  640. function hideTitle() {
  641. $("#myh1").hide("slow");
  642. }
  643. function startApp() {
  644. $("#HCsplash").hide("slow");
  645. $(document.body).css("background","#ffffff");
  646. $("#frmHC").show();
  647. }
  648. <?php if($hideHCSplash!=="1"): ?>
  649. window.addEventListener("load", function() {
  650. $(document.body).css("background","#000000");
  651. $("#HCsplash").show("slow");
  652. setTimeout("hideTitle()", 2000);
  653. setTimeout("startApp()", 4000);
  654. }, true);
  655. <?php else: ?>
  656. window.addEventListener("load", function() {
  657. startApp();
  658. });
  659. <?php endif; ?>
  660. </script>
  661. </head>
  662. <body>
  663. <div id="HCsplash" style="padding-top: 160px; text-align:center;color:#ffffff;display:none;">
  664. <div id="myh1"><H1>Homogram</H1></div><br>
  665. <img src="res/HGlogo2.png" style="width:310px;">
  666. </div>
  667. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data" style="display:<?php echo(($hideHCSplash==="1"?"inline":"none"));?>;">
  668. <div class="header">
  669. <a href="http://homogram.org" target="_blank" style="color:#000000; text-decoration: none;"><img src="res/HGlogo2.png" style="width:45px;">&nbsp;Homogram</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/par7133/Homogram" style="color:#000000;"><span style="color:#119fe2">on</span> github</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:info@homogram.org" style="color:#000000;"><span style="color:#119fe2">for</span> feedback</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="tel:+39-331-4029415" style="font-size:13px;background-color:#15c60b;border:2px solid #15c60b;color:#000000;height:27px;text-decoration:none;">&nbsp;&nbsp;get support&nbsp;&nbsp;</a>
  670. </div>
  671. <div style="clear:both; float:left; padding:8px; width:15%; height:100%; text-align:center;">
  672. <div style="padding-left:12px;text-align: left;">
  673. &nbsp;
  674. <?php if ($password!==PHP_STR): ?>
  675. <a href="#" id="upload" style="color:#5ab5e4;" onclick="upload()">Upload</a>
  676. <input id="files" name="files[]" type="file" accept=".gif,.png,.jpg,.jpeg" style="visibility: hidden;">
  677. <?php else: ?>
  678. <br>
  679. <?php endif; ?>
  680. </div>
  681. <br><br>
  682. <img src="res/HGgenius.png" alt="HG Genius" title="HG Genius" style="position:relative; left:+6px; width:90%; border: 1px dashed #EEEEEE;">
  683. &nbsp;<br><br><br>
  684. &nbsp;<input type="text" id="Password" name="Password" placeholder="password" style="font-size:10px; background:#393939; color:#ffffff; width: 90%; border-radius:3px;" value="<?php echo($password);?>" autocomplete="off"><br>
  685. &nbsp;<input type="text" id="Salt" placeholder="salt" style="position:relative; top:+5px; font-size:10px; background:#393939; color:#ffffff; width: 90%; border-radius:3px;" autocomplete="off"><br>
  686. &nbsp;<a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; color:#000000; font-size:12px;">Hash Me!</a>
  687. <input type="hidden" id="CommandLine" name="CommandLine">
  688. <input type="hidden" id="pwd" name="pwd" value="<?php echo(substr($curPath, strlen(APP_REPO_PATH))); ?>" style="color:black">
  689. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  690. <input type="hidden" name="hideHCSplash" value="1">
  691. </div>
  692. <div style="float:left; width:85%;height:100%; padding:8px; border-left: 1px solid #2c2f34;">
  693. <?php if (APP_SPLASH): ?>
  694. <?php if ($hideSplash !== PHP_STR): ?>
  695. <div id="splash" style="border-radius:20px; position:relative; left:+3px; width:98%; background-color: #33aced; padding: 20px; margin-bottom:8px;">
  696. <button type="button" class="close" aria-label="Close" onclick="closeSplash();" style="position:relative; left:-10px;">
  697. <span aria-hidden="true">&times;</span>
  698. </button>
  699. Hello and welcome to Homogram!<br><br>
  700. Homogram is a light and simple software on premise to share your images.<br><br>
  701. Homogram is released under GPLv3 license, it is supplied AS-IS and we do not take any responsibility for its misusage.<br><br>
  702. The name *Homogram* comes from a prank on the name 'instagram', in fact differently from the latter ones Homogram gives priorities to homines..<br><br>
  703. However Homogram doesn't birth as a replacement but just like its alter ego.. :o)<br><br>
  704. First step, use the left side panel password and salt fields to create the hash to insert in the config file. Remember to manually set there also the salt value.<br><br>
  705. As you are going to run Homogram 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>
  706. <ol>
  707. <li>Check the write permissions of your "HGRepo" folder in your web app private path; and set its path in the config file.</li>
  708. <li>Check the write permissions of your "data" folder in your web app private path; and set its path in the config file.</li>
  709. </ol>
  710. <br>
  711. Hope you can enjoy it and let us know about any feedback: <a href="mailto:info@homogram.org" style="color:#e6d236;">info@homogram.org</a>
  712. </div>
  713. <?php endif; ?>
  714. <?php endif; ?>
  715. <?php
  716. if ($contextType === PUBLIC_CONTEXT_TYPE) {
  717. echo("&nbsp;You are in <span style='color:orange;'>~/" . substr($curPath, strlen(APP_REPO_PATH)+1) . "</span> as <span style='color:black;'>guest</span><br>");
  718. } else {
  719. echo("&nbsp;You are in <span style='color:orange;'>~/" . substr($curPath, strlen(APP_REPO_PATH)+1) . "</span> as <span style='color:green;'>owner</span><br>");
  720. }
  721. ?><br>
  722. <div id="Console" style="hei-ght:493px; over-flow-y:auto; margin-top:10px;">
  723. <?php showImages(); ?>
  724. </div>
  725. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  726. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  727. </div>
  728. <div class="footer">
  729. <div id="footerCont">&nbsp;</div>
  730. <div id="footer"><span style="background:#E1E1E1;color:black;opacity:1.0;margin-right:10px;">&nbsp;&nbsp;A <a href="http://5mode.com">5 Mode</a> project and <a href="http://wysiwyg.systems">WYSIWYG</a> system. Some rights reserved.</span></div>
  731. </div>
  732. </form>
  733. </body>
  734. </html>