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