-
Notifications
You must be signed in to change notification settings - Fork 6
/
maintain.class.php
92 lines (77 loc) · 2.47 KB
/
maintain.class.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
class private_share_maintain extends PluginMaintain
{
private $installed = false;
function __construct($plugin_id)
{
parent::__construct($plugin_id);
}
function install($plugin_version, &$errors=array())
{
global $conf, $prefixeTable;
$query = '
CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'pshare_keys` (
`pshare_key_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uuid` varchar(255) NOT NULL,
`user_id` mediumint(8) unsigned NOT NULL,
`image_id` mediumint(8) unsigned NOT NULL,
`sent_to` varchar(255) NOT NULL,
`created_on` datetime NOT NULL,
`duration` int(10) unsigned DEFAULT NULL,
`expire_on` datetime NOT NULL,
`is_valid` enum(\'true\',\'false\') NOT NULL DEFAULT \'true\',
PRIMARY KEY (`pshare_key_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;';
pwg_query($query);
$query = '
CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'pshare_log` (
`pshare_log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pshare_key_idx` int(10) unsigned NOT NULL,
`occured_on` datetime NOT NULL,
`type` enum(\'download\',\'visit\') NOT NULL DEFAULT \'visit\',
`ip_address` varchar(15) NOT NULL DEFAULT \'\',
`user_id` mediumint(8) unsigned NOT NULL,
`format_id` int(11) unsigned default NULL,
PRIMARY KEY (`pshare_log_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;';
pwg_query($query);
$result = pwg_query('SHOW COLUMNS FROM `'.GROUPS_TABLE.'` LIKE "pshare_enabled";');
if (!pwg_db_num_rows($result))
{
pwg_query('ALTER TABLE '.GROUPS_TABLE.' ADD pshare_enabled enum(\'true\', \'false\') DEFAULT \'false\';');
}
$result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'pshare_log` LIKE "format_id";');
if (!pwg_db_num_rows($result))
{
pwg_query('ALTER TABLE '.$prefixeTable.'pshare_log ADD format_id int(11) DEFAULT NULL;');
}
$this->installed = true;
}
function activate($plugin_version, &$errors=array())
{
global $prefixeTable;
if (!$this->installed)
{
$this->install($plugin_version, $errors);
}
}
function update($old_version, $new_version, &$errors=array())
{
$this->install($new_version, $errors);
}
function deactivate()
{
}
function uninstall()
{
global $prefixeTable;
pwg_query('DROP TABLE '.$prefixeTable.'pshare_keys;');
pwg_query('DROP TABLE '.$prefixeTable.'pshare_log;');
$query = 'DROP TABLE '.GROUPS_TABLE.' DROP pshare_enabled;';
pwg_query($query);
}
}
?>