Auto Update Script 2.0

This commit is contained in:
akshay9
2012-09-12 20:10:08 +05:30
parent 9c29adce25
commit c219225473
+27 -14
View File
@@ -1,27 +1,37 @@
<?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");
} }
include('update_latest.tpl');
if(isset($_GET['u'])) if(isset($_GET['u']))
{ {
$dl=$ver+1; for ($dl=$ver+1; $dl<=$latest; $dl++)
{
$file = "http://travian.gamingcrazy.net/Update/$dl.zip"; $file = "http://travian.gamingcrazy.net/Update/$dl.zip";
$newfile = "update.zip"; $newfile = "update.zip";
if (!copy($file, $newfile)) if (!copy($file, $newfile))
{ {
echo "Failed Update"; echo "Update Files of Version $dl were not found.";
} }
else
{
$zip = new ZipArchive; $zip = new ZipArchive;
if ($zip->open('update.zip') === TRUE) if ($zip->open('update.zip') === TRUE)
{ {
$zip->extractTo('../'); $zip->extractTo('../');
$zip->close(); $zip->close();
unlink('update.zip'); unlink('update.zip');
header("Location: admin.php?p=update&s"); echo "Successfully Updated to Version $dl ";;
} else {echo 'Update Failed';} }
else
{
echo 'Failed to update to Version $dl';
}
}
}
} }
?> ?>
<table id="member" cellpadding="1" cellspacing="1" > <table id="member" cellpadding="1" cellspacing="1" >
@@ -33,11 +43,11 @@ if(isset($_GET['u']))
<tbody> <tbody>
<tr> <tr>
<td class="hab" colspan="2">Current Version :</td> <td class="hab" colspan="2">Current Version :</td>
<td class="hab" colspan="1"><font color="red"><?php echo "$ver"; ?></font></td> <td class="hab" colspan="1"><font color="red"><?php include('ver.tpl'); echo "$ver"; ?></font></td>
</tr> </tr>
<tr> <tr>
<td class="hab" colspan="2">Latest Version :</td> <td class="hab" colspan="2">Latest Version :</td>
<td class="hab" colspan="1"><font color="red"><?php include('update_latest.tpl'); echo "$latest" ?></font></td> <td class="hab" colspan="1"><font color="red"><?php echo "$latest"; ?></font></td>
</tr> </tr>
<tr> <tr>
<td class="hab" colspan="2">Check for Update</td> <td class="hab" colspan="2">Check for Update</td>
@@ -46,17 +56,20 @@ if(isset($_GET['u']))
<tr> <tr>
<td class="hab" colspan="2">Update</td> <td class="hab" colspan="2">Update</td>
<td class="hab" colspan="1"><?php <td class="hab" colspan="1"><?php
if(isset($_GET['s'])) if($latest > $ver)
{echo '<font color="red">Update Success</font>';} {
elseif($latest > $ver) echo'<center><a href="?p=update&u"><img src="../img/admin/b/update.png"></a></center>';
{echo'<center><a href="?p=update&u"><img src="../img/admin/b/update.png"></a></center>'; } }
else { echo "No updates Avaiable";}?></td> else
{
echo "No updates Avaiable";
}
?></td>
</tr> </tr>
<tr> <tr>
<td class="hab" colspan="2">Visit Forum</td> <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> <td class="hab" colspan="1"><center><a href="http://travian.gamingcrazy.net/forum/"><img src="../img/admin/b/ok1.gif"></a></center></td>
</tr> </tr>
</tbody> </tbody>
</table> </table><br /><br />
<br /><br />
<p><font color="red">Guys don`t forget to register at the forum to receive information of the updates"</font></p> <p><font color="red">Guys don`t forget to register at the forum to receive information of the updates"</font></p>