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