]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2/admin/xs_uninstall.php
Vervang Social door blog.
[www.vanrenterghem.biz.git] / phpBB2 / admin / xs_uninstall.php
1 <?php\r
2 \r
3 /***************************************************************************\r
4  *                             xs_uninstall.php\r
5  *                             ----------------\r
6  *   copyright            : (C) 2003 - 2005 CyberAlien\r
7  *   support              : http://www.phpbbstyles.com\r
8  *\r
9  *   version              : 2.3.1\r
10  *\r
11  *   file revision        : 72\r
12  *   project revision     : 78\r
13  *   last modified        : 05 Dec 2005  13:54:54\r
14  *\r
15  ***************************************************************************/\r
16 \r
17 /***************************************************************************\r
18  *\r
19  *   This program is free software; you can redistribute it and/or modify\r
20  *   it under the terms of the GNU General Public License as published by\r
21  *   the Free Software Foundation; either version 2 of the License, or\r
22  *   (at your option) any later version.\r
23  *\r
24  ***************************************************************************/\r
25 \r
26 define('IN_PHPBB', 1);\r
27 $phpbb_root_path = "./../";\r
28 $no_page_header = true;\r
29 require($phpbb_root_path . 'extension.inc');\r
30 require('./pagestart.' . $phpEx);\r
31 \r
32 // check if mod is installed\r
33 if(empty($template->xs_version) || $template->xs_version !== 8)\r
34 {\r
35         message_die(GENERAL_ERROR, isset($lang['xs_error_not_installed']) ? $lang['xs_error_not_installed'] : 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');\r
36 }\r
37 \r
38 define('IN_XS', true);\r
39 include_once('xs_include.' . $phpEx);\r
40 \r
41 $template->assign_block_vars('nav_left',array('ITEM' => '&raquo; <a href="' . append_sid('xs_uninstall.'.$phpEx) . '">' . $lang['xs_uninstall_styles'] . '</a>'));\r
42 \r
43 $lang['xs_uninstall_back'] = str_replace('{URL}', append_sid('xs_uninstall.'.$phpEx), $lang['xs_uninstall_back']);\r
44 $lang['xs_goto_default'] = str_replace('{URL}', append_sid('xs_styles.'.$phpEx), $lang['xs_goto_default']);\r
45 \r
46 //\r
47 // uninstall style\r
48 //\r
49 if(isset($HTTP_GET_VARS['remove']) && !defined('DEMO_MODE'))\r
50 {\r
51         $remove_id = intval($HTTP_GET_VARS['remove']);\r
52         if($board_config['default_style'] == $remove_id)\r
53         {\r
54                 xs_error(str_replace('{URL}', append_sid('xs_styles.'.$phpEx), $lang['xs_uninstall_default']) . '<br /><br />' . $lang['xs_uninstall_back']);\r
55         }\r
56         $sql = "SELECT themes_id, template_name, style_name FROM " . THEMES_TABLE . " WHERE themes_id='{$remove_id}'";\r
57         if(!$result = $db->sql_query($sql))\r
58         {\r
59                 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_uninstall_back'], __LINE__, __FILE__);\r
60         }\r
61         $row = $db->sql_fetchrow($result);\r
62         if(empty($row['themes_id']))\r
63         {\r
64                 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_uninstall_back'], __LINE__, __FILE__);\r
65         }\r
66         $sql = "UPDATE " . USERS_TABLE . " SET user_style=NULL WHERE user_style='{$remove_id}'";\r
67         $db->sql_query($sql);\r
68         $sql = "DELETE FROM " . THEMES_TABLE . " WHERE themes_id='{$remove_id}'";\r
69         $db->sql_query($sql);\r
70         $template->assign_block_vars('removed', array());\r
71         // remove files\r
72         if(!empty($HTTP_GET_VARS['dir']))\r
73         {\r
74                 $HTTP_POST_VARS['remove'] = addslashes($row['template_name']);\r
75         }\r
76         // remove config\r
77         if(empty($HTTP_GET_VARS['nocfg']) && isset($board_config['xs_style_'.$row['template_name']]))\r
78         {\r
79                 $sql = "DELETE FROM " . CONFIG_TABLE . " WHERE config_name='" . addslashes("xs_style_{$row['template_name']}") . "'";\r
80                 $db->sql_query($sql);\r
81                 $template->assign_block_vars('left_refresh', array(\r
82                                 'ACTION'        => append_sid('index.' . $phpEx . '?pane=left')\r
83                         ));\r
84                 // recache config table for cat_hierarchy 2.1.0\r
85                 if(isset($GLOBALS['config']) && is_object($GLOBALS['config']))\r
86                 {\r
87                         global $config;\r
88                         $config->read(true);\r
89                 }\r
90         }\r
91         // recache themes table\r
92         if(defined('XS_MODS_CATEGORY_HIERARCHY210'))\r
93         {\r
94                 if ( empty($themes) )\r
95                 {\r
96                         $themes = new themes();\r
97                 }\r
98                 if ( !empty($themes) )\r
99                 {\r
100                         $themes->read(true);\r
101                 }\r
102         }\r
103 }\r
104 \r
105 function remove_all($dir)\r
106 {\r
107         $res = opendir($dir);\r
108         if(!$res)\r
109         {\r
110                 return false;\r
111         }\r
112         while(($file = readdir($res)) !== false)\r
113         {\r
114                 if($file !== '.' && $file !== '..')\r
115                 {\r
116                         $str = $dir . '/' . $file;\r
117                         if(is_dir($str))\r
118                         {\r
119                                 remove_all($str);\r
120                                 @rmdir($str);\r
121                         }\r
122                         else\r
123                         {\r
124                                 @unlink($str);\r
125                         }\r
126                 }\r
127         }\r
128         closedir($res);\r
129 }\r
130 \r
131 //\r
132 // remove files\r
133 //\r
134 if(isset($HTTP_POST_VARS['remove']) && !defined('DEMO_MODE'))\r
135 {\r
136         $remove = stripslashes($HTTP_POST_VARS['remove']);\r
137         $params = array('remove' => $remove);\r
138         if(!get_ftp_config(append_sid('xs_uninstall.'.$phpEx), $params, true))\r
139         {\r
140                 xs_exit();\r
141         }\r
142         xs_ftp_connect(append_sid('xs_uninstall.'.$phpEx), $params, true);\r
143         $write_local = false;\r
144         if($ftp === XS_FTP_LOCAL)\r
145         {\r
146                 $write_local = true;\r
147                 $write_local_dir = '../templates/';\r
148         }\r
149         if(!$write_local)\r
150         {\r
151                 //\r
152                 // Generate actions list\r
153                 //\r
154                 $actions = array();\r
155                 // chdir to templates directory\r
156                 $actions[] = array(\r
157                                 'command'       => 'chdir',\r
158                                 'dir'           => 'templates'\r
159                         );\r
160                 // chdir to template\r
161                 $actions[] = array(\r
162                                 'command'       => 'chdir',\r
163                                 'dir'           => $remove\r
164                         );\r
165                 // remove all files\r
166                 $actions[] = array(\r
167                                 'command'       => 'removeall',\r
168                                 'ignore'        => true\r
169                         );\r
170                 $actions[] = array(\r
171                                 'command'       => 'cdup'\r
172                         );\r
173                 $actions[] = array(\r
174                                 'command'       => 'rmdir',\r
175                                 'dir'           => $remove\r
176                         );\r
177                 $ftp_log = array();\r
178                 $ftp_error = '';\r
179                 $res = ftp_myexec($actions);\r
180 /*              echo "<!--\n\n";\r
181                 echo "\$actions dump:\n\n";\r
182                 print_r($actions);\r
183                 echo "\n\n\$ftp_log dump:\n\n";\r
184                 print_r($ftp_log);\r
185                 echo "\n\n -->"; */\r
186         }\r
187         else\r
188         {\r
189                 remove_all('../templates/'.$remove);\r
190                 @rmdir('../templates/'.$remove);\r
191         }\r
192         $template->assign_block_vars('removed', array());\r
193 }\r
194 \r
195 \r
196 \r
197 //\r
198 // get list of installed styles\r
199 //\r
200 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name, style_name';\r
201 if(!$result = $db->sql_query($sql))\r
202 {\r
203         xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);\r
204 }\r
205 $style_rowset = $db->sql_fetchrowset($result);\r
206 \r
207 $tpl = array();\r
208 for($i=0; $i<count($style_rowset); $i++)\r
209 {\r
210         $item = $style_rowset[$i];\r
211         $tpl[$item['template_name']][] = $item;\r
212 }\r
213 \r
214 $j = 0;\r
215 foreach($tpl as $tpl => $styles)\r
216 {\r
217         $row_class = $xs_row_class[$j % 2];\r
218         $j++;\r
219         $template->assign_block_vars('styles', array(\r
220                         'ROW_CLASS'     => $row_class,\r
221                         'TPL'           => htmlspecialchars($tpl),\r
222                         'ROWS'          => count($styles),\r
223                 )\r
224         );\r
225         if(count($styles) > 1)\r
226         {\r
227                 for($i=0; $i<count($styles); $i++)\r
228                 {\r
229                         $template->assign_block_vars('styles.item', array(\r
230                                         'ID'            => $styles[$i]['themes_id'],\r
231                                         'THEME'         => htmlspecialchars($styles[$i]['style_name']),\r
232                                         'U_DELETE'      => append_sid('xs_uninstall.'.$phpEx.'?remove='.$styles[$i]['themes_id'].'&nocfg=1'),\r
233                                 )\r
234                         );\r
235                         $template->assign_block_vars('styles.item.nodelete', array());\r
236                 }\r
237         }\r
238         else\r
239         {\r
240                 $i = 0;\r
241                 $template->assign_block_vars('styles.item', array(\r
242                                 'ID'            => $styles[$i]['themes_id'],\r
243                                 'THEME'         => htmlspecialchars($styles[$i]['style_name']),\r
244                                 'U_DELETE'      => append_sid('xs_uninstall.'.$phpEx.'?remove='.$styles[$i]['themes_id']),\r
245                         )\r
246                 );\r
247                 $template->assign_block_vars('styles.item.delete', array(\r
248                                 'U_DELETE'      => append_sid('xs_uninstall.'.$phpEx.'?dir=1&remove='.$styles[$i]['themes_id']),\r
249                         )\r
250                 );\r
251         }\r
252 }\r
253 \r
254 $template->set_filenames(array('body' => XS_TPL_PATH . 'uninstall.tpl'));\r
255 $template->pparse('body');\r
256 xs_exit();\r
257 \r
258 ?>