3 * This function is used in activating plugins.
4 * This can be done by providing id using $_GET global variable of the plugin which
5 * we want to activate. After getting id we update the respective plugin with status
6 * activate which here means '1' .
8 * @author Shubham Meena, mentored by Matthew Lagoe
10 function activate_plugin() {
13 if ( WebUsers
:: isLoggedIn() ) {
15 if ( isset( $_GET['id'] ) )
17 // id of plugin to activate
18 $id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS
);
19 $db = new DBLayer( 'lib' );
20 $result = $db -> update( "plugins", array( 'Status' => '1' ), "Id = $id" );
23 // if result is successfull it redirects and shows success message
24 header("Cache-Control: max-age=1");
25 header( "Location: index.php?page=plugins&result=3" );
26 throw new SystemExit();
30 //if result is unsuccessfull it redirects and throws error
31 header("Cache-Control: max-age=1");
32 header( "Location: index.php?page=plugins&result=4" );
33 throw new SystemExit();
38 //if $_GET variable is not set it redirects and shows error
39 header("Cache-Control: max-age=1");
40 header( "Location: index.php?page=plugins&result=4" );
41 throw new SystemExit();