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 = ltrim($text,PHP_SPACE);
  333. $text = rtrim($text,PHP_SPACE);
  334. $text = ltrim($text,"\n");
  335. $text = rtrim($text,"\n");
  336. $output[] = $child->attributes()['type'] . " #" . $child->INDEX . ":\n" . $text . "\n";
  337. }
  338. $output[] = "\n";
  339. // Update History
  340. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  341. updateHistory($output, HISTORY_MAX_ITEMS);
  342. }
  343. function parseCommand() {
  344. global $command;
  345. global $cmd;
  346. global $opt;
  347. global $param1;
  348. global $param2;
  349. global $param3;
  350. $str = trim($command);
  351. $ipos = stripos($str, PHP_SPACE);
  352. if ($ipos > 0) {
  353. $cmd = left($str, $ipos);
  354. $str = substr($str, $ipos+1);
  355. } else {
  356. $cmd = $str;
  357. return;
  358. }
  359. if (left($str, 1) === "-") {
  360. $ipos = stripos($str, PHP_SPACE);
  361. if ($ipos > 0) {
  362. $opt = left($str, $ipos);
  363. $str = substr($str, $ipos+1);
  364. } else {
  365. $opt = $str;
  366. return;
  367. }
  368. }
  369. $ipos = stripos($str, PHP_SPACE);
  370. if ($ipos > 0) {
  371. $param1 = left($str, $ipos);
  372. $str = substr($str, $ipos+1);
  373. } else {
  374. $param1 = $str;
  375. return;
  376. }
  377. $ipos = stripos($str, PHP_SPACE);
  378. if ($ipos > 0) {
  379. $param2 = left($str, $ipos);
  380. $str = substr($str, $ipos+1);
  381. } else {
  382. $param2 = $str;
  383. return;
  384. }
  385. $ipos = stripos($str, PHP_SPACE);
  386. if ($ipos > 0) {
  387. $param3 = left($str, $ipos);
  388. $str = substr($str, $ipos+1);
  389. } else {
  390. $param3 = $str;
  391. return;
  392. }
  393. }
  394. function cdparamValidation() {
  395. global $curPath;
  396. global $opt;
  397. global $param1;
  398. global $param2;
  399. global $param3;
  400. //opt==""
  401. if ($opt!=PHP_STR) {
  402. updateHistoryWithErr("invalid options");
  403. return false;
  404. }
  405. //param1==""
  406. if ($param1===PHP_STR) {
  407. updateHistoryWithErr("invalid parameters");
  408. return false;
  409. }
  410. //param1!="" and !isword
  411. if (($param1!==PHP_STR) && !is_word($param1)) {
  412. updateHistoryWithErr("invalid dir");
  413. return false;
  414. }
  415. //param2==""
  416. if ($param2!==PHP_STR) {
  417. updateHistoryWithErr("invalid parameters");
  418. return false;
  419. }
  420. //param3==""
  421. if ($param3!=PHP_STR) {
  422. updateHistoryWithErr("invalid parameters");
  423. return false;
  424. }
  425. //param1 exist and is_dir
  426. $path = $curPath . PHP_SLASH . $param1;
  427. if (!file_exists($path) || !is_dir($path)) {
  428. updateHistoryWithErr("dir doesn't exist");
  429. return false;
  430. }
  431. return true;
  432. }
  433. function is_subfolderdest(string $path): bool
  434. {
  435. global $curPath;
  436. $ret=false;
  437. if ($path === "../") {
  438. return $ret;
  439. }
  440. if ($path!=PHP_STR) {
  441. $folderName = left($path, strlen($path)-1);
  442. if (!is_word($folderName)) {
  443. return $ret;
  444. }
  445. if (is_dir($curPath . PHP_SLASH . $folderName) && (right($path,1)==="/")) {
  446. $ret=true;
  447. }
  448. }
  449. return $ret;
  450. }
  451. function cpparamValidation() {
  452. global $curPath;
  453. global $opt;
  454. global $param1;
  455. global $param2;
  456. global $param3;
  457. //ori opt!="" and opt!="-R" and opt!="-Rp"
  458. //ori if (($opt!==PHP_STR) && ($opt!=="-R") && ($opt!=="-Rp") && ($opt!=="-p")) {
  459. if ($opt!==PHP_STR) {
  460. updateHistoryWithErr("invalid options");
  461. return false;
  462. }
  463. //param1!="" and isword
  464. if (($param1===PHP_STR) || !is_word($param1)) {
  465. updateHistoryWithErr("invalid source path");
  466. return false;
  467. }
  468. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  469. if (($param2===PHP_STR) || (!is_word($param2) && ($param2!="../") && !is_subfolderdest($param2))) {
  470. updateHistoryWithErr("invalid destination path");
  471. return false;
  472. }
  473. //param3==""
  474. if ($param3!=PHP_STR) {
  475. updateHistoryWithErr("invalid parameters");
  476. return false;
  477. }
  478. //param1 != param2
  479. if ($param1 === $param2) {
  480. updateHistoryWithErr("source same as destination");
  481. return false;
  482. }
  483. //param1 exist
  484. $path = $curPath . PHP_SLASH . $param1;
  485. if (!file_exists($path)) {
  486. updateHistoryWithErr("source must exists");
  487. return false;
  488. }
  489. //isword(param2) && doesn't exist
  490. if (is_word($param2)) {
  491. $path = $curPath . PHP_SLASH . $param2;
  492. if (file_exists($path)) {
  493. updateHistoryWithErr("destination already exists");
  494. return false;
  495. }
  496. }
  497. // param2=="../" && is_root
  498. // param2=="../" && dest exists
  499. if ($param2==="../") {
  500. if ($curPath === APP_INV_PATH) {
  501. updateHistoryWithErr("out of root boundary");
  502. return false;
  503. }
  504. $path = dirname($curPath) . PHP_SLASH . $param1;
  505. if (file_exists($path)) {
  506. updateHistoryWithErr("destination already exists");
  507. return false;
  508. }
  509. }
  510. return true;
  511. }
  512. function mvparamValidation() {
  513. global $curPath;
  514. global $opt;
  515. global $param1;
  516. global $param2;
  517. global $param3;
  518. //opt!=""
  519. if ($opt!=PHP_STR) {
  520. updateHistoryWithErr("invalid options");
  521. return false;
  522. }
  523. //param1!="" and isword
  524. if (($param1===PHP_STR) || !is_word($param1)) {
  525. updateHistoryWithErr("invalid source path");
  526. return false;
  527. }
  528. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  529. if (($param2===PHP_STR) || (!is_word($param2) && ($param2!="../") && !is_subfolderdest($param2))) {
  530. updateHistoryWithErr("invalid destination path");
  531. return false;
  532. }
  533. //param3!=""
  534. if ($param3!=PHP_STR) {
  535. updateHistoryWithErr("invalid parameters");
  536. return false;
  537. }
  538. //param1 != param2
  539. if ($param1 === $param2) {
  540. updateHistoryWithErr("source same as destination");
  541. return false;
  542. }
  543. //param1 exist
  544. $path = $curPath . PHP_SLASH . $param1;
  545. if (!file_exists($path)) {
  546. updateHistoryWithErr("source must exists");
  547. return false;
  548. }
  549. //isword(param2) && doesn't exist
  550. if (is_word($param2)) {
  551. $path = $curPath . PHP_SLASH . $param2;
  552. if (file_exists($path)) {
  553. updateHistoryWithErr("destination already exists");
  554. return false;
  555. }
  556. }
  557. // param2=="../" && is_root
  558. // param2=="../" && dest exists
  559. if ($param2==="../") {
  560. if ($curPath === APP_INV_PATH) {
  561. updateHistoryWithErr("out of root boundary");
  562. return false;
  563. }
  564. $path = dirname($curPath) . PHP_SLASH . $param1;
  565. if (file_exists($path)) {
  566. updateHistoryWithErr("destination already exists");
  567. return false;
  568. }
  569. }
  570. return true;
  571. }
  572. function myExecEditCommand() {
  573. global $prompt;
  574. global $command;
  575. global $param1;
  576. global $curPath;
  577. // Exec command..
  578. $output = [];
  579. $output[] = $prompt . " " . $command . "\n";
  580. //exec($command, $output);
  581. $path = $curPath . DIRECTORY_SEPARATOR . $param1;
  582. loadEditBoard($path);
  583. // Update History
  584. updateRecallHistory($command, RECALL_HISTORY_MAX_ITEMS);
  585. updateHistory($output, HISTORY_MAX_ITEMS);
  586. }
  587. function loadEditBoard($file) {
  588. global $editBoard;
  589. $xml = simplexml_load_file($file);
  590. $editBoard[] = "\n";
  591. $editBoard[] = "<div id='editBoard' style='display:none'>" . "\n";
  592. $location = $xml->attributes()['location'];
  593. $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";
  594. $i=0;
  595. foreach ($xml->children() as $child) {
  596. $i++;
  597. $deviceType = $child->attributes()['type'];
  598. $description = ltrim($child->DESCRIPTION, "\n");
  599. $index = $child->INDEX;
  600. $editBoard[] = "<br>\n";
  601. $editBoard[] = "<label id='labDevice" . $i . "'>Device #" . $i . "&nbsp;</label>" . "\n";
  602. $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";
  603. $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;'>";
  604. $editBoard[] = $description;
  605. $editBoard[] = "</textarea>" . "\n";
  606. }
  607. $i++;
  608. for ($y=$i;$y<=10;$y++) {
  609. $editBoard[] = "<br>\n";
  610. $editBoard[] = "<label id='labDevice" . $y . "'>Device #" . $y . "&nbsp;</label>" . "\n";
  611. $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";
  612. $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;'>";
  613. $editBoard[] = "</textarea>\n";
  614. }
  615. $editBoard[] = "<input type='hidden' name='editBoardDest' value='" . $file . "'>\n";
  616. $editBoard[] = "<br>\n";
  617. $editBoard[] = "</div>\n";
  618. }
  619. function showEditBoard() {
  620. global $editBoard;
  621. $i = 1;
  622. foreach($editBoard as $val) {
  623. //echo(str_replace("\n", "<br>", $val));
  624. echo($val);
  625. $i++;
  626. }
  627. }
  628. function showparamValidation() {
  629. global $curPath;
  630. global $opt;
  631. global $param1;
  632. global $param2;
  633. global $param3;
  634. //opt!=""
  635. if ($opt!==PHP_STR) {
  636. updateHistoryWithErr("invalid options");
  637. return false;
  638. }
  639. //param1!="" and isword
  640. if (($param1===PHP_STR) || !is_word($param1)) {
  641. updateHistoryWithErr("invalid inventory file");
  642. return false;
  643. }
  644. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  645. if ($param2!=PHP_STR) {
  646. updateHistoryWithErr("invalid parameters");
  647. return false;
  648. }
  649. //param3==""
  650. if ($param3!=PHP_STR) {
  651. updateHistoryWithErr("invalid parameters");
  652. return false;
  653. }
  654. //param1 exist
  655. $path = $curPath . PHP_SLASH . $param1;
  656. if (!file_exists($path)) {
  657. updateHistoryWithErr("file must exists");
  658. return false;
  659. }
  660. //param1 is_file
  661. if (!is_file($path)) {
  662. updateHistoryWithErr("invalid inventory file");
  663. return false;
  664. }
  665. //param1 file extension == xml
  666. $fileExt = pathinfo($param1, PATHINFO_EXTENSION);
  667. if ($fileExt != "xml") {
  668. updateHistoryWithErr("invalid inventory file");
  669. return false;
  670. }
  671. return true;
  672. }
  673. function editparamValidation() {
  674. global $curPath;
  675. global $opt;
  676. global $param1;
  677. global $param2;
  678. global $param3;
  679. //opt!=""
  680. if ($opt!==PHP_STR) {
  681. updateHistoryWithErr("invalid options");
  682. return false;
  683. }
  684. //param1!="" and isword
  685. if (($param1===PHP_STR) || !is_word($param1)) {
  686. updateHistoryWithErr("invalid inventory file");
  687. return false;
  688. }
  689. //param2!="" and (isword or param2=="../" or is_subfolderdest)
  690. if ($param2!=PHP_STR) {
  691. updateHistoryWithErr("invalid parameters");
  692. return false;
  693. }
  694. //param3==""
  695. if ($param3!=PHP_STR) {
  696. updateHistoryWithErr("invalid parameters");
  697. return false;
  698. }
  699. //param1 exist
  700. $path = $curPath . PHP_SLASH . $param1;
  701. if (!file_exists($path)) {
  702. updateHistoryWithErr("file must exists");
  703. return false;
  704. }
  705. //param1 is_file
  706. if (!is_file($path)) {
  707. updateHistoryWithErr("invalid inventory file");
  708. return false;
  709. }
  710. //param1 file extension == xml
  711. $fileExt = pathinfo($param1, PATHINFO_EXTENSION);
  712. if ($fileExt != "xml") {
  713. updateHistoryWithErr("invalid inventory file");
  714. return false;
  715. }
  716. return true;
  717. }
  718. function upload() {
  719. global $curPath;
  720. global $prompt;
  721. //if (!empty($_FILES['files'])) {
  722. if (!empty($_FILES['files']['tmp_name'][0])) {
  723. // Updating history..
  724. $output = [];
  725. $output[] = $prompt . " " . "File upload" . "\n";
  726. updateHistory($output, HISTORY_MAX_ITEMS);
  727. $uploads = (array)fixMultipleFileUpload($_FILES['files']);
  728. //no file uploaded
  729. if ($uploads[0]['error'] === PHP_UPLOAD_ERR_NO_FILE) {
  730. updateHistoryWithErr("No file uploaded.", false);
  731. return;
  732. }
  733. foreach($uploads as &$upload) {
  734. switch ($upload['error']) {
  735. case PHP_UPLOAD_ERR_OK:
  736. break;
  737. case PHP_UPLOAD_ERR_NO_FILE:
  738. updateHistoryWithErr("One or more uploaded files are missing.", false);
  739. return;
  740. case PHP_UPLOAD_ERR_INI_SIZE:
  741. updateHistoryWithErr("File exceeded INI size limit.", false);
  742. return;
  743. case PHP_UPLOAD_ERR_FORM_SIZE:
  744. updateHistoryWithErr("File exceeded form size limit.", false);
  745. return;
  746. case PHP_UPLOAD_ERR_PARTIAL:
  747. updateHistoryWithErr("File only partially uploaded.", false);
  748. return;
  749. case PHP_UPLOAD_ERR_NO_TMP_DIR:
  750. updateHistoryWithErr("TMP dir doesn't exist.", false);
  751. return;
  752. case PHP_UPLOAD_ERR_CANT_WRITE:
  753. updateHistoryWithErr("Failed to write to the disk.", false);
  754. return;
  755. case PHP_UPLOAD_ERR_EXTENSION:
  756. updateHistoryWithErr("A PHP extension stopped the file upload.", false);
  757. return;
  758. default:
  759. updateHistoryWithErr("Unexpected error happened.", false);
  760. return;
  761. }
  762. if (!is_uploaded_file($upload['tmp_name'])) {
  763. updateHistoryWithErr("One or more file have not been uploaded.", false);
  764. return;
  765. }
  766. // name
  767. $name = (string)substr((string)filter_var($upload['name']), 0, 255);
  768. if ($name == PHP_STR) {
  769. updateHistoryWithErr("Invalid file name: " . $name, false);
  770. return;
  771. }
  772. $upload['name'] = $name;
  773. // fileType
  774. $fileType = substr((string)filter_var($upload['type']), 0, 30);
  775. $upload['type'] = $fileType;
  776. // tmp_name
  777. $tmp_name = substr((string)filter_var($upload['tmp_name']), 0, 300);
  778. if ($tmp_name == PHP_STR || !file_exists($tmp_name)) {
  779. updateHistoryWithErr("Invalid file temp path: " . $tmp_name, false);
  780. return;
  781. }
  782. $upload['tmp_name'] = $tmp_name;
  783. //size
  784. $size = substr((string)filter_var($upload['size'], FILTER_SANITIZE_NUMBER_INT), 0, 12);
  785. if ($size == "") {
  786. updateHistoryWithErr("Invalid file size.", false);
  787. return;
  788. }
  789. $upload["size"] = $size;
  790. $tmpFullPath = $upload["tmp_name"];
  791. $originalFilename = pathinfo($name, PATHINFO_FILENAME);
  792. $originalFileExt = pathinfo($name, PATHINFO_EXTENSION);
  793. $FileExt = strtolower(pathinfo($name, PATHINFO_EXTENSION));
  794. if ($originalFileExt!==PHP_STR) {
  795. $destFileName = $originalFilename . "." . $originalFileExt;
  796. } else {
  797. $destFileName = $originalFilename;
  798. }
  799. $destFullPath = $curPath . PHP_SLASH . $destFileName;
  800. if (file_exists($destFullPath)) {
  801. updateHistoryWithErr("destination already exists", false);
  802. return;
  803. }
  804. copy($tmpFullPath, $destFullPath);
  805. // Updating history..
  806. $output = [];
  807. $output[] = $destFileName . " " . "uploaded" . "\n";
  808. updateHistory($output, HISTORY_MAX_ITEMS);
  809. // Cleaning up..
  810. // Delete the tmp file..
  811. unlink($tmpFullPath);
  812. }
  813. }
  814. }
  815. function saveEditBoard() {
  816. global $editBoardParams;
  817. if (!empty($editBoardParams) && $editBoardParams[0]['location']!=PHP_STR) {
  818. $xml = PHP_STR;
  819. $xml .= "<?xml version='1.0' encoding='UTF-8'?>";
  820. $xml .= "<INVENTORY location='" . HTMLencode($editBoardParams[0]['location']) . "'>";
  821. for($i=1;$i<=10;$i++) {
  822. if ($editBoardParams[$i]['type']!=PHP_STR) {
  823. $xml .= "<ITEM type='" . HTMLencode($editBoardParams[$i]['type']) . "'>";
  824. $xml .= "<DESCRIPTION>";
  825. $xml .= "<![CDATA[";
  826. $xml .= HTMLencode($editBoardParams[$i]['desc']);
  827. $xml .= "]]>";
  828. $xml .= "</DESCRIPTION>";
  829. $xml .= "<INDEX>" . $i . "</INDEX>";
  830. $xml .= "</ITEM>";
  831. } else {
  832. break;
  833. }
  834. }
  835. $xml .= "</INVENTORY>";
  836. file_put_contents($editBoardParams[0]['file'], $xml);
  837. }
  838. }
  839. $password = filter_input(INPUT_POST, "Password");
  840. $command = filter_input(INPUT_POST, "CommandLine");
  841. $pwd = filter_input(INPUT_POST, "pwd");
  842. $hideSplash = filter_input(INPUT_POST, "hideSplash");
  843. $hideHCSplash = filter_input(INPUT_POST, "hideHCSplash");
  844. //EditBoard
  845. if (filter_input(INPUT_POST, "txtLocation")!==PHP_STR) {
  846. $editBoardParams[0] = [
  847. 'file' => filter_input(INPUT_POST, "editBoardDest"),
  848. 'location' => filter_input(INPUT_POST, "txtLocation")
  849. ];
  850. for($i=1;$i<=10;$i++) {
  851. $editBoardParams[$i] = [
  852. 'type' => filter_input(INPUT_POST, "txtType" . $i),
  853. 'desc' => filter_input(INPUT_POST, "txtDesc" . $i)
  854. ];
  855. }
  856. }
  857. if ($password !== PHP_STR) {
  858. $hash = hash("sha256", $password . APP_SALT, false);
  859. if ($hash !== APP_HASH) {
  860. $password=PHP_STR;
  861. }
  862. }
  863. $curPath = APP_INV_PATH;
  864. if ($pwd!==PHP_STR) {
  865. if (left($pwd, strlen(APP_INV_PATH)) === APP_INV_PATH) {
  866. $curPath = $pwd;
  867. chdir($curPath);
  868. }
  869. }
  870. $ipos = strripos($curPath, PHP_SLASH);
  871. $curDir = substr($curPath, $ipos);
  872. $prompt = str_replace("$1", $curDir, APP_PROMPT);
  873. if ($password !== PHP_STR) {
  874. loadRecallHistory();
  875. $cmdHistory = file(dirname(__DIR__) . PHP_SLASH . "logs" . PHP_SLASH . ".INV_history");
  876. parseCommand($command);
  877. //echo("cmd=" . $cmd . "<br>");
  878. //echo("opt=" . $opt . "<br>");
  879. //echo("param1=" . $param1 . "<br>");
  880. //echo("param2=" . $param2 . "<br>");
  881. upload();
  882. saveEditBoard();
  883. if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $command . "|")) {
  884. if ($command === "cd ..") {
  885. $ipos = strripos($curPath, PHP_SLASH);
  886. $nextPath = substr($curPath, 0, $ipos);
  887. if (strlen(APP_INV_PATH) > strlen($nextPath)) {
  888. updateHistoryWithErr("out of root boundary");
  889. } else {
  890. myExecCDBackwCommand();
  891. }
  892. } else if ($command === "help") {
  893. myExecHelpCommand();
  894. } else if ($command === "ls") {
  895. myExecLSCommand();
  896. } else if ($command === "pwd") {
  897. myExecPWDCommand();
  898. } else {
  899. myExecCommand();
  900. }
  901. } else if (mb_stripos(CMDLINE_VALIDCMDS, "|" . $cmd . "|")) {
  902. if ($cmd === "cd") {
  903. if (cdparamValidation()) {
  904. myExecCDFolderCommand();
  905. }
  906. } else if ($cmd === "cp") {
  907. if (cpparamValidation()) {
  908. myExecCPCommand();
  909. }
  910. } else if ($cmd === "mv") {
  911. if (mvparamValidation()) {
  912. myExecCommand();
  913. }
  914. } else if ($cmd === "show") {
  915. if (showparamValidation()) {
  916. myExecShowCommand();
  917. }
  918. } else if ($cmd === "edit") {
  919. if (editparamValidation()) {
  920. myExecEditCommand();
  921. }
  922. }
  923. } else {
  924. // if I'm not saving data..
  925. if (empty($editBoardParams) || $editBoardParams[0]['location']===PHP_STR) {
  926. if (empty($_FILES['files']['tmp_name'][0])) {
  927. updateHistoryWithErr("invalid command");
  928. }
  929. }
  930. }
  931. } else {
  932. $cmdHistory = [];
  933. }
  934. ?>
  935. <!DOCTYPE html>
  936. <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  937. <head>
  938. <meta charset="UTF-8"/>
  939. <meta name="style" content="day1"/>
  940. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  941. <!--
  942. Copyright 2021, 2024 5 Mode
  943. This file is part of Invenktory.
  944. Invenktory is free software: you can redistribute it and/or modify
  945. it under the terms of the GNU General Public License as published by
  946. the Free Software Foundation, either version 3 of the License, or
  947. (at your option) any later version.
  948. Invenktory is distributed in the hope that it will be useful,
  949. but WITHOUT ANY WARRANTY; without even the implied warranty of
  950. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  951. GNU General Public License for more details.
  952. You should have received a copy of the GNU General Public License
  953. along with Invenktory. If not, see <https://www.gnu.org/licenses/>.
  954. -->
  955. <title>Invenktory: every device its place..</title>
  956. <link rel="shortcut icon" href="./res/favicon66.ico?v=<?php echo(time()); ?>" />
  957. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  958. <meta name="author" content="5 Mode"/>
  959. <meta name="robots" content="noindex"/>
  960. <script src="./js/jquery-3.1.0.min.js" type="text/javascript"></script>
  961. <script src="./js/common.js" type="text/javascript"></script>
  962. <script src="./js/bootstrap.min.js" type="text/javascript"></script>
  963. <script src="./js/sha.js" type="text/javascript"></script>
  964. <script src="./js/home.js" type="text/javascript" defer></script>
  965. <link href="./css/bootstrap.min.css" type="text/css" rel="stylesheet">
  966. <link href="./css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  967. <script>
  968. $(document).ready(function() {
  969. $(document).on("keydown",function(e){
  970. key = e.which;
  971. if (key===88 && e.ctrlKey && ($("#editBoard").css("display")!="none")) {
  972. // Closing..
  973. e.preventDefault();
  974. $("#editBoard").hide();
  975. $("#CommandL").show()
  976. document.getElementById("CommandLine").focus();
  977. } else if (key===83 && e.ctrlKey && ($("#editBoard").css("display")!="none")) {
  978. // Saving data
  979. if ($("#txtLocation").val()==="") {
  980. $("#txtLocation").addClass("editemptyfield");
  981. document.getElementById("txtLocation").focus();
  982. return;
  983. }
  984. if ($("#txtType1").val()==="") {
  985. $("#txtType1").addClass("editemptyfield");
  986. document.getElementById("txtType1").focus();
  987. return;
  988. }
  989. if ($("#txtDesc1").val()==="") {
  990. $("#txtDesc1").addClass("editemptyfield");
  991. document.getElementById("txtDesc1").focus();
  992. return;
  993. }
  994. // 1 2 3 4 5 6 7 8 9 10
  995. for(i=2;i<=10;i++) {
  996. y=i-1;
  997. if ($("#txtType"+y).val()==="") {
  998. if ($("#txtType"+i).val()!="") {
  999. $("#txtType"+y).addClass("editemptyfield");
  1000. document.getElementById("txtType"+y).focus();
  1001. return;
  1002. }
  1003. }
  1004. if ($("#txtDesc"+y).val()==="") {
  1005. if ($("#txtDesc"+i).val()!="") {
  1006. $("#txtDesc"+y).addClass("editemptyfield");
  1007. document.getElementById("txtDesc"+y).focus();
  1008. return;
  1009. }
  1010. }
  1011. }
  1012. e.preventDefault();
  1013. frmHC.submit();
  1014. } else {
  1015. $("#Salt").val(key);
  1016. }
  1017. });
  1018. $("#CommandLine").on("keydown",function(e){
  1019. key = e.which;
  1020. //alert(key);
  1021. if (key===13) {
  1022. e.preventDefault();
  1023. frmHC.submit();
  1024. } else {
  1025. //e.preventDefault();
  1026. }
  1027. });
  1028. });
  1029. window.addEventListener("load", function() {
  1030. <?php if($password===PHP_STR):?>
  1031. $("#Password").addClass("emptyfield");
  1032. <?php endif; ?>
  1033. maxY = document.getElementById("Console").scrollHeight;
  1034. //alert(maxY);
  1035. if (document.getElementById("editBoard")) {
  1036. document.getElementById("txtDesc1").focus();
  1037. } else {
  1038. //maxY = document.getElementById("Consolep").scrollHeight;
  1039. document.getElementById("CommandLine").focus();
  1040. }
  1041. //document.getElementById("Console").scrollTop=maxY;
  1042. }, true);
  1043. function startApp() {
  1044. $("#HCsplash").hide();
  1045. $("#frmHC").show();
  1046. <?php if (!empty($editBoard)): ?>
  1047. $("#editBoard").show();
  1048. $("#CommandL").hide();
  1049. <?php endif; ?>
  1050. if (document.getElementById("editBoard")) {
  1051. document.getElementById("txtDesc1").focus();
  1052. }
  1053. }
  1054. <?php if($hideHCSplash!=="1"): ?>
  1055. window.addEventListener("load", function() {
  1056. $("#HCsplash").show();
  1057. setTimeout("startApp()", 5000);
  1058. }, true);
  1059. <?php else: ?>
  1060. window.addEventListener("load", function() {
  1061. startApp();
  1062. });
  1063. <?php endif; ?>
  1064. </script>
  1065. </head>
  1066. <body>
  1067. <div id="HCsplash" style="padding-top: 200px; text-align:center;" style="display:none;">
  1068. <img src="res/INVsplash.gif" style="width:310px;">
  1069. </div>
  1070. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data" style="display:<?php echo(($hideHCSplash==="1"?"inline":"none"));?>;">
  1071. <div class="header">
  1072. <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>
  1073. </div>
  1074. <div style="clear:both; float:left; padding:8px; width:15%; height:100%; text-align:center;">
  1075. <div style="padding-left:12px;text-align: left;">
  1076. <!--&nbsp;Upload-->
  1077. &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>
  1078. <input id="files" name="files[]" type="file" accept=".xml" style="visibility: hidden;">
  1079. </div>
  1080. <br><br>
  1081. <img src="res/INVgenius.png" alt="HC Genius" title="HC Genius" style="position:relative; left:+6px; width:90%; border: 1px dashed #EEEEEE;">
  1082. &nbsp;<br><br><br>
  1083. &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>
  1084. &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>
  1085. &nbsp;<a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; color:#ffffff; font-size:12px;">Hash Me!</a>
  1086. </div>
  1087. <div style="float:left; width:85%;height:100%; padding:8px; border-left: 1px solid #2c2f34;">
  1088. <?php if (APP_SPLASH): ?>
  1089. <?php if ($hideSplash !== PHP_STR): ?>
  1090. <div id="splash" style="border-radius:20px; position:relative; left:+3px; width:98%; background-color: #33aced; padding: 20px; margin-bottom:8px;">
  1091. <button type="button" class="close" aria-label="Close" onclick="closeSplash();" style="position:relative; left:-10px;">
  1092. <span aria-hidden="true">&times;</span>
  1093. </button>
  1094. Hello and welcome to Invenktory!<br><br>
  1095. Invenktory is a light and simple software on premise to track your devices.<br><br>
  1096. Invenktory is released under GPLv3 license, it is supplied AS-IS and we do not take any responsibility for its misusage.<br><br>
  1097. 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>
  1098. 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>
  1099. <ol>
  1100. <li>Check the permissions of your "Inventory" folder in your web app private path; and set its path in the config file.</li>
  1101. <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>
  1102. <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>
  1103. <li>Configure the max devices per xml file as required (default: 10).</li>
  1104. <li>Configure the max history items and max recall history items as required (default: 50).</li>
  1105. </ol>
  1106. <br>
  1107. Invenktory understands a limited set of commands with a far limited set of parameters:<br>
  1108. cd, cd.., cp, edit, help, ls, mv, pwd, show<br><br>
  1109. In edit mode press [CTRL]+[X] to exit or [CTRL]+[S] to save.<br><br>
  1110. 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>
  1111. </div>
  1112. <?php endif; ?>
  1113. <?php endif; ?>
  1114. &nbsp;Console<br>
  1115. <div id="Console" style="height:493px; overflow-y:auto; margin-top:10px;">
  1116. <!--<div id="Console" style="height:493px; margin-top:10px;">-->
  1117. <pre id="Consolep" style="margin-left:5px;padding-left:0px;border:0px;background-color: #000000; color: #ffffff;">
  1118. <?php showHistory($cmdHistory); ?>
  1119. <?php showEditBoard(); ?>
  1120. <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>
  1121. </pre>
  1122. </div>
  1123. <datalist id="CommandList">
  1124. <?php foreach($cmdRecallHistory as &$val): ?>
  1125. <?php $val = left($val, strlen($val)-1); ?>
  1126. <?php echo("<option value='$val'>\n"); ?>
  1127. <?php endforeach; ?>
  1128. </datalist>
  1129. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1130. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1131. </div>
  1132. <div class="footer">
  1133. <div id="footerCont">&nbsp;</div>
  1134. <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>
  1135. </div>
  1136. <input type="hidden" name="pwd" value="<?php echo($curPath); ?>" style="color:black">
  1137. <input type="hidden" name="hideSplash" value="<?php echo($hideSplash); ?>">
  1138. <input type="hidden" name="hideHCSplash" value="1">
  1139. </form>
  1140. </body>
  1141. </html>