folder_move.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. require_once ("./header.php");
  3. logged_in_only ();
  4. require_once (ABSOLUTE_PATH . "folders.php");
  5. $sourcefolder = set_post_sourcefolder ();
  6. $tree = new folder;
  7. $parents = $tree->get_path_to_root ($folderid);
  8. if ($sourcefolder == "") {
  9. ?>
  10. <h2 class="title">Move Folder</h2>
  11. <form action="<?php echo $_SERVER['SCRIPT_NAME'] . "?folderid=" . $folderid . "&expand=" . implode (",", $expand);?>" method="POST" id="fmove">
  12. <div style="width:100%; height:330px; overflow:auto;">
  13. <?php
  14. $tree->make_tree (0);
  15. $tree->print_tree ();
  16. ?>
  17. </div>
  18. <br>
  19. <input type="hidden" name="sourcefolder">
  20. <input type="submit" value=" OK ">
  21. <input type="button" value=" Cancel " onClick="self.close()">
  22. <input type="button" value=" New Folder " onClick="self.location.href='javascript:foldernew(<?php echo $folderid; ?>)'">
  23. </form>
  24. <script type="text/javascript">
  25. this.focus();
  26. document.getElementById('fmove').sourcefolder.value = self.name;
  27. </script>
  28. <?php
  29. }
  30. else if ($sourcefolder == $folderid) {
  31. echo '<script language="JavaScript">self.close();</script>';
  32. }
  33. else if (in_array ($sourcefolder, $parents)){
  34. message ("A folder cannot be moved to one of its own subfolders");
  35. }
  36. else if ($sourcefolder != "" && $sourcefolder != $folderid){
  37. $query = sprintf ("UPDATE folder SET childof='%d' WHERE id='%d' AND user='%s'",
  38. $mysql->escape ($folderid),
  39. $mysql->escape ($sourcefolder),
  40. $mysql->escape ($username));
  41. if ($mysql->query ($query)) {
  42. echo "Folder moved<br>\n";
  43. echo '<script language="JavaScript">reloadclose();</script>';
  44. }
  45. else {
  46. message ($mysql->error);
  47. }
  48. }
  49. require_once (ABSOLUTE_PATH . "footer.php");
  50. ?>