<?php
/*
 ########################################################################
#                                                                        #
#           Version 4       /                        /   /               #
#          -----------__---/__---__------__----__---/---/-               #
#           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
#          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
#                       Free Content / Management System                 #
#                                   /                                    #
#                                                                        #
#                                                                        #
#   Copyright 2005-2006 by webspell.org                                  #
#                                                                        #
#   visit webSPELL.org, webspell.info to get webSPELL for free           #
#   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
#   - It's NOT allowed to remove this copyright-tag                      #
#   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
#                                                                        #
#   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
#   Far Development by Development Team - webspell.org                   #
#                                                                        #
#   visit webspell.org                                                   #
#                                                                        #
 ########################################################################
*/

if(!isanyadmin($userID) OR substr(basename($_SERVER[REQUEST_URI]),0,15) != "admincenter.php") die('Access denied.');
//Where to get the newest WebSPELL from? (standard: http://update.webspell.org/)
$updateserver = "http://update.webspell.org/";

// reading version
include('../version.php');

if(!$_GET['action']) {

 if(!$getnew = file_get_contents($updateserver."index.php?show=version")) { echo '<i>Server not update-compatible or file at '.$updateserver.' not available.</i>'; }else{

  $latest = explode(".",$getnew);
  $ownversion = explode(".",$version);

  if($latest[0]>$ownversion[0]) echo '<a href="admincenter.php?site=update&action=update"><p style="color:#EE0000">New WebSPELL-Version available!</p></a>';
  elseif($latest[0]==$ownversion[0] AND $latest[1]>$ownversion[1]) echo '<a href="admincenter.php?site=update&action=update"><p>New functions for webSPELL'.$version[0].' available!</p></a>';
  elseif($latest[0]==$ownversion[0] AND $latest[1]==$ownversion[1] AND $latest[2]>$ownversion[2]) echo '<a href="admincenter.php?site=update&action=update"><p>New updates for webSPELL'.$version[0].' available!</p></a>';
 }

} elseif($_GET['action'] == "update") {

//update server sends update information in following form: package1:updateversion1:additional1.package2:additional2:WritttenBy2..., e.g. members:4.01.30:written by FS

if($getnew = file_get_contents($updateserver."index.php?version=".$version."")) {

 $updates = explode("##",$getnew);

 //get packages

	echo'<h2>webSPELL-update</h2>';

	echo'<table cellpadding="4" cellspacing="1" bgcolor="#999999" width="100%"><tr bgcolor="#CCCCCC"><td class="title" width="20%">filename</td><td class="title" width="10%">version</td><td class="title">information</td></tr><tr><td colspan="4" bgcolor="#EEEEEE"></td></tr><tr> ';


 foreach($updates as $value=>$package) {

  $updateinfo = explode("#",$package);
  //get packageinfos
  if($updateinfo[0]=="noupdates") {
   echo '<tr><td bgcolor="#FFFFFF" colspan="4">no updates available!</td></tr>';
  }else {
   echo '<tr><td bgcolor="#FFFFFF"><a href="'.$updateserver.'?package='.$updateinfo[0].'" target="about:blank">'.$updateinfo[0].'.php</a></td><td bgcolor="#FFFFFF">'.$updateinfo[1].'</td><td bgcolor="#FFFFFF">'.$updateinfo[2].'</td></tr>';
  }
 }
 echo'</table><br>';
 echo '<a href="'.$updateserver.'?get=true">Get the newest webSPELL - Version here!</a>';
}
}
?>

