move.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. include '../auth.php';
  3. /*
  4. Original author: Toby Chui
  5. Branch: Master
  6. Commit ID: c6d6a955446ee4c7e8311229d704a8cebee1d906
  7. Lasted chanegd on: 5/12/2019
  8. URi: ArOZ-Online-Beta/src/master/SystemAOB/functions/file_system/move.php
  9. */
  10. ?>
  11. <?php
  12. //Require variable: from (Full path), to (Full path)
  13. function mv($var){
  14. if (isset($_GET[$var]) !== false && $_GET[$var] != ""){
  15. return $_GET[$var];
  16. }else{
  17. return null;
  18. }
  19. }
  20. if($_GET["DontCreateNewFolder"] == "true"){
  21. //echo mv("from");
  22. $dir = scandir(mv("from"));
  23. array_shift($dir);
  24. array_shift($dir);
  25. //print_r($dir);
  26. foreach ($dir as $filename) {
  27. if(substr(mv("from"), -1) == DIRECTORY_SEPARATOR){
  28. $from = mv("from").$filename;
  29. }else{
  30. $from = mv("from").DIRECTORY_SEPARATOR.$filename;
  31. }
  32. if(substr(mv("to"), -1) == DIRECTORY_SEPARATOR){
  33. $to = mv("to").$filename;
  34. }else{
  35. $to = mv("to").DIRECTORY_SEPARATOR.$filename;
  36. }
  37. if ($from != null && $to != null){
  38. if (file_exists($to)){
  39. die("ERROR. Target already eixsts.");
  40. }
  41. if (file_exists($from)){
  42. rename($from, $to);
  43. echo "DONE";
  44. }else{
  45. echo 'ERROR';
  46. }
  47. }
  48. }
  49. }else{
  50. $from = mv("from");
  51. $to = mv("to");
  52. if ($from != null && $to != null){
  53. if (file_exists($to)){
  54. die("ERROR. Target directory already eixsts.");
  55. }
  56. if (file_exists($from)){
  57. rename($from, $to);
  58. echo "DONE";
  59. return true;
  60. exit();
  61. }else{
  62. echo 'ERROR';
  63. return true;
  64. exit();
  65. }
  66. }
  67. }
  68. ?>