home.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  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. $curPicture = "";
  34. $prevPicture = "";
  35. $nextPicture = "";
  36. $curLocale = APP_LOCALE;
  37. function parseCommand() {
  38. global $command;
  39. global $cmd;
  40. global $opt;
  41. global $param1;
  42. global $param2;
  43. global $param3;
  44. $str = trim($command);
  45. $ipos = stripos($str, PHP_SPACE);
  46. if ($ipos > 0) {
  47. $cmd = left($str, $ipos);
  48. $str = substr($str, $ipos+1);
  49. } else {
  50. $cmd = $str;
  51. return;
  52. }
  53. if (left($str, 1) === "-") {
  54. $ipos = stripos($str, PHP_SPACE);
  55. if ($ipos > 0) {
  56. $opt = left($str, $ipos);
  57. $str = substr($str, $ipos+1);
  58. } else {
  59. $opt = $str;
  60. return;
  61. }
  62. }
  63. if (left($str, 1) === "'") {
  64. $ipos = stripos($str, "'", 1);
  65. if ($ipos > 0) {
  66. $param1 = substr($str, 0, $ipos+1);
  67. $str = substr($str, $ipos+1);
  68. } else {
  69. $param1 = $str;
  70. return;
  71. }
  72. } else {
  73. $ipos = stripos($str, PHP_SPACE);
  74. if ($ipos > 0) {
  75. $param1 = left($str, $ipos);
  76. $str = substr($str, $ipos+1);
  77. } else {
  78. $param1 = $str;
  79. return;
  80. }
  81. }
  82. $ipos = stripos($str, PHP_SPACE);
  83. if ($ipos > 0) {
  84. $param2 = left($str, $ipos);
  85. $str = substr($str, $ipos+1);
  86. } else {
  87. $param2 = $str;
  88. return;
  89. }
  90. $ipos = stripos($str, PHP_SPACE);
  91. if ($ipos > 0) {
  92. $param3 = left($str, $ipos);
  93. $str = substr($str, $ipos+1);
  94. } else {
  95. $param3 = $str;
  96. return;
  97. }
  98. }
  99. function is_subfolderdest(string $path): bool
  100. {
  101. global $curPath;
  102. $ret=false;
  103. if ($path === "../") {
  104. return $ret;
  105. }
  106. if ($path!=PHP_STR) {
  107. $folderName = left($path, strlen($path)-1);
  108. if (!is_word($folderName)) {
  109. return $ret;
  110. }
  111. if (is_dir($curPath . PHP_SLASH . $folderName) && (right($path,1)==="/")) {
  112. $ret=true;
  113. }
  114. }
  115. return $ret;
  116. }
  117. function privatifyparamValidation() {
  118. global $curPath;
  119. global $opt;
  120. global $param1;
  121. global $param2;
  122. global $param3;
  123. //opt!=""
  124. if ($opt!==PHP_STR) {
  125. echo("WARNING: invalid options<br>");
  126. return false;
  127. }
  128. //param1!="" and isword
  129. $test_param1 = trim($param1,"'");
  130. if (($test_param1===PHP_STR) || !is_word($test_param1)) {
  131. echo("WARNING: invalid image file<br>");
  132. return false;
  133. }
  134. //param2==""
  135. if ($param2!==PHP_STR) {
  136. echo("WARNING: invalid parameters<br>");
  137. return false;
  138. }
  139. //param3==""
  140. if ($param3!==PHP_STR) {
  141. echo("WARNING: invalid parameters<br>");
  142. return false;
  143. }
  144. //param1 exist
  145. $path = $curPath . DIRECTORY_SEPARATOR . $test_param1;
  146. if (!file_exists($path)) {
  147. echo("WARNING: file must exists<br>");
  148. return false;
  149. }
  150. //param1 is_file
  151. if (!is_file($path)) {
  152. echo("WARNING: invalid image file<br>");
  153. return false;
  154. }
  155. //param1 file extension == gif | png | jpg | jpeg
  156. if (!is_image($test_param1)) {
  157. echo("WARNING: invalid image file<br>");
  158. return false;
  159. }
  160. return true;
  161. }
  162. function myExecPrivatifyCommand() {
  163. global $param1;
  164. global $curPath;
  165. $privateData = [];
  166. $publicData = [];
  167. $real_param1 = trim($param1, "'");
  168. $curFile = substr($curPath, strlen(APP_REPO_PATH)) . DIRECTORY_SEPARATOR . $real_param1;
  169. //echo "curFile=$curFile";
  170. if (APP_DEFAULT_CONTEXT === "PUBLIC") {
  171. // Insert in .public
  172. $privateFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".private";
  173. //echo "curFile=$privateFile";
  174. if (file_exists($privateFile)) {
  175. $privateData = file($privateFile);
  176. }
  177. if (!in_array($curFile . "\n", $privateData)) {
  178. $privateData[] = $curFile . "\n";
  179. file_put_contents($privateFile, implode('', $privateData));
  180. }
  181. } else {
  182. // Cut off from .private
  183. $publicFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".public";
  184. //echo "curFile=$publicFile";
  185. if (file_exists($publicFile)) {
  186. $publicData = file($publicFile);
  187. }
  188. $key = array_search($curFile . "\n", $publicData);
  189. if ($key!==false) {
  190. unset($publicData[$key]);
  191. file_put_contents($publicFile, implode('', $publicData));
  192. }
  193. }
  194. }
  195. function publicifyparamValidation() {
  196. global $curPath;
  197. global $opt;
  198. global $param1;
  199. global $param2;
  200. global $param3;
  201. //opt!=""
  202. if ($opt!==PHP_STR) {
  203. echo("WARNING: invalid options<br>");
  204. return false;
  205. }
  206. //param1!="" and isword
  207. $test_param1 = trim($param1,"'");
  208. if (($test_param1===PHP_STR) || !is_word($test_param1)) {
  209. echo("WARNING: invalid image file<br>");
  210. return false;
  211. }
  212. //param2==""
  213. if ($param2!==PHP_STR) {
  214. echo("WARNING: invalid parameters<br>");
  215. return false;
  216. }
  217. //param3==""
  218. if ($param3!==PHP_STR) {
  219. echo("WARNING: invalid parameters<br>");
  220. return false;
  221. }
  222. //param1 exist
  223. $path = $curPath . DIRECTORY_SEPARATOR . $test_param1;
  224. if (!file_exists($path)) {
  225. echo("WARNING: file must exists<br>");
  226. return false;
  227. }
  228. //param1 is_file
  229. if (!is_file($path)) {
  230. echo("WARNING: invalid image file<br>");
  231. return false;
  232. }
  233. //param1 file extension == gif | png | jpg | jpeg
  234. if (!is_image($test_param1)) {
  235. echo("WARNING: invalid image file<br>");
  236. return false;
  237. }
  238. return true;
  239. }
  240. function myExecPublicifyCommand() {
  241. global $param1;
  242. global $curPath;
  243. $privateData = [];
  244. $publicData = [];
  245. $real_param1 = trim($param1, "'");
  246. $curFile = substr($curPath, strlen(APP_REPO_PATH)) . DIRECTORY_SEPARATOR . $real_param1;
  247. //echo "curFile=$curFile";
  248. if (APP_DEFAULT_CONTEXT === "PRIVATE") {
  249. // Insert in .public
  250. $publicFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".public";
  251. //echo "curFile=$publicFile";
  252. if (file_exists($publicFile)) {
  253. $publicData = file($publicFile);
  254. }
  255. if (!in_array($curFile . "\n", $publicData)) {
  256. $publicData[] = $curFile . "\n";
  257. file_put_contents($publicFile, implode('', $publicData));
  258. }
  259. } else {
  260. // Cut off from .private
  261. $privateFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".private";
  262. //echo "curFile=$privateFile";
  263. if (file_exists($privateFile)) {
  264. $privateData = file($privateFile);
  265. }
  266. $key = array_search($curFile . "\n", $privateData);
  267. if ($key!==false) {
  268. unset($privateData[$key]);
  269. file_put_contents($privateFile, implode('', $privateData));
  270. }
  271. }
  272. }
  273. function delparamValidation() {
  274. global $curPath;
  275. global $opt;
  276. global $param1;
  277. global $param2;
  278. global $param3;
  279. //opt!=""
  280. if ($opt!==PHP_STR) {
  281. echo("WARNING: invalid options<br>");
  282. return false;
  283. }
  284. //param1!="" and isword
  285. $test_param1 = trim($param1,"'");
  286. //echo("WARNING: ".$test_param1."<br>");
  287. if (($test_param1===PHP_STR) || !is_word($test_param1)) {
  288. echo("WARNING: invalid image file<br>");
  289. return false;
  290. }
  291. //param2==""
  292. if ($param2!==PHP_STR) {
  293. echo("WARNING: invalid parameters<br>");
  294. return false;
  295. }
  296. //param3==""
  297. if ($param3!==PHP_STR) {
  298. echo("WARNING: invalid parameters<br>");
  299. return false;
  300. }
  301. //param1 exist
  302. $path = $curPath . DIRECTORY_SEPARATOR . $test_param1;
  303. if (!file_exists($path)) {
  304. echo("WARNING: file must exists<br>");
  305. return false;
  306. }
  307. //param1 is_file
  308. if (!is_file($path)) {
  309. echo("WARNING: invalid image file<br>");
  310. return false;
  311. }
  312. //param1 file extension == gif | png | jpg | jpeg
  313. if (!is_image($test_param1)) {
  314. echo("WARNING: invalid image file<br>");
  315. return false;
  316. }
  317. return true;
  318. }
  319. function myExecDelCommand() {
  320. global $param1;
  321. global $curPath;
  322. $real_param1 = trim($param1, "'");
  323. $curFile = $curPath . DIRECTORY_SEPARATOR . $real_param1;
  324. unlink($curFile);
  325. $curFileThumb = $curPath . DIRECTORY_SEPARATOR . "thumbs" . DIRECTORY_SEPARATOR . $real_param1;
  326. if (is_readable($curFileThumb)) {
  327. unlink($curFileThumb);
  328. }
  329. }
  330. function makedirparamValidation() {
  331. global $curPath;
  332. global $opt;
  333. global $param1;
  334. global $param2;
  335. global $param3;
  336. //opt!=""
  337. if ($opt!==PHP_STR) {
  338. echo("WARNING: invalid options<br>");
  339. return false;
  340. }
  341. //param1!="" and isword
  342. $test_param1 = trim($param1,"'");
  343. if (($test_param1===PHP_STR) || !is_word($test_param1)) {
  344. echo("WARNING: invalid folder name<br>");
  345. return false;
  346. }
  347. //param2==""
  348. if ($param2!==PHP_STR) {
  349. echo("WARNING: invalid parameters<br>");
  350. return false;
  351. }
  352. //param3==""
  353. if ($param3!==PHP_STR) {
  354. echo("WARNING: invalid parameters<br>");
  355. return false;
  356. }
  357. //param1 exist
  358. $path = $curPath . DIRECTORY_SEPARATOR . $test_param1;
  359. if (file_exists($path)) {
  360. echo("WARNING: file must not exists<br>");
  361. return false;
  362. }
  363. //param1 file extension != gif | png | jpg | jpeg
  364. if (is_image($test_param1)) {
  365. echo("WARNING: invalid folder name<br>");
  366. return false;
  367. }
  368. return true;
  369. }
  370. function myExecMakeDirCommand() {
  371. global $param1;
  372. global $curPath;
  373. $real_param1 = trim($param1, "'");
  374. $newpath = $curPath . DIRECTORY_SEPARATOR . $real_param1;
  375. mkdir($newpath, 0777);
  376. }
  377. function upload() {
  378. global $curPath;
  379. global $prompt;
  380. //if (!empty($_FILES['files'])) {
  381. if (!empty($_FILES['files']['tmp_name'][0])) {
  382. // Updating history..
  383. //$output = [];
  384. //$output[] = $prompt . " " . "File upload" . "\n";
  385. //updateHistory($output, HISTORY_MAX_ITEMS);
  386. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  387. //no file uploaded
  388. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  389. echo("WARNING: No file uploaded.<br>");
  390. return;
  391. }
  392. foreach($uploads as &$upload) {
  393. switch ($upload['error']) {
  394. case PHP_UPLOAD_ERR_OK:
  395. break;
  396. case PHP_UPLOAD_ERR_NO_FILE:
  397. echo("WARNING: One or more uploaded files are missing.<br>");
  398. return;
  399. case PHP_UPLOAD_ERR_INI_SIZE:
  400. echo("WARNING: File exceeded INI size limit.<br>");
  401. return;
  402. case PHP_UPLOAD_ERR_FORM_SIZE:
  403. echo("WARNING: File exceeded form size limit.<br>");
  404. return;
  405. case PHP_UPLOAD_ERR_PARTIAL:
  406. echo("WARNING: File only partially uploaded.<br>");
  407. return;
  408. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  409. echo("WARNING: TMP dir doesn't exist.<br>");
  410. return;
  411. case PHP_UPLOAD_ERR_CANT_WRITE:
  412. echo("WARNING: Failed to write to the disk.<br>");
  413. return;
  414. case PHP_UPLOAD_ERR_EXTENSION:
  415. echo("WARNING: A PHP extension stopped the file upload.<br>");
  416. return;
  417. default:
  418. echo("WARNING: Unexpected error happened.<br>");
  419. return;
  420. }
  421. if (!is_uploaded_file($upload['tmp_name'])) {
  422. echo("WARNING: One or more file have not been uploaded.<br>");
  423. return;
  424. }
  425. // name
  426. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  427. if ($name == PHP_STR) {
  428. echo("WARNING: Invalid file name: " . $name."<br>");
  429. return;
  430. }
  431. $upload['name'] = $name;
  432. // fileType
  433. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  434. $upload['type'] = $fileType;
  435. // tmp_name
  436. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  437. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  438. echo("WARNING: Invalid file temp path: " . $tmp_name."<br>");
  439. return;
  440. }
  441. $upload['tmp_name'] = $tmp_name;
  442. //size
  443. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  444. if ($size == "") {
  445. echo("WARNING: Invalid file size.<br>");
  446. return;
  447. }
  448. $upload["size"] = $size;
  449. $tmpFullPath = $upload["tmp_name"];
  450. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  451. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  452. $FileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  453. if ($originalFileExt!==PHP_STR) {
  454. $destFileName = $originalFilename . "." . $originalFileExt;
  455. } else {
  456. $destFileName = $originalFilename;
  457. }
  458. $destFullPath = $curPath . DIRECTORY_SEPARATOR . $destFileName;
  459. if (file_exists($destFullPath)) {
  460. echo("WARNING: destination already exists.<br>");
  461. return;
  462. }
  463. copy($tmpFullPath, $destFullPath);
  464. chmod($destFullPath, 0766);
  465. // Creating thumb file
  466. if (is_readable($curPath . DIRECTORY_SEPARATOR . "thumbs")) {
  467. $destFullPath = $curPath . DIRECTORY_SEPARATOR . "thumbs" . DIRECTORY_SEPARATOR . $destFileName;
  468. copy($tmpFullPath, $destFullPath);
  469. chmod($destFullPath, 0766);
  470. }
  471. // Updating history..
  472. //$output = [];
  473. //$output[] = $destFileName . " " . "uploaded" . "\n";
  474. //updateHistory($output, HISTORY_MAX_ITEMS);
  475. // Cleaning up..
  476. // Delete the tmp file..
  477. unlink($tmpFullPath);
  478. }
  479. }
  480. }
  481. function showImages() {
  482. global $curPath;
  483. global $contextType;
  484. global $curLocale;
  485. $exclData = [];
  486. if (APP_DEFAULT_CONTEXT === "PUBLIC") {
  487. $exclFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".private";
  488. } else {
  489. $exclFile = APP_DATA_PATH . DIRECTORY_SEPARATOR . ".public";
  490. }
  491. if (file_exists($exclFile)) {
  492. $exclData = file($exclFile);
  493. }
  494. ///$root = "img";
  495. $root = APP_REPO_PATH;
  496. //subpath
  497. $subpath = $curPath;
  498. if ($subpath!=="" && is_dir($subpath)) {
  499. $path = $subpath;
  500. } else {
  501. $path = $root;
  502. }
  503. /*
  504. * Display Link to Home
  505. */
  506. if ($path!==$root) {
  507. $title = getResource("Parent", $curLocale);
  508. $ipos = mb_strripos($subpath, "/");
  509. $parentPath = substr($subpath, 0, $ipos);
  510. $relPath = substr($parentPath, strlen(APP_REPO_PATH));
  511. $cdate = date("d-m-Y", filectime($parentPath));
  512. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  513. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  514. echo "<tr><td style='padding:3px;'><a href='#' onclick='changePath(\"{$relPath}\")'><img src='/res/folder-home.png' width='100%' height='200px'></a></td><tr>";
  515. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  516. echo "</table>";
  517. } else {
  518. $title = getResource("Parent", $curLocale);
  519. $cdate = date("d-m-Y", filectime($root));
  520. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  521. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  522. echo "<tr><td style='padding:3px;'><img src='/res/folder-home-dis.png' width='100%' height='200px'></td><tr>";
  523. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  524. echo "</table>";
  525. }
  526. if ($contextType === PERSONAL_CONTEXT_TYPE) {
  527. $title = getResource("Add folder", $curLocale);
  528. $cdate = date("d-m-Y");
  529. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  530. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  531. echo "<tr><td style='padding:3px;cursor:pointer;' onclick='makeNewFolder()'><img src='/res/new-folder.png' width='100%' height='200px'></td><tr>";
  532. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  533. echo "</table>";
  534. }
  535. $pattern = $path . "/*";
  536. /*
  537. * Display subfolders
  538. */
  539. $aDirs = glob($pattern, GLOB_ONLYDIR);
  540. sort($aDirs);
  541. foreach ($aDirs as &$fsEntry) {
  542. $relPath = substr($fsEntry, strlen(APP_REPO_PATH));
  543. $ipos = mb_strripos($fsEntry, "/");
  544. $title = substr($fsEntry, $ipos+1);
  545. if ($title === "thumbs") {
  546. continue;
  547. }
  548. $cdate = date("d-m-Y", filectime($fsEntry));
  549. echo "<table style='float:left;width:235px;height:200px;margin-top:5px;margin-right:4px;border:0px solid #D2D2D2'>";
  550. echo "<tr><td style='text-align:center;font-size:11px'>{$title}</td><tr>";
  551. echo "<tr><td style='padding:3px;'><a href='#' onclick='changePath(\"{$relPath}\")'><img src='/res/folder.png' width='100%' height='200px'></a></td><tr>";
  552. echo "<tr><td style='text-align:center;font-size:11px'>{$cdate}</td><tr>";
  553. echo "</table>";
  554. }
  555. /*
  556. * Display images
  557. */
  558. if (is_readable($path . "/thumbs")) {
  559. $pattern = $path . "/thumbs/*";
  560. } else {
  561. $pattern = $path . "/*";
  562. }
  563. $aImages = glob($pattern);
  564. sort($aImages);
  565. $serverName = filter_input(INPUT_SERVER, "SERVER_NAME");
  566. $i=1;
  567. foreach ($aImages as &$fsEntry) {
  568. if (!is_dir($fsEntry)) {
  569. $relPath = "/" . substr(APP_REPO_PATH, strlen(APP_PATH)+1) . substr($fsEntry, strlen(APP_REPO_PATH));
  570. $fileName = basename($fsEntry);
  571. $curFile = substr($curPath, strlen(APP_REPO_PATH)) . DIRECTORY_SEPARATOR . $fileName;
  572. if (APP_DEFAULT_CONTEXT === "PUBLIC") {
  573. $isPrivateFile = false;
  574. $imgLock = "/res/public.png";
  575. if (in_array($curFile . "\n",$exclData)) {
  576. $isPrivateFile = true;
  577. $imgLock = "/res/private.png";
  578. }
  579. } else {
  580. $isPrivateFile = true;
  581. $imgLock = "/res/private.png";
  582. if (in_array($curFile . "\n",$exclData)) {
  583. $isPrivateFile = false;
  584. $imgLock = "/res/public.png";
  585. }
  586. }
  587. $ipos = mb_strripos($fsEntry, "/");
  588. $title = substr($fsEntry, $ipos+1);
  589. $ipos = mb_stripos($title, ".");
  590. $title = substr($title, 0, $ipos);
  591. //parsing title for underscore
  592. if (APP_LAST_UNDERSCORE_CHECK) {
  593. $ipos = mb_strripos($title, "_");
  594. if ($ipos === false) {
  595. } else {
  596. $title = substr($title, $ipos+1);
  597. }
  598. }
  599. if (strlen($title)>22) {
  600. $title = left($title,22) . "..";
  601. }
  602. $cdate = date("d-m-Y", filectime($fsEntry));
  603. if ((!$isPrivateFile && ($contextType === PUBLIC_CONTEXT_TYPE)) || ($contextType === PERSONAL_CONTEXT_TYPE)) {
  604. echo "<div class=\"image-cont\" style='float:left;width:235px;margin-right:4px;display:none;'>";
  605. echo "<table style='width:235px;height:230px;margin-top:5px;margin-right:4px;background-color:#e1e1e1;border:1px solid #D2D2D2;'>";
  606. echo "<tr>";
  607. if ($contextType === PERSONAL_CONTEXT_TYPE) {
  608. 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>";
  609. echo "<td style='width:45px;cursor:pointer' ondblclick='changeVisibility(\"{$i}\",\"{$fileName}\")'><img id='lock-{$i}' class='imglock' src='{$imgLock}' style='height:23px;'></td>";
  610. } else {
  611. echo "<td style='width:1px;cursor:pointer; vertical-align:bottom;'><img id='del-{$i}' class='imgdel' src='/res/pxl.gif' style='height:1px;'></td>";
  612. echo "<td style='width:1px;cursor:pointer'><img id='lock-{$i}' class='imglock' src='/res/pxl.gif' style='height:1px;'></td>";
  613. }
  614. //echo "<td style='height:23px;text-align:center;font-size:11px;'>";
  615. if ($contextType === PERSONAL_CONTEXT_TYPE) {
  616. echo "<td style='height:23px;text-align:right;font-size:11px;'>";
  617. echo "{$title}&nbsp;";
  618. } else {
  619. echo "<td style='height:23px;text-align:center;font-size:11px;'>";
  620. echo "{$title}&nbsp;";
  621. }
  622. echo "</td>";
  623. echo "<tr>";
  624. echo "<tr><td style='padding:3px;width:235px;height:200px;background-image:url(\"{$relPath}\");background-size:235px 200px;cursor:zoom-in;' colspan='3' onclick=\"openPic('$fileName')\"'>&nbsp;</td><tr>";
  625. echo "<tr><td style='text-align:left;font-size:11px' colspan='3'>&nbsp;{$cdate}</td><tr>";
  626. echo "</table>";
  627. echo "<div style='position:relative;top:-35px;text-align:right;padding-right:1.5px;'>";
  628. echo "<a href=\"https://www.facebook.com/sharer/sharer.php?u=http://{$serverName}{$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>";
  629. echo "<a href=\"https://twitter.com/share?url=http://{$serverName}{$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>";
  630. echo "<a href=\"whatsapp://send?text=http://{$serverName}{$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>";
  631. echo "</div>";
  632. echo "</div>";
  633. }
  634. $i++;
  635. }
  636. }
  637. }
  638. function openPicParamValidation()
  639. {
  640. global $curPath;
  641. global $opt;
  642. global $param1;
  643. global $param2;
  644. global $param3;
  645. //opt!=""
  646. if ($opt!==PHP_STR) {
  647. echo("invalid options");
  648. return false;
  649. }
  650. //param1!="" and isword
  651. if (($param1===PHP_STR) || !is_word($param1)) {
  652. echo("invalid image file");
  653. return false;
  654. }
  655. //param2==""
  656. if ($param2!==PHP_STR) {
  657. echo("invalid parameters");
  658. return false;
  659. }
  660. //param3==""
  661. if ($param3!==PHP_STR) {
  662. echo("invalid parameters");
  663. return false;
  664. }
  665. //param1 exist
  666. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  667. if (!file_exists($path)) {
  668. echo("file must exists");
  669. return false;
  670. }
  671. //param1 is_file
  672. if (!is_file($path)) {
  673. echo("invalid image file:" . $param1);
  674. return false;
  675. }
  676. //param1 is_image
  677. if (!is_image($param1)) {
  678. echo("invalid image file" . $param1);
  679. return false;
  680. }
  681. return true;
  682. }
  683. function myExecOpenPicCommand() {
  684. global $curPath;
  685. global $curPicture;
  686. global $param1;
  687. $curPicture = substr($curPath.DIRECTORY_SEPARATOR.$param1, strlen(dirname(APP_REPO_PATH)));
  688. }
  689. $password = filter_input(INPUT_POST, "Password")??"";
  690. $password = strip_tags($password);
  691. if ($password==PHP_STR) {
  692. $password = filter_input(INPUT_POST, "Password2")??"";
  693. $password = strip_tags($password);
  694. }
  695. $command = filter_input(INPUT_POST, "CommandLine")??"";
  696. $command = strip_tags($command);
  697. $pwd = filter_input(INPUT_POST, "pwd")??"";
  698. $pwd = strip_tags($pwd);
  699. $hideSplash = filter_input(INPUT_POST, "hideSplash")??"";
  700. $hideSplash = strip_tags($hideSplash);
  701. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash")??"";
  702. $hideHCSplash = strip_tags($hideHCSplash);
  703. if ($password !== PHP_STR) {
  704. $hash = hash("sha256", $password . APP_SALT, false);
  705. if ($hash !== APP_HASH) {
  706. $password=PHP_STR;
  707. }
  708. }
  709. $curPath = APP_REPO_PATH;
  710. if ($pwd!==PHP_STR) {
  711. ///if (left($pwd, strlen(APP_REPO_PATH)) === APP_REPO_PATH) {
  712. if (file_exists(APP_REPO_PATH . $pwd) && is_dir(APP_REPO_PATH . $pwd)) {
  713. $curPath = APP_REPO_PATH . $pwd;
  714. }
  715. }
  716. chdir($curPath);
  717. $ipos = strripos($curPath, PHP_SLASH);
  718. $curDir = substr($curPath, $ipos);
  719. parseCommand($command);
  720. //echo("cmd=" . $cmd . "<br>");
  721. //echo("opt=" . $opt . "<br>");
  722. //echo("param1=" . $param1 . "<br>");
  723. //echo("param2=" . $param2 . "<br>");
  724. if ($password !== PHP_STR) {
  725. upload();
  726. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  727. if ($command === "refresh") {
  728. // refreshing Msg Board..
  729. }
  730. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  731. if ($cmd === "privatify") {
  732. if (privatifyparamValidation()) {
  733. myExecPrivatifyCommand();
  734. }
  735. } else if ($cmd === "publicify") {
  736. if (publicifyparamValidation()) {
  737. myExecPublicifyCommand();
  738. }
  739. } else if ($cmd === "del") {
  740. if (delparamValidation()) {
  741. myExecDelCommand();
  742. }
  743. } else if ($cmd === "makedir") {
  744. if (makedirparamValidation()) {
  745. myExecMakeDirCommand();
  746. }
  747. } else if ($cmd === "openpic") {
  748. if (openPicParamValidation()) {
  749. myExecOpenPicCommand();
  750. }
  751. }
  752. } else {
  753. }
  754. $contextType = PERSONAL_CONTEXT_TYPE;
  755. } else {
  756. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  757. if ($cmd === "openpic") {
  758. if (openPicParamValidation()) {
  759. myExecOpenPicCommand();
  760. }
  761. }
  762. }
  763. }
  764. ?>
  765. <!DOCTYPE html>
  766. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  767. <head>
  768. <meta charset="UTF-8"/>
  769. <meta name="style" content="day1"/>
  770. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  771. <!--
  772. Copyright 2021, 2024 5 Mode
  773. This file is part of Homogram.
  774. Homogram is free software: you can redistribute it and/or modify
  775. it under the terms of the GNU General Public License as published by
  776. the Free Software Foundation, either version 3 of the License, or
  777. (at your option) any later version.
  778. Homogram is distributed in the hope that it will be useful,
  779. but WITHOUT ANY WARRANTY; without even the implied warranty of
  780. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  781. GNU General Public License for more details.
  782. You should have received a copy of the GNU General Public License
  783. along with Homogram. If not, see <https://www.gnu.org/licenses/>.
  784. -->
  785. <title>Homogram: every person its pictures..</title>
  786. <link rel="shortcut icon" href="./res/favicon.ico?v=<?php echo(time()); ?>" />
  787. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  788. <meta name="author" content="5 Mode"/>
  789. <meta name="robots" content="index,follow"/>
  790. <script src="./js/jquery-3.6.0.min.js" type="text/javascript"></script>
  791. <script src="./js/common.js" type="text/javascript"></script>
  792. <script src="./js/bootstrap.min.js" type="text/javascript"></script>
  793. <script src="./js/sha.js" type="text/javascript"></script>
  794. <script src="./js/home.js" type="text/javascript" defer></script>
  795. <link href="./css/bootstrap.min.css" type="text/css" rel="stylesheet">
  796. <link href="./css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  797. </head>
  798. <body>
  799. <div id="HCsplash" style="padding-top: 160px; text-align:center;color:#ffffff;display:none;">
  800. <div id="myh1"><H1>Homogram</H1></div><br>
  801. <img src="res/HGlogo2.png" style="width:310px;">
  802. </div>
  803. <?php
  804. //echo ("curPicture=**$curPicture**");
  805. if ($curPicture != PHP_STR) {
  806. $apic = glob($curPath . DIRECTORY_SEPARATOR . "*");
  807. $i=0;
  808. foreach($apic as &$path) {
  809. $fileName = basename($path);
  810. if (is_file($curPath . DIRECTORY_SEPARATOR . $fileName)) {
  811. $path=$fileName;
  812. } else {
  813. unset($apic[$i]);
  814. }
  815. $i++;
  816. }
  817. $i=array_search(basename($curPicture), $apic);
  818. // if the only one
  819. if (count($apic)==1) {
  820. $prevPicture = basename($apic[0]);
  821. $nextPicture = basename($apic[0]);
  822. // if first
  823. } else if ($i==0) {
  824. $prevPicture = basename($apic[count($apic)-1]);
  825. $nextPicture = basename($apic[1]);
  826. // if last
  827. } else if ($i==(count($apic)-1)) {
  828. $prevPicture = basename($apic[$i-1]);
  829. $nextPicture = basename($apic[0]);
  830. } else {
  831. $prevPicture = basename($apic[$i-1]);
  832. $nextPicture = basename($apic[$i+1]);
  833. }
  834. $hidePlayer = "0";
  835. } else {
  836. $hidePlayer = "1";
  837. }
  838. ?>
  839. <div id="picPlayer" style="width:100%;height:1900px;vertical-align:middle;text-align:center;background:#000000;display:<?php echo(($hidePlayer==="1"? "none": "inline"));?>;">
  840. <div id="closePlayer" style="position: absolute; top:20px; left:20px; cursor:pointer;" onclick="closePlayer()"><img src="/res/parent.png" style="width:64px;"></div>
  841. <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>
  842. <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>
  843. <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>
  844. </div>
  845. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data" style="display:<?php echo((($hideHCSplash == "1") && ($hidePlayer == "1")?"inline":"none"));?>;">
  846. <div class="header">
  847. <a id="burger-menu" href="#" style="display:none;"><img src="/res/burger-menu2.png" style="width:58px;"></a><a id="ahome" href="http://homogram.5mode-foss.eu" target="_blank" style="color:#000000; text-decoration: none;"><img id="logo-hg" src="res/HGlogo2.png" style="width:45px;">&nbsp;Homogram</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="agithub" href="https://github.com/par7133/Homogram" 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-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><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>
  848. </div>
  849. <div style="clear:both;"></div>
  850. <table class="burger-header" style="width:100%;border:3px solid #e4f5f7;display:none;">
  851. <tr>
  852. <td style="width:100%;background:#e4f5f7;">
  853. <?php if ($password!==PHP_STR): ?>
  854. <div class="burger-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="#" style="text-decoration:none;color:black;" onclick="upload()"><?php echo(strtolower(getResource("Upload", $curLocale)));?></a></div>
  855. <?php endif; ?>
  856. <div class="burger-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/Homogram" style="text-decoration:none;color:black;">on github</a></div>
  857. <div class="burger-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>
  858. <div class="burger-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>
  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. <div style="padding-left:12px;text-align: left;">
  865. &nbsp;
  866. <?php if ($password!==PHP_STR): ?>
  867. <a href="#" id="upload" style="color:#5ab5e4;" onclick="upload()"><?php echo(getResource("Upload", $curLocale));?></a>
  868. <input id="files" name="files[]" type="file" accept=".gif,.png,.jpg,.jpeg" style="visibility: hidden;" multiple>
  869. <?php else: ?>
  870. <br>
  871. <?php endif; ?>
  872. </div>
  873. <br><br>
  874. <img src="res/HGgenius.png" alt="HG Genius" title="HG Genius" style="position:relative; left:+6px; width:90%; border: 1px dashed #EEEEEE;">
  875. &nbsp;<br><br><br>
  876. <div style="text-align:left;white-space:nowrap;">
  877. &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>
  878. &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>
  879. <div style="text-align:center;">
  880. <a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; color:#000000; font-size:12px;"><?php echo(getResource("Hash Me", $curLocale));?>!</a>
  881. </div>
  882. </div>
  883. <input type="hidden" id="CommandLine" name="CommandLine">
  884. <input type="hidden" id="pwd" name="pwd" value="<?php echo(substr($curPath, strlen(APP_REPO_PATH))); ?>" style="color:black">
  885. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  886. <input type="hidden" name="hideHCSplash" value="1">
  887. </div>
  888. <div id="contentbar" style="float:left; width:75%;height:100%; padding:8px;">
  889. <?php if (APP_SPLASH): ?>
  890. <?php if ($hideSplash !== PHP_STR): ?>
  891. <div id="splash" style="border-radius:20px; position:relative; left:+3px; width:98%; background-color: #33aced; padding: 20px; margin-bottom:8px;">
  892. <button type="button" class="close" aria-label="Close" onclick="closeSplash();" style="position:relative; left:-10px;">
  893. <span aria-hidden="true">&times;</span>
  894. </button>
  895. Hello and welcome to Homogram!<br><br>
  896. Homogram is a light and simple software on premise to share your images. And it can be used as a private repository (screenshots, private shots, etc).<br><br>
  897. Homogram is released under GPLv3 license, it is supplied AS-IS and we do not take any responsibility for its misusage.<br><br>
  898. The name *Homogram* comes from a prank on the name 'instagram', in fact differently from the latter Homogram gives priorities to homines. However Homogram doesn't birth as a replacement but just like its alter ego.<br><br>
  899. 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>
  900. 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>
  901. <ol>
  902. <li>Check the write permissions of your "HGRepo" folder in your web app public path; and set its path in the config file.</li>
  903. <li>Check the write permissions of your "data" folder in your web app private path; and set its path in the config file.</li>
  904. <li>Set the default Locale.</li>
  905. <li>Set the default Context to PUBLIC or PRIVATE (for a private repository).</li>
  906. </ol>
  907. <br>
  908. 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>
  909. </div>
  910. <?php endif; ?>
  911. <?php endif; ?>
  912. <?php
  913. if ($contextType === PUBLIC_CONTEXT_TYPE) {
  914. echo("&nbsp;" . getResource("You are in ", $curLocale) . "<span style='color:orange;'>~/" . substr($curPath, strlen(APP_REPO_PATH)+1) . "</span>" . getResource(" as ", $curLocale) . "<span style='color:black;'>" . getResource("guest", $curLocale) . "</span><br>");
  915. } else {
  916. echo("&nbsp;" . getResource("You are in ", $curLocale) . "<span style='color:orange;'>~/" . substr($curPath, strlen(APP_REPO_PATH)+1) . "</span>" . getResource(" as ", $curLocale) . "<span style='color:green;'>" . getResource("owner", $curLocale) . "</span><br>");
  917. }
  918. ?><br>
  919. <div id="Console" style="hei-ght:493px; over-flow-y:auto; margin-top:10px;">
  920. <?php showImages(); ?>
  921. </div>
  922. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  923. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  924. </div>
  925. </form>
  926. <div class="footer">
  927. <div id="footerCont">&nbsp;</div>
  928. <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://demo.5mode.com">WYSIWYG</a> system. Some rights reserved.</span></div>
  929. </div>
  930. <script>
  931. function setPPlayer() {
  932. $("#picPlayer").css("height", parseInt(window.innerHeight)+"px");
  933. $("#myPicCont").css("height", parseInt(window.innerHeight)+"px");
  934. $("#myPicCont").css("max-width", parseInt(window.innerWidth)+"px");
  935. $("#closePlayer").css("left", "10px");
  936. $("#navPlayer1").css("top", parseInt((window.innerHeight-200)/2)+"px");
  937. $("#navPlayer2").css("top", parseInt((window.innerHeight-200)/2)+"px");
  938. $("#navPlayer2").css("left", parseInt(window.innerWidth-175)+"px");
  939. if (document.getElementById("myPic").src!="") {
  940. if ($("#myPic").width() > $("#myPic").height()) {
  941. f = $("#myPic").width() / $("#myPic").height();
  942. $("#myPic").css("padding-top", parseInt((window.innerHeight - $("#myPic").height()) / 2)+"px");
  943. $("#myPic").css("width", "100%"); //parseInt(window.innerWidth)+"px");
  944. $("#myPic").css("height", "");
  945. $("#myPic").css("max-height", parseInt(window.innerHeight)+"px");
  946. } else {
  947. $("#myPic").css("width", "");
  948. $("#myPic").css("max-width", parseInt(window.innerWidth)+"px");
  949. $("#myPic").css("height", "100%"); //parseInt(window.innerHeight)+"px");
  950. $("#myPicCont").css("max-width", parseInt(window.innerWidth)+"px");
  951. }
  952. $("#myPic").css("display", "inline");
  953. }
  954. $(document.body).css("overflow-x","hidden");
  955. }
  956. function hideTitle() {
  957. $("#myh1").hide("slow");
  958. }
  959. function startApp() {
  960. $("#HCsplash").hide("slow");
  961. $(document.body).css("background","#ffffff");
  962. $("#frmHC").show();
  963. }
  964. <?php if($hideHCSplash!=="1"): ?>
  965. window.addEventListener("load", function() {
  966. $(document.body).css("background","#000000");
  967. $("#HCsplash").show("slow");
  968. setTimeout("hideTitle()", 2000);
  969. setTimeout("startApp()", 4000);
  970. }, true);
  971. <?php else: ?>
  972. window.addEventListener("load", function() {
  973. <?php if ($hidePlayer == "1"): ?>
  974. startApp();
  975. <?php endif; ?>
  976. });
  977. <?php endif; ?>
  978. window.addEventListener("load", function() {
  979. <?php if ($hideHCSplash != "1" || $hidePlayer != "1"): ?>
  980. $(document.body).css("backgrond","#000000");
  981. <?php else: ?>
  982. $(document.body).css("backgrond","#FFFFFF");
  983. <?php endif; ?>
  984. });
  985. window.addEventListener("load", function() {
  986. <?php if($password===PHP_STR):?>
  987. $("#Password").addClass("emptyfield");
  988. <?php endif; ?>
  989. //maxY = document.getElementById("Console").scrollHeight;
  990. //alert(maxY);
  991. <?php if ($hidePlayer == "0"): ?>
  992. setPPlayer();
  993. <?php endif; ?>
  994. }, true);
  995. window.addEventListener("resize", function() {
  996. <?php if ($hidePlayer == "0"): ?>
  997. setPPlayer();
  998. <?php endif; ?>
  999. }, true);
  1000. </script>
  1001. <!-- SKINNER CODE -->
  1002. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html")): ?>
  1003. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "skinner.html"); ?>
  1004. <?php endif; ?>
  1005. <!-- METRICS CODE -->
  1006. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  1007. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html"); ?>
  1008. <?php endif; ?>
  1009. </body>
  1010. </html>