undef HALF_FREQUENCY_SENDING_TO_CLIENT
[ryzomcore.git] / web / public_php / ams / func / delete_plugin.php
blob3ecd60329dff3d00a2a2b2fa6e7bd68c55f75562
1 <?php
2 /**
3 * This function is used in deleting plugins.
4 * It removes the plugin from the codebase as well as
5 * from the Database. When user request to delete a plugin
6 * id of that plugin is sent in $_GET global variable.
8 * @author Shubham Meena, mentored by Matthew Lagoe
9 */
10 function delete_plugin() {
12 // if logged in
13 if ( WebUsers :: isLoggedIn() ) {
15 if ( isset( $_GET['id'] ) )
17 // id of plugin to delete after filtering
18 $id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
20 $db = new DBLayer( 'lib' );
21 $sth = $db -> selectWithParameter( "FileName", "plugins", array( 'id' => $id ), "Id=:id" );
22 $name = $sth -> fetch();
24 if ( is_dir( "$name[FileName]" ) )
26 // removing plugin directory from the code base
27 if ( Plugincache::rrmdir( "$name[FileName]" ) )
29 $db -> delete( 'plugins', array( 'id' => $id ), "Id=:id" );
31 //if result successfull redirect and show success message
32 header("Cache-Control: max-age=1");
33 header( "Location: index.php?page=plugins&result=2" );
34 throw new SystemExit();
37 else
39 // if result unsuccessfull redirect and show error message
40 header("Cache-Control: max-age=1");
41 header( "Location: index.php?page=plugins&result=0" );
42 throw new SystemExit();
46 else
48 // if result unsuccessfull redirect and show error message
49 header("Cache-Control: max-age=1");
50 header( "Location: index.php?page=plugins&result=0" );
51 throw new SystemExit();