home.php 41 KB

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