diff --git a/files/index.php b/files/index.php
index 8f6a386ad5f..0f318af3eaa 100644
--- a/files/index.php
+++ b/files/index.php
@@ -558,37 +558,6 @@
 
 /// FILE FUNCTIONS ///////////////////////////////////////////////////////////
 
-function fulldelete($location) { 
-    if (is_dir($location)) {
-        $currdir = opendir($location);
-        while (false !== ($file = readdir($currdir))) {
-            if ($file <> ".." && $file <> ".") {
-                $fullfile = $location."/".$file;
-                if (is_dir($fullfile)) { 
-                    if (!fulldelete($fullfile)) {
-                        return false;
-                    }
-                } else {
-                    if (!unlink($fullfile)) {
-                        return false;
-                    }
-                } 
-            }
-        } 
-        closedir($currdir);
-        if (! rmdir($location)) {
-            return false;
-        }
-
-    } else {
-        if (!unlink($location)) {
-            return false;
-        }
-    }
-    return true;
-}
-
-
 
 function setfilelist($VARS) {
     global $USER;
diff --git a/lib/filelib.php b/lib/filelib.php
index d246d2e0a12..e52fc98e1ab 100644
--- a/lib/filelib.php
+++ b/lib/filelib.php
@@ -278,6 +278,7 @@ function put_records_csv($file, $records, $table = NULL) {
     return true;
 }
 
+
 if (!function_exists('file_get_contents')) {
    function file_get_contents($file) {
        $file = file($file);
@@ -285,4 +286,36 @@ if (!function_exists('file_get_contents')) {
    }
 }
 
+
+function fulldelete($location) { 
+    if (is_dir($location)) {
+        $currdir = opendir($location);
+        while (false !== ($file = readdir($currdir))) {
+            if ($file <> ".." && $file <> ".") {
+                $fullfile = $location."/".$file;
+                if (is_dir($fullfile)) { 
+                    if (!fulldelete($fullfile)) {
+                        return false;
+                    }
+                } else {
+                    if (!unlink($fullfile)) {
+                        return false;
+                    }
+                } 
+            }
+        } 
+        closedir($currdir);
+        if (! rmdir($location)) {
+            return false;
+        }
+
+    } else {
+        if (!unlink($location)) {
+            return false;
+        }
+    }
+    return true;
+}
+
+
 ?>