1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | function plugin_activate() |
---|
6 | { |
---|
7 | global $prefixeTable, $template; |
---|
8 | define('meta_DIR' , basename(dirname(__FILE__))); |
---|
9 | define('meta_PATH' , PHPWG_PLUGINS_PATH . meta_DIR . '/'); |
---|
10 | define('meta_TABLE' , $prefixeTable . 'meta'); |
---|
11 | define('meta_img_TABLE' , $prefixeTable . 'meta_img'); |
---|
12 | define('meta_cat_TABLE' , $prefixeTable . 'meta_cat'); |
---|
13 | define('METAPERSO_TABLE', $prefixeTable.'metaperso'); |
---|
14 | |
---|
15 | $query = "CREATE TABLE IF NOT EXISTS ". METAPERSO_TABLE ." ( |
---|
16 | id SMALLINT( 5 ) UNSIGNED NOT NULL auto_increment, |
---|
17 | metaname VARCHAR( 255 ) NOT NULL , |
---|
18 | metaval lONGTEXT NOT NULL , |
---|
19 | metatype VARCHAR( 255 ) NOT NULL , |
---|
20 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
21 | $result = pwg_query($query); |
---|
22 | |
---|
23 | //Gestion MAJ2 |
---|
24 | $majm2='meta 2.1.0'; |
---|
25 | $query = ' |
---|
26 | select param,value |
---|
27 | FROM ' . CONFIG_TABLE . ' |
---|
28 | WHERE param = \''.$majm2.'\' |
---|
29 | ;'; |
---|
30 | $result = pwg_query($query); |
---|
31 | |
---|
32 | $row = pwg_db_fetch_assoc($result); |
---|
33 | $majparam2=$row['param']; |
---|
34 | $majvalue2=$row['value']; |
---|
35 | |
---|
36 | if (!$majvalue2==1 and !is_adviser()) |
---|
37 | { |
---|
38 | |
---|
39 | //Gestion MAJ1 |
---|
40 | $majm1='meta 2.0.5'; |
---|
41 | $query = ' |
---|
42 | select param,value |
---|
43 | FROM ' . CONFIG_TABLE . ' |
---|
44 | WHERE param = \''.$majm1.'\' |
---|
45 | ;'; |
---|
46 | $result = pwg_query($query); |
---|
47 | |
---|
48 | $row = pwg_db_fetch_assoc($result); |
---|
49 | $majparam1=$row['param']; |
---|
50 | $majvalue1=$row['value']; |
---|
51 | |
---|
52 | if (!$majvalue1==1) |
---|
53 | { |
---|
54 | if (!defined('meta_img_TABLE')) define('meta_img_TABLE', $prefixeTable.'meta_img'); |
---|
55 | $query = "CREATE TABLE IF NOT EXISTS ". meta_img_TABLE ." ( |
---|
56 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
57 | metaKeyimg VARCHAR( 255 ) NOT NULL , |
---|
58 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
59 | $result = pwg_query($query); |
---|
60 | |
---|
61 | if (!defined('meta_cat_TABLE')) define('meta_cat_TABLE', $prefixeTable.'meta_cat'); |
---|
62 | $query = "CREATE TABLE IF NOT EXISTS ". meta_cat_TABLE ." ( |
---|
63 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
64 | metaKeycat VARCHAR( 255 ) NOT NULL , |
---|
65 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
66 | $result = pwg_query($query); |
---|
67 | |
---|
68 | $query = ' |
---|
69 | select id |
---|
70 | FROM ' . CATEGORIES_TABLE . ' |
---|
71 | ORDER BY id DESC;'; |
---|
72 | $result = pwg_query($query); |
---|
73 | $row = pwg_db_fetch_assoc($result); |
---|
74 | |
---|
75 | $comp=$row['id']+1; |
---|
76 | $i=1; |
---|
77 | |
---|
78 | while($i < $comp) |
---|
79 | { |
---|
80 | $query = ' |
---|
81 | select id,metaKeywords |
---|
82 | FROM ' . CATEGORIES_TABLE . ' |
---|
83 | WHERE id = \''.$i.'\''; |
---|
84 | $result = pwg_query($query); |
---|
85 | $row = pwg_db_fetch_assoc($result); |
---|
86 | |
---|
87 | if(!$row['id']==0 and !$row['metaKeywords']==0) |
---|
88 | { |
---|
89 | $query = ' |
---|
90 | INSERT INTO ' . $prefixeTable . 'meta_cat(id,metaKeycat)VALUES ('.$row['id'].',"'.$row['metaKeywords'].'");'; |
---|
91 | $result = pwg_query($query); |
---|
92 | } |
---|
93 | ++$i; |
---|
94 | } |
---|
95 | |
---|
96 | $query = ' ALTER TABLE '. CATEGORIES_TABLE .' DROP COLUMN `metaKeywords`'; |
---|
97 | pwg_query($query); |
---|
98 | |
---|
99 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm1.'",1,"MAJ meta");'; |
---|
100 | pwg_query($query); |
---|
101 | $majvalue1==1; |
---|
102 | $maj =0; |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | $q = ' |
---|
107 | ALTER TABLE '.meta_cat_TABLE.' ADD COLUMN metadescat VARCHAR( 255 ) NOT NULL '; |
---|
108 | pwg_query($q); |
---|
109 | |
---|
110 | $q = ' |
---|
111 | ALTER TABLE '.meta_img_TABLE.' ADD COLUMN metadesimg VARCHAR( 255 ) NOT NULL '; |
---|
112 | pwg_query($q); |
---|
113 | |
---|
114 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm2.'",1,"MAJ meta");'; |
---|
115 | pwg_query($query); |
---|
116 | |
---|
117 | $template->delete_compiled_templates(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
118 | |
---|
119 | $majvalue2==1; |
---|
120 | $maj =0; |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | function plugin_install() |
---|
125 | { |
---|
126 | global $prefixeTable; |
---|
127 | |
---|
128 | $q = 'CREATE TABLE ' . $prefixeTable . 'meta( |
---|
129 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
130 | metaname VARCHAR( 255 ) NOT NULL , |
---|
131 | metaval lONGTEXT NOT NULL , |
---|
132 | metatype VARCHAR( 255 ) NOT NULL , |
---|
133 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;'; |
---|
134 | pwg_query($q); |
---|
135 | |
---|
136 | $q = ' |
---|
137 | INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (1,"author","","name");'; |
---|
138 | pwg_query($q); |
---|
139 | |
---|
140 | $q = ' |
---|
141 | INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (2,"keywords","","name");'; |
---|
142 | pwg_query($q); |
---|
143 | |
---|
144 | $q = ' |
---|
145 | INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (3,"Description","","name");'; |
---|
146 | pwg_query($q); |
---|
147 | |
---|
148 | $q = ' |
---|
149 | INSERT INTO ' . $prefixeTable . 'meta(id,metaname,metaval,metatype)VALUES (4,"robots","follow","name");'; |
---|
150 | pwg_query($q); |
---|
151 | |
---|
152 | if (!defined('meta_img_TABLE')) define('meta_img_TABLE', $prefixeTable.'meta_img'); |
---|
153 | $query = "CREATE TABLE IF NOT EXISTS ". meta_img_TABLE ." ( |
---|
154 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
155 | metaKeyimg VARCHAR( 255 ) NOT NULL , |
---|
156 | metadesimg VARCHAR( 255 ) NOT NULL , |
---|
157 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
158 | $result = pwg_query($query); |
---|
159 | |
---|
160 | if (!defined('meta_cat_TABLE')) define('meta_cat_TABLE', $prefixeTable.'meta_cat'); |
---|
161 | $query = "CREATE TABLE IF NOT EXISTS ". meta_cat_TABLE ." ( |
---|
162 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
163 | metaKeycat VARCHAR( 255 ) NOT NULL , |
---|
164 | metadescat VARCHAR( 255 ) NOT NULL , |
---|
165 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
166 | $result = pwg_query($query); |
---|
167 | |
---|
168 | if (!defined('METAPERSO_TABLE')) define('METAPERSO_TABLE', $prefixeTable.'metaperso'); |
---|
169 | $query = "CREATE TABLE IF NOT EXISTS ". METAPERSO_TABLE ." ( |
---|
170 | id SMALLINT( 5 ) UNSIGNED NOT NULL auto_increment, |
---|
171 | metaname VARCHAR( 255 ) NOT NULL , |
---|
172 | metaval lONGTEXT NOT NULL , |
---|
173 | metatype VARCHAR( 255 ) NOT NULL , |
---|
174 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
175 | $result = pwg_query($query); |
---|
176 | |
---|
177 | $majm1='meta 2.0.5'; |
---|
178 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm1.'",1,"MAJ meta");'; |
---|
179 | pwg_query($query); |
---|
180 | |
---|
181 | $majm2='meta 2.1.0'; |
---|
182 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'.$majm2.'",1,"MAJ meta");'; |
---|
183 | pwg_query($query); |
---|
184 | } |
---|
185 | |
---|
186 | function plugin_uninstall() |
---|
187 | { |
---|
188 | |
---|
189 | $majm1='meta 2.0.5'; |
---|
190 | $majm2='meta 2.1.0'; |
---|
191 | |
---|
192 | global $prefixeTable; |
---|
193 | |
---|
194 | $q = 'DROP TABLE ' . $prefixeTable . 'meta;'; |
---|
195 | pwg_query($q); |
---|
196 | |
---|
197 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="'.$majm1.'" LIMIT 1;'; |
---|
198 | pwg_query($q); |
---|
199 | |
---|
200 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="'.$majm2.'" LIMIT 1;'; |
---|
201 | pwg_query($q); |
---|
202 | |
---|
203 | $q = 'DROP TABLE ' . $prefixeTable . 'meta_img;'; |
---|
204 | pwg_query($q); |
---|
205 | |
---|
206 | $q = 'DROP TABLE ' . $prefixeTable . 'meta_cat;'; |
---|
207 | pwg_query($q); |
---|
208 | } |
---|
209 | |
---|
210 | |
---|
211 | ?> |
---|