]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2/admin/xs_install.php
Baseline
[www.vanrenterghem.biz.git] / phpBB2 / admin / xs_install.php
1 <?php\r
2 \r
3 /***************************************************************************\r
4  *                              xs_install.php\r
5  *                              --------------\r
6  *   copyright            : (C) 2003 - 2005 CyberAlien\r
7  *   support              : http://www.phpbbstyles.com\r
8  *\r
9  *   version              : 2.3.1\r
10  *\r
11  *   file revision        : 72\r
12  *   project revision     : 78\r
13  *   last modified        : 05 Dec 2005  13:54:54\r
14  *\r
15  ***************************************************************************/\r
16 \r
17 /***************************************************************************\r
18  *\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
23  *\r
24  ***************************************************************************/\r
25 \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
31 \r
32 // check if mod is installed\r
33 if(empty($template->xs_version) || $template->xs_version !== 8)\r
34 {\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
36 }\r
37 \r
38 define('IN_XS', true);\r
39 include_once('xs_include.' . $phpEx);\r
40 \r
41 $template->assign_block_vars('nav_left',array('ITEM' => '&raquo; <a href="' . append_sid('xs_install.'.$phpEx) . '">' . $lang['xs_install_styles'] . '</a>'));\r
42 \r
43 $lang['xs_install_back'] = str_replace('{URL}', append_sid('xs_install.'.$phpEx), $lang['xs_install_back']);\r
44 $lang['xs_goto_default'] = str_replace('{URL}', append_sid('xs_styles.'.$phpEx), $lang['xs_goto_default']);\r
45 \r
46 // remove timeout. useful for forum with 100+ styles\r
47 @set_time_limit(XS_MAX_TIMEOUT);\r
48 \r
49 // install style\r
50 if(!empty($HTTP_GET_VARS['style']) && !defined('DEMO_MODE'))\r
51 {\r
52         $style = stripslashes($HTTP_GET_VARS['style']);\r
53         $num = intval($HTTP_GET_VARS['num']);\r
54         $res = xs_install_style($style, $num);\r
55         if(defined('REFRESH_NAVBAR'))\r
56         {\r
57                 $template->assign_block_vars('left_refresh', array(\r
58                                 'ACTION'        => append_sid('index.' . $phpEx . '?pane=left')\r
59                         ));\r
60         }\r
61         if($res)\r
62         {\r
63                 if(defined('XS_MODS_CATEGORY_HIERARCHY'))\r
64                 {\r
65                         cache_themes();\r
66                 }\r
67                 xs_message($lang['Information'], $lang['xs_install_installed'] . '<br /><br />' . $lang['xs_install_back'] . '<br /><br />' . $lang['xs_goto_default']);\r
68         }\r
69         xs_error($lang['xs_install_error'] . '<br /><br />' . $lang['xs_install_back']);\r
70 }\r
71 \r
72 // install styles\r
73 if(!empty($HTTP_POST_VARS['total']) && !defined('DEMO_MODE'))\r
74 {\r
75         $tpl = array();\r
76         $num = array();\r
77         $total = intval($HTTP_POST_VARS['total']);\r
78         for($i=0; $i<$total; $i++)\r
79         {\r
80                 if(!empty($HTTP_POST_VARS['install_'.$i]))\r
81                 {\r
82                         $tpl[] = stripslashes($HTTP_POST_VARS['install_'.$i.'_style']);\r
83                         $num[] = intval($HTTP_POST_VARS['install_'.$i.'_num']);\r
84                 }\r
85         }\r
86         if(count($tpl))\r
87         {\r
88                 for($i=0; $i<count($tpl); $i++)\r
89                 {\r
90                         xs_install_style($tpl[$i], $num[$i]);\r
91                 }\r
92                 if(defined('REFRESH_NAVBAR'))\r
93                 {\r
94                         $template->assign_block_vars('left_refresh', array(\r
95                                         'ACTION'        => append_sid('index.' . $phpEx . '?pane=left')\r
96                                 ));\r
97                 }\r
98                 if(defined('XS_MODS_CATEGORY_HIERARCHY'))\r
99                 {\r
100                         cache_themes();\r
101                 }\r
102                 xs_message($lang['Information'], $lang['xs_install_installed'] . '<br /><br />' . $lang['xs_install_back'] . '<br /><br />' . $lang['xs_goto_default']);\r
103         }\r
104 }\r
105 \r
106 \r
107 // get all installed styles\r
108 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';\r
109 if(!$result = $db->sql_query($sql))\r
110 {\r
111         xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);\r
112 }\r
113 $style_rowset = $db->sql_fetchrowset($result);\r
114 \r
115 // find all styles to install\r
116 $res = @opendir('../templates/');\r
117 $styles = array();\r
118 while(($file = readdir($res)) !== false)\r
119 {\r
120         if($file !== '.' && $file !== '..' && @file_exists('../templates/'.$file.'/theme_info.cfg') && @file_exists('../templates/'.$file.'/'.$file.'.cfg'))\r
121         {\r
122                 $arr = xs_get_themeinfo($file);\r
123                 for($i=0; $i<count($arr); $i++)\r
124                 {\r
125                         if(isset($arr[$i]['template_name']) && $arr[$i]['template_name'] === $file)\r
126                         {\r
127                                 $arr[$i]['num'] = $i;\r
128                                 $style = $arr[$i]['style_name'];\r
129                                 $found = false;\r
130                                 for($j=0; $j<count($style_rowset); $j++)\r
131                                 {\r
132                                         if($style_rowset[$j]['style_name'] == $style)\r
133                                         {\r
134                                                 $found = true;\r
135                                         }\r
136                                 }\r
137                                 if(!$found)\r
138                                 {\r
139                                         $styles[$arr[$i]['style_name']] = $arr[$i];\r
140                                 }\r
141                         }\r
142                 }\r
143         }\r
144 }\r
145 closedir($res);\r
146 \r
147 if(!count($styles))\r
148 {\r
149         xs_message($lang['Information'], $lang['xs_install_none'] . '<br /><br />' . $lang['xs_goto_default']);\r
150 }\r
151 \r
152 ksort($styles);\r
153 \r
154 $j = 0;\r
155 foreach($styles as $var => $value)\r
156 {\r
157         $row_class = $xs_row_class[$j % 2];\r
158         $template->assign_block_vars('styles', array(\r
159                         'ROW_CLASS'     => $row_class,\r
160                         'STYLE'         => htmlspecialchars($value['template_name']),\r
161                         'THEME'         => htmlspecialchars($value['style_name']),\r
162                         'U_INSTALL'     => append_sid('xs_install.'.$phpEx.'?style='.urlencode($value['template_name']).'&num='.$value['num']),\r
163                         'CB_NAME'       => 'install_'.$j,\r
164                         'NUM'           => $value['num'],\r
165                 )\r
166         );\r
167         $j++;\r
168 }\r
169 \r
170 $template->assign_vars(array(\r
171         'U_INSTALL'             => append_sid('xs_install.'.$phpEx),\r
172         'TOTAL'                 => count($styles)\r
173         ));\r
174 \r
175 $template->set_filenames(array('body' => XS_TPL_PATH . 'install.tpl'));\r
176 $template->pparse('body');\r
177 xs_exit();\r
178 \r
179 ?>