From 8abe4e0c13eaf051cb625fae338da47b1fced576 Mon Sep 17 00:00:00 2001 From: shubham_meena Date: Fri, 13 Jun 2014 17:21:49 +0530 Subject: [PATCH] deleting plugin from ams --- .../ryzom_ams/www/html/func/delete_plugin.php | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php new file mode 100644 index 000000000..53af36157 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php @@ -0,0 +1,68 @@ + selectWithParameter( "FileName", "plugins", array( 'id' => $id ), "Id=:id" ); + $name = $sth -> fetch(); + + if ( is_dir( "$name[FileName]" ) ) + { + // removing plugin directory from the code base + if ( rrmdir( "$name[FileName]" ) ) + { + $db -> delete( 'plugins', array( 'id' => $id ), "Id=:id" ); + + header( "Location: index.php?page=plugins&result=2" ); + exit; + + } + else + { + header( "Location: index.php?page=plugins&result=0" ); + exit; + } + } + } + else + { + header( "Location: index.php?page=plugins&result=0" ); + exit; + } + } + } + +/** + * function to remove a non empty directory + * + * @param $dir directory address + * @return boolean + */ +function rrmdir( $dir ) { + if ( is_dir( $dir ) ) { + $objects = scandir( $dir ); + foreach ( $objects as $object ) { + if ( $object != "." && $object != ".." ) { + if ( filetype( $dir . "/" . $object ) == "dir" ) rmdir( $dir . "/" . $object ); + else unlink( $dir . "/" . $object ); + } + } + reset( $objects ); + return rmdir( $dir ); + } + } +