-
Notifications
You must be signed in to change notification settings - Fork 3
/
maintain.inc.php
175 lines (154 loc) · 5.34 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
<?php
function plugin_install()
{
global $prefixeTable;
$q = 'CREATE TABLE IF NOT EXISTS ' . $prefixeTable . 'mp_playlist (
id BIGINT NOT NULL AUTO_INCREMENT ,
type VARCHAR( 50 ) NOT NULL ,
url VARCHAR( 255 ) NOT NULL ,
texte TINYTEXT NOT NULL ,
PRIMARY KEY ( id )
);
';
pwg_query($q);
$q = 'CREATE TABLE IF NOT EXISTS ' . $prefixeTable . 'mp_music (
id BIGINT NOT NULL AUTO_INCREMENT ,
pl_id BIGINT NOT NULL ,
rang BIGINT NOT NULL ,
url VARCHAR( 255 ) NOT NULL ,
nom VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( id )
);
';
pwg_query($q);
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");';
pwg_query($q);
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");';
pwg_query($q);
}
function plugin_activate()
{
global $prefixeTable;
///[ update from 1.2 ]
$q = pwg_query('SHOW COLUMNS FROM '.$prefixeTable.'mp_playlist');
$champ = array();
while ($rep = pwg_db_fetch_row($q))
{
array_push($champ, $rep[0]);
}
if (!in_array('type', $champ)) {
pwg_query('ALTER TABLE '.$prefixeTable.'mp_playlist ADD type VARCHAR( 50 ) NOT NULL AFTER id ');
}
//ALTER TABLE `phpwebgallery_mp_playlist` ADD `type` VARCHAR( 50 ) NOT NULL AFTER `id` ;
$query = '
SELECT COUNT(*) AS result FROM '.$prefixeTable.'mp_playlist
WHERE type=""
;';
$data_table = pwg_db_fetch_array(pwg_query($query));
$exist = $data_table['result'];
if ( $exist != 0 )
{
$query = '
SELECT id FROM '.$prefixeTable.'mp_playlist
WHERE type=""
;';
$result = pwg_query($query);
while ($data = pwg_db_fetch_assoc($result))
{
$query = '
UPDATE '.$prefixeTable.'mp_playlist
SET type="local"
WHERE id="'.$data['id'].'"
LIMIT 1';
pwg_query($query);
}
}
///[\]
$query = '
SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.'
WHERE param IN (\'mp_lecteur\')
;';
$data_table = pwg_db_fetch_array(pwg_query($query));
$exist = $data_table['result'];
if ( $exist == 0 )
{
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");';
pwg_query($q);
}
else {
$query = '
SELECT value FROM '.CONFIG_TABLE.'
WHERE param IN (\'mp_lecteur\')
;';
$data_conf = pwg_db_fetch_array(pwg_query($query));
$conf=explode(',', $data_conf['value']);
$nbr=count($conf);
if ($nbr!=11 or $conf[9]=='lecteur.css')// pour update depuis 2.1.0
{
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')');
pwg_query($q);
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");';
pwg_query($q);
}
}
$query = '
SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.'
WHERE param IN (\'mp_plugin\')
;';
$data_table = pwg_db_fetch_array(pwg_query($query));
$exist = $data_table['result'];
if ( $exist == 0 )
{
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");';
pwg_query($q);
}
else {
$query = '
SELECT value FROM '.CONFIG_TABLE.'
WHERE param IN (\'mp_plugin\')
;';
$data_conf = pwg_db_fetch_array(pwg_query($query));
$conf=explode(',', $data_conf['value']);
$nbr=count($conf);
if ($nbr!=5)
{
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')');
pwg_query($q);
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES
("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");';
pwg_query($q);
}
}
$q = 'ALTER TABLE '.$prefixeTable.'mp_playlist CHANGE id id BIGINT( 4 ) NOT NULL AUTO_INCREMENT';pwg_query($q);
$q = 'ALTER TABLE '.$prefixeTable.'mp_music CHANGE id id BIGINT( 4 ) NOT NULL AUTO_INCREMENT';pwg_query($q);
$q = 'ALTER TABLE '.$prefixeTable.'mp_music CHANGE pl_id pl_id BIGINT( 4 ) NOT NULL';pwg_query($q);
$q = 'ALTER TABLE '.$prefixeTable.'mp_music CHANGE rang rang BIGINT( 4 ) NOT NULL';pwg_query($q);
}//fin active
function plugin_uninstall()
{
global $prefixeTable;
$q = 'DROP TABLE ' . $prefixeTable . 'mp_playlist;';
pwg_query($q);
$q = 'DROP TABLE ' . $prefixeTable . 'mp_music;';
pwg_query($q);
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')');
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')');
}//fin uninstall
?>