(2011-10-04, 06:41 PM)MattRogowski Wrote: I think it sends off the GUIDs of the plugins you have, gets the versions for those plugins, and then loops through and checks them.
This is pretty much correct.
Relevant Code:
if($mybb->input['action'] == "check")
{
$plugins_list = get_plugins_list();
$plugins->run_hooks("admin_config_plugins_check");
$info = array();
if($plugins_list)
{
$active_hooks = $plugins->hooks;
foreach($plugins_list as $plugin_file)
{
require_once MYBB_ROOT."inc/plugins/".$plugin_file;
$codename = str_replace(".php", "", $plugin_file);
$infofunc = $codename."_info";
if(!function_exists($infofunc))
{
continue;
}
$plugininfo = $infofunc();
$plugininfo['guid'] = trim($plugininfo['guid']);
if($plugininfo['guid'] != "")
{
$info[] = $plugininfo['guid'];
$names[$plugininfo['guid']] = array('name' => $plugininfo['name'], 'version' => $plugininfo['version']);
}
}
$plugins->hooks = $active_hooks;
}
if(empty($info))
{
flash_message($lang->error_vcheck_no_supported_plugins, 'error');
admin_redirect("index.php?module=config-plugins");
}
$url = "http://mods.mybb.com/version_check.php?";
foreach($info as $guid)
{
$url .= "info[]=".urlencode($guid)."&";
}
$url = substr($url, 0, -1);
require_once MYBB_ROOT."inc/class_xml.php";
$contents = fetch_remote_file($url);
if(!$contents)
{
flash_message($lang->error_vcheck_communications_problem, 'error');
admin_redirect("index.php?module=config-plugins");
}
$parser = new XMLParser($contents);
$tree = $parser->get_tree();
if(array_key_exists('error', $tree['plugins']))
{
switch($tree['plugins'][0]['error'])
{
case "1":
$error_msg = $lang->error_no_input;
break;
case "2":
$error_msg = $lang->error_no_pids;
break;
default:
$error_msg = "";
}
flash_message($lang->error_communication_problem.$error_msg, 'error');
admin_redirect("index.php?module=config-plugins");
}
$table = new Table;
$table->construct_header($lang->plugin);
$table->construct_header($lang->your_version, array("class" => "align_center", 'width' => 125));
$table->construct_header($lang->latest_version, array("class" => "align_center", 'width' => 125));
$table->construct_header($lang->controls, array("class" => "align_center", 'width' => 125));
if(!is_array($tree['plugins']['plugin']))
{
flash_message($lang->success_plugins_up_to_date, 'success');
admin_redirect("index.php?module=config-plugins");
}
if(array_key_exists("tag", $tree['plugins']['plugin']))
{
$only_plugin = $tree['plugins']['plugin'];
unset($tree['plugins']['plugin']);
$tree['plugins']['plugin'][0] = $only_plugin;
}
foreach($tree['plugins']['plugin'] as $plugin)
{
if(version_compare($names[$plugin['attributes']['guid']]['version'], $plugin['version']['value'], "<"))
{
$table->construct_cell("<strong>{$names[$plugin['attributes']['guid']]['name']}</strong>");
$table->construct_cell("{$names[$plugin['attributes']['guid']]['version']}", array("class" => "align_center"));
$table->construct_cell("<strong><span style=\"color: #C00\">{$plugin['version']['value']}</span></strong>", array("class" => "align_center"));
$table->construct_cell("<strong><a href=\"http://mods.mybb.com/view/{$plugin['download_url']['value']}\" target=\"_blank\">{$lang->download}</a></strong>", array("class" => "align_center"));
$table->construct_row();
}
}
if($table->num_rows() == 0)
{
flash_message($lang->success_plugins_up_to_date, 'success');
admin_redirect("index.php?module=config-plugins");
}
$page->add_breadcrumb_item($lang->plugin_updates);
$page->output_header($lang->plugin_updates);
$sub_tabs['plugins'] = array(
'title' => $lang->plugins,
'link' => "index.php?module=config-plugins",
);
$sub_tabs['update_plugins'] = array(
'title' => $lang->plugin_updates,
'link' => "index.php?module=config-plugins&action=check",
'description' => $lang->plugin_updates_desc
);
$sub_tabs['browse_plugins'] = array(
'title' => $lang->browse_plugins,
'link' => "index.php?module=config-plugins&action=browse",
'description' => $lang->browse_plugins_desc
);
$page->output_nav_tabs($sub_tabs, 'update_plugins');
$table->output($lang->plugin_updates);
$page->output_footer();
}