-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
54 lines (46 loc) · 1.51 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
//For security purposes, it is MANDATORY that this page be wrapped in the following
//if statement. This prevents remote execution of this code.
require_once("init.php");
if (in_array($user->data()->id, $master_account)){
//all actions should be performed here.
//check which updates have been installed
$count = 0;
$db = DB::getInstance();
include "plugin_info.php";
pluginActive($plugin_name);
//Make sure the plugin is installed and get the existing updates
$checkQ = $db->query("SELECT id,updates FROM us_plugins WHERE plugin = ?",array($plugin_name));
$checkC = $checkQ->count();
if($checkC < 1){
err($plugin_name." is not installed!");
die();
}
$check = $checkQ->first();
if($check->updates == ''){
$existing = []; //deal with not finding any updates
}else{
$existing = json_decode($check->updates);
}
//list your updates here from oldest at the top to newest at the bottom.
//Give your update a unique update number/code.
//here is an example
$update = '00001';
if(!in_array($update,$existing)){
//do something
$existing[] = $update; //add the update you just did to the existing update array
$count++;
}
//after all updates are done. Keep this at the bottom.
$new = json_encode($existing);
$db->update('us_plugins',$check->id,['updates'=>$new]);
if(!$db->error()) {
if($count == 1){
}else{
err($count.' updates applied!');
}
} else {
err('Failed to save updates');
logger($user->data()->id,"USPlugins","Failed to save updates, Error: ".$db->errorString());
}
} //do not perform actions outside of this statement