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