includes/plugins.php
changeset 529 7803c9db3506
parent 528 43535769970b
child 536 218a627eb53e
equal deleted inserted replaced
528:43535769970b 529:7803c9db3506
   449         if ( !$db->sql_query($query) )
   449         if ( !$db->sql_query($query) )
   450           $db->die_json();
   450           $db->die_json();
   451       }
   451       }
   452     }
   452     }
   453     
   453     
       
   454     // log action
       
   455     $time        = time();
       
   456     $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
       
   457     $username_db = $db->escape($session->username);
       
   458     $file_db     = $db->escape($filename);
       
   459     $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
       
   460                       . "  ('security', 'plugin_install', $time, '$ip_db', '$username_db', '$file_db');");
       
   461     if ( !$q )
       
   462       $db->_die();
       
   463     
   454     // register plugin
   464     // register plugin
   455     $version_db = $db->escape($dataset['version']);
   465     $version_db = $db->escape($dataset['version']);
   456     $filename_db = $db->escape($filename);
   466     $filename_db = $db->escape($filename);
   457     $flags = PLUGIN_INSTALLED;
   467     $flags = PLUGIN_INSTALLED;
   458     
   468     
   552       {
   562       {
   553         if ( !$db->sql_query($query) )
   563         if ( !$db->sql_query($query) )
   554           $db->die_json();
   564           $db->die_json();
   555       }
   565       }
   556     }
   566     }
       
   567     
       
   568     // log action
       
   569     $time        = time();
       
   570     $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
       
   571     $username_db = $db->escape($session->username);
       
   572     $file_db     = $db->escape($filename);
       
   573     $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
       
   574                       . "  ('security', 'plugin_uninstall', $time, '$ip_db', '$username_db', '$file_db');");
       
   575     if ( !$q )
       
   576       $db->_die();
   557     
   577     
   558     // deregister plugin
   578     // deregister plugin
   559     $q = $db->sql_query('DELETE FROM ' . table_prefix . "plugins WHERE plugin_id = {$dataset['plugin id']};");
   579     $q = $db->sql_query('DELETE FROM ' . table_prefix . "plugins WHERE plugin_id = {$dataset['plugin id']};");
   560     if ( !$q )
   580     if ( !$q )
   561       $db->die_json();
   581       $db->die_json();
   764         if ( !$db->sql_query($query) )
   784         if ( !$db->sql_query($query) )
   765           $db->die_json();
   785           $db->die_json();
   766       }
   786       }
   767     }
   787     }
   768     
   788     
       
   789     // log action
       
   790     $time        = time();
       
   791     $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
       
   792     $username_db = $db->escape($session->username);
       
   793     $file_db     = $db->escape($filename);
       
   794     $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
       
   795                       . "  ('security', 'plugin_upgrade', $time, '$ip_db', '$username_db', '$file_db');");
       
   796     if ( !$q )
       
   797       $db->_die();
       
   798     
   769     // update version number
   799     // update version number
   770     $version = $db->escape($dataset['version']);
   800     $version = $db->escape($dataset['version']);
   771     $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_version = '$version' WHERE plugin_id = {$dataset['plugin id']};");
   801     $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_version = '$version' WHERE plugin_id = {$dataset['plugin id']};");
   772     if ( !$q )
   802     if ( !$q )
   773       $db->die_json();
   803       $db->die_json();