Location: PHPKode > projects > DantoBB > DantoBB_1-0/sources/admin_version.php
<?php

/*
	Copyright (C) 2009 DantoBB Team
	http://www.dantobb.com
*/

/**
 * ACP version check
 *
 * Gives an interface to check for the latest DantoBB version.
 *
 * @author	DantoBB Team
 * @link	http://www.dantobb.com
 * @license	GPL-2
 * @version	$Revision: 1.0.1 $
 * @copyright	Copyright (C) 2009 DantoBB Team
 * @package	DantoBB
 * @subpackage	ACP
 */

//
// Die when called directly in browser
//
if ( !defined('INCLUDED') )
	exit();

$url = 'http://dantobb.sourceforge.net/latest_version';
$success = false;

if ( !empty($_SESSION['latest_version']) ) {
	
	$success = true;
	
} elseif ( function_exists('curl_init') ) {
	
	//
	// Check using cURL
	//
	$curl = curl_init($url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_HEADER, false);
	$_SESSION['latest_version'] = trim(curl_exec($curl));
	curl_close($curl);
	
	$success = ( !empty($_SESSION['latest_version']) );
	
} elseif ( ini_get('allow_url_fopen') ) {
	
	//
	// Check using fopen()
	//
	$fp = fopen($url, 'r');
	$_SESSION['latest_version'] = trim(fread($fp, 16));
	fclose($fp);
	
	$success = ( !empty($_SESSION['latest_version']) );
	
}

if ( !$success ) {
	
	$content = '<p>'.sprintf($lang['VersionFailed'], '<a href="http://www.dantobb.com/">www.dantobb.com</a>').'</p>';
	
} else {
	
	switch ( version_compare(DANTOBB_VERSION, $_SESSION['latest_version']) ) {
		
		case -1:
			$content = '<h2>'.$lang['VersionNeedUpdateTitle'].'</h2>';
			$content .= '<p><strong>'.sprintf($lang['VersionNeedUpdate'], DANTOBB_VERSION, $_SESSION['latest_version'], '<a href="http://www.dantobb.com/downloads/">www.dantobb.com/downloads/index.php</a>').'</strong></p>';
			break;
		case 1:
			$content = '<h2>'.$lang['VersionBewareDevVersionsTitle'].'</h2>';
			$content .= '<p>'.sprintf($lang['VersionBewareDevVersions'], DANTOBB_VERSION, $_SESSION['latest_version']).'</p>';
			break;
		default:
			$content = '<h2>'.$lang['VersionLatestVersionTitle'].'</h2>';
			$content .= '<p>'.sprintf($lang['VersionLatestVersion'], DANTOBB_VERSION).'</p>';
		
	}
	
}

$admin_functions->create_body('version', $content);

?>
Return current item: DantoBB