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 ); + } + } +