]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2_old/admin/xs_install.php
b0fee4096c69004a8b6b9e79750dde35688191f7
[www.vanrenterghem.biz.git] / phpBB2_old / admin / xs_install.php
1 <?php
3 /***************************************************************************
4  *                              xs_install.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_install.'.$phpEx) . '">' . $lang['xs_install_styles'] . '</a>'));
43 $lang['xs_install_back'] = str_replace('{URL}', append_sid('xs_install.'.$phpEx), $lang['xs_install_back']);
44 $lang['xs_goto_default'] = str_replace('{URL}', append_sid('xs_styles.'.$phpEx), $lang['xs_goto_default']);
46 // remove timeout. useful for forum with 100+ styles
47 @set_time_limit(XS_MAX_TIMEOUT);
49 // install style
50 if(!empty($HTTP_GET_VARS['style']) && !defined('DEMO_MODE'))
51 {
52         $style = stripslashes($HTTP_GET_VARS['style']);
53         $num = intval($HTTP_GET_VARS['num']);
54         $res = xs_install_style($style, $num);
55         if($res)
56         {
57                 if(defined('XS_MODS_CATEGORY_HIERARCHY'))
58                 {
59                         cache_themes();
60                 }
61                 xs_message($lang['Information'], $lang['xs_install_installed'] . '<br /><br />' . $lang['xs_install_back'] . '<br /><br />' . $lang['xs_goto_default']);
62         }
63         xs_error($lang['xs_install_error'] . '<br /><br />' . $lang['xs_install_back']);
64 }
66 // install styles
67 if(!empty($HTTP_POST_VARS['total']) && !defined('DEMO_MODE'))
68 {
69         $tpl = array();
70         $num = array();
71         $total = intval($HTTP_POST_VARS['total']);
72         for($i=0; $i<$total; $i++)
73         {
74                 if(!empty($HTTP_POST_VARS['install_'.$i]))
75                 {
76                         $tpl[] = stripslashes($HTTP_POST_VARS['install_'.$i.'_style']);
77                         $num[] = intval($HTTP_POST_VARS['install_'.$i.'_num']);
78                 }
79         }
80         if(count($tpl))
81         {
82                 for($i=0; $i<count($tpl); $i++)
83                 {
84                         xs_install_style($tpl[$i], $num[$i]);
85                 }
86                 if(defined('XS_MODS_CATEGORY_HIERARCHY'))
87                 {
88                         cache_themes();
89                 }
90                 xs_message($lang['Information'], $lang['xs_install_installed'] . '<br /><br />' . $lang['xs_install_back'] . '<br /><br />' . $lang['xs_goto_default']);
91         }
92 }
95 // get all installed styles
96 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';
97 if(!$result = $db->sql_query($sql))
98 {
99         xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
101 $style_rowset = $db->sql_fetchrowset($result);
103 // find all styles to install
104 $res = @opendir('../templates/');
105 $styles = array();
106 while(($file = readdir($res)) !== false)
108         if($file !== '.' && $file !== '..' && @file_exists('../templates/'.$file.'/theme_info.cfg') && @file_exists('../templates/'.$file.'/'.$file.'.cfg'))
109         {
110                 $arr = xs_get_themeinfo($file);
111                 for($i=0; $i<count($arr); $i++)
112                 {
113                         if(isset($arr[$i]['template_name']) && $arr[$i]['template_name'] === $file)
114                         {
115                                 $arr[$i]['num'] = $i;
116                                 $style = $arr[$i]['style_name'];
117                                 $found = false;
118                                 for($j=0; $j<count($style_rowset); $j++)
119                                 {
120                                         if($style_rowset[$j]['style_name'] == $style)
121                                         {
122                                                 $found = true;
123                                         }
124                                 }
125                                 if(!$found)
126                                 {
127                                         $styles[$arr[$i]['style_name']] = $arr[$i];
128                                 }
129                         }
130                 }
131         }
133 closedir($res);
135 if(!count($styles))
137         xs_message($lang['Information'], $lang['xs_install_none'] . '<br /><br />' . $lang['xs_goto_default']);
140 ksort($styles);
142 $j = 0;
143 foreach($styles as $var => $value)
145         $row_class = $xs_row_class[$j % 2];
146         $template->assign_block_vars('styles', array(
147                         'ROW_CLASS'     => $row_class,
148                         'STYLE'         => htmlspecialchars($value['template_name']),
149                         'THEME'         => htmlspecialchars($value['style_name']),
150                         'U_INSTALL'     => append_sid('xs_install.'.$phpEx.'?style='.urlencode($value['template_name']).'&num='.$value['num']),
151                         'CB_NAME'       => 'install_'.$j,
152                         'NUM'           => $value['num'],
153                 )
154         );
155         $j++;
158 $template->assign_vars(array(
159         'U_INSTALL'             => append_sid('xs_install.'.$phpEx),
160         'TOTAL'                 => count($styles)
161         ));
163 $template->set_filenames(array('body' => XS_TPL_PATH . 'install.tpl'));
164 $template->pparse('body');
165 xs_exit();
167 ?>