home.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of Invenktory.
  6. *
  7. * Invenktory 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. * Invenktory 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 Invenktory. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home.php
  21. *
  22. * Invenktory home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2021, 2024, 5 Mode
  26. */
  27. $cmdHistory = [];
  28. $cmd = PHP_STR;
  29. $opt = PHP_STR;
  30. $param1 = PHP_STR;
  31. $param2 = PHP_STR;
  32. $param3 = PHP_STR;
  33. $cmdRecallHistory = [];
  34. $editBoard = [];
  35. $editBoardParams = [];
  36. function showHistory() {
  37. global $cmdHistory;
  38. $i = 1;
  39. foreach($cmdHistory as $val) {
  40. echo(str_replace("\n", "<br>", $val));
  41. $i++;
  42. }
  43. }
  44. function updateHistory(&$update, $maxItems) {
  45. global $cmdHistory;
  46. // Making enough space in $cmdHistory for the update..
  47. $shift = (count($cmdHistory) + count($update)) - $maxItems;
  48. if ($shift > 0) {
  49. $cmdHistory = array_slice($cmdHistory, $shift, $maxItems);
  50. }
  51. // Adding $cmdHistory update..
  52. if (count($update) > $maxItems) {
  53. $beginUpd = count($update) - ($maxItems-1);
  54. } else {
  55. $beginUpd = 0;
  56. }
  57. $update = array_slice($update, $beginUpd, $maxItems);
  58. foreach($update as $val) {
  59. $cmdHistory[] = $val;
  60. }
  61. // Writing out $cmdHistory on disk..
  62. $filepath = dirname(__DIR__) . PHP_SLASH . "logs" . PHP_SLASH . ".INV_history";
  63. file_put_contents($filepath, implode('', $cmdHistory));
  64. }
  65. function loadRecallHistory() {
  66. global $cmdRecallHistory;
  67. $tmpcmdRecallHistory = file(dirname(__DIR__) . PHP_SLASH . "logs" . PHP_SLASH . ".INV_Recallhistory");
  68. foreach($tmpcmdRecallHistory as $val) {
  69. $cmdRecallHistory[left($val, strlen($val)-1)]=$val;
  70. }
  71. }
  72. function updateRecallHistory($update, $maxItems) {
  73. global $cmdRecallHistory;
  74. if (!array_key_exists($update, $cmdRecallHistory)) {
  75. // Making enough space in $cmdHistory for the update..
  76. $shift = (count($cmdRecallHistory) + 1) - $maxItems;
  77. if ($shift > 0) {
  78. $cmdRecallHistory = array_slice($cmdRecallHistory, $shift, $maxItems);
  79. }
  80. $cmdRecallHistory[$update] = $update . "\n";
  81. }
  82. // Writing out $cmdRecallHistory on disk..
  83. $filepath = dirname(__DIR__) . PHP_SLASH . "logs" . PHP_SLASH . ".INV_Recallhistory";
  84. file_put_contents($filepath, implode('', $cmdRecallHistory));
  85. }
  86. function updateHistoryWithErr(string $err, bool $withCommand = true)
  87. {
  88. global $prompt;
  89. global $command;
  90. $output = [];
  91. if ($withCommand) {
  92. $output[] = $prompt . " " . $command . "\n";
  93. }
  94. $output[] = "$err\n";
  95. updateHistory($output, HISTORY_MAX_ITEMS);
  96. }
  97. function myExecCommand() {
  98. global $prompt;
  99. global $command;
  100. // Exec command..
  101. $output = [];
  102. $output[] = $prompt . " " . $command . "\n";
  103. exec($command, $output);
  104. // Update history..
  105. foreach ($output as &$val) {
  106. if (right($val,1)!="\n") {
  107. $val = $val . "\n";
  108. }
  109. }
  110. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  111. updateHistory($output, HISTORY_MAX_ITEMS);
  112. }
  113. function myExecCPCommand() {
  114. global $prompt;
  115. global $command;
  116. $realCommand = str_replace("cp", "cp -Rp", $command);
  117. // Exec command..
  118. $output = [];
  119. $output[] = $prompt . " " . $command . "\n";
  120. exec($realCommand, $output);
  121. // Update history..
  122. foreach ($output as &$val) {
  123. if (right($val,1)!="\n") {
  124. $val = $val . "\n";
  125. }
  126. }
  127. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  128. updateHistory($output, HISTORY_MAX_ITEMS);
  129. }
  130. function myExecCopy() {
  131. global $prompt;
  132. global $command;
  133. global $param1;
  134. global $param2;
  135. // Exec command..
  136. $output = [];
  137. $output[] = $prompt . " " . $command . "\n";
  138. copy($param1, $param2);
  139. // Update history..
  140. foreach ($output as &$val) {
  141. if (right($val,1)!="\n") {
  142. $val = $val . "\n";
  143. }
  144. }
  145. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  146. updateHistory($output, HISTORY_MAX_ITEMS);
  147. }
  148. function myExecCDFolderCommand() {
  149. global $prompt;
  150. global $command;
  151. global $param1;
  152. global $curPath;
  153. // Exec command..
  154. $output = [];
  155. $output[] = $prompt . " " . $command . "\n";
  156. //exec($command, $output);
  157. $newPath = $curPath . PHP_SLASH . $param1;
  158. chdir($newPath);
  159. $curPath = $newPath;
  160. $curDir = $param1;
  161. // Creating the Download folder if doesn't exist..
  162. $downloadPath = $curPath . PHP_SLASH . ".HCdownloads";
  163. if (!file_exists($downloadPath)) {
  164. //copy(APP_INV_PATH . PHP_SLASH . ".HCsampledir", $downloadPath);
  165. $mycmd = "cp -Rp " . APP_INV_PATH . PHP_SLASH . ".HCsampledir" . " " . $downloadPath;
  166. $myret = exec($mycmd);
  167. }
  168. $prompt = str_replace("$1", $curDir, APP_PROMPT);
  169. // Update history..
  170. foreach ($output as &$val) {
  171. if (right($val,1)!="\n") {
  172. $val = $val . "\n";
  173. }
  174. }
  175. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  176. updateHistory($output, HISTORY_MAX_ITEMS);
  177. }
  178. function myExecCDBackwCommand() {
  179. global $prompt;
  180. global $command;
  181. global $curPath;
  182. // Exec command..
  183. $output = [];
  184. $output[] = $prompt . " " . $command . "\n";
  185. //exec($command, $output);
  186. $ipos = strripos($curPath, PHP_SLASH);
  187. $newPath = substr($curPath, 0, $ipos);
  188. chdir($newPath);
  189. $curPath = getcwd();
  190. $ipos = strripos($curPath, PHP_SLASH);
  191. $curDir = substr($curPath, $ipos);
  192. $prompt = str_replace("$1", $curDir, APP_PROMPT);
  193. // Update history..
  194. foreach ($output as &$val) {
  195. if (right($val,1)!="\n") {
  196. $val = $val . "\n";
  197. }
  198. }
  199. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  200. updateHistory($output, HISTORY_MAX_ITEMS);
  201. }
  202. function myarray_filter_cb($val) {
  203. return isset($val);
  204. }
  205. function myExecLSCommand() {
  206. global $prompt;
  207. global $command;
  208. global $curPath;
  209. $downloadPath = $curPath . PHP_SLASH . ".HCdownloads";
  210. $realCommand = "ls -a";
  211. // Exec command..
  212. $output = [];
  213. $output[] = $prompt . " " . $command . "\n";
  214. exec($realCommand, $output);
  215. // Creating the Download path for the current folder..
  216. /*
  217. if (!file_exists($downloadPath)) {
  218. //copy(APP_INV_PATH . PHP_SLASH . ".HCsampledir", $downloadPath);
  219. $mycmd = "cp -Rp " . APP_INV_PATH . PHP_SLASH . ".HCsampledir" . " " . $downloadPath;
  220. $myret=exec($mycmd);
  221. }
  222. // Cleaning the Download folder..
  223. if (file_exists($downloadPath)) {
  224. $files1 = scandir($downloadPath);
  225. foreach($files1 as $file) {
  226. if (!is_dir($downloadPath . PHP_SLASH . $file) && $file !== "." && $file !== "..") {
  227. unlink($downloadPath . PHP_SLASH . $file);
  228. }
  229. }
  230. }*/
  231. // Update history..
  232. foreach ($output as &$val) {
  233. if ($val === $prompt . " " . $realCommand . "\n") {
  234. } else if ($val === "." || $val === "..") {
  235. $val = null;
  236. } else {
  237. if (right($val,1)==="\n") {
  238. $val = left($val, strlen($val)-1);
  239. }
  240. // Creating the tmp download for the file entry and generating the virtual path..
  241. /*
  242. $virtualPath = PHP_STR;
  243. if (file_exists($downloadPath)) {
  244. if (!is_dir($curPath . PHP_SLASH . $val) && filesize($curPath . PHP_SLASH . $val)<=651000) {
  245. $fileext = strtolower(pathinfo($val, PATHINFO_EXTENSION));
  246. if ($fileext === "php" || $fileext === "inc") {
  247. copy($curPath . PHP_SLASH . $val, $downloadPath . PHP_SLASH . $val . ".hcd");
  248. $virtualPath = getVirtualPath($downloadPath . PHP_SLASH . $val . ".hcd");
  249. } else {
  250. copy($curPath . PHP_SLASH . $val, $downloadPath . PHP_SLASH . $val);
  251. $virtualPath = getVirtualPath($downloadPath . PHP_SLASH . $val);
  252. }
  253. }
  254. } else {
  255. $virtualPath=PHP_STR;
  256. }
  257. if ($virtualPath!==PHP_STR) {
  258. $val = "<a href='$virtualPath'>" . $val . "</a>\n";
  259. } else {
  260. $val = $val . "\n";
  261. }
  262. */
  263. $val = $val . "\n";
  264. }
  265. }
  266. $output = array_filter($output, "myarray_filter_cb");
  267. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  268. updateHistory($output, HISTORY_MAX_ITEMS);
  269. }
  270. function myExecHelpCommand() {
  271. global $prompt;
  272. global $command;
  273. // Exec command..
  274. $output = [];
  275. $output[] = $prompt . " " . $command . "\n";
  276. //exec($command, $output);
  277. //cd, cd.., cp, help, ls, ls -lsa, mv, pwd
  278. $output[] = "Copyright 2021, 2024 5 Mode" . "\n";
  279. $output[] = "Invenktory is licensed GNUv3" . "\n";
  280. $output[] = "" . "\n";
  281. $output[] = "Supported commands are:" . "\n";
  282. $output[] = "cd" . "\n";
  283. $output[] = "cd .." . "\n";
  284. $output[] = "cp" . "\n";
  285. $output[] = "edit" . " " . "[CTRL]+[X]=Close [CTRL]+[S]=Save" . "\n";
  286. $output[] = "help" . "\n";
  287. $output[] = "ls" . "\n";
  288. $output[] = "mv" . "\n";
  289. $output[] = "pwd" . "\n";
  290. $output[] = "show" . "\n";
  291. $output[] = "\n";
  292. $output[] = "Thx for using Invenktory! :)" . "\n";
  293. $output[] = "\n";
  294. // Update History
  295. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  296. updateHistory($output, HISTORY_MAX_ITEMS);
  297. }
  298. function myExecPWDCommand() {
  299. global $prompt;
  300. global $command;
  301. global $curPath;
  302. // Exec command..
  303. $output = [];
  304. $output[] = $prompt . " " . $command . "\n";
  305. exec($command, $output);
  306. // Update history..
  307. foreach ($output as &$val) {
  308. if (mb_stripos("~".$val,APP_INV_PATH)) {
  309. $val = str_replace(dirname(APP_INV_PATH), "~ ", $val) . "\n";
  310. }
  311. }
  312. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  313. updateHistory($output, HISTORY_MAX_ITEMS);
  314. }
  315. function myExecShowCommand() {
  316. global $prompt;
  317. global $command;
  318. global $param1;
  319. global $curPath;
  320. // Exec command..
  321. $output = [];
  322. $output[] = $prompt . " " . $command . "\n";
  323. //exec($command, $output);
  324. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  325. $xml = simplexml_load_file($path);
  326. $output[] = "\n";
  327. $output[] = "Location: " . $xml->attributes()['location'] . "\n";
  328. $output[] = "\n";
  329. // Printing out the item descriptions
  330. foreach ($xml->children() as $child) {
  331. $text = $child->DESCRIPTION;
  332. $text = rtrim1($text, PHP_SPACE . chr(13) . chr(10) . chr(32) . "\n");
  333. $text = ltrim1($text, PHP_SPACE . chr(13) . chr(10) . chr(32) . "\n");
  334. //print_r("*" . right($text, 1) . "*");
  335. //print_r(ord(right($text, 1)));
  336. $output[] = $child->attributes()['type'] . " #" . $child->INDEX . ":\n" . $text . "\n\n";
  337. }
  338. // Update History
  339. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  340. updateHistory($output, HISTORY_MAX_ITEMS);
  341. }
  342. function parseCommand() {
  343. global $command;
  344. global $cmd;
  345. global $opt;
  346. global $param1;
  347. global $param2;
  348. global $param3;
  349. $str = trim($command);
  350. $ipos = stripos($str, PHP_SPACE);
  351. if ($ipos > 0) {
  352. $cmd = left($str, $ipos);
  353. $str = substr($str, $ipos+1);
  354. } else {
  355. $cmd = $str;
  356. return;
  357. }
  358. if (left($str, 1) === "-") {
  359. $ipos = stripos($str, PHP_SPACE);
  360. if ($ipos > 0) {
  361. $opt = left($str, $ipos);
  362. $str = substr($str, $ipos+1);
  363. } else {
  364. $opt = $str;
  365. return;
  366. }
  367. }
  368. $ipos = stripos($str, PHP_SPACE);
  369. if ($ipos > 0) {
  370. $param1 = left($str, $ipos);
  371. $str = substr($str, $ipos+1);
  372. } else {
  373. $param1 = $str;
  374. return;
  375. }
  376. $ipos = stripos($str, PHP_SPACE);
  377. if ($ipos > 0) {
  378. $param2 = left($str, $ipos);
  379. $str = substr($str, $ipos+1);
  380. } else {
  381. $param2 = $str;
  382. return;
  383. }
  384. $ipos = stripos($str, PHP_SPACE);
  385. if ($ipos > 0) {
  386. $param3 = left($str, $ipos);
  387. $str = substr($str, $ipos+1);
  388. } else {
  389. $param3 = $str;
  390. return;
  391. }
  392. }
  393. function cdparamValidation() {
  394. global $curPath;
  395. global $opt;
  396. global $param1;
  397. global $param2;
  398. global $param3;
  399. //opt==""
  400. if ($opt!=PHP_STR) {
  401. updateHistoryWithErr("invalid options");
  402. return false;
  403. }
  404. //param1==""
  405. if ($param1===PHP_STR) {
  406. updateHistoryWithErr("invalid parameters");
  407. return false;
  408. }
  409. //param1!="" and !isword
  410. if (($param1!==PHP_STR) && !is_word($param1)) {
  411. updateHistoryWithErr("invalid dir");
  412. return false;
  413. }
  414. //param2==""
  415. if ($param2!==PHP_STR) {
  416. updateHistoryWithErr("invalid parameters");
  417. return false;
  418. }
  419. //param3==""
  420. if ($param3!=PHP_STR) {
  421. updateHistoryWithErr("invalid parameters");
  422. return false;
  423. }
  424. //param1 exist and is_dir
  425. $path = $curPath . PHP_SLASH . $param1;
  426. if (!file_exists($path) || !is_dir($path)) {
  427. updateHistoryWithErr("dir doesn't exist");
  428. return false;
  429. }
  430. return true;
  431. }
  432. function is_subfolderdest(string $path): bool
  433. {
  434. global $curPath;
  435. $ret=false;
  436. if ($path === "../") {
  437. return $ret;
  438. }
  439. if ($path!=PHP_STR) {
  440. $folderName = left($path, strlen($path)-1);
  441. if (!is_word($folderName)) {
  442. return $ret;
  443. }
  444. if (is_dir($curPath . PHP_SLASH . $folderName) && (right($path,1)==="/")) {
  445. $ret=true;
  446. }
  447. }
  448. return $ret;
  449. }
  450. function cpparamValidation() {
  451. global $curPath;
  452. global $opt;
  453. global $param1;
  454. global $param2;
  455. global $param3;
  456. //ori opt!="" and opt!="-R" and opt!="-Rp"
  457. //ori if (($opt!==PHP_STR) && ($opt!=="-R") && ($opt!=="-Rp") && ($opt!=="-p")) {
  458. if ($opt!==PHP_STR) {
  459. updateHistoryWithErr("invalid options");
  460. return false;
  461. }
  462. //param1!="" and isword
  463. if (($param1===PHP_STR) || !is_word($param1)) {
  464. updateHistoryWithErr("invalid source path");
  465. return false;
  466. }
  467. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  468. if (($param2===PHP_STR) || (!is_word($param2) && ($param2!="../") && !is_subfolderdest($param2))) {
  469. updateHistoryWithErr("invalid destination path");
  470. return false;
  471. }
  472. //param3==""
  473. if ($param3!=PHP_STR) {
  474. updateHistoryWithErr("invalid parameters");
  475. return false;
  476. }
  477. //param1 != param2
  478. if ($param1 === $param2) {
  479. updateHistoryWithErr("source same as destination");
  480. return false;
  481. }
  482. //param1 exist
  483. $path = $curPath . PHP_SLASH . $param1;
  484. if (!file_exists($path)) {
  485. updateHistoryWithErr("source must exists");
  486. return false;
  487. }
  488. //isword(param2) && doesn't exist
  489. if (is_word($param2)) {
  490. $path = $curPath . PHP_SLASH . $param2;
  491. if (file_exists($path)) {
  492. updateHistoryWithErr("destination already exists");
  493. return false;
  494. }
  495. }
  496. // param2=="../" && is_root
  497. // param2=="../" && dest exists
  498. if ($param2==="../") {
  499. if ($curPath === APP_INV_PATH) {
  500. updateHistoryWithErr("out of root boundary");
  501. return false;
  502. }
  503. $path = dirname($curPath) . PHP_SLASH . $param1;
  504. if (file_exists($path)) {
  505. updateHistoryWithErr("destination already exists");
  506. return false;
  507. }
  508. }
  509. return true;
  510. }
  511. function mvparamValidation() {
  512. global $curPath;
  513. global $opt;
  514. global $param1;
  515. global $param2;
  516. global $param3;
  517. //opt!=""
  518. if ($opt!=PHP_STR) {
  519. updateHistoryWithErr("invalid options");
  520. return false;
  521. }
  522. //param1!="" and isword
  523. if (($param1===PHP_STR) || !is_word($param1)) {
  524. updateHistoryWithErr("invalid source path");
  525. return false;
  526. }
  527. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  528. if (($param2===PHP_STR) || (!is_word($param2) && ($param2!="../") && !is_subfolderdest($param2))) {
  529. updateHistoryWithErr("invalid destination path");
  530. return false;
  531. }
  532. //param3!=""
  533. if ($param3!=PHP_STR) {
  534. updateHistoryWithErr("invalid parameters");
  535. return false;
  536. }
  537. //param1 != param2
  538. if ($param1 === $param2) {
  539. updateHistoryWithErr("source same as destination");
  540. return false;
  541. }
  542. //param1 exist
  543. $path = $curPath . PHP_SLASH . $param1;
  544. if (!file_exists($path)) {
  545. updateHistoryWithErr("source must exists");
  546. return false;
  547. }
  548. //isword(param2) && doesn't exist
  549. if (is_word($param2)) {
  550. $path = $curPath . PHP_SLASH . $param2;
  551. if (file_exists($path)) {
  552. updateHistoryWithErr("destination already exists");
  553. return false;
  554. }
  555. }
  556. // param2=="../" && is_root
  557. // param2=="../" && dest exists
  558. if ($param2==="../") {
  559. if ($curPath === APP_INV_PATH) {
  560. updateHistoryWithErr("out of root boundary");
  561. return false;
  562. }
  563. $path = dirname($curPath) . PHP_SLASH . $param1;
  564. if (file_exists($path)) {
  565. updateHistoryWithErr("destination already exists");
  566. return false;
  567. }
  568. }
  569. return true;
  570. }
  571. function myExecEditCommand() {
  572. global $prompt;
  573. global $command;
  574. global $param1;
  575. global $curPath;
  576. // Exec command..
  577. $output = [];
  578. $output[] = $prompt . " " . $command . "\n";
  579. //exec($command, $output);
  580. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  581. loadEditBoard($path);
  582. // Update History
  583. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  584. updateHistory($output, HISTORY_MAX_ITEMS);
  585. }
  586. function loadEditBoard($file) {
  587. global $editBoard;
  588. $xml = simplexml_load_file($file);
  589. $editBoard[] = "\n";
  590. $editBoard[] = "<div id='editBoard' style='display:none'>" . "\n";
  591. $location = $xml->attributes()['location'];
  592. $editBoard[] = "<label id='labLocation' for='txtLocation'>Location:&nbsp;</label><input id='txtLocation' name='txtLocation' class='standardfield' type='text' autocomplete='off' style='width:200px; height:22px; background-color: black; color:white;' value='" . $location . "'>" . "\n";
  593. $i=0;
  594. foreach ($xml->children() as $child) {
  595. $i++;
  596. $deviceType = $child->attributes()['type'];
  597. $description = ltrim($child->DESCRIPTION, "\n");
  598. $index = $child->INDEX;
  599. $editBoard[] = "<br>\n";
  600. $editBoard[] = "<label id='labDevice" . $i . "'>Device #" . $i . "&nbsp;</label>" . "\n";
  601. $editBoard[] = "<label id='labType" . $i . "' for='txtType" . $i . "'>Device type:&nbsp;</label><input id='txtType" . $i . "' name='txtType" . $i . "' class='standardfield' type='text' autocomplete='off' style='width:200px; height:22px; background-color: black; color:white;' value='" . $deviceType . "'>" . "\n";
  602. $editBoard[] = "<textarea id='txtDesc" . $i . "' name='txtDesc" . $i . "' class='standardfield' placeholder='description' style='position:relative; top:3px; width: 400px; height:120px; background-color: #EEEEEE; color:black; resize: none;'>";
  603. $editBoard[] = $description;
  604. $editBoard[] = "</textarea>" . "\n";
  605. }
  606. $i++;
  607. for ($y=$i;$y<=10;$y++) {
  608. $editBoard[] = "<br>\n";
  609. $editBoard[] = "<label id='labDevice" . $y . "'>Device #" . $y . "&nbsp;</label>" . "\n";
  610. $editBoard[] = "<label id='labType" . $y. "' for='txtType" . $y. "'>Device type:&nbsp;</label><input id='txtType" . $y. "' name='txtType" . $y. "' class='standardfield' type='text' autocomplete='off' placeholder='type' style='width:200px; height:22px; background-color: black; color:white;' value=''>" . "\n";
  611. $editBoard[] = "<textarea id='txtDesc" . $y. "' name='txtDesc" . $y. "' class='standardfield' placeholder='description' style='position:relative; top:3px; width: 400px; height:120px; background-color: #EEEEEE; color:black; border:0px; resize: none;'>";
  612. $editBoard[] = "</textarea>\n";
  613. }
  614. $editBoard[] = "<input type='hidden' name='editBoardDest' value='" . $file . "'>\n";
  615. $editBoard[] = "<br>\n";
  616. $editBoard[] = "</div>\n";
  617. }
  618. function showEditBoard() {
  619. global $editBoard;
  620. $i = 1;
  621. foreach($editBoard as $val) {
  622. //echo(str_replace("\n", "<br>", $val));
  623. echo($val);
  624. $i++;
  625. }
  626. }
  627. function is_validxmlsynax(string $path) {
  628. $xml = rtrim1(ltrim1(file_get_contents($path), chr(10) . chr(13) . chr(32) . "\n"), chr(10) . chr(13) . chr(32) . "\n");
  629. if (left($xml, 5) !== "<?xml") {
  630. return false;
  631. }
  632. if (!mb_stripos("~" . $xml, "<INVENTORY location=")) {
  633. return false;
  634. }
  635. if (!mb_stripos("~" . $xml, "<ITEM type=")) {
  636. return false;
  637. }
  638. if (!mb_stripos("~" . $xml, "</ITEM>")) {
  639. return false;
  640. }
  641. if (!mb_stripos("~" . $xml, "</INVENTORY>")) {
  642. return false;
  643. }
  644. return true;
  645. }
  646. function showparamValidation() {
  647. global $curPath;
  648. global $opt;
  649. global $param1;
  650. global $param2;
  651. global $param3;
  652. //opt!=""
  653. if ($opt!==PHP_STR) {
  654. updateHistoryWithErr("invalid options");
  655. return false;
  656. }
  657. //param1!="" and isword
  658. if (($param1===PHP_STR) || !is_word($param1)) {
  659. updateHistoryWithErr("invalid inventory file");
  660. return false;
  661. }
  662. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  663. if ($param2!=PHP_STR) {
  664. updateHistoryWithErr("invalid parameters");
  665. return false;
  666. }
  667. //param3==""
  668. if ($param3!=PHP_STR) {
  669. updateHistoryWithErr("invalid parameters");
  670. return false;
  671. }
  672. //param1 exist
  673. $path = $curPath . PHP_SLASH . $param1;
  674. if (!file_exists($path)) {
  675. updateHistoryWithErr("file must exists");
  676. return false;
  677. }
  678. //param1 is_file
  679. if (!is_file($path)) {
  680. updateHistoryWithErr("invalid inventory file");
  681. return false;
  682. }
  683. //param1 file extension == xml
  684. $fileExt = pathinfo($param1, PATHINFO_EXTENSION);
  685. if ($fileExt != "xml") {
  686. updateHistoryWithErr("invalid inventory file");
  687. return false;
  688. }
  689. //check file syntax
  690. if (!is_validxmlsynax($curPath . DIRECTORY_SEPARATOR . $param1)) {
  691. updateHistoryWithErr("invalid file syntax");
  692. return false;
  693. }
  694. return true;
  695. }
  696. function editparamValidation() {
  697. global $curPath;
  698. global $opt;
  699. global $param1;
  700. global $param2;
  701. global $param3;
  702. //opt!=""
  703. if ($opt!==PHP_STR) {
  704. updateHistoryWithErr("invalid options");
  705. return false;
  706. }
  707. //param1!="" and isword
  708. if (($param1===PHP_STR) || !is_word($param1)) {
  709. updateHistoryWithErr("invalid inventory file");
  710. return false;
  711. }
  712. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  713. if ($param2!=PHP_STR) {
  714. updateHistoryWithErr("invalid parameters");
  715. return false;
  716. }
  717. //param3==""
  718. if ($param3!=PHP_STR) {
  719. updateHistoryWithErr("invalid parameters");
  720. return false;
  721. }
  722. //param1 exist
  723. $path = $curPath . PHP_SLASH . $param1;
  724. if (!file_exists($path)) {
  725. updateHistoryWithErr("file must exists");
  726. return false;
  727. }
  728. //param1 is_file
  729. if (!is_file($path)) {
  730. updateHistoryWithErr("invalid inventory file");
  731. return false;
  732. }
  733. //param1 file extension == xml
  734. $fileExt = pathinfo($param1, PATHINFO_EXTENSION);
  735. if ($fileExt != "xml") {
  736. updateHistoryWithErr("invalid inventory file");
  737. return false;
  738. }
  739. //check file syntax
  740. if (!is_validxmlsynax($curPath . DIRECTORY_SEPARATOR . $param1)) {
  741. updateHistoryWithErr("invalid file syntax");
  742. return false;
  743. }
  744. return true;
  745. }
  746. function upload() {
  747. global $curPath;
  748. global $prompt;
  749. //if (!empty($_FILES['files'])) {
  750. if (!empty($_FILES['files']['tmp_name'][0])) {
  751. // Updating history..
  752. $output = [];
  753. $output[] = $prompt . " " . "File upload" . "\n";
  754. updateHistory($output, HISTORY_MAX_ITEMS);
  755. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  756. //no file uploaded
  757. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  758. updateHistoryWithErr("No file uploaded.", false);
  759. return;
  760. }
  761. foreach($uploads as &$upload) {
  762. switch ($upload['error']) {
  763. case PHP_UPLOAD_ERR_OK:
  764. break;
  765. case PHP_UPLOAD_ERR_NO_FILE:
  766. updateHistoryWithErr("One or more uploaded files are missing.", false);
  767. return;
  768. case PHP_UPLOAD_ERR_INI_SIZE:
  769. updateHistoryWithErr("File exceeded INI size limit.", false);
  770. return;
  771. case PHP_UPLOAD_ERR_FORM_SIZE:
  772. updateHistoryWithErr("File exceeded form size limit.", false);
  773. return;
  774. case PHP_UPLOAD_ERR_PARTIAL:
  775. updateHistoryWithErr("File only partially uploaded.", false);
  776. return;
  777. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  778. updateHistoryWithErr("TMP dir doesn't exist.", false);
  779. return;
  780. case PHP_UPLOAD_ERR_CANT_WRITE:
  781. updateHistoryWithErr("Failed to write to the disk.", false);
  782. return;
  783. case PHP_UPLOAD_ERR_EXTENSION:
  784. updateHistoryWithErr("A PHP extension stopped the file upload.", false);
  785. return;
  786. default:
  787. updateHistoryWithErr("Unexpected error happened.", false);
  788. return;
  789. }
  790. if (!is_uploaded_file($upload['tmp_name'])) {
  791. updateHistoryWithErr("One or more file have not been uploaded.", false);
  792. return;
  793. }
  794. // name
  795. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  796. if ($name == PHP_STR) {
  797. updateHistoryWithErr("Invalid file name: " . $name, false);
  798. return;
  799. }
  800. $upload['name'] = $name;
  801. // fileType
  802. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  803. $upload['type'] = $fileType;
  804. // tmp_name
  805. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  806. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  807. updateHistoryWithErr("Invalid file temp path: " . $tmp_name, false);
  808. return;
  809. }
  810. $upload['tmp_name'] = $tmp_name;
  811. //size
  812. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  813. if ($size == "") {
  814. updateHistoryWithErr("Invalid file size.", false);
  815. return;
  816. }
  817. $upload["size"] = $size;
  818. $tmpFullPath = $upload["tmp_name"];
  819. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  820. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  821. $FileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  822. if ($originalFileExt!==PHP_STR) {
  823. $destFileName = $originalFilename . "." . $originalFileExt;
  824. } else {
  825. $destFileName = $originalFilename;
  826. }
  827. $destFullPath = $curPath . PHP_SLASH . $destFileName;
  828. if (file_exists($destFullPath)) {
  829. updateHistoryWithErr("destination already exists", false);
  830. return;
  831. }
  832. copy($tmpFullPath, $destFullPath);
  833. // Updating history..
  834. $output = [];
  835. $output[] = $destFileName . " " . "uploaded" . "\n";
  836. updateHistory($output, HISTORY_MAX_ITEMS);
  837. // Cleaning up..
  838. // Delete the tmp file..
  839. unlink($tmpFullPath);
  840. }
  841. }
  842. }
  843. function saveEditBoard() {
  844. global $editBoardParams;
  845. if (!empty($editBoardParams) && $editBoardParams[0]['location']!=PHP_STR) {
  846. $xml = PHP_STR;
  847. $xml .= "<?xml version='1.0' encoding='UTF-8'?>";
  848. $xml .= "<INVENTORY location='" . HTMLencode($editBoardParams[0]['location']) . "'>";
  849. for($i=1;$i<=10;$i++) {
  850. if ($editBoardParams[$i]['type']!=PHP_STR) {
  851. $xml .= "<ITEM type='" . HTMLencode($editBoardParams[$i]['type']) . "'>";
  852. $xml .= "<DESCRIPTION>";
  853. $xml .= "<![CDATA[";
  854. $xml .= HTMLencode($editBoardParams[$i]['desc']);
  855. $xml .= "]]>";
  856. $xml .= "</DESCRIPTION>";
  857. $xml .= "<INDEX>" . $i . "</INDEX>";
  858. $xml .= "</ITEM>";
  859. } else {
  860. break;
  861. }
  862. }
  863. $xml .= "</INVENTORY>";
  864. file_put_contents($editBoardParams[0]['file'], $xml);
  865. }
  866. }
  867. $password = filter_input(INPUT_POST, "Password")??"";
  868. $password = strip_tags($password);
  869. $command = filter_input(INPUT_POST, "CommandLine")??"";
  870. $command = strip_tags($command);
  871. $pwd = filter_input(INPUT_POST, "pwd")??"";
  872. $pwd = strip_tags($pwd);
  873. $hideSplash = filter_input(INPUT_POST, "hideSplash")??"";
  874. $hideSplash = strip_tags($hideSplash);
  875. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash")??"";
  876. $hideHCSplash = strip_tags($hideHCSplash);
  877. //EditBoard
  878. if (strip_tags(filter_input(INPUT_POST, "txtLocation")??"")!==PHP_STR) {
  879. $editBoardParams[0] = [
  880. 'file' => strip_tags(filter_input(INPUT_POST, "editBoardDest")??""),
  881. 'location' => strip_tags(filter_input(INPUT_POST, "txtLocation")??"")
  882. ];
  883. for($i=1;$i<=10;$i++) {
  884. $editBoardParams[$i] = [
  885. 'type' => strip_tags(filter_input(INPUT_POST, "txtType" . $i)??""),
  886. 'desc' => strip_tags(filter_input(INPUT_POST, "txtDesc" . $i)??"")
  887. ];
  888. }
  889. }
  890. if ($password !== PHP_STR) {
  891. $hash = hash("sha256", $password . APP_SALT, false);
  892. if ($hash !== APP_HASH) {
  893. $password=PHP_STR;
  894. }
  895. }
  896. $curPath = APP_INV_PATH;
  897. if ($pwd!==PHP_STR) {
  898. if (left($pwd, strlen(APP_INV_PATH)) === APP_INV_PATH) {
  899. $curPath = $pwd;
  900. chdir($curPath);
  901. }
  902. }
  903. $ipos = strripos($curPath, PHP_SLASH);
  904. $curDir = substr($curPath, $ipos);
  905. $prompt = str_replace("$1", $curDir, APP_PROMPT);
  906. if ($password !== PHP_STR) {
  907. loadRecallHistory();
  908. $cmdHistory = file(dirname(__DIR__) . PHP_SLASH . "logs" . PHP_SLASH . ".INV_history");
  909. parseCommand($command);
  910. //echo("cmd=" . $cmd . "<br>");
  911. //echo("opt=" . $opt . "<br>");
  912. //echo("param1=" . $param1 . "<br>");
  913. //echo("param2=" . $param2 . "<br>");
  914. upload();
  915. saveEditBoard();
  916. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  917. if ($command === "cd ..") {
  918. $ipos = strripos($curPath, PHP_SLASH);
  919. $nextPath = substr($curPath, 0, $ipos);
  920. if (strlen(APP_INV_PATH) > strlen($nextPath)) {
  921. updateHistoryWithErr("out of root boundary");
  922. } else {
  923. myExecCDBackwCommand();
  924. }
  925. } else if ($command === "help") {
  926. myExecHelpCommand();
  927. } else if ($command === "ls") {
  928. myExecLSCommand();
  929. } else if ($command === "pwd") {
  930. myExecPWDCommand();
  931. } else {
  932. myExecCommand();
  933. }
  934. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  935. if ($cmd === "cd") {
  936. if (cdparamValidation()) {
  937. myExecCDFolderCommand();
  938. }
  939. } else if ($cmd === "cp") {
  940. if (cpparamValidation()) {
  941. myExecCPCommand();
  942. }
  943. } else if ($cmd === "mv") {
  944. if (mvparamValidation()) {
  945. myExecCommand();
  946. }
  947. } else if ($cmd === "show") {
  948. if (showparamValidation()) {
  949. myExecShowCommand();
  950. }
  951. } else if ($cmd === "edit") {
  952. if (editparamValidation()) {
  953. myExecEditCommand();
  954. }
  955. }
  956. } else {
  957. // if I'm not saving data..
  958. if (empty($editBoardParams) || $editBoardParams[0]['location']===PHP_STR) {
  959. if (empty($_FILES['files']['tmp_name'][0])) {
  960. updateHistoryWithErr("invalid command");
  961. }
  962. }
  963. }
  964. } else {
  965. $cmdHistory = [];
  966. }
  967. ?>
  968. <!DOCTYPE html>
  969. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  970. <head>
  971. <meta charset="UTF-8"/>
  972. <meta name="style" content="day1"/>
  973. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  974. <!--
  975. Copyright 2021, 2024 5 Mode
  976. This file is part of Invenktory.
  977. Invenktory is free software: you can redistribute it and/or modify
  978. it under the terms of the GNU General Public License as published by
  979. the Free Software Foundation, either version 3 of the License, or
  980. (at your option) any later version.
  981. Invenktory is distributed in the hope that it will be useful,
  982. but WITHOUT ANY WARRANTY; without even the implied warranty of
  983. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  984. GNU General Public License for more details.
  985. You should have received a copy of the GNU General Public License
  986. along with Invenktory. If not, see <https://www.gnu.org/licenses/>.
  987. -->
  988. <title>Invenktory: every device its place..</title>
  989. <link rel="shortcut icon" href="./res/favicon66.ico?v=<?php echo(time()); ?>" />
  990. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  991. <meta name="author" content="5 Mode"/>
  992. <meta name="robots" content="noindex"/>
  993. <script src="./js/jquery-3.6.0.min.js" type="text/javascript"></script>
  994. <script src="./js/common.js" type="text/javascript"></script>
  995. <script src="./js/bootstrap.min.js" type="text/javascript"></script>
  996. <script src="./js/sha.js" type="text/javascript"></script>
  997. <script src="./js/home.js" type="text/javascript" defer></script>
  998. <link href="./css/bootstrap.min.css" type="text/css" rel="stylesheet">
  999. <link href="./css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  1000. <script>
  1001. $(document).ready(function() {
  1002. $(document).on("keydown",function(e){
  1003. key = e.which;
  1004. if (key===88 && e.ctrlKey && ($("#editBoard").css("display")!="none")) {
  1005. // Closing..
  1006. e.preventDefault();
  1007. $("#editBoard").hide();
  1008. $("#CommandL").show()
  1009. document.getElementById("CommandLine").focus();
  1010. } else if (key===83 && e.ctrlKey && ($("#editBoard").css("display")!="none")) {
  1011. // Saving data
  1012. if ($("#txtLocation").val()==="") {
  1013. $("#txtLocation").addClass("editemptyfield");
  1014. document.getElementById("txtLocation").focus();
  1015. return;
  1016. }
  1017. if ($("#txtType1").val()==="") {
  1018. $("#txtType1").addClass("editemptyfield");
  1019. document.getElementById("txtType1").focus();
  1020. return;
  1021. }
  1022. if ($("#txtDesc1").val()==="") {
  1023. $("#txtDesc1").addClass("editemptyfield");
  1024. document.getElementById("txtDesc1").focus();
  1025. return;
  1026. }
  1027. // 1 2 3 4 5 6 7 8 9 10
  1028. for(i=2;i<=10;i++) {
  1029. y=i-1;
  1030. if ($("#txtType"+y).val()==="") {
  1031. if ($("#txtType"+i).val()!="") {
  1032. $("#txtType"+y).addClass("editemptyfield");
  1033. document.getElementById("txtType"+y).focus();
  1034. return;
  1035. }
  1036. }
  1037. if ($("#txtDesc"+y).val()==="") {
  1038. if ($("#txtDesc"+i).val()!="") {
  1039. $("#txtDesc"+y).addClass("editemptyfield");
  1040. document.getElementById("txtDesc"+y).focus();
  1041. return;
  1042. }
  1043. }
  1044. }
  1045. e.preventDefault();
  1046. frmHC.submit();
  1047. } else {
  1048. //$("#Salt").val(key);
  1049. }
  1050. });
  1051. $("#CommandLine").on("keydown",function(e){
  1052. key = e.which;
  1053. //alert(key);
  1054. if (key===13) {
  1055. e.preventDefault();
  1056. frmHC.submit();
  1057. } else {
  1058. //e.preventDefault();
  1059. }
  1060. });
  1061. });
  1062. window.addEventListener("load", function() {
  1063. <?php if($password===PHP_STR):?>
  1064. $("#Password").addClass("emptyfield");
  1065. <?php endif; ?>
  1066. maxY = document.getElementById("Console").scrollHeight;
  1067. //alert(maxY);
  1068. if (document.getElementById("editBoard")) {
  1069. document.getElementById("txtDesc1").focus();
  1070. } else {
  1071. //maxY = document.getElementById("Consolep").scrollHeight;
  1072. document.getElementById("CommandLine").focus();
  1073. }
  1074. //document.getElementById("Console").scrollTop=maxY;
  1075. }, true);
  1076. function startApp() {
  1077. $("#HCsplash").hide();
  1078. $("#frmHC").show();
  1079. <?php if (!empty($editBoard)): ?>
  1080. $("#editBoard").show();
  1081. $("#CommandL").hide();
  1082. <?php endif; ?>
  1083. if (document.getElementById("editBoard")) {
  1084. document.getElementById("txtDesc1").focus();
  1085. }
  1086. }
  1087. <?php if($hideHCSplash!=="1"): ?>
  1088. window.addEventListener("load", function() {
  1089. $("#HCsplash").show();
  1090. setTimeout("startApp()", 5000);
  1091. }, true);
  1092. <?php else: ?>
  1093. window.addEventListener("load", function() {
  1094. startApp();
  1095. });
  1096. <?php endif; ?>
  1097. </script>
  1098. </head>
  1099. <body>
  1100. <div id="HCsplash" style="padding-top: 200px; text-align:center; display:none;">
  1101. <img src="res/INVsplash.gif" style="width:310px;">
  1102. </div>
  1103. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data" style="display:<?php echo(($hideHCSplash==="1"?"inline":"none"));?>;">
  1104. <div class="header">
  1105. <a href="http://invenktory.com" target="_blank" style="color:white; text-decoration: none;"><img src="res/INVlogo.png" style="width:48px;">&nbsp;Invenktory</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/par7133/Invenktory" style="color:#ffffff"><span style="color:#119fe2">on</span> github</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:info@invenktory.com" style="color:#ffffff"><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:white;height:27px;text-decoration:none;">&nbsp;&nbsp;get support&nbsp;&nbsp;</a>
  1106. </div>
  1107. <div style="clear:both; float:left; padding:8px; width:15%; height:100%; text-align:center;">
  1108. <div style="padding-left:12px;text-align: left;">
  1109. <!--&nbsp;Upload-->
  1110. &nbsp;<a href="#" id="upload" style="<?php echo(($password===PHP_STR?'text-decoration:none;color:gray;':'color:#ffffff;')); ?>" onclick="<?php echo(($password!==PHP_STR?'upload()':'')); ?>">Upload</a>
  1111. <input id="files" name="files[]" type="file" accept=".xml" style="visibility: hidden;">
  1112. </div>
  1113. <br><br>
  1114. <img src="res/INVgenius.png" alt="HC Genius" title="HC Genius" style="position:relative; left:+6px; width:90%; border: 1px dashed #EEEEEE;">
  1115. &nbsp;<br><br><br>
  1116. &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>
  1117. &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>
  1118. &nbsp;<a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; color:#ffffff; font-size:12px;">Hash Me!</a>
  1119. </div>
  1120. <div style="float:left; width:85%;height:100%; padding:8px; border-left: 1px solid #2c2f34;">
  1121. <?php if (APP_SPLASH): ?>
  1122. <?php if ($hideSplash !== PHP_STR): ?>
  1123. <div id="splash" style="border-radius:20px; position:relative; left:+3px; width:98%; background-color: #33aced; padding: 20px; margin-bottom:8px;">
  1124. <button type="button" class="close" aria-label="Close" onclick="closeSplash();" style="position:relative; left:-10px;">
  1125. <span aria-hidden="true">&times;</span>
  1126. </button>
  1127. Hello and welcome to Invenktory!<br><br>
  1128. Invenktory is a light and simple software on premise to track your devices.<br><br>
  1129. Invenktory is released under GPLv3 license, it is supplied AS-IS and we do not take any responsibility for its misusage.<br><br>
  1130. 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>
  1131. As you are going to run Invenktory 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>
  1132. <ol>
  1133. <li>Check the permissions of your "Inventory" folder in your web app private path; and set its path in the config file.</li>
  1134. <li>In the Inventory path create a ".INVsampledir" folder and give to this folder the write permission. This folder will be the sample folder to copy from new folders inside the inventory path.</li>
  1135. <li>Likewise, in the Inventory path must exist ".INVsamplefile.xml" and give to this file the write permission. This file will be the sample file to copy from new inventory files.</li>
  1136. <li>Configure the max devices per xml file as required (default: 10).</li>
  1137. <li>Configure the max history items and max recall history items as required (default: 50).</li>
  1138. </ol>
  1139. <br>
  1140. Invenktory understands a limited set of commands with a far limited set of parameters:<br>
  1141. cd, cd.., cp, edit, help, ls, mv, pwd, show<br><br>
  1142. In edit mode press [CTRL]+[X] to exit or [CTRL]+[S] to save.<br><br>
  1143. Hope you can enjoy it and let us know about any feedback: <a href="mailto:info@invenktory.com" style="color:#e6d236;">info@invenktory.com</a>
  1144. </div>
  1145. <?php endif; ?>
  1146. <?php endif; ?>
  1147. &nbsp;Console<br>
  1148. <div id="Console" style="height:493px; overflow-y:auto; margin-top:10px;">
  1149. <!--<div id="Console" style="height:493px; margin-top:10px;">-->
  1150. <pre id="Consolep" style="margin-left:5px;padding-left:0px;border:0px;background-color: #000000; color: #ffffff;">
  1151. <?php showHistory($cmdHistory); ?>
  1152. <?php showEditBoard(); ?>
  1153. <div id="CommandL" style="position:relative;top:3px;"><label id="Prompt" for="CommandLine"><?php echo($prompt); ?></label>&nbsp;<input id="CommandLine" name="CommandLine" list="CommandList" type="text" autocomplete="off" style="width:80%; height:22px; background-color: black; color:white; border:0px; border-bottom: 1px dashed #EEEEEE;"></div>
  1154. </pre>
  1155. </div>
  1156. <datalist id="CommandList">
  1157. <?php foreach($cmdRecallHistory as &$val): ?>
  1158. <?php $val = left($val, strlen($val)-1); ?>
  1159. <?php echo("<option value='$val'>\n"); ?>
  1160. <?php endforeach; ?>
  1161. </datalist>
  1162. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1163. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1164. </div>
  1165. <div class="footer">
  1166. <div id="footerCont">&nbsp;</div>
  1167. <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 and <a href="http://demo.5mode.com">WYSIWYG</a> system. Some rights reserved.</span></div>
  1168. </div>
  1169. <input type="hidden" name="pwd" value="<?php echo($curPath); ?>" style="color:black">
  1170. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  1171. <input type="hidden" name="hideHCSplash" value="1">
  1172. </form>
  1173. </body>
  1174. </html>