+++ /dev/null
-<?php\r
-\r
-/***************************************************************************\r
- * xs_export.php\r
- * -------------\r
- * copyright : (C) 2003 - 2005 CyberAlien\r
- * support : http://www.phpbbstyles.com\r
- *\r
- * version : 2.3.1\r
- *\r
- * file revision : 72\r
- * project revision : 78\r
- * last modified : 05 Dec 2005 13:54:54\r
- *\r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- ***************************************************************************/\r
-\r
-define('IN_PHPBB', 1);\r
-$phpbb_root_path = "./../";\r
-$no_page_header = true;\r
-require($phpbb_root_path . 'extension.inc');\r
-require('./pagestart.' . $phpEx);\r
-\r
-// check if mod is installed\r
-if(empty($template->xs_version) || $template->xs_version !== 8)\r
-{\r
- 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
-}\r
-\r
-define('IN_XS', true);\r
-include_once('xs_include.' . $phpEx);\r
-\r
-$template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_export.'.$phpEx) . '">' . $lang['xs_export_styles'] . '</a>'));\r
-\r
-$lang['xs_export_back'] = str_replace('{URL}', append_sid('xs_export.'.$phpEx), $lang['xs_export_back']);\r
-\r
-//\r
-// Check required functions\r
-//\r
-if(!@function_exists('gzcompress'))\r
-{\r
- xs_error($lang['xs_import_nogzip']);\r
-}\r
-\r
-\r
-//\r
-// Export page\r
-//\r
-$export = isset($HTTP_GET_VARS['export']) ? $HTTP_GET_VARS['export'] : '';\r
-$export = xs_tpl_name($export);\r
-if(!empty($export) && @file_exists($phpbb_root_path . $template_dir . $export . '/theme_info.cfg'))\r
-{\r
- // Get list of styles\r
- $sql = "SELECT themes_id, style_name FROM " . THEMES_TABLE . " WHERE template_name = '$export' ORDER BY style_name ASC";\r
- if(!$result = $db->sql_query($sql))\r
- {\r
- xs_error($lang['xs_no_theme_data'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- $theme_rowset = $db->sql_fetchrowset($result);\r
- if(count($theme_rowset) == 0)\r
- {\r
- xs_error($lang['xs_no_themes'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- $template->set_filenames(array('body' => XS_TPL_PATH . 'export2.tpl'));\r
- $xs_send_method = isset($board_config['xs_export_data']) ? $board_config['xs_export_data'] : '';\r
- $xs_send = @unserialize($xs_send_method);\r
- $xs_send_method = $xs_send['method'] == 'ftp' ? 'ftp' : ($xs_send['method'] == 'file' ? 'file' : 'save');\r
- $template->assign_vars(array(\r
- 'FORM_ACTION' => append_sid('xs_export.'.$phpEx),\r
- 'EXPORT_TEMPLATE' => htmlspecialchars($export),\r
- 'STYLE_ID' => $theme_rowset[0]['themes_id'],\r
- 'STYLE_NAME' => htmlspecialchars($theme_rowset[0]['style_name']),\r
- 'TOTAL' => count($theme_rowset),\r
- 'SEND_METHOD_'.strtoupper($xs_send_method) => ' checked="checked"',\r
- 'SEND_DATA_DIR' => isset($xs_send['dir']) ? htmlspecialchars($xs_send['dir']) : '',\r
- 'SEND_DATA_HOST' => isset($xs_send['host']) ? htmlspecialchars($xs_send['host']) : '',\r
- 'SEND_DATA_LOGIN' => isset($xs_send['login']) ? htmlspecialchars($xs_send['login']) : '',\r
- 'SEND_DATA_FTPDIR' => isset($xs_send['ftpdir']) ? htmlspecialchars($xs_send['ftpdir']) : '',\r
- 'L_TITLE' => str_replace('{TPL}', $export, $lang['xs_export_style_title']),\r
- ));\r
- if(count($theme_rowset) == 1)\r
- {\r
- $template->assign_block_vars('switch_select_nostyle', array());\r
- }\r
- else\r
- {\r
- $template->assign_block_vars('switch_select_style', array());\r
- for($i=0; $i<count($theme_rowset); $i++)\r
- {\r
- $template->assign_block_vars('switch_select_style.style', array(\r
- 'NUM' => $i,\r
- 'ID' => $theme_rowset[$i]['themes_id'],\r
- 'NAME' => htmlspecialchars($theme_rowset[$i]['style_name'])\r
- ));\r
- }\r
- }\r
- $template->pparse('body');\r
- xs_exit();\r
-}\r
-\r
-//\r
-// Export style\r
-//\r
-$export = isset($HTTP_POST_VARS['export']) ? $HTTP_POST_VARS['export'] : '';\r
-$export = xs_tpl_name($export);\r
-if(!empty($export) && @file_exists($phpbb_root_path . $template_dir . $export . '/theme_info.cfg') && !defined('DEMO_MODE'))\r
-{\r
- $total = intval($HTTP_POST_VARS['total']);\r
- $comment = substr(stripslashes($HTTP_POST_VARS['export_comment']), 0, 255);\r
- $list = array();\r
- for($i=0; $i<$total; $i++)\r
- {\r
- if(!empty($HTTP_POST_VARS['export_style_'.$i]))\r
- {\r
- $list[] = intval($HTTP_POST_VARS['export_style_id_'.$i]);\r
- }\r
- }\r
- if(!count($list))\r
- {\r
- xs_error($lang['xs_export_noselect_themes'] . '<br /><br /> ' . $lang['xs_export_back']);\r
- }\r
- // Export as...\r
- $exportas = empty($HTTP_POST_VARS['export_template']) ? $export : $HTTP_POST_VARS['export_template'];\r
- $exportas = xs_tpl_name($exportas);\r
- // Generate theme_info.cfg\r
- $sql = "SELECT * FROM " . THEMES_TABLE . " WHERE template_name = '$export' AND themes_id IN (" . implode(', ', $list) . ")";\r
- if(!$result = $db->sql_query($sql))\r
- {\r
- xs_error($lang['xs_no_theme_data'] . $lang['xs_export_back']);\r
- }\r
- $theme_rowset = $db->sql_fetchrowset($result);\r
- if(count($theme_rowset) == 0)\r
- {\r
- xs_error($lang['xs_no_themes'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- $theme_data = xs_generate_themeinfo($theme_rowset, $export, $exportas, $total);\r
-\r
- // prepare to pack \r
- $pack_error = '';\r
- $pack_list = array();\r
- $pack_replace = array('./theme_info.cfg' => $theme_data);\r
-\r
- // pack style\r
- for($i=0; $i<count($theme_rowset); $i++)\r
- {\r
- $id = $theme_rowset[$i]['themes_id'];\r
- $theme_name = $theme_rowset[$i]['style_name'];\r
- for($j=0; $j<$total; $j++)\r
- {\r
- if(!empty($HTTP_POST_VARS['export_style_name_'.$j]) && $HTTP_POST_VARS['export_style_id_'.$j] == $id)\r
- {\r
- $theme_name = stripslashes($HTTP_POST_VARS['export_style_name_'.$j]);\r
- }\r
- }\r
- $theme_rowset[$i]['style_name'] = $theme_name;\r
- }\r
- $data = pack_style($export, $exportas, $theme_rowset, $comment);\r
-\r
- // check errors\r
- if($pack_error)\r
- {\r
- xs_error(str_replace('{TPL}', $export, $lang['xs_export_error']) . $pack_error . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- if(!$data)\r
- {\r
- xs_error(str_replace('{TPL}', $export, $lang['xs_export_error2']) . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
-\r
- //\r
- // Got file. Sending it.\r
- //\r
- $send_method = isset($HTTP_POST_VARS['export_to']) ? $HTTP_POST_VARS['export_to'] : '';\r
- $export_filename = empty($HTTP_POST_VARS['export_filename']) ? $exportas . STYLE_EXTENSION : $HTTP_POST_VARS['export_filename'];\r
- if($send_method === 'file')\r
- {\r
- // store on local server\r
- $send_dir = isset($HTTP_POST_VARS['export_to_dir']) ? $HTTP_POST_VARS['export_to_dir'] : '';\r
- $send_dir = str_replace('\\', '/', stripslashes($send_dir));\r
- if(empty($send_dir))\r
- {\r
- $send_dir = XS_TEMP_DIR;\r
- }\r
- if(substr($send_dir, strlen($send_dir) - 1) !== '/')\r
- {\r
- $send_dir .= '/';\r
- }\r
- $filename = $send_dir . $export_filename;\r
- $f = @fopen($filename, 'wb');\r
- if(!$f)\r
- {\r
- xs_error(str_replace('{FILE}', $filename, $lang['xs_error_cannot_create_file']) . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- @fwrite($f, $data);\r
- @fclose($f);\r
- set_export_method('file', array('dir' => $send_dir));\r
- xs_message($lang['Information'], str_replace('{FILE}', $filename, $lang['xs_export_saved']) . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- elseif($send_method === 'ftp')\r
- {\r
- // upload via ftp\r
- $ftp_host = $HTTP_POST_VARS['export_to_ftp_host'];\r
- $ftp_login = $HTTP_POST_VARS['export_to_ftp_login'];\r
- $ftp_pass = $HTTP_POST_VARS['export_to_ftp_pass'];\r
- $ftp_dir = str_replace('\\', '/', $HTTP_POST_VARS['export_to_ftp_dir']);\r
- if($ftp_dir && substr($ftp_dir, strlen($ftp_dir) - 1) !== '/')\r
- {\r
- $ftp_dir .= '/';\r
- }\r
- // save as temporary file\r
- $filename = XS_TEMP_DIR.'tmp_' . time() . '.tmp';\r
- $f = @fopen($filename, 'wb');\r
- if(!$f)\r
- {\r
- xs_error(str_replace('{FILE}', $filename, $lang['xs_error_cannot_create_tmp']) . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- @fwrite($f, $data);\r
- @fclose($f);\r
- // connect to ftp\r
- $ftp = @ftp_connect($ftp_host);\r
- if(!$ftp)\r
- {\r
- @unlink($filename);\r
- xs_error($lang['xs_ftp_error_noconnect'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- $res = @ftp_login($ftp, $ftp_login, $ftp_pass);\r
- if(!$res)\r
- {\r
- @unlink($filename);\r
- xs_error($lang['xs_ftp_error_login2'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- if($ftp_dir)\r
- {\r
- @ftp_chdir($ftp, $ftp_dir);\r
- }\r
- $res = @ftp_put($ftp, $ftp_dir . $export_filename, $filename, FTP_BINARY);\r
- @unlink($filename);\r
- if(!$res)\r
- {\r
- xs_error($lang['xs_export_error_uploading'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- set_export_method('ftp', array('host' => $ftp_host, 'login' => $ftp_login, 'ftpdir' => $ftp_dir));\r
- xs_message($lang['Information'], $lang['xs_export_uploaded'] . '<br /><br />' . $lang['xs_export_back']);\r
- }\r
- // send file\r
- xs_download_file($export_filename, $data, 'application/phpbbstyle');\r
- xs_exit();\r
-}\r
-\r
-$template->set_filenames(array('body' => XS_TPL_PATH . 'export.tpl'));\r
-\r
-//\r
-// get list of installed styles\r
-//\r
-$sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';\r
-if(!$result = $db->sql_query($sql))\r
-{\r
- xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);\r
-}\r
-$style_rowset = $db->sql_fetchrowset($result);\r
-\r
-$prev_id = -1;\r
-$prev_tpl = '';\r
-$style_names = array();\r
-$j = 0;\r
-for($i=0; $i<count($style_rowset); $i++)\r
-{\r
- $item = $style_rowset[$i];\r
- if($item['template_name'] === $prev_tpl)\r
- {\r
- $style_names[] = htmlspecialchars($item['style_name']);\r
- }\r
- else\r
- {\r
- if($prev_id > 0)\r
- {\r
- $str = implode('<br />', $style_names);\r
- $str2 = urlencode($prev_tpl);\r
- $row_class = $xs_row_class[$j % 2];\r
- $j++;\r
- $template->assign_block_vars('styles', array(\r
- 'ROW_CLASS' => $row_class,\r
- 'TPL' => $prev_tpl,\r
- 'STYLES' => $str,\r
- 'U_EXPORT' => "xs_export.{$phpEx}?export={$str2}&sid={$userdata['session_id']}",\r
- )\r
- );\r
- }\r
- $prev_id = $item['themes_id'];\r
- $prev_tpl = $item['template_name'];\r
- $style_names = array(htmlspecialchars($item['style_name']));\r
- }\r
-}\r
-\r
-if($prev_id > 0)\r
-{\r
- $str = implode('<br />', $style_names);\r
- $str2 = urlencode($prev_tpl);\r
- $row_class = $xs_row_class[$j % 2];\r
- $j++;\r
- $template->assign_block_vars('styles', array(\r
- 'ROW_CLASS' => $row_class,\r
- 'TPL' => $prev_tpl,\r
- 'STYLES' => $str,\r
- 'U_EXPORT' => "xs_export.{$phpEx}?export={$str2}&sid={$userdata['session_id']}",\r
- )\r
- );\r
-}\r
-\r
-$template->pparse('body');\r
-xs_exit();\r
-\r
-?>
\ No newline at end of file