Skip to content

Commit

Permalink
feat: add update_checker
Browse files Browse the repository at this point in the history
If an update is available, then some nice, red text appears to tell the user.
  • Loading branch information
TGRHavoc committed May 17, 2019
1 parent 537f16e commit 5e81393
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
19 changes: 16 additions & 3 deletions index.php
Expand Up @@ -25,6 +25,7 @@
require_once("utils/minifier.php");
require_once("utils/config.php");
require_once("utils/params.php");
require_once("utils/update_checker.php");

$config = Config::getConfig();
$parser = ParamParser::getParser();
Expand Down Expand Up @@ -137,11 +138,13 @@
<body>

<nav class="navbar navbar-default-invert navbar-static-top" style="margin: 0;">
<!-- At some point, I'll add more stuff here. For the time being, it'll just be the site logo -->
<div class="container-fluid">
<div class="container">
<div class="navbar-brand" style="padding: 10px 15px">
<a href="https://identityrp.co.uk">
<img src="https://identityrp.co.uk/assets/logo-pmx43bj0.png" style="max-height: 30px" >
<!-- You can change this shit -->
<a href="https://github.com/TGRHavoc/">
<img src="https://avatars1.githubusercontent.com/u/1770893?s=460&v=4" style="max-height: 30px" >
</a>
</div>
</div>
Expand Down Expand Up @@ -197,7 +200,17 @@
</ul>
</div>

<p style="color: black; text-align: center;">This was originaly created for <a href="https://identityrp.co.uk">IdentityRP</a></p>
<p style="color: black; text-align: center;">This was originaly created by <a href="https://github.com/TGRHavoc">Havoc</a></p>

<?php
if (!Update::latestVersion()){
// If not the latest version, tell them
?>
<p style="color: red; text-align: center; font-weight: 700;">An update is available, please download it <a href="https://github.com/TGRHavoc/live_map-interface">HERE</a></p>
<?php
}
?>

</div>
</div>

Expand Down
16 changes: 16 additions & 0 deletions utils/update_checker.php
@@ -0,0 +1,16 @@
<?php

class Update{

private static $version = "2.1.1";
private static $url = "https://gist.githubusercontent.com/TGRHavoc/581ec66730b7abafe49ab616db87b0bb/raw/f27c6f2573dd1df0692f97c78a73f5687d20f791/live_map.versions";

public static function latestVersion(){
$data = file_get_contents(self::$url);
$data = json_decode($data);

return $data->interface == self::$version;
}
}

?>

0 comments on commit 5e81393

Please sign in to comment.