+++ /dev/null
-<?php\r
-\r
-/***************************************************************************\r
- * xs_update.php\r
- * -------------\r
- * copyright : (C) 2003 - 2005 CyberAlien\r
- * support : http://www.phpbbstyles.com\r
- *\r
- * version : 2.3.1\r
- *\r
- * file revision : 72\r
- * project revision : 78\r
- * last modified : 05 Dec 2005 13:54:54\r
- *\r
- ***************************************************************************/\r
-\r
-/***************************************************************************\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- ***************************************************************************/\r
-\r
-define('IN_PHPBB', 1);\r
-$phpbb_root_path = "./../";\r
-$no_page_header = true;\r
-require($phpbb_root_path . 'extension.inc');\r
-require('./pagestart.' . $phpEx);\r
-\r
-// check if mod is installed\r
-if(empty($template->xs_version) || $template->xs_version !== 8)\r
-{\r
- 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
-}\r
-\r
-define('IN_XS', true);\r
-include_once('xs_include.' . $phpEx);\r
-\r
-$template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_update.'.$phpEx) . '">' . $lang['xs_check_for_updates'] . '</a>'));\r
-\r
-$updates = array();\r
-\r
-function include_update($filename)\r
-{\r
- $update = array();\r
- @include($filename);\r
- global $updates;\r
- $updates = array_merge($updates, $update);\r
-}\r
-\r
-if($dir = @opendir($phpbb_root_path. 'templates/'))\r
-{\r
- while($sub_dir = @readdir($dir))\r
- if(($sub_dir !== '.') && ($sub_dir !== '..') && ($sub_dir !== 'CVS'))\r
- {\r
- $file = $phpbb_root_path . 'templates/' . $sub_dir . '/xs.cfg';\r
- if(@file_exists($file))\r
- {\r
- include_update($file);\r
- }\r
- }\r
- closedir($dir);\r
-}\r
-\r
-// check for xs files in acp. mask: xs_*.cfg\r
-if($dir = @opendir('.'))\r
-{\r
- while($file = @readdir($dir))\r
- if(strlen($file) > 6 && substr($file, 0, 3) === 'xs_' && substr($file, strlen($file) - 4) === '.cfg')\r
- {\r
- include_update($file);\r
- }\r
- closedir($dir);\r
-}\r
-\r
-\r
-// nothing to update\r
-if(!count($updates))\r
-{\r
- xs_error($lang['xs_update_nothing']);\r
-}\r
-\r
-// show list of available updates\r
-if(!isset($HTTP_GET_VARS['doupdate']))\r
-{\r
- $template->set_filenames(array('body' => XS_TPL_PATH . 'update.tpl'));\r
- $template->assign_vars(array(\r
- 'UPDATE_URL' => append_sid('xs_update.'.$phpEx.'?doupdate=1'),\r
- 'L_XS_UPDATE_TOTAL1' => str_replace('{NUM}', count($updates), $lang['xs_update_total1']),\r
- )\r
- );\r
- $counter = 0;\r
- @reset($updates);\r
- foreach($updates as $var => $item)\r
- {\r
- $counter ++;\r
- $type = isset($lang['xs_update_types'][$item['update_type']]) ? $item['update_type'] : 0;\r
- $row_class = $xs_row_class[$counter % 2];\r
- $template->assign_block_vars('row',\r
- array(\r
- 'ROW_CLASS' => $row_class,\r
- 'NUM' => $counter,\r
- 'VAR' => 'item_'.$counter.'_',\r
- 'ITEM' => htmlspecialchars($var),\r
- 'NAME' => htmlspecialchars($item['update_name']),\r
- 'TYPE' => $lang['xs_update_types'][$type],\r
- 'URL' => htmlspecialchars($item['update_url']),\r
- 'VERSION' => htmlspecialchars($item['update_version'])\r
- )\r
- );\r
- $template->assign_block_vars('row.'.(empty($item['update_url']) ? 'nourl' : 'url'), array());\r
- }\r
- $template->pparse('body');\r
- xs_exit();\r
-}\r
-\r
-// check updates.\r
-\r
-// getting list of items to update\r
-@reset($updates);\r
-$urls = array();\r
-$items = array();\r
-$i=0;\r
-foreach($updates as $var1 => $item)\r
-{\r
- $i++;\r
- $var = 'item_'.$i.'_';\r
- if(!empty($HTTP_POST_VARS[$var.'item']) && !empty($HTTP_POST_VARS[$var.'checked']) && $HTTP_POST_VARS[$var.'checked'])\r
- {\r
- $item = $HTTP_POST_VARS[$var.'item'];\r
- if(!empty($updates[$item]['update_url']))\r
- {\r
- $items[] = $var1;\r
- $found = false;\r
- $url = $updates[$item]['update_url'];\r
- for($j=0; $j<count($urls) && !$found; $j++)\r
- {\r
- if($urls[$j] === $url)\r
- {\r
- $found = true;\r
- }\r
- }\r
- if(!$found)\r
- {\r
- $urls[] = $url;\r
- }\r
- }\r
- }\r
- if(isset($updates[$var1]['data']))\r
- {\r
- unset($updates[$var1]['data']);\r
- }\r
-}\r
-\r
-// showing error message if there is nothing to update\r
-if(!count($urls))\r
-{\r
- xs_error($lang['xs_update_nothing']);\r
-}\r
-\r
-@set_time_limit(intval($HTTP_POST_VARS['timeout']));\r
-\r
-// getting data\r
-for($i=0; $i<count($urls); $i++)\r
-{\r
- $arr = @file($urls[$i]);\r
- if(empty($arr))\r
- {\r
- // cannot connect. show it as error message\r
- @reset($items);\r
- for($j=0; $j<count($items); $j++)\r
- {\r
- $item = $updates[$items[$j]];\r
- if($item['update_url'] === $urls[$i])\r
- {\r
- $updates[$items[$j]]['data']['error'] = $lang['xs_update_error_noconnect'];\r
- }\r
- }\r
- }\r
- else\r
- {\r
- for($j=0; $j<count($arr); $j++)\r
- { // trim all lines and replace tab with space\r
- $arr[$j] = trim(str_replace("\t", ' ', $arr[$j]));\r
- }\r
- // checking all items to see which ones are for this url\r
- for($j=0; $j<count($items); $j++)\r
- {\r
- $item = $updates[$items[$j]];\r
- if($item['update_url'] === $urls[$i])\r
- {\r
- // searching for data for this item\r
- $begin_text = '<!-- BEGIN ' . $item['update_item'] . ' -->';\r
- $end_text = '<!-- END ' . $item['update_item'] . ' -->';\r
- $begin_pos = -1;\r
- $end_pos = -1;\r
- // getting begin and end tags for it\r
- for($k=0; ($k<count($arr)-1) && ($begin_pos < 0); $k++)\r
- {\r
- if($arr[$k] === $begin_text)\r
- {\r
- $begin_pos = $k;\r
- for(; ($k<count($arr)) && ($end_pos < 0); $k++)\r
- {\r
- if($arr[$k] === $end_text)\r
- {\r
- $end_pos = $k;\r
- }\r
- }\r
- if($end_pos < 0)\r
- {\r
- $end_pos = count($arr);\r
- }\r
- }\r
- }\r
- $data = array();\r
- // found item position in text\r
- if($begin_pos >= 0)\r
- {\r
- // getting all data for this item in array\r
- for($k=$begin_pos+1; $k<$end_pos; $k++)\r
- {\r
- $arr2 = explode(' ', $arr[$k], 2);\r
- if(count($arr2) == 2)\r
- {\r
- $data[trim($arr2[0])] = trim($arr2[1]);\r
- }\r
- }\r
- }\r
- else\r
- {\r
- $data['error'] = $lang['xs_update_error_noitem'];\r
- }\r
- $updates[$items[$j]]['data'] = $data;\r
- }\r
- }\r
- }\r
-}\r
-\r
-$template->set_filenames(array('body' => XS_TPL_PATH . 'update2.tpl'));\r
-\r
-@reset($updates);\r
-$count_total = 0;\r
-$count_error = 0;\r
-$count_update = 0;\r
-foreach($updates as $var => $item)\r
-{\r
- if(isset($item['data']) && is_array($item['data']))\r
- {\r
- $count_total++;\r
- $type = isset($lang['xs_update_types'][$item['update_type']]) ? $item['update_type'] : 0;\r
- $ver1 = htmlspecialchars($item['update_version']);\r
- $row_class = $xs_row_class[$count_total % 2];\r
- $template->assign_block_vars('row',\r
- array(\r
- 'ROW_CLASS' => $row_class,\r
- 'ITEM' => htmlspecialchars($item['update_name']),\r
- 'TYPE' => $lang['xs_update_types'][$type],\r
- 'VERSION' => $ver1,\r
- )\r
- );\r
- if(!empty($item['data']['version']))\r
- {\r
- $ver2 = htmlspecialchars($item['data']['version']);\r
- $info = isset($item['data']['info']) ? $item['data']['info'] : '';\r
- if($ver2 !== $ver1 && (!empty($item['data']['update']) || !empty($item['data']['autoupdate'])))\r
- {\r
- $count_update++;\r
- $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
- $template->assign_block_vars('row.update',\r
- array(\r
- 'NUM' => $count_total,\r
- 'VERSION' => $ver2,\r
- 'UPDATE' => isset($item['data']['update']) ? htmlspecialchars($item['data']['update']) : '',\r
- 'U_IMPORT' => $u_import,\r
- 'INFO' => htmlspecialchars($info),\r
- )\r
- );\r
- $template->assign_block_vars('row.update.' . (empty($item['data']['update']) ? 'noupdate' : 'updated'), array());\r
- $template->assign_block_vars('row.update.' . (empty($item['data']['info']) ? 'noinfo' : 'info'), array());\r
- $template->assign_block_vars('row.update.' . (empty($u_import) ? 'noimport' : 'import'), array());\r
- }\r
- else\r
- {\r
- $template->assign_block_vars('row.noupdate', \r
- array(\r
- 'VERSION' => $ver2,\r
- 'MESSAGE' => $lang['xs_update_noupdate'],\r
- 'INFO' => empty($info) ? '' : htmlspecialchars($info),\r
- )\r
- );\r
- $template->assign_block_vars('row.noupdate.' . (empty($item['data']['info']) ? 'noinfo' : 'info'), array());\r
- }\r
- }\r
- else\r
- {\r
- if(empty($item['data']['error']))\r
- {\r
- $item['data']['error'] = $lang['xs_update_error_noitem'];\r
- }\r
- $template->assign_block_vars('row.error', array('ERROR' => htmlspecialchars($item['data']['error'])));\r
- $count_error++;\r
- }\r
- }\r
-}\r
-\r
-$template->assign_vars(\r
- array(\r
- 'COUNT_TOTAL' => str_replace('{NUM}', $count_total, $lang['xs_update_total1']),\r
- 'COUNT_ERROR' => str_replace('{NUM}', $count_error, $lang['xs_update_total2']),\r
- 'COUNT_UPDATE' => str_replace('{NUM}', $count_update, $lang['xs_update_total3'])\r
- )\r
-);\r
-\r
-$template->pparse('body');\r
-xs_exit();\r
-\r
-?>
\ No newline at end of file