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_export_data.'.$phpEx) . '">' . $lang['xs_edit_styles_data'] . '</a>'));
\r
43 $lang['xs_export_data_back'] = str_replace('{URL}', append_sid('xs_export_data.'.$phpEx), $lang['xs_export_data_back']);
\r
48 if(isset($HTTP_GET_VARS['export']))
\r
50 $export = str_replace(array('\\', '/'), array('',''), stripslashes($HTTP_GET_VARS['export']));
\r
51 // get list of themes for style
\r
52 $sql = "SELECT themes_id, style_name FROM " . THEMES_TABLE . " WHERE template_name = '$export' ORDER BY style_name ASC";
\r
53 if(!$result = $db->sql_query($sql))
\r
55 xs_error($lang['xs_no_theme_data'] . '<br /><br />' . $lang['xs_export_data_back']);
\r
57 $theme_rowset = $db->sql_fetchrowset($result);
\r
58 if(count($theme_rowset) == 0)
\r
60 xs_error($lang['xs_no_themes'] . '<br /><br />' . $lang['xs_export_data_back']);
\r
62 if(count($theme_rowset) == 1)
\r
64 $HTTP_POST_VARS['export'] = $HTTP_GET_VARS['export'];
\r
65 $HTTP_POST_VARS['export_total'] = '1';
\r
66 $HTTP_POST_VARS['export_id_0'] = $theme_rowset[0]['themes_id'];
\r
67 $HTTP_POST_VARS['export_check_0'] = 'checked';
\r
71 $template->set_filenames(array('body' => XS_TPL_PATH . 'export_data2.tpl'));
\r
72 $template->assign_vars(array(
\r
73 'TOTAL' => count($theme_rowset),
\r
74 'EXPORT' => htmlspecialchars($export),
\r
75 'U_ACTION' => append_sid("xs_export_data.{$phpEx}")
\r
78 for($i=0; $i<count($theme_rowset); $i++)
\r
80 $row_class = $xs_row_class[$i % 2];
\r
81 $template->assign_block_vars('styles', array(
\r
82 'ROW_CLASS' => $row_class,
\r
84 'ID' => $theme_rowset[$i]['themes_id'],
\r
85 'STYLE' => htmlspecialchars($theme_rowset[$i]['style_name'])
\r
89 $template->pparse('body');
\r
94 if(!empty($HTTP_POST_VARS['export']) && !defined('DEMO_MODE'))
\r
96 $export = xs_tpl_name($HTTP_POST_VARS['export']);
\r
97 // get ftp configuration
\r
98 $params = array('export' => $export);
\r
99 $total = intval($HTTP_POST_VARS['export_total']);
\r
101 for($i=0; $i<$total; $i++)
\r
103 if(!empty($HTTP_POST_VARS['export_check_'.$i]))
\r
105 $params['export_id_'.$count] = intval($HTTP_POST_VARS['export_id_'.$i]);
\r
106 $params['export_check_'.$count] = 'checked';
\r
110 $params['export_total'] = $count;
\r
113 xs_error($lang['xs_export_noselect_themes'] . '<br /><br />' . $lang['xs_export_data_back']);
\r
115 $write_local = false;
\r
116 if(!get_ftp_config(append_sid('xs_export_data.'.$phpEx), $params, true))
\r
120 xs_ftp_connect(append_sid('xs_export_data.'.$phpEx), $params, true);
\r
121 if($ftp === XS_FTP_LOCAL)
\r
123 $write_local = true;
\r
124 $local_filename = '../templates/'. $export . '/theme_info.cfg';
\r
128 $local_filename = XS_TEMP_DIR . 'export_' . time() . '.tmp';
\r
130 // get all themes for style
\r
131 $export_list = array();
\r
132 for($i=0; $i<$total; $i++)
\r
134 if(!empty($HTTP_POST_VARS['export_check_'.$i]))
\r
136 $export_list[] = intval($HTTP_POST_VARS['export_id_'.$i]);
\r
139 $sql = "SELECT * FROM " . THEMES_TABLE . " WHERE themes_id IN (" . implode(', ', $export_list) . ") ORDER BY style_name ASC";
\r
140 if(!$result = $db->sql_query($sql))
\r
142 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_export_data_back'], __LINE__, __FILE__);
\r
144 $style_rowset = $db->sql_fetchrowset($result);
\r
145 if(!count($style_rowset))
\r
147 xs_error($lang['xs_no_style_info'] . '<br /><br />' . $lang['xs_export_data_back'], __LINE__, __FILE__);
\r
149 $data = xs_generate_themeinfo($style_rowset, $export, $export, 0);
\r
150 $f = @fopen($local_filename, 'wb');
\r
153 xs_error(str_replace('{FILE}', $local_filename, $lang['xs_error_cannot_create_file']) . '<br /><br />' . $lang['xs_export_data_back']);
\r
159 xs_message($lang['Information'], $lang['xs_export_data_saved'] . '<br /><br />' . $lang['xs_export_data_back']);
\r
161 // generate ftp actions
\r
162 $actions = array();
\r
163 // chdir to template directory
\r
164 $actions[] = array(
\r
165 'command' => 'chdir',
\r
166 'dir' => 'templates'
\r
168 $actions[] = array(
\r
169 'command' => 'chdir',
\r
172 $actions[] = array(
\r
173 'command' => 'upload',
\r
174 'local' => $local_filename,
\r
175 'remote' => 'templates/' . $export . '/theme_info.cfg'
\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
186 @unlink($local_filename);
\r
189 xs_message($lang['Information'], $lang['xs_export_data_saved'] . '<br /><br />' . $lang['xs_export_data_back']);
\r
191 xs_error($ftp_error . '<br /><br />' . $lang['xs_export_data_back']);
\r
197 $template->set_filenames(array('body' => XS_TPL_PATH . 'export_data.tpl'));
\r
199 // get list of installed styles
\r
201 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';
\r
202 if(!$result = $db->sql_query($sql))
\r
204 xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
\r
206 $style_rowset = $db->sql_fetchrowset($result);
\r
210 $style_names = array();
\r
212 for($i=0; $i<count($style_rowset); $i++)
\r
214 $item = $style_rowset[$i];
\r
215 if($item['template_name'] === $prev_tpl)
\r
217 $style_names[] = htmlspecialchars($item['style_name']);
\r
223 $str = implode('<br />', $style_names);
\r
224 $str2 = urlencode($prev_tpl);
\r
225 $row_class = $xs_row_class[$j % 2];
\r
227 $template->assign_block_vars('styles', array(
\r
228 'ROW_CLASS' => $row_class,
\r
229 'TPL' => $prev_tpl,
\r
231 'U_EXPORT' => "xs_export_data.{$phpEx}?export={$str2}&sid={$userdata['session_id']}",
\r
235 $prev_id = $item['themes_id'];
\r
236 $prev_tpl = $item['template_name'];
\r
237 $style_names = array(htmlspecialchars($item['style_name']));
\r
243 $str = implode('<br />', $style_names);
\r
244 $str2 = urlencode($prev_tpl);
\r
245 $row_class = $xs_row_class[$j % 2];
\r
247 $template->assign_block_vars('styles', array(
\r
248 'ROW_CLASS' => $row_class,
\r
249 'TPL' => $prev_tpl,
\r
251 'U_EXPORT' => "xs_export_data.{$phpEx}?export={$str2}&sid={$userdata['session_id']}",
\r
256 $template->pparse('body');
\r