Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / ams / func / update_plugin.php
blobe120c133906adee590094ad331a8e86d50a4b7e9
1 <?php
2 /**
3 * This function is used in installing updates for plugins.
4 * It takes id of the plugin whose update is available using
5 * $_GET global variable and then extract the update details
6 * from db and then install it in the plugin.
8 * @author Shubham Meena, mentored by Matthew Lagoe
9 */
10 function update_plugin() {
12 // if logged in
13 if ( WebUsers :: isLoggedIn() ) {
15 if ( isset( $_GET['id'] ) )
17 // id of plugin to update
18 $id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
19 $db = new DBLayer( 'lib' );
20 $sth = $db -> executeWithoutParams( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id=$id" );
21 $row = $sth -> fetch();
23 // replacing update in the database
24 Plugincache :: rrmdir( $row['FileName'] );
25 Plugincache :: zipExtraction( $row['UpdatePath'], rtrim( $row['FileName'], strtolower( $row['Name'] ) ) );
27 $db -> update( "plugins", array( 'Info' => $row['UpdateInfo'] ), "Id=$row[Id]" );
29 // deleting the previous update
30 $db -> delete( "updates", array( 'id' => $row['s.no'] ), "s.no=:id" );
32 // if update is installed succesffully redirect to show success message
33 header("Cache-Control: max-age=1");
34 header( "Location: index.php?page=plugins&result=8" );
35 throw new SystemExit();