khanat-code-old/code/web/public_php/ams/func/delete_plugin.php
shubham_meena c4ce26501c Merged in Gsoc14-ryzomAppImprovements (pull request #1)
Merging Gsoc 14 branch with default
2014-08-15 01:05:39 +05:30

47 lines
1.4 KiB
PHP

<?php
/**
* This function is used in deleting plugins.
*
* It removes the plugin from the codebase.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function delete_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete after filtering
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$sth = $db -> selectWithParameter( "FileName", "plugins", array( 'id' => $id ), "Id=:id" );
$name = $sth -> fetch();
if ( is_dir( "$name[FileName]" ) )
{
// removing plugin directory from the code base
if ( Plugincache::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;
}
}
}