From 39a3c15ae59a374a99bca422d020f2fd026d841c Mon Sep 17 00:00:00 2001 From: pentium10 Date: Sun, 16 Feb 2014 16:43:12 +0200 Subject: [PATCH] check for latest version --- config.php | 9 ++- lib/include.php | 5 ++ lib/tpl/serversList.php | 121 +++++++++++++++++++++++++--------------- src/Storage.php | 6 +- 4 files changed, 93 insertions(+), 48 deletions(-) diff --git a/config.php b/config.php index 3685592..b5917a7 100644 --- a/config.php +++ b/config.php @@ -1,9 +1,16 @@ array(/* 'localhost:11300' */), /** * Saved samples jobs are kept in this file, must be writable */ - 'storage' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'storage.json' + 'storage' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'storage.json', + /** + * Version number + */ + 'version' => '1.4', ); diff --git a/lib/include.php b/lib/include.php index eb23569..d27c6f7 100644 --- a/lib/include.php +++ b/lib/include.php @@ -207,6 +207,11 @@ protected function __init() { $this->servers[] = $server; } } + try { + $storage = new Storage($config['storage']); + } catch (Exception $ex) { + $this->_errors[] = $ex->getMessage(); + } } public function getErrors() { diff --git a/lib/tpl/serversList.php b/lib/tpl/serversList.php index 4f2063d..e2e1879 100644 --- a/lib/tpl/serversList.php +++ b/lib/tpl/serversList.php @@ -14,39 +14,40 @@ ); } ?> - + - getServerStats(reset($servers)) as $key => $item):?> - - + getServerStats(reset($servers)) as $key => $item): ?> + + - getServerStats($server); - ?> + getServerStats($server); + ?> - - - - - - $item):?> - - - - - - + + + + + + $item): ?> + + + + + + - +
name  
  
- + @@ -56,15 +57,41 @@

Your servers' list is empty. You could fix it in two ways: -

    -
  1. Click the button below to add server just for you and save it in cookies
  2. -
  3. Edit config.php file and add server for everybody
  4. -
+
    +
  1. Click the button below to add server just for you and save it in cookies
  2. +
  3. Edit config.php file and add server for everybody
  4. +

- +
Add server + array( + 'timeout' => 2, + 'header' => "Accept-language: en\r\n" . + "Cookie: foo=bar\r\n" . // check function.stream-context-create on php.net + "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n" . + "Accept: application/vnd.github.v3+json\r\n", + ) + )); +$json = @file_get_contents($url, false, $ctx); +if ($json) { + $document = json_decode($json, true); + $latest = current($document); + $version = @$latest['name']; + if (version_compare($version, $config['version'])>0) { + ?> +
+
+ A new version is available: Get it from Github +
+