-
-
Notifications
You must be signed in to change notification settings - Fork 408
/
versioncheck.php
82 lines (67 loc) · 1.97 KB
/
versioncheck.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
<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
function task_versioncheck($task)
{
global $cache, $lang, $mybb;
$current_version = rawurlencode($mybb->version_code);
$updated_cache = array(
'last_check' => TIME_NOW
);
// Check for the latest version
require_once MYBB_ROOT.'inc/class_xml.php';
$contents = fetch_remote_file("https://mybb.com/version_check.php");
if(!$contents)
{
add_task_log($task, $lang->task_versioncheck_ran_errors);
return false;
}
$contents = trim($contents);
$parser = new XMLParser($contents);
$tree = $parser->get_tree();
$latest_code = (int)$tree['mybb']['version_code']['value'];
$latest_version = "<strong>".htmlspecialchars_uni($tree['mybb']['latest_version']['value'])."</strong> (".$latest_code.")";
if($latest_code > $mybb->version_code)
{
$latest_version = "<span style=\"color: #C00;\">".$latest_version."</span>";
$version_warn = 1;
$updated_cache['latest_version'] = $latest_version;
$updated_cache['latest_version_code'] = $latest_code;
}
else
{
$latest_version = "<span style=\"color: green;\">".$latest_version."</span>";
}
// Check for the latest news
require_once MYBB_ROOT."inc/class_feedparser.php";
$feed_parser = new FeedParser();
$feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
$updated_cache['news'] = array();
require_once MYBB_ROOT . '/inc/class_parser.php';
$post_parser = new postParser();
if($feed_parser->error == '')
{
foreach($feed_parser->items as $item)
{
if (isset($updated_cache['news'][2]))
{
break;
}
$updated_cache['news'][] = array(
'title' => $item['title'],
'description' => $item['description'],
'link' => $item['link'],
'author' => $item['author'],
'dateline' => $item['date_timestamp']
);
}
}
$cache->update("update_check", $updated_cache);
add_task_log($task, $lang->task_versioncheck_ran);
}