-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.php
94 lines (81 loc) · 2.46 KB
/
client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
class client
{
public $client_os = 'unknown';
public $client_version = 'unknown';
public $client_lang = 'unknown';
public $client_test = false;
public $beta = false;
private $failed = false;
private $errmsg = "";
public static function Latest()
{
return "3.4.10";
}
public static function LatestMac()
{
return self::Latest();
}
public static function LatestBeta()
{
return self::Latest(); // no beta atm
}
function Failed()
{
return $this->failed;
}
private function setError($e)
{
$this->errmsg = "<error>ERROR: $e</error>\n";
$this->failed = true;
}
function getErrorMsg()
{
return $this->errmsg;
}
function IsObsolete()
{
if ($this->client_test)
return true;
if ($this->client_os == "huggle-devs")
return false;
return version_compare($this->client_version, $this->getNewVersion(), '<');
}
function getNewVersion()
{
// here can you change the logic to return the latest version based on e.g. os
if ($this->beta)
return self::LatestBeta();
else if ($this->client_os == 'mac')
return self::LatestMac();
return self::Latest();
}
function __construct()
{
if (!isset($_GET['os'])) {
$this->setError("System must be defined");
return;
}
if (!isset($_GET['version'])) {
$this->setError("Version must be defined");
return;
}
if (isset($_GET['test']))
$this->client_test = true;
if (isset($_GET['language']))
$this->client_lang = $_GET['language'];
$this->client_version = preg_replace('/[^a-zA-Z0-9-_\.]/', '', $_GET['version']);
$this->client_os = preg_replace('/[^a-zA-Z0-9-_\.]/', '', $_GET['os']);
if (isset($_GET['notifybeta'])) {
$this->beta = true;
}
}
}