Merge pull request #138 from akshay9/master

Auto Update Script 2.0
This commit is contained in:
yi12345
2012-09-12 11:57:30 -07:00
+75 -62
View File
@@ -1,62 +1,75 @@
<?php <?php
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
include_once('ver.tpl'); include('ver.tpl');
if(isset($_GET['c'])) if(isset($_GET['c']))
{ {
copy("http://travian.gamingcrazy.net/Update/update_latest.tpl", "Templates/update_latest.tpl"); copy("http://travian.gamingcrazy.net/Update/update_latest.tpl", "Templates/update_latest.tpl");
} }
if(isset($_GET['u'])) include('update_latest.tpl');
{ if(isset($_GET['u']))
$dl=$ver+1; {
$file = "http://travian.gamingcrazy.net/Update/$dl.zip"; for ($dl=$ver+1; $dl<=$latest; $dl++)
$newfile = "update.zip"; {
if (!copy($file, $newfile)) $file = "http://travian.gamingcrazy.net/Update/$dl.zip";
{ $newfile = "update.zip";
echo "Failed Update"; if (!copy($file, $newfile))
} {
$zip = new ZipArchive; echo "Update Files of Version $dl were not found.";
if ($zip->open('update.zip') === TRUE) }
{ else
$zip->extractTo('../'); {
$zip->close(); $zip = new ZipArchive;
unlink('update.zip'); if ($zip->open('update.zip') === TRUE)
header("Location: admin.php?p=update&s"); {
} else {echo 'Update Failed';} $zip->extractTo('../');
} $zip->close();
?> unlink('update.zip');
<table id="member" cellpadding="1" cellspacing="1" > echo "Successfully Updated to Version $dl ";;
<thead> }
<tr> else
<th colspan="3">System Updates</th> {
</tr> echo 'Failed to update to Version $dl';
</thead> }
<tbody> }
<tr> }
<td class="hab" colspan="2">Current Version :</td> }
<td class="hab" colspan="1"><font color="red"><?php echo "$ver"; ?></font></td> ?>
</tr> <table id="member" cellpadding="1" cellspacing="1" >
<tr> <thead>
<td class="hab" colspan="2">Latest Version :</td> <tr>
<td class="hab" colspan="1"><font color="red"><?php include('update_latest.tpl'); echo "$latest" ?></font></td> <th colspan="3">System Updates</th>
</tr> </tr>
<tr> </thead>
<td class="hab" colspan="2">Check for Update</td> <tbody>
<td class="hab" colspan="1"><center><a href="?p=update&c"><img src="../img/admin/b/ok1.gif"></a></center></td> <tr>
</tr> <td class="hab" colspan="2">Current Version :</td>
<tr> <td class="hab" colspan="1"><font color="red"><?php include('ver.tpl'); echo "$ver"; ?></font></td>
<td class="hab" colspan="2">Update</td> </tr>
<td class="hab" colspan="1"><?php <tr>
if(isset($_GET['s'])) <td class="hab" colspan="2">Latest Version :</td>
{echo '<font color="red">Update Success</font>';} <td class="hab" colspan="1"><font color="red"><?php echo "$latest"; ?></font></td>
elseif($latest > $ver) </tr>
{echo'<center><a href="?p=update&u"><img src="../img/admin/b/update.png"></a></center>'; } <tr>
else { echo "No updates Avaiable";}?></td> <td class="hab" colspan="2">Check for Update</td>
</tr> <td class="hab" colspan="1"><center><a href="?p=update&c"><img src="../img/admin/b/ok1.gif"></a></center></td>
<tr> </tr>
<td class="hab" colspan="2">Visit Forum</td> <tr>
<td class="hab" colspan="1"><center><a href="http://travian.gamingcrazy.net/forum/"><img src="../img/admin/b/ok1.gif"></a></center></td> <td class="hab" colspan="2">Update</td>
</tr> <td class="hab" colspan="1"><?php
</tbody> if($latest > $ver)
</table> {
<br /><br /> echo'<center><a href="?p=update&u"><img src="../img/admin/b/update.png"></a></center>';
<p><font color="red">Guys don`t forget to register at the forum to receive information of the updates"</font></p> }
else
{
echo "No updates Avaiable";
}
?></td>
</tr>
<tr>
<td class="hab" colspan="2">Visit Forum</td>
<td class="hab" colspan="1"><center><a href="http://travian.gamingcrazy.net/forum/"><img src="../img/admin/b/ok1.gif"></a></center></td>
</tr>
</tbody>
</table><br /><br />
<p><font color="red">Guys don`t forget to register at the forum to receive information of the updates"</font></p>