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