home.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  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 showparamValidation() {
  628. global $curPath;
  629. global $opt;
  630. global $param1;
  631. global $param2;
  632. global $param3;
  633. //opt!=""
  634. if ($opt!==PHP_STR) {
  635. updateHistoryWithErr("invalid options");
  636. return false;
  637. }
  638. //param1!="" and isword
  639. if (($param1===PHP_STR) || !is_word($param1)) {
  640. updateHistoryWithErr("invalid inventory file");
  641. return false;
  642. }
  643. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  644. if ($param2!=PHP_STR) {
  645. updateHistoryWithErr("invalid parameters");
  646. return false;
  647. }
  648. //param3==""
  649. if ($param3!=PHP_STR) {
  650. updateHistoryWithErr("invalid parameters");
  651. return false;
  652. }
  653. //param1 exist
  654. $path = $curPath . PHP_SLASH . $param1;
  655. if (!file_exists($path)) {
  656. updateHistoryWithErr("file must exists");
  657. return false;
  658. }
  659. //param1 is_file
  660. if (!is_file($path)) {
  661. updateHistoryWithErr("invalid inventory file");
  662. return false;
  663. }
  664. //param1 file extension == xml
  665. $fileExt = pathinfo($param1, PATHINFO_EXTENSION);
  666. if ($fileExt != "xml") {
  667. updateHistoryWithErr("invalid inventory file");
  668. return false;
  669. }
  670. return true;
  671. }
  672. function editparamValidation() {
  673. global $curPath;
  674. global $opt;
  675. global $param1;
  676. global $param2;
  677. global $param3;
  678. //opt!=""
  679. if ($opt!==PHP_STR) {
  680. updateHistoryWithErr("invalid options");
  681. return false;
  682. }
  683. //param1!="" and isword
  684. if (($param1===PHP_STR) || !is_word($param1)) {
  685. updateHistoryWithErr("invalid inventory file");
  686. return false;
  687. }
  688. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  689. if ($param2!=PHP_STR) {
  690. updateHistoryWithErr("invalid parameters");
  691. return false;
  692. }
  693. //param3==""
  694. if ($param3!=PHP_STR) {
  695. updateHistoryWithErr("invalid parameters");
  696. return false;
  697. }
  698. //param1 exist
  699. $path = $curPath . PHP_SLASH . $param1;
  700. if (!file_exists($path)) {
  701. updateHistoryWithErr("file must exists");
  702. return false;
  703. }
  704. //param1 is_file
  705. if (!is_file($path)) {
  706. updateHistoryWithErr("invalid inventory file");
  707. return false;
  708. }
  709. //param1 file extension == xml
  710. $fileExt = pathinfo($param1, PATHINFO_EXTENSION);
  711. if ($fileExt != "xml") {
  712. updateHistoryWithErr("invalid inventory file");
  713. return false;
  714. }
  715. return true;
  716. }
  717. function upload() {
  718. global $curPath;
  719. global $prompt;
  720. //if (!empty($_FILES['files'])) {
  721. if (!empty($_FILES['files']['tmp_name'][0])) {
  722. // Updating history..
  723. $output = [];
  724. $output[] = $prompt . " " . "File upload" . "\n";
  725. updateHistory($output, HISTORY_MAX_ITEMS);
  726. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  727. //no file uploaded
  728. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  729. updateHistoryWithErr("No file uploaded.", false);
  730. return;
  731. }
  732. foreach($uploads as &$upload) {
  733. switch ($upload['error']) {
  734. case PHP_UPLOAD_ERR_OK:
  735. break;
  736. case PHP_UPLOAD_ERR_NO_FILE:
  737. updateHistoryWithErr("One or more uploaded files are missing.", false);
  738. return;
  739. case PHP_UPLOAD_ERR_INI_SIZE:
  740. updateHistoryWithErr("File exceeded INI size limit.", false);
  741. return;
  742. case PHP_UPLOAD_ERR_FORM_SIZE:
  743. updateHistoryWithErr("File exceeded form size limit.", false);
  744. return;
  745. case PHP_UPLOAD_ERR_PARTIAL:
  746. updateHistoryWithErr("File only partially uploaded.", false);
  747. return;
  748. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  749. updateHistoryWithErr("TMP dir doesn't exist.", false);
  750. return;
  751. case PHP_UPLOAD_ERR_CANT_WRITE:
  752. updateHistoryWithErr("Failed to write to the disk.", false);
  753. return;
  754. case PHP_UPLOAD_ERR_EXTENSION:
  755. updateHistoryWithErr("A PHP extension stopped the file upload.", false);
  756. return;
  757. default:
  758. updateHistoryWithErr("Unexpected error happened.", false);
  759. return;
  760. }
  761. if (!is_uploaded_file($upload['tmp_name'])) {
  762. updateHistoryWithErr("One or more file have not been uploaded.", false);
  763. return;
  764. }
  765. // name
  766. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  767. if ($name == PHP_STR) {
  768. updateHistoryWithErr("Invalid file name: " . $name, false);
  769. return;
  770. }
  771. $upload['name'] = $name;
  772. // fileType
  773. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  774. $upload['type'] = $fileType;
  775. // tmp_name
  776. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  777. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  778. updateHistoryWithErr("Invalid file temp path: " . $tmp_name, false);
  779. return;
  780. }
  781. $upload['tmp_name'] = $tmp_name;
  782. //size
  783. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  784. if ($size == "") {
  785. updateHistoryWithErr("Invalid file size.", false);
  786. return;
  787. }
  788. $upload["size"] = $size;
  789. $tmpFullPath = $upload["tmp_name"];
  790. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  791. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  792. $FileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  793. if ($originalFileExt!==PHP_STR) {
  794. $destFileName = $originalFilename . "." . $originalFileExt;
  795. } else {
  796. $destFileName = $originalFilename;
  797. }
  798. $destFullPath = $curPath . PHP_SLASH . $destFileName;
  799. if (file_exists($destFullPath)) {
  800. updateHistoryWithErr("destination already exists", false);
  801. return;
  802. }
  803. copy($tmpFullPath, $destFullPath);
  804. // Updating history..
  805. $output = [];
  806. $output[] = $destFileName . " " . "uploaded" . "\n";
  807. updateHistory($output, HISTORY_MAX_ITEMS);
  808. // Cleaning up..
  809. // Delete the tmp file..
  810. unlink($tmpFullPath);
  811. }
  812. }
  813. }
  814. function saveEditBoard() {
  815. global $editBoardParams;
  816. if (!empty($editBoardParams) && $editBoardParams[0]['location']!=PHP_STR) {
  817. $xml = PHP_STR;
  818. $xml .= "<?xml version='1.0' encoding='UTF-8'?>";
  819. $xml .= "<INVENTORY location='" . HTMLencode($editBoardParams[0]['location']) . "'>";
  820. for($i=1;$i<=10;$i++) {
  821. if ($editBoardParams[$i]['type']!=PHP_STR) {
  822. $xml .= "<ITEM type='" . HTMLencode($editBoardParams[$i]['type']) . "'>";
  823. $xml .= "<DESCRIPTION>";
  824. $xml .= "<![CDATA[";
  825. $xml .= HTMLencode($editBoardParams[$i]['desc']);
  826. $xml .= "]]>";
  827. $xml .= "</DESCRIPTION>";
  828. $xml .= "<INDEX>" . $i . "</INDEX>";
  829. $xml .= "</ITEM>";
  830. } else {
  831. break;
  832. }
  833. }
  834. $xml .= "</INVENTORY>";
  835. file_put_contents($editBoardParams[0]['file'], $xml);
  836. }
  837. }
  838. $password = filter_input(INPUT_POST, "Password");
  839. $command = filter_input(INPUT_POST, "CommandLine");
  840. $pwd = filter_input(INPUT_POST, "pwd");
  841. $hideSplash = filter_input(INPUT_POST, "hideSplash");
  842. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash");
  843. //EditBoard
  844. if (filter_input(INPUT_POST, "txtLocation")!==PHP_STR) {
  845. $editBoardParams[0] = [
  846. 'file' => filter_input(INPUT_POST, "editBoardDest"),
  847. 'location' => filter_input(INPUT_POST, "txtLocation")
  848. ];
  849. for($i=1;$i<=10;$i++) {
  850. $editBoardParams[$i] = [
  851. 'type' => filter_input(INPUT_POST, "txtType" . $i),
  852. 'desc' => filter_input(INPUT_POST, "txtDesc" . $i)
  853. ];
  854. }
  855. }
  856. if ($password !== PHP_STR) {
  857. $hash = hash("sha256", $password . APP_SALT, false);
  858. if ($hash !== APP_HASH) {
  859. $password=PHP_STR;
  860. }
  861. }
  862. $curPath = APP_INV_PATH;
  863. if ($pwd!==PHP_STR) {
  864. if (left($pwd, strlen(APP_INV_PATH)) === APP_INV_PATH) {
  865. $curPath = $pwd;
  866. chdir($curPath);
  867. }
  868. }
  869. $ipos = strripos($curPath, PHP_SLASH);
  870. $curDir = substr($curPath, $ipos);
  871. $prompt = str_replace("$1", $curDir, APP_PROMPT);
  872. if ($password !== PHP_STR) {
  873. loadRecallHistory();
  874. $cmdHistory = file(dirname(__DIR__) . PHP_SLASH . "logs" . PHP_SLASH . ".INV_history");
  875. parseCommand($command);
  876. //echo("cmd=" . $cmd . "<br>");
  877. //echo("opt=" . $opt . "<br>");
  878. //echo("param1=" . $param1 . "<br>");
  879. //echo("param2=" . $param2 . "<br>");
  880. upload();
  881. saveEditBoard();
  882. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  883. if ($command === "cd ..") {
  884. $ipos = strripos($curPath, PHP_SLASH);
  885. $nextPath = substr($curPath, 0, $ipos);
  886. if (strlen(APP_INV_PATH) > strlen($nextPath)) {
  887. updateHistoryWithErr("out of root boundary");
  888. } else {
  889. myExecCDBackwCommand();
  890. }
  891. } else if ($command === "help") {
  892. myExecHelpCommand();
  893. } else if ($command === "ls") {
  894. myExecLSCommand();
  895. } else if ($command === "pwd") {
  896. myExecPWDCommand();
  897. } else {
  898. myExecCommand();
  899. }
  900. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  901. if ($cmd === "cd") {
  902. if (cdparamValidation()) {
  903. myExecCDFolderCommand();
  904. }
  905. } else if ($cmd === "cp") {
  906. if (cpparamValidation()) {
  907. myExecCPCommand();
  908. }
  909. } else if ($cmd === "mv") {
  910. if (mvparamValidation()) {
  911. myExecCommand();
  912. }
  913. } else if ($cmd === "show") {
  914. if (showparamValidation()) {
  915. myExecShowCommand();
  916. }
  917. } else if ($cmd === "edit") {
  918. if (editparamValidation()) {
  919. myExecEditCommand();
  920. }
  921. }
  922. } else {
  923. // if I'm not saving data..
  924. if (empty($editBoardParams) || $editBoardParams[0]['location']===PHP_STR) {
  925. if (empty($_FILES['files']['tmp_name'][0])) {
  926. updateHistoryWithErr("invalid command");
  927. }
  928. }
  929. }
  930. } else {
  931. $cmdHistory = [];
  932. }
  933. ?>
  934. <!DOCTYPE html>
  935. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  936. <head>
  937. <meta charset="UTF-8"/>
  938. <meta name="style" content="day1"/>
  939. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  940. <!--
  941. Copyright 2021, 2024 5 Mode
  942. This file is part of Invenktory.
  943. Invenktory is free software: you can redistribute it and/or modify
  944. it under the terms of the GNU General Public License as published by
  945. the Free Software Foundation, either version 3 of the License, or
  946. (at your option) any later version.
  947. Invenktory is distributed in the hope that it will be useful,
  948. but WITHOUT ANY WARRANTY; without even the implied warranty of
  949. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  950. GNU General Public License for more details.
  951. You should have received a copy of the GNU General Public License
  952. along with Invenktory. If not, see <https://www.gnu.org/licenses/>.
  953. -->
  954. <title>Invenktory: every device its place..</title>
  955. <link rel="shortcut icon" href="./res/favicon66.ico?v=<?php echo(time()); ?>" />
  956. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  957. <meta name="author" content="5 Mode"/>
  958. <meta name="robots" content="noindex"/>
  959. <script src="./js/jquery-3.1.0.min.js" type="text/javascript"></script>
  960. <script src="./js/common.js" type="text/javascript"></script>
  961. <script src="./js/bootstrap.min.js" type="text/javascript"></script>
  962. <script src="./js/sha.js" type="text/javascript"></script>
  963. <script src="./js/home.js" type="text/javascript" defer></script>
  964. <link href="./css/bootstrap.min.css" type="text/css" rel="stylesheet">
  965. <link href="./css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  966. <script>
  967. $(document).ready(function() {
  968. $(document).on("keydown",function(e){
  969. key = e.which;
  970. if (key===88 && e.ctrlKey && ($("#editBoard").css("display")!="none")) {
  971. // Closing..
  972. e.preventDefault();
  973. $("#editBoard").hide();
  974. $("#CommandL").show()
  975. document.getElementById("CommandLine").focus();
  976. } else if (key===83 && e.ctrlKey && ($("#editBoard").css("display")!="none")) {
  977. // Saving data
  978. if ($("#txtLocation").val()==="") {
  979. $("#txtLocation").addClass("editemptyfield");
  980. document.getElementById("txtLocation").focus();
  981. return;
  982. }
  983. if ($("#txtType1").val()==="") {
  984. $("#txtType1").addClass("editemptyfield");
  985. document.getElementById("txtType1").focus();
  986. return;
  987. }
  988. if ($("#txtDesc1").val()==="") {
  989. $("#txtDesc1").addClass("editemptyfield");
  990. document.getElementById("txtDesc1").focus();
  991. return;
  992. }
  993. // 1 2 3 4 5 6 7 8 9 10
  994. for(i=2;i<=10;i++) {
  995. y=i-1;
  996. if ($("#txtType"+y).val()==="") {
  997. if ($("#txtType"+i).val()!="") {
  998. $("#txtType"+y).addClass("editemptyfield");
  999. document.getElementById("txtType"+y).focus();
  1000. return;
  1001. }
  1002. }
  1003. if ($("#txtDesc"+y).val()==="") {
  1004. if ($("#txtDesc"+i).val()!="") {
  1005. $("#txtDesc"+y).addClass("editemptyfield");
  1006. document.getElementById("txtDesc"+y).focus();
  1007. return;
  1008. }
  1009. }
  1010. }
  1011. e.preventDefault();
  1012. frmHC.submit();
  1013. } else {
  1014. //$("#Salt").val(key);
  1015. }
  1016. });
  1017. $("#CommandLine").on("keydown",function(e){
  1018. key = e.which;
  1019. //alert(key);
  1020. if (key===13) {
  1021. e.preventDefault();
  1022. frmHC.submit();
  1023. } else {
  1024. //e.preventDefault();
  1025. }
  1026. });
  1027. });
  1028. window.addEventListener("load", function() {
  1029. <?php if($password===PHP_STR):?>
  1030. $("#Password").addClass("emptyfield");
  1031. <?php endif; ?>
  1032. maxY = document.getElementById("Console").scrollHeight;
  1033. //alert(maxY);
  1034. if (document.getElementById("editBoard")) {
  1035. document.getElementById("txtDesc1").focus();
  1036. } else {
  1037. //maxY = document.getElementById("Consolep").scrollHeight;
  1038. document.getElementById("CommandLine").focus();
  1039. }
  1040. //document.getElementById("Console").scrollTop=maxY;
  1041. }, true);
  1042. function startApp() {
  1043. $("#HCsplash").hide();
  1044. $("#frmHC").show();
  1045. <?php if (!empty($editBoard)): ?>
  1046. $("#editBoard").show();
  1047. $("#CommandL").hide();
  1048. <?php endif; ?>
  1049. if (document.getElementById("editBoard")) {
  1050. document.getElementById("txtDesc1").focus();
  1051. }
  1052. }
  1053. <?php if($hideHCSplash!=="1"): ?>
  1054. window.addEventListener("load", function() {
  1055. $("#HCsplash").show();
  1056. setTimeout("startApp()", 5000);
  1057. }, true);
  1058. <?php else: ?>
  1059. window.addEventListener("load", function() {
  1060. startApp();
  1061. });
  1062. <?php endif; ?>
  1063. </script>
  1064. </head>
  1065. <body>
  1066. <div id="HCsplash" style="padding-top: 200px; text-align:center;" style="display:none;">
  1067. <img src="res/INVsplash.gif" style="width:310px;">
  1068. </div>
  1069. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data" style="display:<?php echo(($hideHCSplash==="1"?"inline":"none"));?>;">
  1070. <div class="header">
  1071. <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>
  1072. </div>
  1073. <div style="clear:both; float:left; padding:8px; width:15%; height:100%; text-align:center;">
  1074. <div style="padding-left:12px;text-align: left;">
  1075. <!--&nbsp;Upload-->
  1076. &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>
  1077. <input id="files" name="files[]" type="file" accept=".xml" style="visibility: hidden;">
  1078. </div>
  1079. <br><br>
  1080. <img src="res/INVgenius.png" alt="HC Genius" title="HC Genius" style="position:relative; left:+6px; width:90%; border: 1px dashed #EEEEEE;">
  1081. &nbsp;<br><br><br>
  1082. &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>
  1083. &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>
  1084. &nbsp;<a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; color:#ffffff; font-size:12px;">Hash Me!</a>
  1085. </div>
  1086. <div style="float:left; width:85%;height:100%; padding:8px; border-left: 1px solid #2c2f34;">
  1087. <?php if (APP_SPLASH): ?>
  1088. <?php if ($hideSplash !== PHP_STR): ?>
  1089. <div id="splash" style="border-radius:20px; position:relative; left:+3px; width:98%; background-color: #33aced; padding: 20px; margin-bottom:8px;">
  1090. <button type="button" class="close" aria-label="Close" onclick="closeSplash();" style="position:relative; left:-10px;">
  1091. <span aria-hidden="true">&times;</span>
  1092. </button>
  1093. Hello and welcome to Invenktory!<br><br>
  1094. Invenktory is a light and simple software on premise to track your devices.<br><br>
  1095. Invenktory is released under GPLv3 license, it is supplied AS-IS and we do not take any responsibility for its misusage.<br><br>
  1096. 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>
  1097. 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>
  1098. <ol>
  1099. <li>Check the permissions of your "Inventory" folder in your web app private path; and set its path in the config file.</li>
  1100. <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>
  1101. <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>
  1102. <li>Configure the max devices per xml file as required (default: 10).</li>
  1103. <li>Configure the max history items and max recall history items as required (default: 50).</li>
  1104. </ol>
  1105. <br>
  1106. Invenktory understands a limited set of commands with a far limited set of parameters:<br>
  1107. cd, cd.., cp, edit, help, ls, mv, pwd, show<br><br>
  1108. In edit mode press [CTRL]+[X] to exit or [CTRL]+[S] to save.<br><br>
  1109. 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>
  1110. </div>
  1111. <?php endif; ?>
  1112. <?php endif; ?>
  1113. &nbsp;Console<br>
  1114. <div id="Console" style="height:493px; overflow-y:auto; margin-top:10px;">
  1115. <!--<div id="Console" style="height:493px; margin-top:10px;">-->
  1116. <pre id="Consolep" style="margin-left:5px;padding-left:0px;border:0px;background-color: #000000; color: #ffffff;">
  1117. <?php showHistory($cmdHistory); ?>
  1118. <?php showEditBoard(); ?>
  1119. <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>
  1120. </pre>
  1121. </div>
  1122. <datalist id="CommandList">
  1123. <?php foreach($cmdRecallHistory as &$val): ?>
  1124. <?php $val = left($val, strlen($val)-1); ?>
  1125. <?php echo("<option value='$val'>\n"); ?>
  1126. <?php endforeach; ?>
  1127. </datalist>
  1128. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1129. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1130. </div>
  1131. <div class="footer">
  1132. <div id="footerCont">&nbsp;</div>
  1133. <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://wysiwyg.systems">WYSIWYG</a> system. Some rights reserved.</span></div>
  1134. </div>
  1135. <input type="hidden" name="pwd" value="<?php echo($curPath); ?>" style="color:black">
  1136. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  1137. <input type="hidden" name="hideHCSplash" value="1">
  1138. </form>
  1139. </body>
  1140. </html>