Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
ajax.latestversion.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
24
global
$bearsamppLang
,
$bearsamppCore
,
$githubVersionData
;
25
26
$result
= array(
27
'display'
=>
false
,
28
'download'
=>
''
,
29
);
30
31
// Assuming getAppVersion() returns the current version number
32
$bearsamppCurrentVersion
=
$bearsamppCore
->getAppVersion();
33
39
$githubVersionData
=
HttpClient::getLatestVersion
(
APP_GITHUB_LATEST_URL
);
40
Log::debug
(
'GitHub Version Data: '
. print_r(
$githubVersionData
,
true
));
41
42
if
(!empty(
$githubVersionData
)) {
43
Log::debug
(
'GitHub Version Data: '
. print_r(
$githubVersionData
,
true
));
44
}
else
{
45
Log::error
(
'No data available in $githubVersionData'
);
46
}
47
53
if
(
$githubVersionData
===
null
) {
54
Log::error
(
'Failed to retrieve version data from GitHub URL: '
.
APP_GITHUB_LATEST_URL
);
55
echo json_encode(
$result
);
56
return
;
57
}
58
66
$githubLatestVersion
=
$githubVersionData
[
'version'
];
67
$githubLatestVersionUrl
=
$githubVersionData
[
'html_url'
];
// URL of the latest version
68
$githubVersionName
=
$githubVersionData
[
'name'
];
69
Log::debug
(
'Latest version: '
.
$githubLatestVersion
.
' ('
.
$githubLatestVersionUrl
.
')'
);
70
80
if
(version_compare(
$bearsamppCurrentVersion
,
$githubLatestVersion
,
'<'
)) {
81
$result
[
'display'
] =
true
;
82
$result
[
'download'
] .=
'<a role="button" class="btn btn-success fullversionurl" href="'
.
$githubLatestVersionUrl
.
'" target="_blank"><i class="fa-solid fa-cloud-arrow-down"></i> '
;
83
$result
[
'download'
] .=
$bearsamppLang
->getValue(
Lang::DOWNLOAD
) .
' <strong>'
.
APP_TITLE
.
' '
.
$githubVersionName
.
'</strong><br />'
;
84
$result
[
'changelog'
] =
''
;
85
}
86
93
echo json_encode(
$result
);
$result
$result
Definition
ajax.apache.php:19
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppCurrentVersion
$bearsamppCurrentVersion
Definition
ajax.latestversion.php:32
$githubVersionData
global $githubVersionData
Definition
ajax.latestversion.php:24
$githubVersionName
$githubVersionName
Definition
ajax.latestversion.php:68
$githubLatestVersionUrl
$githubLatestVersionUrl
Definition
ajax.latestversion.php:67
$githubLatestVersion
$githubLatestVersion
Definition
ajax.latestversion.php:66
$bearsamppCore
global $bearsamppCore
Definition
ajax.latestversion.php:24
HttpClient\getLatestVersion
static getLatestVersion($url)
Definition
class.httpclient.php:336
Lang\DOWNLOAD
const DOWNLOAD
Definition
class.lang.php:40
Log\debug
static debug($data, $file=null)
Definition
class.log.php:616
Log\error
static error($data, $file=null)
Definition
class.log.php:650
APP_GITHUB_LATEST_URL
const APP_GITHUB_LATEST_URL
Definition
root.php:19
APP_TITLE
const APP_TITLE
Definition
root.php:13
sandbox
core
resources
homepage
ajax
ajax.latestversion.php
Generated by
1.17.0