1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | global $prefixeTable, $conf; |
---|
6 | |
---|
7 | $query = 'SHOW FULL COLUMNS FROM '.STUFFS_TABLE.';'; |
---|
8 | $result = array_from_query($query, 'Field'); |
---|
9 | if ($result[5] == 'params') |
---|
10 | { |
---|
11 | $query = 'ALTER TABLE '.STUFFS_TABLE.' |
---|
12 | MODIFY COLUMN name TEXT CHARACTER SET utf8 NOT NULL, |
---|
13 | MODIFY COLUMN descr VARCHAR(255) CHARACTER SET utf8 default NULL, |
---|
14 | MODIFY COLUMN type VARCHAR(255) CHARACTER SET utf8 NOT NULL, |
---|
15 | MODIFY COLUMN params VARCHAR(255) CHARACTER SET utf8 default NULL, |
---|
16 | MODIFY COLUMN datas LONGTEXT CHARACTER SET utf8 default NULL, |
---|
17 | MODIFY COLUMN users VARCHAR(255) CHARACTER SET utf8 default NULL, |
---|
18 | MODIFY COLUMN groups VARCHAR(255) CHARACTER SET utf8 default NULL, |
---|
19 | DEFAULT CHARACTER SET utf8, |
---|
20 | ADD show_title ENUM(\'true\',\'false\') NOT NULL, |
---|
21 | ADD on_home ENUM(\'true\',\'false\') NOT NULL, |
---|
22 | ADD on_cats ENUM(\'true\',\'false\') NOT NULL, |
---|
23 | ADD on_picture ENUM(\'true\',\'false\') NOT NULL, |
---|
24 | ADD id_line VARCHAR(1) default NULL, |
---|
25 | ADD width SMALLINT(9) default NULL, |
---|
26 | ADD INDEX (on_home), |
---|
27 | ADD INDEX (on_cats), |
---|
28 | ADD INDEX (on_picture);'; |
---|
29 | |
---|
30 | pwg_query($query); |
---|
31 | |
---|
32 | $query = 'SELECT id, name, type, params, datas FROM '.STUFFS_TABLE.';'; |
---|
33 | $result = pwg_query($query); |
---|
34 | |
---|
35 | $modules = array(); |
---|
36 | while ($row = mysql_fetch_assoc($result)) |
---|
37 | { |
---|
38 | if ($row['name'] != 'MainBlock') |
---|
39 | { |
---|
40 | $array = array(); |
---|
41 | foreach (explode('///', $row['name']) as $name) |
---|
42 | { |
---|
43 | $a = explode(':', $name); |
---|
44 | array_push($array, '[lang='.substr($a[0],0,2).']'.$a[1].'[/lang]'); |
---|
45 | } |
---|
46 | $new_name = implode("\r\n", $array); |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | $new_name = 'MainBlock'; |
---|
51 | } |
---|
52 | |
---|
53 | if ($row['type'] == 'LastComs') |
---|
54 | { |
---|
55 | $datas = unserialize($row['datas']); |
---|
56 | $row['datas'] = serialize(array($datas[0], $datas[1], $datas[6], $datas[2], $datas[3])); |
---|
57 | } |
---|
58 | |
---|
59 | $params = explode(',', $row['params']); |
---|
60 | $params[4] = !empty($params[4]) ? '"'.$params[4].'"' : 'NULL'; |
---|
61 | $params[5] = !empty($params[5]) ? $params[5] : 'NULL'; |
---|
62 | |
---|
63 | $query = 'UPDATE ' . $prefixeTable . 'stuffs |
---|
64 | SET |
---|
65 | name = "'. $new_name . '", |
---|
66 | datas = "' . addslashes($row['datas']) . '", |
---|
67 | show_title = "'. ($params[0] ? 'true' : 'false') .'", |
---|
68 | on_home = "'. ($params[1] ? 'true' : 'false') .'", |
---|
69 | on_cats = "'. ($params[2] ? 'true' : 'false') .'", |
---|
70 | on_picture = "'. ($params[3] ? 'true' : 'false') .'", |
---|
71 | id_line = '. $params[4] .', |
---|
72 | width = '. $params[5] .' |
---|
73 | WHERE id = '.$row['id'].';'; |
---|
74 | |
---|
75 | pwg_query($query); |
---|
76 | } |
---|
77 | |
---|
78 | $query = 'ALTER TABLE '.STUFFS_TABLE.' DROP params;'; |
---|
79 | pwg_query($query); |
---|
80 | |
---|
81 | if (isset($conf['Stuffs'])) |
---|
82 | { |
---|
83 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="Stuffs" LIMIT 1;'; |
---|
84 | pwg_query($q); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | $query = 'SHOW FULL COLUMNS FROM '.STUFFS_TABLE.';'; |
---|
89 | $result = array_from_query($query, 'Field'); |
---|
90 | if ($result[4] != 'path') |
---|
91 | { |
---|
92 | $path = $plugin['id']; |
---|
93 | $conf['Stuffs'] = array(); |
---|
94 | |
---|
95 | $query = 'ALTER TABLE '.STUFFS_TABLE.' |
---|
96 | CHANGE `type` `path` VARCHAR( 255 ) NULL DEFAULT NULL, |
---|
97 | ADD `level` TINYINT( 3 ) NOT NULL default "0" AFTER `groups`, |
---|
98 | ADD `on_root` enum(\'true\',\'false\') NOT NULL AFTER `on_home` |
---|
99 | ;'; |
---|
100 | pwg_query($query); |
---|
101 | |
---|
102 | $query = 'UPDATE '.STUFFS_TABLE.' |
---|
103 | SET on_root = "false" |
---|
104 | WHERE on_cats <> "true" |
---|
105 | ;'; |
---|
106 | pwg_query($query); |
---|
107 | |
---|
108 | $query = 'SELECT * FROM '.STUFFS_TABLE.';'; |
---|
109 | $result = pwg_query($query); |
---|
110 | |
---|
111 | while ($row = pwg_db_fetch_assoc($result)) |
---|
112 | { |
---|
113 | if ($row['path'] == 'Personal') |
---|
114 | { |
---|
115 | $data = unserialize($row['datas']); |
---|
116 | $row['datas'] = serialize($data[0]); |
---|
117 | } |
---|
118 | if ($row['path'] == 'piclenswall') |
---|
119 | { |
---|
120 | $row['path'] = PHPWG_PLUGINS_PATH.'piclens/stuffs_module/'; |
---|
121 | } |
---|
122 | elseif ($row['path'] != 'MainBlock') |
---|
123 | { |
---|
124 | $row['path'] = PHPWG_PLUGINS_PATH.$path.'/modules/'.$row['path'].'/'; |
---|
125 | } |
---|
126 | else |
---|
127 | { |
---|
128 | // Main Block |
---|
129 | $row['path'] = null; |
---|
130 | if (!empty($row['datas'])) |
---|
131 | { |
---|
132 | $data = unserialize($row['datas']); |
---|
133 | $row['datas'] = serialize(!$data['hide']); |
---|
134 | } |
---|
135 | else |
---|
136 | { |
---|
137 | $row['datas'] = serialize(true); |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | $query = 'UPDATE '.STUFFS_TABLE.' |
---|
142 | SET path = '.(is_null($row['path']) ? 'NULL' : '"'.$row['path'].'"').', |
---|
143 | datas = "'.addslashes($row['datas']).'" |
---|
144 | WHERE id = '.$row['id'].' |
---|
145 | ;'; |
---|
146 | pwg_query($query); |
---|
147 | } |
---|
148 | |
---|
149 | $conf['Stuffs']['level_perm'] = false; |
---|
150 | |
---|
151 | $query = 'SELECT id |
---|
152 | FROM '.STUFFS_TABLE.' |
---|
153 | WHERE users <> "guest,generic,normal,admin,webmaster" |
---|
154 | ;'; |
---|
155 | $ids = array_from_query($query, 'id'); |
---|
156 | $conf['Stuffs']['user_perm'] = !empty($ids); |
---|
157 | |
---|
158 | $query = 'SELECT id |
---|
159 | FROM '.STUFFS_TABLE.' |
---|
160 | WHERE groups IS NOT NULL |
---|
161 | ;'; |
---|
162 | $ids = array_from_query($query, 'id'); |
---|
163 | $conf['Stuffs']['group_perm'] = !empty($ids); |
---|
164 | |
---|
165 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
166 | VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($conf['Stuffs'])).'" , "PWG Stuffs plugin configuration");'; |
---|
167 | pwg_query($query); |
---|
168 | } |
---|
169 | |
---|
170 | ?> |
---|