mirror of
https://github.com/typecho/typecho.git
synced 2025-03-20 01:49:40 +01:00
最后检查
This commit is contained in:
parent
5b561a246c
commit
8c6eeb8b42
@ -43,11 +43,11 @@ class Widget_Ajax extends Widget_Abstract_Options implements Widget_Interface_Do
|
||||
$client = Typecho_Http_Client::get();
|
||||
if ($client) {
|
||||
$client->setHeader('User-Agent', $this->options->generator)
|
||||
->send('http://code.google.com/feeds/p/typecho/downloads/basic');
|
||||
->send('https://github.com/typecho/typecho/releases.atom');
|
||||
|
||||
/** 匹配内容体 */
|
||||
$response = $client->getResponseBody();
|
||||
preg_match_all("/<link[^>]*href=\"([^>]*)\"\s*\/>\s*<title>([^>]*)<\/title>/is", $response, $matches);
|
||||
preg_match_all("/<link rel=\"alternate\"[^>]+href=\"([^>]*)\"\s*\/>/is", $response, $matches);
|
||||
$result = array('available' => 0);
|
||||
|
||||
list($soft, $version) = explode(' ', $this->options->generator);
|
||||
@ -55,12 +55,16 @@ class Widget_Ajax extends Widget_Abstract_Options implements Widget_Interface_Do
|
||||
|
||||
if ($matches) {
|
||||
foreach ($matches[0] as $key => $val) {
|
||||
$title = trim($matches[2][$key]);
|
||||
if (preg_match("/([0-9\.]+)\(([0-9\.]+)\)\-release/is", $title, $out)) {
|
||||
$title = trim($matches[1][$key]);
|
||||
if (preg_match("/v([0-9\.]+)\-([0-9\.]+)\-release$/is", $title, $out)) {
|
||||
if (version_compare($out[1], $current[0], '>=')
|
||||
&& version_compare($out[2], $current[1], '>')) {
|
||||
$result = array('available' => 1, 'latest' => $out[1] . '-' . $out[2],
|
||||
'current' => $current[0] . '-' . $current[1], 'link' => $matches[1][$key]);
|
||||
$result = array(
|
||||
'available' => 1,
|
||||
'latest' => $out[1] . '-' . $out[2],
|
||||
'current' => $current[0] . '-' . $current[1],
|
||||
'link' => 'https://github.com' . $matches[1][$key]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user