3 /***************************************************************************
\r
6 * copyright : (C) 2003 - 2005 CyberAlien
\r
7 * support : http://www.phpbbstyles.com
\r
11 * file revision : 72
\r
12 * project revision : 78
\r
13 * last modified : 05 Dec 2005 13:54:54
\r
15 ***************************************************************************/
\r
17 /***************************************************************************
\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
24 ***************************************************************************/
\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
32 // check if mod is installed
\r
33 if(empty($template->xs_version) || $template->xs_version !== 8)
\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
38 define('IN_XS', true);
\r
39 include_once('xs_include.' . $phpEx);
\r
41 $template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_uninstall.'.$phpEx) . '">' . $lang['xs_uninstall_styles'] . '</a>'));
\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
49 if(isset($HTTP_GET_VARS['remove']) && !defined('DEMO_MODE'))
\r
51 $remove_id = intval($HTTP_GET_VARS['remove']);
\r
52 if($board_config['default_style'] == $remove_id)
\r
54 xs_error(str_replace('{URL}', append_sid('xs_styles.'.$phpEx), $lang['xs_uninstall_default']) . '<br /><br />' . $lang['xs_uninstall_back']);
\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
59 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_uninstall_back'], __LINE__, __FILE__);
\r
61 $row = $db->sql_fetchrow($result);
\r
62 if(empty($row['themes_id']))
\r
64 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_uninstall_back'], __LINE__, __FILE__);
\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
72 if(!empty($HTTP_GET_VARS['dir']))
\r
74 $HTTP_POST_VARS['remove'] = addslashes($row['template_name']);
\r
77 if(empty($HTTP_GET_VARS['nocfg']) && isset($board_config['xs_style_'.$row['template_name']]))
\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
84 // recache config table for cat_hierarchy 2.1.0
\r
85 if(isset($GLOBALS['config']) && is_object($GLOBALS['config']))
\r
88 $config->read(true);
\r
91 // recache themes table
\r
92 if(defined('XS_MODS_CATEGORY_HIERARCHY210'))
\r
94 if ( empty($themes) )
\r
96 $themes = new themes();
\r
98 if ( !empty($themes) )
\r
100 $themes->read(true);
\r
105 function remove_all($dir)
\r
107 $res = opendir($dir);
\r
112 while(($file = readdir($res)) !== false)
\r
114 if($file !== '.' && $file !== '..')
\r
116 $str = $dir . '/' . $file;
\r
134 if(isset($HTTP_POST_VARS['remove']) && !defined('DEMO_MODE'))
\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
142 xs_ftp_connect(append_sid('xs_uninstall.'.$phpEx), $params, true);
\r
143 $write_local = false;
\r
144 if($ftp === XS_FTP_LOCAL)
\r
146 $write_local = true;
\r
147 $write_local_dir = '../templates/';
\r
152 // Generate actions list
\r
154 $actions = array();
\r
155 // chdir to templates directory
\r
156 $actions[] = array(
\r
157 'command' => 'chdir',
\r
158 'dir' => 'templates'
\r
160 // chdir to template
\r
161 $actions[] = array(
\r
162 'command' => 'chdir',
\r
165 // remove all files
\r
166 $actions[] = array(
\r
167 'command' => 'removeall',
\r
170 $actions[] = array(
\r
171 'command' => 'cdup'
\r
173 $actions[] = array(
\r
174 'command' => 'rmdir',
\r
177 $ftp_log = array();
\r
179 $res = ftp_myexec($actions);
\r
180 /* echo "<!--\n\n";
\r
181 echo "\$actions dump:\n\n";
\r
183 echo "\n\n\$ftp_log dump:\n\n";
\r
185 echo "\n\n -->"; */
\r
189 remove_all('../templates/'.$remove);
\r
190 @rmdir('../templates/'.$remove);
\r
192 $template->assign_block_vars('removed', array());
\r
198 // get list of installed styles
\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
203 xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
\r
205 $style_rowset = $db->sql_fetchrowset($result);
\r
208 for($i=0; $i<count($style_rowset); $i++)
\r
210 $item = $style_rowset[$i];
\r
211 $tpl[$item['template_name']][] = $item;
\r
215 foreach($tpl as $tpl => $styles)
\r
217 $row_class = $xs_row_class[$j % 2];
\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
225 if(count($styles) > 1)
\r
227 for($i=0; $i<count($styles); $i++)
\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
235 $template->assign_block_vars('styles.item.nodelete', array());
\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
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
254 $template->set_filenames(array('body' => XS_TPL_PATH . 'uninstall.tpl'));
\r
255 $template->pparse('body');
\r