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:47
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_update.'.$phpEx) . '">' . $lang['xs_check_for_updates'] . '</a>'));
45 function include_update($filename)
50 $updates = array_merge($updates, $update);
53 if($dir = @opendir($phpbb_root_path. 'templates/'))
55 while($sub_dir = @readdir($dir))
56 if(($sub_dir !== '.') && ($sub_dir !== '..') && ($sub_dir !== 'CVS'))
58 $file = $phpbb_root_path . 'templates/' . $sub_dir . '/xs.cfg';
59 if(@file_exists($file))
61 include_update($file);
67 // check for xs files in acp. mask: xs_*.cfg
68 if($dir = @opendir('.'))
70 while($file = @readdir($dir))
71 if(strlen($file) > 6 && substr($file, 0, 3) === 'xs_' && substr($file, strlen($file) - 4) === '.cfg')
73 include_update($file);
82 xs_error($lang['xs_update_nothing']);
85 // show list of available updates
86 if(!isset($HTTP_GET_VARS['doupdate']))
88 $template->set_filenames(array('body' => XS_TPL_PATH . 'update.tpl'));
89 $template->assign_vars(array(
90 'UPDATE_URL' => append_sid('xs_update.'.$phpEx.'?doupdate=1'),
91 'L_XS_UPDATE_TOTAL1' => str_replace('{NUM}', count($updates), $lang['xs_update_total1']),
96 foreach($updates as $var => $item)
99 $type = isset($lang['xs_update_types'][$item['update_type']]) ? $item['update_type'] : 0;
100 $row_class = $xs_row_class[$counter % 2];
101 $template->assign_block_vars('row',
103 'ROW_CLASS' => $row_class,
105 'VAR' => 'item_'.$counter.'_',
106 'ITEM' => htmlspecialchars($var),
107 'NAME' => htmlspecialchars($item['update_name']),
108 'TYPE' => $lang['xs_update_types'][$type],
109 'URL' => htmlspecialchars($item['update_url']),
110 'VERSION' => htmlspecialchars($item['update_version'])
113 $template->assign_block_vars('row.'.(empty($item['update_url']) ? 'nourl' : 'url'), array());
115 $template->pparse('body');
121 // getting list of items to update
126 foreach($updates as $var1 => $item)
129 $var = 'item_'.$i.'_';
130 if(!empty($HTTP_POST_VARS[$var.'item']) && !empty($HTTP_POST_VARS[$var.'checked']) && $HTTP_POST_VARS[$var.'checked'])
132 $item = $HTTP_POST_VARS[$var.'item'];
133 if(!empty($updates[$item]['update_url']))
137 $url = $updates[$item]['update_url'];
138 for($j=0; $j<count($urls) && !$found; $j++)
140 if($urls[$j] === $url)
151 if(isset($updates[$var1]['data']))
153 unset($updates[$var1]['data']);
157 // showing error message if there is nothing to update
160 xs_error($lang['xs_update_nothing']);
163 @set_time_limit(intval($HTTP_POST_VARS['timeout']));
166 for($i=0; $i<count($urls); $i++)
168 $arr = @file($urls[$i]);
171 // cannot connect. show it as error message
173 for($j=0; $j<count($items); $j++)
175 $item = $updates[$items[$j]];
176 if($item['update_url'] === $urls[$i])
178 $updates[$items[$j]]['data']['error'] = $lang['xs_update_error_noconnect'];
184 for($j=0; $j<count($arr); $j++)
185 { // trim all lines and replace tab with space
186 $arr[$j] = trim(str_replace("\t", ' ', $arr[$j]));
188 // checking all items to see which ones are for this url
189 for($j=0; $j<count($items); $j++)
191 $item = $updates[$items[$j]];
192 if($item['update_url'] === $urls[$i])
194 // searching for data for this item
195 $begin_text = '<!-- BEGIN ' . $item['update_item'] . ' -->';
196 $end_text = '<!-- END ' . $item['update_item'] . ' -->';
199 // getting begin and end tags for it
200 for($k=0; ($k<count($arr)-1) && ($begin_pos < 0); $k++)
202 if($arr[$k] === $begin_text)
205 for(; ($k<count($arr)) && ($end_pos < 0); $k++)
207 if($arr[$k] === $end_text)
214 $end_pos = count($arr);
219 // found item position in text
222 // getting all data for this item in array
223 for($k=$begin_pos+1; $k<$end_pos; $k++)
225 $arr2 = explode(' ', $arr[$k], 2);
226 if(count($arr2) == 2)
228 $data[trim($arr2[0])] = trim($arr2[1]);
234 $data['error'] = $lang['xs_update_error_noitem'];
236 $updates[$items[$j]]['data'] = $data;
242 $template->set_filenames(array('body' => XS_TPL_PATH . 'update2.tpl'));
248 foreach($updates as $var => $item)
250 if(isset($item['data']) && is_array($item['data']))
253 $type = isset($lang['xs_update_types'][$item['update_type']]) ? $item['update_type'] : 0;
254 $ver1 = htmlspecialchars($item['update_version']);
255 $row_class = $xs_row_class[$count_total % 2];
256 $template->assign_block_vars('row',
258 'ROW_CLASS' => $row_class,
259 'ITEM' => htmlspecialchars($item['update_name']),
260 'TYPE' => $lang['xs_update_types'][$type],
264 if(!empty($item['data']['version']))
266 $ver2 = htmlspecialchars($item['data']['version']);
267 $info = isset($item['data']['info']) ? $item['data']['info'] : '';
268 if($ver2 !== $ver1 && (!empty($item['data']['update']) || !empty($item['data']['autoupdate'])))
271 $u_import = (isset($item['data']['style']) && substr($item['data']['style'], 0, 7) === 'http://') ? append_sid('xs_import.'.$phpEx.'?get_web=' . urlencode($item['data']['style'])) : '';
272 $template->assign_block_vars('row.update',
274 'NUM' => $count_total,
276 'UPDATE' => isset($item['data']['update']) ? htmlspecialchars($item['data']['update']) : '',
277 'U_IMPORT' => $u_import,
278 'INFO' => htmlspecialchars($info),
281 $template->assign_block_vars('row.update.' . (empty($item['data']['update']) ? 'noupdate' : 'updated'), array());
282 $template->assign_block_vars('row.update.' . (empty($item['data']['info']) ? 'noinfo' : 'info'), array());
283 $template->assign_block_vars('row.update.' . (empty($u_import) ? 'noimport' : 'import'), array());
287 $template->assign_block_vars('row.noupdate',
290 'MESSAGE' => $lang['xs_update_noupdate'],
291 'INFO' => empty($info) ? '' : htmlspecialchars($info),
294 $template->assign_block_vars('row.noupdate.' . (empty($item['data']['info']) ? 'noinfo' : 'info'), array());
299 if(empty($item['data']['error']))
301 $item['data']['error'] = $lang['xs_update_error_noitem'];
303 $template->assign_block_vars('row.error', array('ERROR' => htmlspecialchars($item['data']['error'])));
309 $template->assign_vars(
311 'COUNT_TOTAL' => str_replace('{NUM}', $count_total, $lang['xs_update_total1']),
312 'COUNT_ERROR' => str_replace('{NUM}', $count_error, $lang['xs_update_total2']),
313 'COUNT_UPDATE' => str_replace('{NUM}', $count_update, $lang['xs_update_total3'])
317 $template->pparse('body');