

This is the source code for the Newest Browser Joomla extension. Plug this Joomla extension in your Joomla CMS to promote your browser of choice to visitors. The lastest numerical version will be shown to visitors, for example Upgrade to "Version 1.1.1". Data is pulled from NewestBrowser.com.
Make suggestions for new features in upcoming versions in the comments below.
This extension is released under GPL: http://www.opensource.org/licenses/gpl-license.php Newest Browser Wordpress Plugin - shows updated version to user's browser or site owner's promoted browser of choice Copyright (C) 2010 CW Web Solutions LLC This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
Newest Browser CW Web Solutions LLC 2010-02-25 All rights reserved by CW Web Solutions LLC 2009. GPL 2.0 support@newestbrowser.com www.chriswashington.net.com 1.0.0 Encourage upgrading to the lastest in technology and security by displaying updates for major browsers your visitor is using, or promote a browser your of choice. Updated are extracted from NewestBrowser.com. install.sql uninstall.sql index.html admin.newestbrowser.php install.sql uninstall.sql
DROP TABLE IF EXISTS `jos_newestbrowser`; CREATE TABLE `jos_newestbrowser` ( `id` INT(1) UNSIGNED NOT NULL AUTO_INCREMENT, `lastupdated` VARCHAR(10) DEFAULT NULL, `win-ie` VARCHAR(25) DEFAULT NULL, `win-opera` VARCHAR(25) DEFAULT NULL, `win-safari` VARCHAR(25) DEFAULT NULL, `win-ff` VARCHAR(25) DEFAULT NULL, `win-chrome` VARCHAR(25) DEFAULT NULL, `mac-safari` VARCHAR(25) DEFAULT NULL, `mac-ff` VARCHAR(25) DEFAULT NULL, `mac-chrome` VARCHAR(25) DEFAULT NULL, `mac-opera` VARCHAR(25) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; INSERT INTO `jos_newestbrowser` (`lastupdated`, `win-ie`, `win-opera`, `win-safari`, `win-ff`, `win-chrome`, `mac-safari`, `mac-ff`, `mac-chrome`, `mac-opera`) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
DROP TABLE IF EXISTS `jos_newestbrowser`;
Newest Browser CW Web Solutions LLC 2010-02-25 All rights reserved by CW Web Solutions LLC 2009 GPL 2.0 support@newestbrowser.com www.chriswashington.net 1.0.0 Encourage upgrading to the lastest in technology and security by displaying updates for major browsers your visitor is using, or promote a browser your of choice. Updated are extracted from NewestBrowser.com. mod_newestbrowser.php index.html helper.php newestbrowser.css tmpl/default.php tmpl/index.html images/icon-chrome.png images/icon-firefox.png images/icon-internet-explorer.png images/icon-opera.png images/icon-safari.png images/icon.png images/logo-black.jpg en-GB.mod_newestbrowser.ini
#cssNewestBrowser {
/* CHANGE FONT SIZE STYLING HERE */
}
#cssNewestBrowser img {
border:none;
padding:0px;
margin:0px;
vertical-align:middle;
}
#cssCWWSClear {
clear:both;
}
PROMOTE=Which browser do you want to promote the lastest version of: DESCRIPTION=Description
<?php
defined('_JEXEC') or die('Access Denied');
class ModNewestBrowserHelper {
public $id;
public $lastupdated;
public $win_ie;
public $win_opera;
public $win_safari;
public $win_ff;
public $win_chrome;
public $mac_safari;
public $mac_ff;
public $mac_chrome;
public $mac_opera;
public function GetNewestBrowser($strPromote) {
$db =& JFactory::getDBO();
$query = "SELECT * FROM `jos_newestbrowser` WHERE `id` = '1'";
$db->setQuery($query);
$row = $db->loadRow();
$lastupdated = $row['1'];
$win_ie = $row['2'];
$win_opera = $row['3'];
$win_safari = $row['4'];
$win_ff = $row['5'];
$win_chrome = $row['6'];
$mac_safari = $row['7'];
$mac_ff = $row['8'];
$mac_chrome = $row['9'];
$mac_opera = $row['10'];
// FIRST SEE IF YOU HAVE TODAY'S VERION FROM REMOTE XML FILE, IF NOT GO GET IT ONLY ONCE A DAY
if($lastupdated == "" || $lastupdated != date('m/d/Y')) {
$strPass = 'HTTP/1.1 200 OK';
$strVersion = "http://www.newestbrowser.com/versions.xml";
$arrayResults = get_headers($strVersion);
$strXML = simplexml_load_file($strVersion);
if ($arrayResults[0] == $strPass && $strXML != "") {
// LOOP THROUGH XML TO GET ALL DATA THEN SAVE INTO DATABASE
foreach($strXML->children() as $child) {
foreach($child->children() as $grandchild) {
switch($grandchild->getName()) {
case "OS":
$strOS = trim($grandchild);
break;
case "Browser":
$strBrowser = trim($grandchild);
break;
case "Version":
$strVersion = trim($grandchild);
break;
};
}
// WHATEVER READ, STORE IN DATABASE
if($strOS == "Windows" && $strBrowser == "Internet Explorer") $win_ie = $strVersion;
if($strOS == "Windows" && $strBrowser == "Opera") $win_opera = $strVersion;
if($strOS == "Windows" && $strBrowser == "Safari") $win_safari = $strVersion;
if($strOS == "Windows" && $strBrowser == "Firefox") $win_ff = $strVersion;
if($strOS == "Windows" && $strBrowser == "Chrome") $win_chrome = $strVersion;
if($strOS == "Macintosh" && $strBrowser == "Safari") $mac_safari = $strVersion;
if($strOS == "Macintosh" && $strBrowser == "Firefox") $mac_ff = $strVersion;
if($strOS == "Macintosh" && $strBrowser == "Chrome") $mac_chrome = $strVersion;
if($strOS == "Macintosh" && $strBrowser == "Opera") $mac_opera = $strVersion;
}
// SAVE TODAYS DATE IN DATABASE FOR PLUGIN
$id = 1;
$lastupdated = date('m/d/Y');
$query = "UPDATE `jos_newestbrowser`"
. " SET `lastupdated` = '" . $lastupdated
. "', `win-ie` = '" . $win_ie
. "', `win-opera` = '" . $win_opera
. "', `win-safari` = '" . $win_safari
. "', `win-ff` = '" . $win_ff
. "', `win-chrome` = '" . $win_chrome
. "', `mac-safari` = '" . $mac_safari
. "', `mac-ff` = '" . $mac_ff
. "', `mac-chrome` = '" . $mac_chrome
. "', `mac-opera` = '" . $mac_opera
. "' WHERE `id` = 1";
$db->setQuery($query);
$result = $db->query();
}
}
// CHOOSE WHICH OPTION IS SELECTED FROM PLUGIN SETTINGS, THEN DISPLAY THE BROWSER AND VERSION TO UPGRADE TO
$strUserAgent = $_SERVER['HTTP_USER_AGENT'];
$strModulePath = JURI::base() . 'modules/mod_newestbrowser';
switch($strPromote) {
case "Internet Explorer":
$strResults .= "<div id=\"cssNewestBrowser\"><a href=\"http://www.microsoft.com/windows/internet-explorer/worldwide-sites.aspx\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-internet-explorer.png" . "\" /> Upgrade to version " . $win_ie . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
break;
case "Opera":
$strResults .= "<div id=\"cssNewestBrowser\"><a href=\"http://www.opera.com/browser/download/\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-opera.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"windows")) > 0)
$strResults .= $win_opera . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
else
$strResults .= $mac_opera . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
break;
case "Safari":
$strResults .= "<div id=\"cssNewestBrowser\"><a href=\"http://www.apple.com/safari/download/\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-safari.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"windows")) > 0)
$strResults .= $win_safari . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
else
$strResults .= $mac_safari . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
break;
case "Firefox":
$strResults .= "<div id=\"cssNewestBrowser\"><a href=\"http://www.mozilla.com/en-US/firefox/all.html\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-firefox.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"windows")) > 0)
$strResults .= $win_ff . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
else
$strResults .= $mac_ff . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
break;
case "Chrome":
$strResults .= "<div id=\"cssNewestBrowser\"><a href=\"http://www.google.com/chrome\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-chrome.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"windows")) > 0)
$strResults .= $win_chrome . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
else
$strResults .= $mac_chrome . "</a><br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div>";
break;
default:
// SHOW LASTEST BROWSER THAT VISITOR IS CURRENTLY USING
if(strlen(strstr(strtolower($strUserAgent),"firefox")) > 0 && strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0 || strlen(strstr(strtolower($strUserAgent),"firefox")) > 0 && strlen(strstr(strtolower($strUserAgent),"windows")) > 0) {
// IF USERAGENT CONTAINS FIREFOX
$strText = "<a href=\"http://www.mozilla.com/en-US/firefox/all.html\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-firefox.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0)
$strText = $strText . $mac_ff . "</a>";
else
$strText = $strText . $win_ff . "</a>";
} else if(strlen(strstr(strtolower($strUserAgent),"msie")) > 0) {
// IF USERAGENT CONTAINS INTERNET EXPLORER
$strText = "<a href=\"http://www.microsoft.com/windows/internet-explorer/worldwide-sites.aspx\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-internet-explorer.png" . "\" /> Upgrade to version " . $win_ie . "</a>";
} else if(strlen(strstr(strtolower($strUserAgent),"opera")) > 0 && strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0 || strlen(strstr(strtolower($strUserAgent),"opera")) > 0 && strlen(strstr(strtolower($strUserAgent),"windows")) > 0) {
// IF USERAGENT CONTAINS OPERA
$strText = "<a href=\"http://www.opera.com/browser/download/\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-opera.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0)
$strText = $strText . $mac_opera . "</a>";
else
$strText = $strText . $win_opera . "</a>";
} else if(strlen(strstr(strtolower($strUserAgent),"chrome")) > 0 && strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0 || strlen(strstr(strtolower($strUserAgent),"chrome")) > 0 && strlen(strstr(strtolower($strUserAgent),"windows")) > 0) {
// IF USERAGENT CONTAINS CHROME
$strText = "<a href=\"http://www.google.com/chrome\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-chrome.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0)
$strText = $strText . $mac_chrome . "</a>";
else
$strText = $strText . $win_chrome . "</a>";
} else if(strlen(strstr(strtolower($strUserAgent),"safari")) > 0 && strlen(strstr(strtolower($strUserAgent),"iphone")) < 1 && strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0 || strlen(strstr(strtolower($strUserAgent),"safari")) > 0 && strlen(strstr(strtolower($strUserAgent),"iphone")) < 1 && strlen(strstr(strtolower($strUserAgent),"windows")) > 0) {
// IF USERAGENT CONTAINS SAFARI, BUT NOT IPHONE
// IPHONE USERS CANNOT UPGRADE OUTSIDE ITUNES, SO THIS PLUGIN IS POINTLESS FOR THEM
// SAFARI CONDITION IS CALLED AFTER CROME BECAUE CHROME HAS SAFARI IN USERAGENT STRING
$strText = "<a href=\"http://www.apple.com/safari/download/\" target=\"_blank\" rel=\"nofollow\"><img src=\"" . $strModulePath . "/images/icon-safari.png" . "\" /> Upgrade to version ";
if(strlen(strstr(strtolower($strUserAgent),"macintosh")) > 0)
$strText = $strText . $mac_safari . "</a>";
else
$strText = $strText . $win_safari . "</a>";
} // ELSE MUST BE LINUX OR A MINOR BROWSER
$strResults .= "<div id=\"cssNewestBrowser\">" . $strText . "<br /><a href=\"http://www.chriswashington.net/projects/newest-browser-for-joomla\" title=\"Newest Browser module powered by CW Web Solutions LLC\" target=\"_blank\"><img src=\"" . $strModulePath . "/images/icon.png" . "\" style=\"float:right;\" /></a></div></div>";
break;
};
$strResults .= "<div id=\"cssCWWSClear\" />";
return $strResults;
}
}
?>
addStyleSheet($url); echo $strResult; ?>