-
Notifications
You must be signed in to change notification settings - Fork 2
/
maintain.inc.php
213 lines (184 loc) · 6.26 KB
/
maintain.inc.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
function plugin_install()
{
global $conf;
////////////créer groupe////////////
$query = '
INSERT INTO '.GROUPS_TABLE.'
(name)
VALUES
(\'+18\')
;';
pwg_query($query);
$query = '
INSERT INTO '.GROUPS_TABLE.'
(name)
VALUES
(\'16-17\')
;';
pwg_query($query);
$query = '
INSERT INTO '.GROUPS_TABLE.'
(name)
VALUES
(\'nothing\')
;';
pwg_query($query);
////////////créer user////////////
include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php');
register_user('18', 'adult_content', '');
register_user('16', 'adult_content', '');
////////////placer dans group 16////////////
$result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;');
$data_group = pwg_db_fetch_array($result);
pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
////////////placer dans group 18////////////
$result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;');
$data_group = pwg_db_fetch_array($result);
pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
////////////placer dans group nothing////////////
$result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;');
$data_group = pwg_db_fetch_array($result);
pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' );
/////////////Config plugin
$config_start=array('menublock_for_guest'=>true,'manage_what'=>'both');
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, manage_what");';
pwg_query($q);
}
function plugin_activate()
{
global $conf;
///user exist ?///
$query = '
SELECT COUNT(*) AS result FROM '.USERS_TABLE.'
WHERE username IN (\'18\')
;';
$data_user = pwg_db_fetch_array(pwg_query($query));
$exist = $data_user['result'];
if ( $exist == 0 )
{
register_user('18', 'adult_content', '');
}
$query = '
SELECT COUNT(*) AS result FROM '.USERS_TABLE.'
WHERE username IN (\'16\')
;';
$data_user = pwg_db_fetch_array(pwg_query($query));
$exist = $data_user['result'];
if ( $exist == 0 )
{
register_user('16', 'adult_content', '');
}
///groups///
$query = 'INSERT IGNORE INTO '.GROUPS_TABLE.' (name) VALUES (\'+18\'),(\'16-17\'),(\'nothing\') ;';
pwg_query($query);
////////////placer dans group 18////////////
$result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;');
$data_group = pwg_db_fetch_array($result);
pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
////////////placer dans group 16////////////
$result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;');
$data_group = pwg_db_fetch_array($result);
pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
////////////placer dans group nothing////////////
$result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;');
$data_group = pwg_db_fetch_array($result);
pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' );
////////////mis en generic////////////
$query = '
UPDATE '.USER_INFOS_TABLE.'
SET status=\'generic\'
WHERE user_id IN (\''.get_userid('16').'\')
;';
pwg_query($query);
$query = '
UPDATE '.USER_INFOS_TABLE.'
SET status=\'generic\'
WHERE user_id IN (\''.get_userid('18').'\')
;';
pwg_query($query);
//////////// Check Config
$query = '
SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.'
WHERE param IN (\'ad_c_plugin\')
;';
$data_table = pwg_db_fetch_array(pwg_query($query));
$exist = $data_table['result'];
if ( $exist == 0 )
{
$config_start=array('menublock_for_guest'=>true,'manage_what'=>'both');
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, manage_what");';
pwg_query($q);
}
else {
$query = '
SELECT value FROM '.CONFIG_TABLE.'
WHERE param IN (\'ad_c_plugin\')
;';
$data_conf = pwg_db_fetch_array(pwg_query($query));
$cf=@unserialize($data_conf);
$nbr=@count($cf);
if ($nbr!=2)
{
$config_start=array('menublock_for_guest'=>true,'manage_what'=>'both');
$q = '
UPDATE ' . CONFIG_TABLE . ' SET
param="ad_c_plugin", value="'.pwg_db_real_escape_string(serialize($config_start)).'", comment="Plugin adult_content : menublock_for_guest, manage_what"
WHERE param IN (\'ad_c_plugin\');';
pwg_query($q);
}
}
}//fin active
function plugin_uninstall()
{
include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php');
////////////suppr user////////////
delete_user(get_userid('18'));
delete_user(get_userid('16'));
////////////suppr assoc user all /groupe 16////////////
$query = '
SELECT id FROM '.GROUPS_TABLE.'
WHERE name IN (\'16-17\')
;';
$data_group = pwg_db_fetch_array(pwg_query($query));
pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
////////////suppr assoc user all /groupe 18////////////
$query = '
SELECT id FROM '.GROUPS_TABLE.'
WHERE name IN (\'+18\')
;';
$data_group = pwg_db_fetch_array(pwg_query($query));
pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
////////////suppr assoc user all /groupe nothing////////////
$query = '
SELECT id FROM '.GROUPS_TABLE.'
WHERE name IN (\'nothing\')
;';
$data_group = pwg_db_fetch_array(pwg_query($query));
pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
////////////suppr groupe////////////
$query = '
DELETE FROM '.GROUPS_TABLE.'
WHERE name IN (\'+18\')
;';
pwg_query($query);
$query = '
DELETE FROM '.GROUPS_TABLE.'
WHERE name IN (\'16-17\')
;';
pwg_query($query);
$query = '
DELETE FROM '.GROUPS_TABLE.'
WHERE name IN (\'nothing\')
;';
pwg_query($query);
//////////////// Delete config
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'ad_c_plugin\')');
}//fin uninstall
?>