Use functions to delete and copy files. check whether magic reference is enabled.
The deletion and copying of files through functions has shown whether magic reference is enabled.
- /**
- I still have a hard time
- * The custom addslashes function supports multi-dimensional arrays and automatically identifies whether the server enables magic reference.
- */
- Function add_slashes ($ var ){
- // First determine whether the server supports magic reference
- If (get_magic_quotes_gpc () = 0 ){
- If (is_array ($ var )){
- // Traverse the array
- Foreach ($ var as $ key => $ value ){
- $ Var [$ key] = add_slashes ($ value );
- }
- Return $ var;
- }
- } Elseif (is_string ($ var )){
- // It is a string instead of an array.
- Return addslashes ($ var );
- } Else {
- // Enabled
- Return $ var;
- }
- }
- // Copy function to copy files and folders
- Function dir_copy ($ src, $ dst ){
- If (is_dir ($ src )){
- If (! File_exists ($ dst )){
- @ Mkdir ($ dst, 0777, true );
- }
- }
- $ Fp = opendir ($ src );
- While (! False = ($ fn = readdir ($ fp ))){
- If ($ fn = "." | $ fn = ".."){
- Continue;
- }
- $ Path = $ src. DIRECTORY_SEPARATOR. $ fn;
- If (is_dir ($ path )){
- Dis_copy ($ path, ($ dst. DIRECTORY_SEPARATOR. $ fn ));
- } Elseif (is_file ($ path )){
- Copy ($ path, ($ dst. DIRECTORY_SEPARATOR. $ fn ));
- } Else {
- Copy ($ path, ($ dst. DIRECTORY_SEPARATOR. $ fn ));
- }
- }
- Closedir ($ fp );
- }
- // Delete a function
- Function delete_dir ($ src ){
- If (is_dir ($ src )){
- $ Fp = opendir ($ src );
- While (! False = ($ fn = readdir ($ fp ))){
- If ($ fn = "." | $ fn = ".."){
- Continue;
- }
- $ Path = $ src. DIRECTORY_SEPARATOR. $ fn;
- If (is_dir ($ path )){
- Delete_dir ($ path );
- } Elseif (is_file ($ path )){
- @ Unlink ($ path );
- } Else {
- @ Unlink ($ path );
- }
- }
- }
- Closedir ($ fp );
- @ Rmdir ($ src );
- }
- // Msg output
- Function msg ($ msg ){
- Echo $ msg ."
";
- Echo "back to previous page ";
- Die;
- }
|