3 /***************************************************************************
6 * copyright : (C) 2003, 2004 CyberAlien
7 * support : http://www.phpbbstyles.com
12 * project revision : 51
13 * last modified : 25 Aug 2004 11:51:48
15 ***************************************************************************/
17 /***************************************************************************
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.
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)
35 message_die(GENERAL_ERROR, 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');
38 define('IN_XS', true);
39 include_once('xs_include.' . $phpEx);
41 $template->assign_block_vars('nav_left',array('ITEM' => '» <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']);
49 if(isset($HTTP_GET_VARS['remove']) && !defined('DEMO_MODE'))
51 $remove_id = intval($HTTP_GET_VARS['remove']);
52 if($board_config['default_style'] == $remove_id)
54 xs_error(str_replace('{URL}', append_sid('xs_styles.'.$phpEx), $lang['xs_uninstall_default']) . '<br /><br />' . $lang['xs_uninstall_back']);
56 $sql = "SELECT themes_id, template_name, style_name FROM " . THEMES_TABLE . " WHERE themes_id='{$remove_id}'";
57 if(!$result = $db->sql_query($sql))
59 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_uninstall_back'], __LINE__, __FILE__);
61 $row = $db->sql_fetchrow($result);
62 if(empty($row['themes_id']))
64 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_uninstall_back'], __LINE__, __FILE__);
66 $sql = "UPDATE " . USERS_TABLE . " SET user_style=NULL WHERE user_style='{$remove_id}'";
68 $sql = "DELETE FROM " . THEMES_TABLE . " WHERE themes_id='{$remove_id}'";
70 $template->assign_block_vars('removed', array());
72 if(!empty($HTTP_GET_VARS['dir']))
74 $HTTP_POST_VARS['remove'] = addslashes($row['template_name']);
78 function remove_all($dir)
85 while(($file = readdir($res)) !== false)
87 if($file !== '.' && $file !== '..')
89 $str = $dir . '/' . $file;
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))
115 xs_ftp_connect(append_sid('xs_uninstall.'.$phpEx), $params, true);
116 $write_local = false;
117 if($ftp === XS_FTP_LOCAL)
120 $write_local_dir = '../templates/';
125 // Generate actions list
128 // chdir to templates directory
130 'command' => 'chdir',
135 'command' => 'chdir',
140 'command' => 'removeall',
147 'command' => 'rmdir',
152 $res = ftp_myexec($actions);
154 echo "\$actions dump:\n\n";
156 echo "\n\n\$ftp_log dump:\n\n";
162 remove_all('../templates/'.$remove);
163 @rmdir('../templates/'.$remove);
165 $template->assign_block_vars('removed', array());
171 // get list of installed styles
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);
181 for($i=0; $i<count($style_rowset); $i++)
183 $item = $style_rowset[$i];
184 $tpl[$item['template_name']][] = $item;
188 foreach($tpl as $tpl => $styles)
190 $row_class = $xs_row_class[$j % 2];
192 $template->assign_block_vars('styles', array(
193 'ROW_CLASS' => $row_class,
194 'TPL' => htmlspecialchars($tpl),
195 'ROWS' => count($styles),
198 if(count($styles) > 1)
200 for($i=0; $i<count($styles); $i++)
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']),
208 $template->assign_block_vars('styles.item.nodelete', array());
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']),
220 $template->assign_block_vars('styles.item.delete', array(
221 'U_DELETE' => append_sid('xs_uninstall.'.$phpEx.'?dir=1&remove='.$styles[$i]['themes_id']),
227 $template->set_filenames(array('body' => XS_TPL_PATH . 'uninstall.tpl'));
228 $template->pparse('body');