Baseline
[www.vanrenterghem.biz.git] / phpBB2_old / admin / xs_download.php
1 <?php
3 /***************************************************************************
4  *                               xs_import.php
5  *                               -------------
6  *   copyright            : (C) 2003, 2004 CyberAlien
7  *   support              : http://www.phpbbstyles.com
8  *
9  *   version              : 2.0.1
10  *
11  *   file revision        : 46
12  *   project revision     : 51
13  *   last modified        : 25 Aug 2004  11:51:48
14  *
15  ***************************************************************************/
17 /***************************************************************************
18  *
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.
23  *
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)
34 {
35         message_die(GENERAL_ERROR, 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');
36 }
38 define('IN_XS', true);
39 include_once('xs_include.' . $phpEx);
41 $template->assign_block_vars('nav_left',array('ITEM' => '&raquo; <a href="' . append_sid('xs_import.'.$phpEx) . '">' . $lang['xs_import_styles'] . '</a>'));
42 $template->assign_block_vars('nav_left',array('ITEM' => '&raquo; <a href="' . append_sid('xs_download.'.$phpEx) . '">' . $lang['xs_download_styles'] . '</a>'));
44 // submit url
45 if(isset($HTTP_GET_VARS['url']) && !defined('DEMO_MODE'))
46 {
47         $id = intval($HTTP_GET_VARS['url']);
48         $var = 'xs_downloads_' . $id;
49         $import_data = array(
50                 'host'          => $HTTP_SERVER_VARS['HTTP_HOST'],
51                 'port'          => $HTTP_SERVER_VARS['SERVER_PORT'],
52                 'url'           => str_replace('xs_download.', 'xs_frameset.', $HTTP_SERVER_VARS['PHP_SELF']),
53                 'session'       => $userdata['session_id'],
54                 'xs'            => $template->xs_versiontxt,
55                 'style'         => STYLE_HEADER_VERSION,
56         );
57         $str = '<form action="' . $board_config[$var] . '" method="post" style="display: inline;" target="main"><input type="hidden" name="data" value="' . htmlspecialchars(serialize($import_data)) . '" /><input type="submit" value="' . $lang['xs_continue'] . '" class="post" /></form>';
58         $message = $lang['xs_import_download_warning'] . '<br /><br />' . $str . '<br /><br />' . str_replace('{URL}', append_sid('xs_download.'.$phpEx), $lang['xs_download_back']);
59         xs_message($lang['Information'], $message);
60 }
63 if(isset($HTTP_GET_VARS['edit']))
64 {
65         $id = intval($HTTP_GET_VARS['edit']);
66         $template->assign_block_vars('edit', array(
67                 'ID'            => $id,
68                 'TITLE'         => $board_config['xs_downloads_title_'.$id],
69                 'URL'           => $board_config['xs_downloads_'.$id]
70                 ));
71 }
73 if(isset($HTTP_POST_VARS['edit']) && !defined('DEMO_MODE'))
74 {
75         $id = intval($HTTP_POST_VARS['edit']);
76         $update = array();
77         if(!empty($HTTP_POST_VARS['edit_delete']))
78         {
79                 // delete link
80                 $total = $board_config['xs_downloads_count'];
81                 $update['xs_downloads_count'] = $total - 1;
82                 for($i=$id; $i<($total-1); $i++)
83                 {
84                         $update['xs_downloads_'.$i] = $update['xs_downloads_'.($i+1)];
85                         $update['xs_downloads_title_'.$i] = $update['xs_downloads_title_'.($i+1)];
86                 }
87                 $update['xs_downloads_'.($total-1)] = '';
88                 $update['xs_downloads_title_'.($total-1)] = '';
89         }
90         else
91         {
92                 $update['xs_downloads_'.$id] = stripslashes($HTTP_POST_VARS['edit_url']);
93                 $update['xs_downloads_title_'.$id] = stripslashes($HTTP_POST_VARS['edit_title']);
94         }
95         foreach($update as $var => $value)
96         {
97                 if(isset($board_config[$var]))
98                 {
99                         $sql = "UPDATE " . CONFIG_TABLE . " SET config_value='" . xs_sql($value) . "' WHERE config_name='" . $var . "'";
100                 }
101                 else
102                 {
103                         $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) VALUES ('" . $var . "', '" . xs_sql($value) . "')";
104                 }
105                 $db->sql_query($sql);
106                 $board_config[$var] = $value;
107         }
110 if(!empty($HTTP_POST_VARS['add_url']) && !defined('DEMO_MODE'))
112         $id = $board_config['xs_downloads_count'];
113         $update = array();
114         $update['xs_downloads_'.$id] = stripslashes($HTTP_POST_VARS['add_url']);
115         $update['xs_downloads_title_'.$id] = stripslashes($HTTP_POST_VARS['add_title']);
116         $update['xs_downloads_count'] = $board_config['xs_downloads_count'] + 1;
117         foreach($update as $var => $value)
118         {
119                 if(isset($board_config[$var]))
120                 {
121                         $sql = "UPDATE " . CONFIG_TABLE . " SET config_value='" . xs_sql($value) . "' WHERE config_name='" . $var . "'";
122                 }
123                 else
124                 {
125                         $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) VALUES ('" . $var . "', '" . xs_sql($value) . "')";
126                 }
127                 $db->sql_query($sql);
128                 $board_config[$var] = $value;
129         }
132 for($i=0; $i<$board_config['xs_downloads_count']; $i++)
134         $row_class = $xs_row_class[$i % 2];
135         $template->assign_block_vars('url', array(
136                 'ROW_CLASS'             => $row_class,
137                 'NUM'                   => $i,
138                 'NUM1'                  => $i + 1,
139                 'URL'                   => htmlspecialchars($board_config['xs_downloads_'.$i]),
140                 'TITLE'                 => htmlspecialchars($board_config['xs_downloads_title_'.$i]),
141                 'U_DOWNLOAD'    => append_sid('xs_download.'.$phpEx.'?url='.$i),
142                 'U_EDIT'                => append_sid('xs_download.'.$phpEx.'?edit='.$i),
143                 ));
146 $template->assign_vars(array(
147         'U_POST'                => append_sid('xs_download.'.$phpEx)
148         ));
150 $template->set_filenames(array('body' => XS_TPL_PATH . 'downloads.tpl'));
151 $template->pparse('body');
152 xs_exit();
154 ?>