Category Archives: Site Navigation

Browser ReDirect – cross-browser; proprietary pages

Copy and paste this redirect script between the
tags of a new web page – no other content is required within this page.

Create two other web pages with content.
One for Internet Explorer and one for NetScape.

In the Script change the “IEpage.html” to the name of
the page you created for IE users.

In the Script change the “NSpage.html” to the name of
the page you created for NS users.

Create a link to the page that contains the redirect script.
It will then redirect your users to the appropriate page you
created for them based on browser.

You can also use it as the “index.html” page for your website
or a particular directory.

<SCRIPT language="JavaScript">
<!--
var browserName = navigator.appName;
browserVer = parseInt ( navigator.appVersion );
name = "0";

if ( browserName == "Netscape" ) name="NS";

if ( browserName != "Netscape" ) name="IE";

if (name == "NS") location.replace("NSpage.html");
else
if (name == "IE")
{
location.replace("IEpage.html");
}
// --></SCRIPT>

ApPHP Tabs Pro AJAX Enabled menu

The ApPHP Tabs is a simple PHP script that generates multilevel tab menu control which consists of nice-looking tabs. It may be useful for web developers who appreciate their time and do not want to waste it on boring work but instead focus on really challenging tasks. It takes you only few seconds to add or remove a tab. You can use the script to organize your website navigation system. It was written according to object-oriented principles and is very simple to install, implement, use and modify.

 

<?php
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  ApPHP Tabs version 1.0.2 (20.11.2009)                                      #
##  Developed by:  ApPhp <info@apphp.com>                                      #
##  License:       GNU GPL v.2                                                 #
##  Site:          http://www.apphp.com/php-tabs/                              #
##  Copyright:     ApPHP Tabs (c) 2009. All rights reserved.                   #
##                                                                             #
################################################################################
class Tab
 {
 // PUBLIC
 // -------
 // constructor
 // AddTab
 // View
 // Enable
 // Disable
 // IsSelected
 // Deselect
 // GetCaption
 // GetId
 // GetNumChildren
 //
 // PRIVATE
 // --------
 // SelectWithChildren
 // Calculate

 private $caption;
 private $enabled=true;
 private $selected=false;
 private $level;
 private $id;
 private $filename;
 private $tabs;
 private $numOfSelectedTabs;
 private $numchildren=1;
 private $parent;
 private $preselected="";
 private $defaultTab;
 private $tabsVersion="1.0.2";
 /**
 *    Create new set of tabs
 @param $caption - text on the tab
 @param $parent - caption of the parent's tab
 @param $file - graphic file associated with this tab
 @param $defaultTab - caption of the child's tab which should be selected by default
 @param $enabled - is tab enabled or disabled
 *
 */

 function Tab($caption,$parent=null,$file="",$defaultTab="",$enabled=true)
 {
 $this->file=$file;
 $this->tabs=array();
 $this->filename=array();
 $this->numOfSelectedTabs;
 $this->caption=$caption;
 $this->enabled=$enabled;
 $this->defaultTab=$defaultTab;
 if($this->preselected=="")
 //picking up $_GET parameters
 Tab::Calculate();
 if($parent==null)
 {
 $this->parent=null;
 $this->level=0;
 $this->id=1;
 $this->selected=true;
 return;
 }
 else
 {
 $this->parent=$parent;
 $this->level=$parent->level+1;
 $this->id=$this->parent->GetId()*10+$this->parent->GetNumChildren();
 }

 if($this->preselected!=""&amp;&amp;substr($this->preselected,$this->level,1)==$this->id%10)
 $this->selected=true;
 else $this->Deselect();
 }

 /**
 *    Add a new child tab to this set of tabs
 @param $caption - text on the tab
 @param $parent - the direct parent of this tab (current tab object may be its grandgrandfather etc.)
 @param $file - graphic file associated with this tab
 @param $defaultTab - caption of the child's tab which should be selected by default
 @param $enabled - is tab enabled or disabled
 *
 */

 public function AddTab($caption,$parent,$file="",$defaultTab="",$enabled=true)
 {
 if($parent==$this->caption)
 {
 if ($this->numchildren<10)
 {
 $this->tabs[$this->numchildren]=new Tab($caption,$this,$file,$defaultTab,$enabled);
 $this->numchildren++;
 }
 return true;
 }
 else foreach($this->tabs as $tab)
 {
 if($tab->AddTab($caption,$parent,$file,$defaultTab,$enabled))
 return true;
 }
 }

 /**
 *    Display this tab and selected child tab (recursive function)
 *
 */

 public function View()
 {
 $g=0;
 //display this tab
 $this->SelectWithChildren();
 if($this->numchildren!=1)
 {
 echo "<ul id=\"navlist\" class=\"menu\">";
 $root=substr($_SERVER['REQUEST_URI'],0,strrchr($_SERVER['REQUEST_URI'],'?'));
 foreach($this->tabs as $tab)
 {
 $href=$root."?id=".$tab->id;
 if($tab->selected)
 $style="sel";
 else if($tab->enabled)
 $style="";
 else
 {
 $href="#";
 $style="dis";
 }
 echo "\n\t<li class=\"element\"><a href=\"".$href."\" class=\"tab".$style."\"><span class=\"inner".$style."\">".$tab->caption."</span></a></li>";
 }
 echo "\n</ul><br/>\n";
 $g=0;
 //display selected child tab
 foreach($this->tabs as $tab)
 if($tab->isSelected())
 {
 $tab->View();
 $g=1;
 break;
 }
 //display image which is associated with this tab
 }
 if($this->isSelected()&amp;&amp;$this->file!=""&amp;&amp;$g==0)
 echo "<img border=\"0\" src=\"style/images/",$this->file,"\">";
 if($this->level==0)
 echo "\n<!-- END This script was generated by tabs.class.php v.".$this->tabsVersion."(http://www.apphp.com/php-tabs/index.php) END -->\n";

 }
 /**
 *    disable the tab or one of its child tabs
 @param $caption - caption of the tab that should be disabled
 *
 */

 public function Disable($caption)
 {
 if($caption==$this->caption)
 {
 $this->enabled=false;
 return true;
 }
 else foreach($this->tabs as $tab)
 if($tab->Disable($caption))
 return true;
 return false;
 }
 /**
 *    enable the tab or one of its child tabs
 @param $caption - caption of the tab that should be disabled
 *
 */

 public function Enable($caption)
 {
 if($caption==$this->caption)
 {
 $this->enabled=true;
 return true;
 }
 else foreach($this->tabs as $tab)
 if($tab->Enable($caption))
 return true;
 return false;
 }
 /**
 *    Pick up $_GET parameter id which denotes which tabs should be selected
 in the form: id=45 => button #4 on the first level and button #5 on the second level should be selected
 Define its number of digits (which means number of levels in the menu)
 *
 */

 private function Calculate()
 {
 $this->preselected= isset ($_GET['id']) ? $_GET['id'] : "";
 if($this->preselected!="")
 {
 for($i=0;$i<strlen($this->preselected);$i++)
 $numOfSelectedTabs[$i++]=substr($this->preselected,$i,1);
 }
 }

 /**
 *    selecting this tab and necessary lower tabs
 *
 */

 private function SelectWithChildren()
 {
 //select this tab
 $this->selected=true;
 $g=true;
 //check if one of its child tabs has already been selected manually
 foreach($this->tabs as $tab)
 {
 if($tab->isSelected())
 {
 $tab->SelectWithChildren();
 return;
 }
 }
 //if default tab for selection is not indicated select the first enabled child tab
 if($this->defaultTab=="")
 {
 foreach($this->tabs as $tab)
 if($tab->enabled==true)
 {
 $tab->SelectWithChildren();
 break;
 }
 }
 //if default tab for selection is indicated select it
 else foreach($this->tabs as $tab)
 {
 if($tab->caption==$this->defaultTab)
 {
 $tab->SelectWithChildren();
 }
 }

 }

 public function IsSelected()
 {
 return $this->selected;
 }
 public function Deselect()
 {
 $this->selected=false;
 }
 public function GetCaption()
 {
 return $this->caption;
 }
 public function GetId()
 {
 return $this->id;
 }
 public function GetNumChildren()
 {
 return $this->numchildren;
 }

 }
?>

Warcraft III Dota Replay for PHP (Scripts

Warcraft III Dota Replay for PHP is a PHP Parser of Warcraft III replay files designed specially to deal with replays made with DotA custom maps.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
 <!-- this charset is the best for replays because chat messages are encoded in it -->
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <link rel="stylesheet" type="text/css" href="style.css" media="screen, projection" />
 <meta name="author" content="Juliusz 'Julas' Gonera" />
 <title>Warcraft III Replay Parser for PHP</title>
 <script type="text/javascript">
 <!--//--><![CDATA[//><!--
 function display(id) {
 if (document.layers) {
 document.layers[id].display = (document.layers[id].display != 'block') ? 'block' : 'none';
 } else if (document.all) {
 document.all[id].style.display = (document.all[id].style.display != 'block') ? 'block'    : 'none';
 } else if (document.getElementById) {
 document.getElementById(id).style.display = (document.getElementById(id).style.display != 'block') ? 'block' : 'none';
 }
 }
 //--><!]]>
 </script>
 </head>
 <body>
 <?php
 $time_start = microtime();
 require('w3g-julas.php');

 $id = $_GET['id'];

 // path to the replay directory (*.w3g files) - must be ended with /
 if (isset($_GET['w3g_path'])) {
 $w3g_path = $_GET['w3g_path'];
 } else {
 $w3g_path = 'replays/';
 }
 // path to the data files, can be identical as w3g one or not
 $txt_path = 'database/';
 // only for links to webprofiles
 $gateway = 'Northrend';

 // listing replay files (we need it even when viewing details for
 // prev/next links
 if (false !== ($replays_dir = opendir($w3g_path))) {
 $i = 0;
 while (false !== ($replay_file = readdir($replays_dir))) {
 if ($replay_file != '.' &amp;&amp; $replay_file != '..' &amp;&amp; false !== ($ext_pos = strpos($replay_file, '.w3g'))) {
 $replay_file = substr($replay_file, 0, $ext_pos);
 // create database file if replay is new
 if (!file_exists($txt_path.$replay_file.'.txt') &amp;&amp; $replay_file != 'LastReplay') { // LastReplay additions just for my own purposes
 $replay = new replay($w3g_path.$replay_file.'.w3g');
 $txt_file = fopen($txt_path.$replay_file.'.txt', 'a');
 flock($txt_file, 2);
 fputs($txt_file, serialize($replay));
 flock($txt_file, 3);
 fclose($txt_file);
 }
 $replays[$i] = $replay_file;
 $i++;
 }
 }
 closedir($replays_dir);
 if ($replays) {
 sort($replays);
 } else {
 echo('<p>Replay folder contains no replays!</p>');
 }
 } else {
 echo('<p>Can\'t read replay folder!</p>');
 }

 // listing replays - short info
 if (!isset($id) &amp;&amp; !isset($_FILES['replay_file'])) {
 echo('<div id="top"><h1>index of '.$w3g_path.'</h1></div>
 <div id="functions"><b>'
.$i.'</b> total</div>
 <div id="content">'
);
 ?>
 <h2>Check your own replay!</h2>
 <form enctype="multipart/form-data" action="?" method="post">
 <fieldset>
 <input type="hidden" name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="300000" />
 <label for="replay_file">File: </label><input name="replay_file" id="replay_file" type="file" />
 <label for="gateway">Gateway: </label><select name="gateway" id="gateway">
 <option selected="selected">Lordaeron</option>
 <option>Azeroth</option>
 <option>Northrend</option>
 <option>Kalimdor</option>
 </select>
 <input type="submit" value="Send" />
 </fieldset>
 </form>
 <ol id="replays">
 <?php
 foreach ($replays as $replay_file) {
 if ($replay_file == 'LastReplay') { // LastReplay additions just for my own purposes
 continue;
 }
 echo('<li><a href="?id='.$replay_file.'">'.$replay_file.'</a>
 <a href="'
. $w3g_path.$replay_file.'.w3g">&#187; download</a>('.round(filesize($w3g_path.$replay_file.'.w3g')/1024).' KB)<br />');

 $txt_file = fopen($txt_path.$replay_file.'.txt', 'r');
 flock($txt_file, 1);
 $replay = unserialize(fgets($txt_file));
 flock($txt_file, 3);
 fclose($txt_file);
 $i = 1;
 foreach ($replay->teams as $team=>$players) {
 if ($team != 12) {
 //echo('<b>team '.$i.': </b>');
 echo('<b>'.$team.': </b>');
 foreach ($players as $player) {
 if (isset($player['dotaheroname']))
 {
 $hero_file = strtolower(str_replace(' ', '', $player['dotaheroname']));
 $hero_file = get_hero_icon($hero_file);
 echo('<img style="width: 16px; height: 16px;" src="img/h32x32/'.$hero_file.'.gif" alt="Hero icon" />');
 }
 //echo(' <img src="img/'.strtolower($replay->header['ident']).'/'.strtolower($player['race']).'.gif" alt="'.$player['race'].'" />');
 if ($player['race'] == 'Random') {
 echo('&#187; <img src="img/'.strtolower($replay->header['ident']).'/'.strtolower($player['race_detected']).'.gif" alt="'.$player['race_detected'].'" />');
 }
 /*if (!$player['computer']) {
 echo('<a href="http://www.battle.net/war3/ladder/'.$replay->header['ident'].'-player-profile.aspx?Gateway='.$gateway.'&amp;amp;PlayerName='.$player['name'].'">'.$player['name'].'</a> ('.round($player['apm']).' APM)');
 } else {
 echo('Computer ('.$player['ai_strength'].')');
 }*/

 if (!$player['computer']) {
 echo('<span>'.$player['name'].'</span>');
 } else {
 echo('Computer ('.$player['ai_strength'].')');
 }
 }
 echo('<br />');
 $i++;
 }
 }
 //$temp = strpos($replay->game['map'], ')')+1;
 $temp = strrpos($replay->game['map'], '\')+1;
 $map = substr($replay->game['
map'], $temp, strlen($replay->game['map'])-$temp-4);
 $version = sprintf('
%02d', $replay->header['major_v']);
 echo($replay->game['
type']);
 echo('
with '.$replay->game['observers']);
 echo('
| '.$map.' | '.convert_time($replay->header['length']).' | v1.'.$version.' '.$replay->header['ident'].'</li>');
 }
 echo('
</ol></div>');

 // details about the replay
 } else {
 $pos = array_search($id, $replays);

 echo('

 <h1>'.$id.' details</h1>
 <div id="functions">');
 if ($pos > 0) {
 echo('
<a href="?id='.$replays[$pos-1].'">&#171; prev</a>');
}
 echo('<a href="?">index</a>
 <a href="?id='
.$replays[$pos+1].'">next &#187;</a>
 </div>
 <div id="content">'
);

 if (0 &amp;&amp; file_exists($txt_path.$id.'.txt')) {
 $txt_file = fopen($txt_path.$id.'.txt', 'r');
 flock($txt_file, 1);
 $replay = unserialize(fgets($txt_file));
 flock($txt_file, 3);
 fclose($txt_file);
 } elseif ($id) {
 $replay = new replay($w3g_path.$id.'.w3g');
 } elseif (is_uploaded_file($_FILES['replay_file']['tmp_name'])) {
 $replay = new replay($_FILES['replay_file']['tmp_name']);
 $gateway = $_POST['gateway'];
 } else {
 echo('No replay file given!');
 $error = 1;
 }

 if (!isset($error)) {
 if ($replay->errors) {
 echo('<p><b>Warning!</b> The script has encountered some errors when parsing the replay. Please report them to the <a href="mailto:julas&#064;toya.net.pl">author</a>. <a href="javascript:display(\'errors\');">&#187; details</a></p>
 <div id="errors">'
);
 foreach ($replay->errors as $time=>$info) {
 echo('<b>'.convert_time($time).': </b>'.$info.'<br />');
 }
 echo('</div>');
 }

 echo('
 <h2>General information</h2>'
);
 //$temp = strpos($replay->game['map'], '(')+1;
 $temp = strrpos($replay->game['map'], '\')+1;
 $map = substr($replay->game['
map'], $temp, strlen($replay->game['map'])-$temp-4);
 $version = sprintf('
%02d', $replay->header['major_v']);
 echo('

 <img style="float: left; margin-right: 10px;" src="http://www.battle.net/war3/images/ladder-revise/minimaps/'.$map.'.jpg" alt="Mini Map" />
 <ul>
 <li><b>name:</b> '.$replay->game['name'].'</li>
 <li><b>type:</b> '.$replay->game['type'].'</li>
 <li><b>host:</b> '.$replay->game['creator'].'</li>
 <li><b>saver:</b> '.$replay->game['saver_name'].'</li>
 <li><br /><b>map:</b> '.$map.'</li>
 <li><b>players:</b> '.$replay->game['player_count'].'</li>
 <li><b>length:</b> '.convert_time($replay->header['length']).'</li>
 <li><b>speed:</b> '.$replay->game['speed'].'</li>
 <li><b>version:</b> 1.'.$version.' '.$replay->header['ident'].'</li>');
 if (file_exists($w3g_path.$id.'
.w3g')) {
 echo('
<li><br /><a href="'.$w3g_path.$id.'.w3g">&#187; download</a>('.round(filesize($w3g_path.$id.'.w3g')/1024).' KB)</li>');
}

 echo('</ul><ul>
 <li><b>lock teams:</b> '
.convert_yesno($replay->game['lock_teams']).'</li>
 <li><b>teams together:</b> '
.convert_yesno($replay->game['teams_together']).'</li>
 <li><b>full shared unit control:</b> '
.convert_yesno($replay->game['full_shared_unit_control']).'</li>
 <li><br /><b>random races:</b> '
.convert_yesno($replay->game['random_races']).'</li>
 <li><b>random hero:</b> '
.convert_yesno($replay->game['random_hero']).'</li>
 <li><br /><b>observers:</b> '
.$replay->game['observers'].'</li>
 <li><b>visibility:</b> '
.$replay->game['visibility'].'</li>
 <li><b>winner:</b> '
.$replay->game['winner_team'].'</li>
 </ul>'
);

 echo('<h2>Players</h2>
 <div>'
);
 $i = 1;
 foreach ($replay->teams as $team=>$players) {
 if ($team != 12) {
 //echo('<b>team '.$i.'</b>');
 echo('<b>'.$team.'</b>');
 // "If at least one player gets a draw result the whole game is draw."
 if (!isset($replay->game['winner_team'])) {
 echo(' (unknown)');
 } else if ($replay->game['winner_team'] === 'tie' || $replay->game['loser_team'] === 'tie') {
 echo(' (tie)');
 } elseif ($team === $replay->game['winner_team']) {
 echo(' (winner)');
 } else {
 echo(' (loser)');
 }
 echo('<br />');
 foreach ($players as $player)
 {
 //echo "Player id : {$player['player_id']}";
 echo('
 <div>
 <img src="img/'
.strtolower($replay->header['ident']).'/'.strtolower($player['race']).'.gif" alt="'.$player['race'].'" />');
 if ($player['race'] == 'Random') {
 echo('&#187; <img src="img/'.strtolower($replay->header['ident']).'/'.strtolower($player['race_detected']).'.gif" alt="'.$player['race_detected'].'" />');
 }
 if (!$player['computer']) {
 echo('<b>'.$player['name'].'</b> (');
 } else {
 echo('<b>Computer ('.$player['ai_strength'].')</b> (');
 }
 // remember there's no color in tournament replays from battle.net website
 if ($player['color']) {
 echo('<span>'.$player['color'].'</span>');
 // since version 2.0 of the parser there's no players array so
 // we have to gather colors and names earlier as it will be harder later ;)
 $colors[$player['player_id']] = $player['color'];
 $names[$player['player_id']] = $player['name'];
 }
 if (!$player['computer']) {
 echo(' | '.round($player['apm']).' APM | ');
 echo($player['actions'].' actions | ');
 echo(convert_time($player['time']).')<br />
 <div>'
);
 if (isset($player['heroes'])) {
 foreach ($player['heroes'] as $name=>$info) {
 // don't display info for heroes whose summoning was aborted
 if ($name != 'order' &amp;&amp; isset($info['level']))
 {
 $hero_file = strtolower(str_replace(' ', '', $name));
 $hero_file = get_hero_icon($hero_file);
 echo('<img style="width: 32px; height: 32px;" src="img/h32x32/'.$hero_file.'.gif" alt="Hero icon" /> <b>Level '.$info['level'].'</b> <a href="javascript:display(\''.$hero_file.$player['player_id'].'\');" title="Click to see skill order">'.$name.'</a> <div id="'.$hero_file.$player['player_id'].'">');
 $counter = 1;
 foreach ($info['abilities']['order'] as $time=>$ability) {
 if ($time !== 'order') {
 if ($time) {
 echo('<br /><b>'.convert_time($time).'</b> Level '.$counter++.'<br />');
 }
 if ($ability === "Attribute Bonus")
 {
 echo('<img style="width: 32px; height: 32px;" src="img/h32x32/Stats.gif" alt="Ability icon" /> <b>'.$ability.'</b><br />');
 }
 else
 {
 echo('<img style="width: 32px; height: 32px;" src="img/h32x32/'.$hero_file.'_'.str_replace(' ', '', $ability).'.gif" alt="Ability icon" /> <b>'.$ability.'</b><br />');
 }
 }
 }
 echo('</div>');
 }
 if (isset($player['kills']))
 {
 echo ("<br />Kills: {$player[kills]}; Deaths: {$player[deaths]}; Last hits: {$player[ckills]}; Denies: {$player[cdenies]}");
 }
 }
 }

 if (isset($player['actions_details'])) {
 echo('<br />
 <a href="javascript:display(\'actions'
.$player['player_id'].'\');">&#187; actions </a>
 <div id="actions'
.$player['player_id'].'">
 <table>'
);
 ksort($player['actions_details']);
 foreach ($player['actions_details'] as $name=>$info) {
 echo('<tr><td style="text-align: right;">'.$name.'</td><td style="text-align: right;"><b>'.$info.'</b></td><td><div style="width: '.round($info/10).'px;"></div></td></tr>');
 }
 echo('</table>
 <b>'
.$player['actions'].'</b> total</div>');
 }

 if (isset($player['hotkeys'])) {
 echo('<a href="javascript:display(\'hotkeys'.$player['player_id'].'\');">&#187; hotkeys </a>
 <div id="hotkeys'
.$player['player_id'].'">
 <table>'
);
 ksort($player['hotkeys']);
 foreach ($player['hotkeys'] as $name=>$info) {
 echo('<tr><td style="text-align: right;"><b>'.($name+1).'</b></td><td style="text-align: right;">'.$info['assigned'].'</td><td><div style="width: '.round($info['assigned']/7).'px;"></div></td><td style="text-align: right;">'.$info['used'].'</td><td><div style="width: '.round($info['used']/7).'px;"></div></td></tr>');
 }
 echo('</table>(assigned/used)</div>');
 }

 if (isset($player['units'])) {
 echo('<a href="javascript:display(\'units'.$player['player_id'].'\');">&#187; units </a>
 <div id="units'
.$player['player_id'].'">
 <table>'
);
 $ii = 0;
 foreach ($player['units'] as $name=>$info) {
 if ($name != 'order' &amp;&amp; $info > 0) { // don't show units which were cancelled and finally never made by player
 echo('<tr><td style="text-align: right;">'.$name.'</td><td style="text-align: right;"><b>'.$info.'</b></td><td><div style="width: '.($info*5).'px;"></div></td></tr>');
 $ii += $info;
 }
 }
 echo('</table>
 <b>'
.$ii.'</b> total</div>');
 }

 if (isset($player['upgrades'])) {
 echo('<a href="javascript:display(\'upgrades'.$player['player_id'].'\');">&#187; upgrades</a>
 <div id="upgrades'
.$player['player_id'].'">
 <table>'
);
 $ii = 0;
 foreach ($player['upgrades'] as $name=>$info) {
 if ($name != 'order') {
 echo('<tr><td style="text-align: right;">'.$name.'</td><td style="text-align: right;"><b>'.$info.'</b></td><td><div style="width: '.($info*20).'px;"></div></td></tr>');
 $ii += $info;
 }
 }
 echo('</table>
 <b>'
.$ii.'</b> total</div>');
 }

 if (isset($player['buildings'])) {
 echo('<a href="javascript:display(\'buildings'.$player['player_id'].'\');">&#187; buildings</a>
 <div id="buildings'
.$player['player_id'].'">
 <table>'
);
 $ii = 0;
 foreach ($player['buildings'] as $name=>$info) {
 if ($name != 'order') {
 echo('<tr><td style="text-align: right;">'.$name.'</td><td style="text-align: right;"><b>'.$info.'</b></td><td><div style="width: '.($info*20).'px;"></div></td></tr>');
 $ii += $info;
 }
 }
 echo('</table>
 <b>'
.$ii.'</b> total</div>');

 echo('<a href="javascript:display(\'buildorder'.$player['player_id'].'\');">&#187; build order</a>
 <div id="buildorder'
.$player['player_id'].'">');
 foreach ($player['buildings']['order'] as $time=>$name) {
 echo('<b>'.convert_time($time).'</b> '.$name.'<br />');
 }
 echo('</div>');
 }

 if (isset($player['items'])) {
 echo('<a href="javascript:display(\'items'.$player['player_id'].'\');">&#187; items</a>
 <div id="items'
.$player['player_id'].'">
 <table>'
);
 $ii = 0;
 foreach ($player['items']['order'] as $name=>$info) {
 if ($name != 'order') {
 echo('<tr><td style="text-align: right;"><b>'.convert_time($name).'</b></td><td style="text-align: right;"><img style="width: 32px; height: 32px;" src="img/i64x64/'.str_replace(' ', '', $info).'.gif" alt="Item icon" /></td><td style="text-align: right;"><b>'.$info.'</b></td><td><div style="width: '.($info*20).'px;"></div></td></tr>');
 $ii += $info;
 }
 }
 echo('</table>
 <b>'
.$ii.'</b> total</div>');
 }
 echo('</div>');
 } else {
 echo(')');
 }
 echo('</div>');
 }
 $i++;
 }
 }
 if (isset($replay->teams['12'])) {
 echo('<b>observers</b> ('.$replay->game['observers'].')<br />');
 $comma = 0;
 foreach ($replay->teams['12'] as $player) {
 if ($comma) {
 echo(', ');
 }
 $comma = 1;
 echo('<a href="http://www.battle.net/war3/ladder/'.$replay->header['ident'].'-player-profile.aspx?Gateway='.$gateway.'&amp;amp;PlayerName='.$player['name'].'">'.$player['name'].'</a>');
 }
 echo('<br /><br />');
 }
 echo('</div>');
 if ($replay->chat) {
 echo('<h2>Chat log</h2>
 <p>'
);

 $prev_time = 0;
 foreach ($replay->chat as $content) {
 if ($content['time'] - $prev_time > 45000) {
 echo('<br />'); // we can easily see when players stopped chatting
 }
 $prev_time = $content['time'];
 echo('('.convert_time($content['time']));
 if (isset($content['mode'])) {
 if (is_int($content['mode'])) {
 echo(' / '.'<span>'.$names[$content['mode']].'</span>');
 } else {
 echo(' / '.$content['mode']);
 }
 }
 echo(') ');
 if (isset($content['player_id'])) {
 // no color for observers
 if (isset($colors[$content['player_id']])) {
 echo('<span>'.$content['player_name'].'</span>: ');
 } else {
 echo('<span>'.$content['player_name'].'</span>: ');
 }
 }
 echo(htmlspecialchars($content['text'], ENT_COMPAT, 'UTF-8').'<br />');
 }
 echo('</p>');
 }
 }
 echo('</div>');
 }
 $time_end = microtime();
 $temp = explode(' ', $time_start.' '.$time_end);
 $duration=sprintf('%.8f',($temp[2]+$temp[3])-($temp[0]+$temp[1]));
 ?>
 <div id="footer">
 <a href="http://w3rep.sourceforge.net/">Warcraft III Replay Parser for PHP</a>. Copyright &amp;copy; 2003-2005 <a href="mailto:julas&#064;toya.net.pl?Subject=Warcraft III Replay Parser for PHP">Juliusz 'Julas' Gonera</a>.
 All rights reserved.
 <?php
 echo('Generated in '.$duration.' seconds.');
 ?>
 </div>
 </body>
</html>

&amp;nbsp;

Easy Niche Store Script Shopping Carts

The Easy Niche Store Script is a PHP script that PLUGS IN to your existing (PHP based) website or existing Ecommerce site to allow you to display Ebay products via RSS.The advantages of being able to do this are:You can add an instant Niche store to your website or existing ecommerce site to ‘boost’ your product offerings You can make money through ebay through referrals. The Ebay affiliate code (from Commission Junction) is embedded in all…

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
BODY { BACKGROUND: #eee; color: black;  margin-top: 0px; }
DIV { FONT-SIZE: 12px; COLOR: #666666; LINE-HEIGHT: 1.5em; FONT-FAMILY: Arial,Verdana, Helvetica, sans-serif }
.componentheading { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 3px; MARGIN: 0px 0px 0px; FONT: bold 14px Arial, Helvetica, sans-serif; COLOR: #013D6D; PADDING-TOP: 3px; LETTER-SPACING: normal; }
A:link { COLOR: #000f35; TEXT-DECORATION: none }
A:visited { COLOR: #000f35; TEXT-DECORATION: none }
A:hover { COLOR: #6299dc }
.content { BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 5px; BACKGROUND: #fff; PADDING-BOTTOM: 5px; MARGIN: 10px auto; BORDER-LEFT: #ccc 1px solid; WIDTH: 760px; PADDING-TOP: 5px; BORDER-BOTTOM: #ccc 1px solid }
.largeheading { font-size: 32px; font-weight: bold; }
-->
</style>
</head>
<body>
<div>
 <table width="100%"  border="0" cellpadding="0" cellspacing="0">
 <tr>
 <td bgcolor="#eeeeee"><p><br>
 </p>
 <p align="center"><span><br>
 YOUR TOP LOGO</span></p>
 <p align="center"><span> OR DESCRIPTION GOES HERE </span><br>
 </p>      <p align="center">&amp;nbsp;</p></td>
 </tr>
 </table>
</td>
 </tr>
 </table>
 <br />
 <table width="100%"  border="0" cellspacing="0" cellpadding="0">
 <tr>
 <td width="77%" valign="top"><table width="100%" cellpadding="5" cellspacing="0">
 <tbody>
 <tr>
 <td valign="top" style="font-size: 8px;"><div>
 <table width="180" border="0" cellspacing="0" cellpadding="8" style="background-color: #f7f7f8;">
 <tr>
 <td ><ul>
 <li>
 <a href="demo.php"><strong>Home</strong></a> (Default) </li>
 <li><strong><a href="demo.php?cat=1335&amp;nshow=15&amp;nsort=newlylisted&amp;nsearch=dogs">Dogs</a></strong></li>
 <li><strong><a href="demo.php?cat=28131&amp;nshow=10&amp;nsort=highestfirst&amp;nsearch=">Leather Stuff </a></strong></li>
 <li><strong><a href="demo.php?cat=281&amp;nshow=10&amp;nsort=highestfirst&amp;nsearch=ring">Rings</a></strong></li>
 <li><strong><a href="demo.php?cat=1&amp;nshow=10&amp;nsort=highestfirst&amp;nsearch=star+wars">Star Wars</a></strong></li>
 <li><strong><a href="demo.php?cat=31817&amp;nshow=10&amp;nsort=endingsoonest&amp;nsearch=weight+loss">Weight Loss</a></strong></li>
 </ul>                        </td>
 </tr>
 </table>
 <br>
 <table width="180" border="0" cellspacing="0" cellpadding="8" style="background-color: #f7f7f8;">
 <tr>
 <td><hr size="1" noshade="noshade" />                      <div><strong>Go shopping </strong>
 <p>Browse through our store for great prices!</p>
 </div>
 <hr size="1" noshade="noshade" /></td>
 </tr>
 </table>
 </div>
 </td>
 <td width="597" valign="top" style="padding-left: 20px; text-align: justify; color: #222222;"><h3><strong></strong>Your Shop</h3>
 <p><strong> Choose which item you want to buy from the list below</strong></p>
 <table width="100%"  border="0" cellpadding="10" cellspacing="5" bgcolor="#eeeeee">
 <tr>
 <td bgcolor="#ffffff"><table width="100%"  border="0" cellspacing="0" cellpadding="10">
 <tr>
 <td width="91%" bgcolor="#EEEEEE"><strong><span><strong> The Shop </strong></span></strong></td>
 </tr>
 <tr>
 <td><p>
 <?PHP
include('easynichestore.php');
?>
 </p>
 <p>This is a demo web page. You can change it and use it if you wish.</p>
 <p>NOTE: The default country used in this demo is Australia, and it is using Australias category numbers. All category numbers can be viewed with the links below: </p>
 <p>For the Ebay Category numbers in Australia <a href="http://listings.ebay.com.au/_W0QQfclZ3QQloctZShowCatIdsQQsacatZQ2d1QQsalocationZatsQQsocmdZListingCategoryList" target="_blank"><strong>click here</strong></a><br>For the Ebay Category numbers in the UK <strong><a href="http://listings.ebay.co.uk/_W0QQfclZ3QQloctZShowCatIdsQQsacatZQ2d1QQsalocationZatsQQsocmdZListingCategoryList" target="_blank">click here</a></strong><br>
For the Ebay Category numbers in the USA <a href="http://listings.ebay.com/_W0QQfclZ3QQloctZShowCatIdsQQsacatZQ2d1QQsalocationZatsQQsocmdZListingCategoryList" target="_blank"><strong>click here</strong></a></p>
 </td>
 </tr>
 </table>
 </td>
 </tr>
 </table>                <p>&amp;nbsp;</p>
 </td>
 </tr>
 </tbody>
 </table></td>
 </tr>
 </table>
 <br>
 <table width="100%" border="0" cellspacing="0" cellpadding="8" style="background-color: #f7f7f8;">
 <tr>
 <td><div>
 <p align="center">  (C) Copyright Your website 2007 </p>
 </div></td>
 </tr>
 </table>
</div>
</body>
</html>

&amp;nbsp;

Drop Down List Generator Plugin PHP

This script is designed only to be plugin for the TNET Weather – WD Avg/Extreme Extraction Script This script automatically generates a drop down HTML list of monthly weather report files on your web server.

 

 

<pre><?php
/*
PHP script by Mike Challis, www.642weather.com/weather
Drop Down List Generator Plugin PHP Script - include-get-month-files.php
Script available at: http://www.642weather.com/weather/scripts.php
Contact Mike: http://www.642weather.com/weather/contact_us.php
Live Demo: http://www.642weather.com/weather/monthly-stats.php
Version: 2.10  12-Feb-2008

See change log for complete history:
http://www.642weather.com/weather/scripts-history.php
Version: 2.10  12-Feb-2008 - Bug fix: uninitialized value causing error
                             when error warnings are enabled in PHP.
                             Error: 'Undefined variable: datestring'


You are free to use and modify the code for your own non-commercial use

This php code provided "as is," and Long Beach Weather (Michael Challis)
disclaims any and all warranties, whether express or implied, including
(without limitation) any implied warranties of merchantability or
fitness for a particular purpose.

License:
    This work is licensed under a
    CREATIVE COMMONS ATTRIBUTION - NONCOMMERCIAL 3.0
    UNITED STATES LICENSE
    For Complete Details please go to:
    http://creativecommons.org/licenses/by-nc/3.0/us/


################
# What does it do?:
# ##############

Drop Down List Generator Plugin PHP Script
this function will make a list of Monthly WD Report files from a
directory on your web server.

it looks for and compiles a list of all the monthly Monthly WD Report files:
it also checks to be sure the files are really there, if one is missing, it will be skipped
October2007.htm
November2007.htm
December2007.htm

It will output the drop down select html for the monthly files found on your server.
The output will be html code like this:

<option value="200712">December 2007</option>
<option value="200711">November 2007</option>
<option value="200710">October 2007</option>

################
# Suggested use:
# ##############

You need Monthly WD Report files from Weather Display Software,
and they must be located on your web server
http://www.weather-display.com/index.php

This script is designed to be a plugin for
TNET Weather - tws-avgext-script where the date string is used like this:
sample.php?date=200712
http://www.tnetweather.com/tws-avgext-script.php
This is a great addition to a great report script, it can save everyone having to edit the report page every month.
Thanks to Kevin Reed at TNET Weather for offering his scripts

I use it as a plugin on my tws-avgext-script Monthly Weather Reports page
http://www.642weather.com/weather/monthly-stats.php

################
# How to use it:
# ##############

upload the contents of this file as include-get-month-files.php
in the same directory as your reports page

call it like this from the php page where your drop down list will be:
 Note: (make sure to change sample.php to the name of your php page)

 ##### copy below here #####
<form method="get" action="sample.php">
<select name="date">
<?php
global $datefile;
include ('include-get-month-files.php');
$datefile = getmonthfiles();
?>
</select>
<input type="submit" value="Go" />
</form>
 ##### copy above here  #####

*/


#################
# begin settings
# ##############

# be sure to set the two settings variables below

# enter 4 digit year of your oldest report on your server - example: 2006
$startyear = 2006;

# Location of where the data files are located.
# You may need to change this and it must end with a slash.
# ./ is used if the files are in the same folder as your page with the dropdown list
$webdir = './';

#################
# end settings
# ##############

if (isset($_REQUEST['sce']) &amp;&amp; strtolower($_REQUEST['sce']) == 'view' ) {
   //--self downloader --
   $filenameReal = __FILE__;
   $download_size = filesize($filenameReal);
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   header("Content-type: text/plain");
   header("Accept-Ranges: bytes");
   header("Content-Length: $download_size");
   header('Connection: close');

   readfile($filenameReal);
   exit;
}

function getmonthfiles() {
 global $startyear, $webdir;

 # find out how many years do we need to list files for
$thisyear  = date('Y');
 $yearcount = $thisyear - $startyear;

 # Saftey setting incase some goofy year is entered like 200 for $startyear setting
# only allows 20 years in the past maximum.
if($yearcount > 20) $yearcount = 20;

 $yearsarray = array();
 for ($num=0; $num <= $yearcount; $num++ ) {
      $yearsarray[]=$thisyear;
      $thisyear--;
 }

 $monthsarray = array('12' => 'December','11' => 'November','10' => 'October','09' => 'September','08' => 'August','07' => 'July',
 '06' => 'June','05' => 'May','04' => 'April','03' => 'March','02' => 'February','01' => 'January');

 # $datestring is used to keep the dropdown properly selected
# see if it is there and 6 digits only
# make sure a month selected exists
# input sanity (allow only 6 digits for date query, nothing else)
$defaultdatefound=0;
 $datestring = '';
 $selected = '';
 if ( isset($_GET['date'] ) &amp;&amp; preg_match("/^[0-9]{6}$/", $_GET['date']) ) {
    if (is_file($webdir.$monthsarray[substr($_GET['date'],4,2)].substr($_GET['date'],0,4).'.htm')) {
       $datestring = $_GET['date'];
       $defaultdatefound=1;
    }
 }

  # this part properly sorts the files for the dropdown
 # start with this year and work back
 $count =1;
  foreach ($yearsarray as $yk => $yv) {
       # start with December and work towards January for each year we are working with
      foreach ($monthsarray as $mk => $mv) {
              # only files FOUND on the server are included
             if(is_file("$webdir$mv$yv.htm")){
                # make the default month, the first one we actually have found
               # prevents January of a new year not found on Jan 1 because the file was not uploaded
               if ($count ==1) $firstdatestring = "$yv$mk";
                if ($datestring == "$yv$mk")  $selected = ' selected="selected"';
                echo '<option value="'.$yv.$mk.'"'.$selected.'>'.$mv.' '.$yv.'</option>'."\n";
                $selected = '';
                $count++;
              }
       }
  }
    # make the default month, the first one we actually have found
  if (!$defaultdatefound) $datestring = $firstdatestring;
   return $datestring;
}
?>
</pre>
&amp;nbsp;

Printable Flyer Add-on for WD/PHP

I made a printable weather flyer page to help promote my weather site to locals. The page is specially formatted to be printed as a flier (flyer). All the pertinent weather data should fit on one page. To see how it would look printed, click on “print preview” in your web browser. The flier may be freely used by local hotels, motels, restaurants, businesses, and local government offices to pin on bulletin boards or distribute to their patrons. This is a Plugin Page for the USA.

 

 

<?php
require_once('Settings.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-US">
<head>
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
//ini_set('log_errors', 1);
//ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

require_once('common.php');
require_once('testtags.php');

$wxflyer_version = 'Version: 1.11 - 06-Nov-2009 Carterlake Plugin Page - Printable Weather Flyer by Mike Challis';

// BEGIN SETTINGS --------------------------------------------------------------

// 'www.642weather.com' domain with no http and no slash at end!
// used for identifying your site: "... this discussion continues at www.642weather.com"
$domain = 'www.642weather.com';

// flyerpromo will show on your printable flyer page just after an advisory headline
// example: High Wind Warning - South Washington Coast (Washington)(view at www.642weather.com)
// Note: this setting requires version 2.00 or higher of rss-advisory.php to be installed
$flyerpromo = '<span style="font-size: 11px;"> (view at www.642weather.com)</span>';

// 'Reports from [station name] at [neighborhood]';
$reports_from = 'Reports from Long Beach Weather Station at Sandridge Rd., near Pioneer Rd.';

//$wu_satellite_image = 'http://icons.wunderground.com/data/640x480/pa_ir.gif'; // Northwest USA
$wu_satellite_image = 'http://icons.wunderground.com/data/640x480/pa_ir.gif';

// NWS Area Forecast Discussion URL for your area (must be in text format)
$WRH_URL = 'http://www.crh.noaa.gov/product.php?site=NWS&amp;issuedby=PQR&amp;product=AFD&amp;format=TXT&amp;version=1&amp;glossary=0';

// The rest of the settings are imported from Settings.php
// -------------------------------------------------------

//$site_name = 'Long Beach Weather';
$site_name = $SITE['organ'];

//$location = 'Long Beach, WA 98631';
$location = $SITE['location'];

//$noaazone = 'WAZ021';
$noaazone = $SITE['noaazone'];

//$uomTemp = '&amp;deg;F';
$uomTemp = $SITE['uomTemp'];

//$uomBaro = ' inHg';
$uomBaro = $SITE['uomBaro'];

//$uomWind = ' mph';
$uomWind = $SITE['uomWind'];

//$uomRain = ' in';
$uomRain = $SITE['uomRain'];

// END SETTINGS --------------------------------------------------------------
?>
<title>Printable local weather flyer</title>
<meta name="description" content="Printable local weather flyer for <?php echo $location; ?>. The flyer may be freely used by local hotels, motels, restaurants, businesses, and local government offices" />
<meta name="keywords" content="weather,flier,flyer,forecast,<?php echo $location; ?>" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=<?php echo $SITE['charset']; ?>" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<?php echo $SITE['CSSscreen']; ?>" media="screen" title="screen" />
<link rel="stylesheet" type="text/css" href="<?php echo $SITE['CSSprint']; ?>" media="print" />
<?php
if (isset($SITE['flyoutmenu']) and $SITE['flyoutmenu'] or
 isset($_REQUEST['menu']) and strtolower($_REQUEST['menu']) == 'test' ) {
 $SITE['flyoutmenu'] = true;
 $PrintFlyoutMenu = false;
 $genDiv =false;
 global $FlyoutCSS, $FlyoutMenuText;
 include_once('flyout-menu.php');
 print $FlyoutCSS;
}
?>
<style type="text/css">
.column-flyer {
 font-size: 8px;
 text-align: left;
}
 </style>
</head>

<body>

<div id="page">

 <!-- For non-visual user agents: -->
 <a href="#main-copy">Skip to main content.</a>

 <!-- ##### Header ##### -->

 <div id="header">
 <h1>
 <span style="font-size: 34px;"><b><?php echo $domain ?></b></span>
 </h1>

 <div>
 <?php echo $location; ?>
 </div>

 <div>Published: <?php echo date("l") . ' ' .$date ?> <?php echo $time ?> <?php echo date('T')?>
 </div>

 </div>

<?php include("menubar.php"); ?>

 <div id="main-copy">

 <div>
 <h3>Printable local weather flyer for <?php echo $location; ?></h3>
 <br />
 </div>

 <span style="font-size: 14px;">
Notice: This page is specially formatted to be printed as a flyer.
All the pertinent weather data should fit on one page. To see how it would look printed,
click on "print preview" in your web browser.
The flyer may be freely used by local hotels, motels, restaurants, businesses,
and local government offices to pin on bulletin boards or distribute to their patrons.
If you find the flyer useful, please
<a href="wxcontact.php">contact us</a>, we would be happy to know.
<br />
</span>

<div>

<?php
 if ( isset($_GET['zone']) ) {
 $DefaultZone = $_GET['zone'];
 } else {
 $DefaultZone = $noaazone;
 }
$doSummary = 1;    // display alert links, not full alert details
$includeOnly = 1;  // include mode
$noprint = 1;      // required for echo $advisory_html output
$flyer = 1;        // alerts are just the titles without links
include 'atom-advisory.php';

$advisories = 0;
if (preg_match("|There are no active|i",$advisory_html) || preg_match("|Advisory Information Unavailable|i",$advisory_html)) {
 // do nothing
}else{
 $advisories = 1;
 echo '<br /><div>' . $advisory_html .'</div>';
}
?>

<br />

<div align="center">
<?php
$doPrintNWS = false;
require_once("advforecast2.php");
?>
<table border="0" cellpadding="2" cellspacing="0">
 <tr>
 <td colspan="4" valign="top">
 <span style="font-size: 18px;"><b>Today's Weather for <?php echo $location; ?></b></span>
 </td>
 <td rowspan="2" align="center" valign="top">
 <img src="<?php echo $wu_satellite_image; ?>?dontcache=<?php echo time(); ?>"
 alt="Satellite Image" title="Satellite Image" width="240" height="180"
 style="border:1px; border-color:#000000; border-style:solid;" />
 </td>
 </tr>

 <tr>
 <td width="20%" align="center" valign="top">
 <div style="font-size: 12px;">
 <?php print "$forecasticons[0]\n"; ?>
 <br />
 <?php print "$forecasttemp[0]\n"; ?>
 </div></td>

 <td width="20%" align="center" valign="top">
 <div style="font-size: 12px;">
 <?php print "$forecasticons[1]\n"; ?>
 <br />
 <?php print "$forecasttemp[1]\n"; ?>
 </div></td>

 <td width="20%" align="center" valign="top">
 <div style="font-size: 12px;">
 <?php print "$forecasticons[2]\n"; ?>
 <br />
 <?php print "$forecasttemp[2]\n"; ?>
 </div></td>

 <td width="20%" align="center" valign="top">
 <div style="font-size: 12px;">
 <?php print "$forecasticons[3]\n"; ?>
 <br />
 <?php print "$forecasttemp[3]\n"; ?>
 </div></td>
 </tr>
</table>
</div>

<p><b><?php print "$forecasttitles[0]\n"; ?></b>
<br /><?php print "$forecasttext[0]\n"; ?></p>

<p><b><?php print "$forecasttitles[1]\n"; ?></b>
<br /><?php print "$forecasttext[1]\n"; ?></p>

<?php
// make a short paragraph of the forecast discussion
$Status = $curl_debug = '';
echo get_forecast_discussion_flyer();
?>

<br />

<br />
<b><?php echo $reports_from; ?></b>
<br />

<table cellpadding="2" cellspacing="0" border="1">

<tr>
<td colspan="2"><b>Rain</b></td><td colspan="2"><b>Wind Gust</b></td><td colspan="2"><b>Sun</b></td><td colspan="2"><b>Moon</b></td>
<td rowspan="4">
<img src="cwp_logo.gif" alt="Citizen Weather Observer Program Logo" title="Citizen Weather Observer Program Logo" width="80" height="80" />
</td>
</tr>

<tr>
<td><b>Yest.</b></td>
<td><?php echo $yesterdayrain ?></td>

<td><b>Yest.</b></td>
<td><?php echo $maxgustyest ?> at <?php echo $maxgustyestt ?></td>

<td><b>Sunrise:</b></td>
<td><?php echo $sunrise ?></td>

<td><b>Moonrise:</b></td>
<td><?php echo $moonrise ?></td>
</tr>

<tr>
<td><b>Month</b></td>
<td><?php echo $monthrn ?></td>

<td><b>Month</b></td>
<td><?php echo $mrecordwindgust ?> <?php echo $uomWind ?> on
<?php echo $mrecordhighgustmonth ?>/<?php echo $mrecordhighgustday ?>/<?php echo $mrecordhighgustyear ?></td>

<td><b>Sunset:</b></td>
<td><?php echo $sunset ?></td>

<td><b>Moonset:</b></td>
<td><?php echo $moonset ?></td>
</tr>

<tr>
<td><b>Year</b></td>
<td><?php echo $yearrn ?></td>

<td><b>Year</b></td>
<td><?php echo $yrecordwindgust ?> <?php echo $uomWind ?> on
<?php echo $yrecordhighgustmonth ?>/<?php echo $yrecordhighgustday ?>/<?php echo $yrecordhighgustyear ?></td>

<td><b>Daylight Hrs:</b></td>
<td><?php echo $hoursofpossibledaylight ?></td>

<td><b>Illuminated:</b></td>
<td><?php echo $moonphase ?></td>
</tr>

</table>

<?php
// when there are more than 2 advisories, hide this table so it might still fit on one page
if ((!$advisories) || ($advisories &amp;&amp; $advcount < 3)) {
?>

<br />

<table cellpadding="2" cellspacing="0" border="1">
<tr>
<td colspan="3"><b>Temperature</b></td><td colspan="3"><b>Barometer</b></td>
</tr>

<tr>
<td><b>Yest.</b></td>
<td><b>Hi</b> <?php echo $maxtempyest ?> at <?php echo $maxtempyestt ?></td>
<td><b>Lo</b> <?php echo $mintempyest ?> at <?php echo $mintempyestt ?></td>

<td><b>Yest.</b></td>
<td><b>Hi</b> <?php echo $maxbaroyest ?> at <?php echo $maxbaroyestt ?></td>
<td><b>Lo</b> <?php echo $minbaroyest ?> at <?php echo $minbaroyestt ?></td>
</tr>

<tr>
<td><b>Month</b></td>
<td><b>Hi</b> <?php echo $mrecordhightemp ?> <?php echo $uomTemp ?> on <?php echo $mrecordhightempmonth ?>/<?php echo $mrecordhightempday ?>/<?php echo $mrecordhightempyear ?></td>
<td><b>Lo</b> <?php echo $mrecordlowtemp ?> <?php echo $uomTemp ?> on <?php echo $mrecordlowtempmonth ?>/<?php echo $mrecordlowtempday ?>/<?php echo $mrecordlowtempyear ?></td>

<td><b>Month</b></td>
<td><b>Hi</b> <?php echo $mrecordhighbaro ?> <?php echo $uomRain ?> on <?php echo $mrecordhighbaromonth ?>/<?php echo $mrecordhighbaroday ?>/<?php echo $mrecordhighbaroyear ?></td>
<td><b>Lo</b> <?php echo $mrecordlowbaro ?> <?php echo $uomRain ?> on <?php echo $mrecordlowbaromonth ?>/<?php echo $mrecordlowbaroday ?>/<?php echo $mrecordlowbaroyear ?></td>
</tr>

<tr>
<td><b>Year</b></td>
<td><b>Hi</b> <?php echo $yrecordhightemp ?> <?php echo $uomTemp ?> on <?php echo $yrecordhightempmonth ?>/<?php echo $yrecordhightempday ?>/<?php echo $yrecordhightempyear ?></td>
<td><b>Lo</b> <?php echo $yrecordlowtemp ?> <?php echo $uomTemp ?> on <?php echo $yrecordlowtempmonth ?>/<?php echo $yrecordlowtempday ?>/<?php echo $yrecordlowtempyear ?></td>

<td><b>Year</b></td>
<td><b>Hi</b> <?php echo $yrecordhighbaro ?> <?php echo $uomRain ?> on <?php echo $yrecordhighbaromonth ?>/<?php echo $yrecordhighbaroday ?>/<?php echo $yrecordhighbaroyear ?></td>
<td><b>Lo</b> <?php echo $yrecordlowbaro ?> <?php echo $uomRain ?> on <?php echo $yrecordlowbaromonth ?>/<?php echo $yrecordlowbaroday ?>/<?php echo $yrecordlowbaroyear ?></td>
</tr>

</table>

<?php
} // if ! $advisories

echo '<!-- '.$wxflyer_version." -->\n";
echo "<!-- http://www.642weather.com/weather/scripts.php -->\n\n";
?>


<!-- ##### EOF Main Copy ##### -->

 </div>
</div>

 <!-- ##### Footer ##### -->

 <div align="center">

<?php
echo '<span style="font-size: 11px;"><br />Copyright &amp;copy; '.date('Y').', '.$site_name.'<br />
Forecast by National Weather Service and Satellite Image by Weather Underground (excluded from copyright)</span><br />
<span style="font-size: 8px;">
This weather data provided "as is," and '
.$site_name.' disclaims any and all warranties,
whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose.
Never base important decisions that could result in harm to people or property on this weather information.
This weather flyer is freely redistributable without modification provided this notice is preserved.
</span>'
;
?>

 </div>

<?php
// functions -------------------------------------------------------------------

function get_forecast_discussion_flyer() {
 //import NWS Area Forecast Discussion
 global $domain, $Status, $curl_debug, $WRH_URL;

 $cacheName = "./nws-forecast-discussion.txt";
 $refetchSeconds = 3600;

 $xml = '';
 $get_file_failed = 0;
 $force =0;

 if (isset($_GET['force']) &amp;&amp; $_GET['force'] == 1) {
 $force = 1;
 }


 if (!$force and file_exists($cacheName) and filemtime($cacheName) + $refetchSeconds > time()) {  //600=10 min
 $age = time() - filectime($cacheName);
 $nextFetch = $refetchSeconds - $age;
 $Status .= "<!-- using cached forecast-discussion version from $cacheName - age=$age secs. Next fetch in $nextFetch secs. -->\n";
 //$html = file_get_contents($cacheName);
 $xml = implode('', file($cacheName));
 if (strlen($xml) < 300) {
 $Status .= "<!-- Warning: forecast-discussion cache file size = " . strlen($xml) . " is too small.. fetched data not found. -->\n";
 $Status .= "<!-- forecast-discussion Cache file HTML contents: " . htmlspecialchars(strip_tags(str_replace('-->','',trim($xml)))) . " -->\n";
 $get_file_failed = 1;
 }
 }
 else {

 if (!function_exists('curl_init')) {
 $xml = GrabURLWithoutHangingRA($WRH_URL);
 $Status .= "<!-- Using fsocketopen to get new forecast-discussion file from $WRH_URL -->\n";
 }
 else {
 $xml = curl_fetch_file($WRH_URL,0);
 $Status .= "<!-- Using CURL to get new forecast-discussion file from $WRH_URL -->\n";
 }
 $Status .= $curl_debug;
 $curl_debug = '';

 $junk = 'n/a';
 if (preg_match("/\r\n\r\n/", $xml)) {
 list($junk, $xml) = explode("\r\n\r\n", $xml, 2);
 }
 if ($xml == '') {
 $xml = $junk;    // curl method does not have the headers
 $junk = 'n/a';
 }
 if (preg_match("/No data were returned/i", $xml)) {
 $xml = 'no data';
 }
 if ($xml != 'no data') { // not going to be a valid data return, do not cache it
 $fp = fopen($cacheName, "w");
 if ($fp) {
 $write = fputs($fp, $xml);
 fclose($fp);
 $Status .= "<!-- forecast-discussion cache saved to $cacheName -->\n";
 }
 else {
 $Status .= "<!-- forecast-discussion unable to write $cacheName -->\n";
 }
 }
 if (strlen($xml) < 300 &amp;&amp; $xml != 'no data') {  // not going to be a valid data return, do cache it
 $Status .= "<!-- forecast-discussion HTML characters length = " . strlen($xml) . " -->\n";
 $Status .= "<!-- HTML headers received: " . htmlspecialchars(strip_tags(trim($junk))) . " -->\n";
 $Status .= "<!-- HTML received: " . htmlspecialchars(strip_tags(str_replace('-->','',trim($xml)))) . " -->\n";
 $get_file_failed = 1;
 }
 }

 echo $Status;
 $html = $xml;
 $text = '';

 // now slice it up
 // some forecast discussions start with "synopsys..." and some start with "short term..."
 // make different attempts to select the text
 // attempt
 preg_match("|synopsis\.\.\.([^&amp;{2}]+)&amp;{2}|is", $html, $betweenspan);
 $text = trim($betweenspan[1]);

 // attempt
 if ($text == '') {
 preg_match("|synopsis\.\.\.([^&amp;&amp;]+)&amp;{2}|is", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 // attempt
 if ($text == '') {
 preg_match("|SHORT TERM \([ a-zA-Z]+\)\.\.\.(.*)LONG TERM|is", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 // attempt
 if ($text == '') {
 preg_match("|SHORT TERM[ a-zA-Z/]*\.\.\.([^&amp;{2}]+)&amp;{2}|is", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 // attempt
 if ($text == '') {
 preg_match("|SHORT TERM[ a-zA-Z/]*\.\.\.([^&amp;&amp;]+)&amp;{2}|is", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 // attempt
 if ($text == '') {
 preg_match("|DISCUSSION\.\.\.(.*)\.PREVIOUS|Us", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 // attempt
 if ($text == '') {
 preg_match("|DISCUSSION\.\.\.(.*)\.\.\.|Us", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 // attempt
 if ($text == '') {
 preg_match("|PREV DISCUSSION\.\.\.([^&amp;&amp;]+)&amp;{2}|is", $html, $betweenspan);
 $text = trim($betweenspan[1]);
 }

 if ($text != '') {
 $text = ucfirst(htmlspecialchars(strip_tags(strtolower($text))));
 $text = truncate_flyer($text,750,'');
 // uppercase first word of every sentance
 $text = preg_replace('/([\.!\?]\s+|\A)(\w)/e', '"$1" . strtoupper("$2")', $text);
 return $text .' ... This discussion continues at '. $domain;
 } else {
 return '<!-- error: could not find text in forecast discussion -->';
 }
} // end function get_forecast_duscussion_flyer

// change the hh:mm AM/PM to h:mmam/pm format
function fixup_time ( $WDtime ) {
 return date('g:ia' , strtotime($WDtime));
}

// strip trailing units from a measurement
// i.e. '30.01 in. Hg' becomes '30.01'
function strip_units ($data) {
 preg_match('/([\d\.\+\-]+)/',$data,$t);
//  print "<!-- '$data'\n";
//  print_r($t);
//  print "-->\n";
 return $t[1];
}

function truncate_flyer($text,$numb,$etc = "...") {
 $text = html_entity_decode($text, ENT_QUOTES);
 if (strlen($text) > $numb) {
 $text = substr($text, 0, $numb);
 $text = substr($text,0,strrpos($text,' '));
 $punctuation = "!?:;,-"; //punctuation you want removed
 $text = (strspn(strrev($text),  $punctuation)!=0) ? substr($text, 0, -strspn(strrev($text),  $punctuation)) : $text;
 $text = $text.$etc;
 }
 $text = htmlentities($text, ENT_QUOTES);
 return $text;
}

?>
</div>
 </body>
</html>

&amp;nbsp;

Volcano Conditions Add-on for WD/PHP

Displays the U.S. Geological Survey’s daily/weekly current conditions and observations for the given volcano. Also displays a web cam image. This is a Plugin Page for the USA

 

<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (WD-USA template set)
############################################################################
#
#   Project:    Sample Included Website Design
#   Module:     sample.php
#   Purpose:    Sample Page
#   Authors:    Kevin W. Reed <kreed@tnet.com>
#               TNET Services, Inc.
#
#     Copyright:    (c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# 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 2
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
############################################################################
#    This document uses Tab 4 Settings
############################################################################
require_once("Settings.php");
require_once("common.php");
############################################################################
$TITLE= $SITE['organ'] . " - Mt. Redoubt Volcano - Current Update";
$showGizmo = true;  // set to false to exclude the gizmo
include("top.php");
############################################################################
?>
</head>
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
?>

<div id="main-copy">

<!-- content begins -->

<h1>Mt. Redoubt Volcano - Current Update</h1>

<br />

<?php

// get volcano current update , parse and display

/*
Mt Redoubt Volcano Conditions Script by Mike Challis
Volcano Conditions - Carterlake Plugin Page by Mike Challis
Free PHP Scripts - www.642weather.com/weather/scripts.php
Download         - www.642weather.com/weather/scripts/wxvolcano.zip
Live Demo AK     - www.642weather.com/weather/volcano-ak.php
Live Demo WA     - www.642weather.com/weather/volcano.php
Contact Mike     - www.642weather.com/weather/contact_us.php
Donate:          https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2319642

Version: 1.03 - 11-Sep-2010 see changelog.txt for changes

Support thread at weather-watch forum:
http://www.weather-watch.com/smf/index.php/topic,40385.0.html

You are free to use and modify the code

This php code provided "as is", and Long Beach Weather (Michael Challis)
disclaims any and all warranties, whether express or implied, including
(without limitation) any implied warranties of merchantability or
fitness for a particular purpose.

Copyright (C) 2008-2010 Mike Challis  (www.642weather.com/weather/contact_us.php)

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 2 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.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/


$Version = 'V1.0 14-Jun-2009';

$cacheName = "volcano-current-ak.txt";  // used to store the file so we
//                                        don't have to fetch it each time

$refetchSeconds = 1800;     // # 1800 = 1/2 hour - refetch every nnnn seconds (600=5 minutes)

$RSS_URL = 'http://www.avo.alaska.edu/release.php';
//
// end of settings -------------------------------------------------

$Status = "<!-- wxvolcano-ak.php - $Version -->\n";
$Status .= "<!-- http://www.642weather.com/weather/scripts.php -->\n";

// refresh cached copy of page if needed
// fetch/cache code by Tom at carterlake.org

if (file_exists($cacheName) and filemtime($cacheName) + $refetchSeconds > time()) {
 $Status .= "<!-- using Cached version from $cacheName -->\n";
 $age = time() - filectime($cacheName);
 $nextFetch = $refetchSeconds - $age;
 $Status .= "<!-- cache is $age seconds old. Refetch in $nextFetch secs. -->\n";
} else {
 $Status .= "<!-- loading $cacheName from URL\n $RSS_URL\n -->\n";
 $html = GrabURLWithoutHanging($RSS_URL,false);
 $fp = fopen($cacheName, "w");
 $write = fputs($fp, $html);
 fclose($fp);
 $Status .= "<!-- loading finished. -->\n";
}


// all output from program comes from here
$volcano_html = main_code();


// ----------------------------functions -----------------------------------

function main_code() {

 global  $cacheName, $string, $Status, $Debug;

 if (!$volcanodata=file_get_contents("$cacheName") ) {
 $string .= gracefulerror('Error reading volcano current update data.');
 return $string;
 }

 preg_match('|<b>ALASKA VOLCANO OBSERVATORY WEEKLY UPDATE</b>(.*)</avo_update>|Us', $volcanodata, $betweenspan);

 $string .= $betweenspan[1];


 if ($string == '') {
 $string  = 'Volcano Update unavailable, please try later.';
 } else {
 $string = "<b>ALASKA VOLCANO OBSERVATORY</b><br />$string<br /><br />";
 }

 $string = strip_tags($string, '<b><br>');

 return $Status . $Debug . $string;

}

// get contents from one URL and return as string
function GrabURLWithoutHanging($url,$useFopen) {
// thanks to Tom at Carterlake.org for this script fragment
 global $Debug;
 $UA = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)';
 if (! $useFopen) {
 // Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
 $numberOfSeconds=4;

 // Suppress error reporting so Web site visitors are unaware if the feed fails
 error_reporting(0);

 // Extract resource path and domain from URL ready for fsockopen
 $FullUrl = $url;
 $url = str_replace("http://","",$url);
 $urlComponents = explode("/",$url);
 $domain = $urlComponents[0];
 $resourcePath = str_replace($domain,"",$url);
 $Debug .= "<!-- GET $resourcePath HTTP/1.0 \n      Host: $domain -->\n";
 $time_start = microtime_float();

 // Establish a connection
 $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);

 if (!$socketConnection){
 // You may wish to remove the following debugging line on a live Web site
 // print("<!-- Network error: $errstr ($errno) -->");
 }else {
 $xml = '';
 fputs($socketConnection, "GET $resourcePath HTTP/1.0\r\nHost: $domain\r\nUser-agent: $UA\r\nConnection: close\r\n\r\n");

 // Loop until end of file
 while (!feof($socketConnection)) {
 $xml .= fgets($socketConnection, 4096);
 }
 fclose ($socketConnection);
 }
 $time_stop = microtime_float();
 $total_time += ($time_stop - $time_start);
 $time_fetch = sprintf("%01.3f",round($time_stop - $time_start,3));
 $Debug .= "<!-- Time to fetch: $time_fetch sec -->\n";

 list($headers,$html) = explode("\r\n\r\n",$xml,2);
 return($html);
 } else {
 $Debug .= "<!-- using file function -->\n";
 $time_start = microtime_float();
 $xml = implode('',file($url));
 $time_stop = microtime_float();
 $total_time += ($time_stop - $time_start);
 $time_fetch = sprintf("%01.3f",round($time_stop - $time_start,3));
 $Debug .= "<!-- Time to fetch: $time_fetch sec -->\n";
 return($xml);
 }
}    // end fetchUrlWithoutHanging

function microtime_float() {
 list($usec, $sec) = explode(" ", microtime());
 return ((float)$usec + (float)$sec);
}

function gracefulerror($reason) {
 return "Mt. Redoubt Volcano Current Conditions Unavailable<br />$reason";
}

?>

 <?php echo $volcano_html ?>


 Source: <a href="http://www.avo.alaska.edu/activity/avoreport.php" title="Alaska Volcano Observatory" target="_blank">Alaska Volcano Observatory</a>

 <br />
 <br />

<div
style="border: 1px solid black;
padding: .5em">

 <h3>Mount Redoubt Volcano Cam</h3>

<br />

<img src="http://volcanoes.usgs.gov/avo/webcam/redoubt-3.jpg?dontcache=<?php echo time() ?>"
 alt="Mount Redoubt - DFR Web Cam"
 title="Mount Redoubt - DFR Web Cam" width="640" height="480" />

<br />

<p>
This is a static image of Mount Redoubt,
The VolcanoCam image automatically updates approximately every two hours.<br />
Volcano image courtesy of ...<br />
<a href="http://www.avo.alaska.edu/webcam/index.php" title="Live webcam images of various Alaskan volcanoes" target="_blank">Live webcam images of various Alaskan volcanoes</a><br />
<a href="http://www.avo.alaska.edu/webcam/Redoubt_-_DFR.php" title="Alaska Volcano Observatory Webcam - Redoubt - DFR" target="_blank">Alaska Volcano Observatory Webcam - Redoubt - DFR</a>
</p>


</div>


<br />
<br />

Information courtesy of ...<br />
U.S. Geological Survey, the University of Alaska Fairbanks Geophysical Institute,
and the Alaska Division of Geological and Geophysical Surveys.
<br />

<a href="http://vulcan.wr.usgs.gov/" title="USGS Cascades Volcano Observatory" target="_blank">USGS Cascades Volcano Observatory</a><br />
<a href="http://volcano.wr.usgs.gov/" title="U.S. Geological Survey - Cascade Range Current Update" target="_blank">Cascade Range Current Update</a><br />
<a href="http://volcanoes.usgs.gov/2006/warnschemes.html" title="USGS Alert-Notification System for Volcanic Activity" target="_blank">USGS Alert-Notification System for Volcanic Activity</a><br />
<a href="http://www.avo.alaska.edu/" title="Volcano Observatories: Alaska" target="_blank">Volcano Observatories: Alaska</a><br />
<a href="http://vulcan.wr.usgs.gov/" title="Volcano Observatories: Cascades" target="_blank">Volcano Observatories: Cascades</a><br />
<a href="http://hvo.wr.usgs.gov/" title="Volcano Observatories: Hawaii" target="_blank">Volcano Observatories: Hawaii</a><br />
<a href="http://lvo.wr.usgs.gov/" title="Volcano Observatories: Long Valley" target="_blank">Volcano Observatories: Long Valley</a><br />
<a href="http://hvo.wr.usgs.gov/cnmi/" title="Volcano Observatories: Mariana Islands" target="_blank">Volcano Observatories: Mariana Islands</a><br />
<a href="http://volcanoes.usgs.gov/yvo/" title="Volcano Observatories: Yellowstone" target="_blank">Volcano Observatories: Yellowstone</a><br />

<!-- content ends -->

</div><!-- end main-copy -->

<?php
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################
?>

&amp;nbsp;

Space Weather Add-on for WD/PHP

This script will show a space weather forecast page, Real Time Images of the Sun, and graphs of Real Time Solar X-ray and Solar Wind. This is a Plugin Page for the USA.

 

 

<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (WD-USA template set)
############################################################################
#
#   Project:    Sample Included Website Design
#   Module:     sample.php
#   Purpose:    Sample Page
#   Authors:    Kevin W. Reed <kreed@tnet.com>
#               TNET Services, Inc.
#
#     Copyright:    (c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# 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 2
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
############################################################################
#    This document uses Tab 4 Settings
############################################################################
require_once("Settings.php");
require_once("common.php");
############################################################################
$TITLE= $SITE['organ'] . " - Space Weather";
$showGizmo = true;  // set to false to exclude the gizmo
include("top.php");
############################################################################
?>
</head>
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
?>

<?php

// get spaceweather current update , parse and display

// settings --------------------------------------------------------

$Version        = 'V 1.2 24-Oct-2009';
$cacheName      = 'spaceweather-current.txt';  // used to cache the file
$refetchSeconds = 1800; // # 1800 = 1/2 hour - refetch every nnnn seconds (600=5 minutes)
$SPACE_URL      = 'http://www.swpc.noaa.gov/today.html';

// end of settings -------------------------------------------------

$Status = "<!-- space weather - $Version -->\n";

// refresh cached copy of page if needed
// fetch/cache code by Tom at carterlake.org

if (file_exists($cacheName) and filemtime($cacheName) + $refetchSeconds > time()) {
 $Status .= "<!-- using Cached version from $cacheName -->\n";
 $age = time() - filectime($cacheName);
 $nextFetch = $refetchSeconds - $age;
 $Status .= "<!-- cache is $age seconds old. Refetch in $nextFetch secs. -->\n";
} else {
 $Status .= "<!-- loading $cacheName from URL\n $SPACE_URL\n -->\n";
 $html = GrabURLWithoutHangingSW($SPACE_URL,false);
 $fp = fopen($cacheName, "w");
 if ($fp) {
 $write = fputs($fp, $html);
 fclose($fp);
 } else {
 $Status .= "<!-- unable to write cache file $cacheName -->\n";
 }
 $Status .= "<!-- loading finished. -->\n";
}

?>

<div id="main-copy">

 <h3>Space Weather Observations, Alerts, and Forecast</h3>


<br />

<h3>3-day Solar-Geophysical Forecast <?php echo main_code();

echo $Status;
?>

<div style="text-align:center">
<a href="http://www.swpc.noaa.gov/alerts/archive/current_month.html">Space Weather Alerts - Current Month</a>
</div>

<br />
<h3>Real Time Images of the Sun</h3>
<br />


<table width="99%" cellpadding="0" border="0" cellspacing="0">
<tr>

<td align="center">
<a href="http://sohowww.nascom.nasa.gov/data/realtime-images.html">SOHO EIT 304</a><br />
<a href="http://sohowww.nascom.nasa.gov/data/LATEST/current_eit_304.mpg">
 <img src="image-space-eit-304.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="170" height="170"
 alt="Click for time-lapse image of the sun"
 title="Click for time-lapse image of the sun"
 /></a>
</td>

<td align="center">
<a href="http://sohowww.nascom.nasa.gov/data/realtime-images.html">SOHO EIT 284</a><br />
<a href="http://sohowww.nascom.nasa.gov/data/realtime-images.html">
<img src="image-space-eit-284.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="170" height="170"
 alt="SOHO EIT 284 image of the sun"
 title="SOHO EIT 284 image of the sun" /></a>
</td>

<td align="center">
<a href="http://mlso.hao.ucar.edu/cgi-bin/mlso_homepage.cgi">Mauna Loa Solar Image</a><br />
<a href="http://mlso.hao.ucar.edu/cgi-bin/mlso_homepage.cgi">
 <img src="image-space-solar-disk.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="170" height="170"
 alt="Latest Mauna Loa image of the Sun"
 title="Latest Mauna Loa image of the Sun" /></a>
</td>

</tr>
</table>

<p>The sun is constantly monitored for <a href="http://en.wikipedia.org/wiki/Sunspot">sun spots</a> and <a href="http://en.wikipedia.org/wiki/Coronal_mass_ejections">coronal mass ejections</a>.
EIT (Extreme ultraviolet Imaging Telescope) images the solar atmosphere at several wavelengths,
and therefore, shows solar material at different temperatures.
In the images taken at 304 Angstrom the bright material is at 60,000 to 80,000 degrees Kelvin.
In those taken at 171 Angstrom, at 1 million degrees.
195 Angstrom images correspond to about 1.5 million Kelvin, 284 Angstrom to 2 million degrees.
The hotter the temperature, the higher you look in the solar atmosphere.</p>

<h3>Real Time Solar X-ray and Solar Wind</h3>
<br />

<table width="99%" cellpadding="0" border="0" cellspacing="0">
<tr>

<td align="center">
 <a href="http://www.swpc.noaa.gov/SolarCycle/">Solar Cycle Progression</a><br />
<a href="http://www.swpc.noaa.gov/SolarCycle/">
<img src="image-space-solar-cycle.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="239" height="183"
 alt="Graph showing current solar cycle progression"
 title="Graph showing current solar cycle progression" /></a>
 <br />
 Solar Cycle chart updated using the latest ISES predictions.
</td>

<td align="center" valign="top">
 <a href="http://www.swpc.noaa.gov/ace/">Real-Time Solar Wind</a><br />
<a href="http://www.swpc.noaa.gov/ace/">
<img src="image-space-solar-wind.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="310" height="170"
 alt="Graph showing Real-Time Solar Wind"
 title="Graph showing Real-Time Solar Wind" /></a>
 <br />
 Real-Time Solar Wind data broadcast from NASA's ACE satellite.
</td>

</tr>
</table>

<p>
The <a href="http://en.wikipedia.org/wiki/Solar_cycle">Solar Cycle</a> is observed by counting the frequency and placement of sunspots visible on the Sun.
Solar minimum occurred in December, 2008. Solar maximum is expected to occur in May, 2013.
</p>

<table width="99%" cellpadding="0" border="0" cellspacing="0">
<tr>
<td align="center">
<a href="http://www.swpc.noaa.gov/today.html#xray">Solar X-ray Flux</a><br />
 <a href="http://www.swpc.noaa.gov/today.html#xray">
 <img src="image-space-xray.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="320" height="240"
 alt="Graph showing Real-Time Solar X-ray Flux"
 title="Graph showing Real-Time Solar X-ray Flux" /></a><br />
This plot shows 3-days of 5-minute solar x-ray flux values measured on the SWPC primary and secondary GOES satellites.
</td>

<td align="center">
<a href="http://www.swpc.noaa.gov/today.html#satenv">Satellite Environment Plot</a><br />
 <a href="http://www.swpc.noaa.gov/today.html#satenv">
 <img src="image-space-sat-env.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="320" height="240"
 alt="Graph showing Real-Time Satellite Environment Plot"
 title="Graph showing Real-Time Satellite Environment Plot" /></a><br />
The Satellite Environment Plot combines satellite and ground-based data to provide an overview of the current geosynchronous satellite environment.
</td>

</tr>
</table>

<br />
<h3>Auroral Activity Extrapolated from NOAA POES</h3>
<br />

<table width="99%" cellpadding="0" border="0" cellspacing="0">
<tr>

<td align="center">
<a href="http://www.swpc.noaa.gov/pmap/index.html">Northern Hemi Auroral Map</a><br />
 <a href="http://www.swpc.noaa.gov/pmap/index.html">
 <img src="image-space-aurora.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="315" height="280"
 alt="Current Northern hemispheric power input map"
 title="Current Northern hemispheric power input map" /></a>
</td>

<td align="center">
<a href="http://www.swpc.noaa.gov/pmap/index.html">Southern Hemi Auroral Map</a><br />
 <a href="http://www.swpc.noaa.gov/pmap/index.html">
 <img src="image-space-aurora-s.php?dontcache=<?php echo time(); ?>"
 style="border:none;" width="315" height="280"
 alt="Current Southern hemispheric power input map"
 title="Current Southern hemispheric power input map" /></a>
</td>

</tr>
</table>

<p>
Instruments on board the NOAA Polar-orbiting Operational Environmental Satellite (POES) continually monitor the power flux carried by the protons and electrons that produce aurora in the atmosphere. SWPC has developed a technique that uses the power flux observations obtained during a single pass of the satellite over a polar region (which takes about 25 minutes) to estimate the total power deposited in an entire polar region by these auroral particles.
The power input estimate is converted to an auroral activity index that ranges from 1 to 10.
</p>

<h3>Credits: </h3>
Space Weather Images and Information (excluded from copyright) courtesy of:
<a href="http://www.swpc.noaa.gov/">NOAA / NWS Space Weather Prediction Center</a>,
<a href="http://mlso.hao.ucar.edu/cgi-bin/mlso_homepage.cgi">Mauna Loa Solar Observatory (HAO/NCAR)</a>,
and <a href="http://sohowww.nascom.nasa.gov/home.html">SOHO (ESA &amp;amp; NASA)</a>.
<br />
<br />

<b>Space Weather links: </b><br />
<a href="http://www.swpc.noaa.gov/forecast.html">3-Day Forecast of Solar and Geophysical Activity</a><br />
<a href="http://www.swpc.noaa.gov/SWN/index.html">Space Weather Now</a><br />
<a href="http://www.swpc.noaa.gov/today.html">Today's Space Weather</a><br />
<a href="http://www.swpc.noaa.gov/ace/">Real-Time Solar Wind</a><br />
<a href="http://www.swpc.noaa.gov/advisories/outlooks.html">Space Weather Outlooks</a><br />
<a href="http://www.swpc.noaa.gov/advisories/bulletins.html">Space Weather Bulletins</a><br />
<a href="http://www.swpc.noaa.gov/alerts/index.html">Space Weather Alerts and Warnings</a><br />
<a href="http://www.swpc.noaa.gov/alerts/archive/current_month.html">Space Weather Alerts - Current Month</a><br />
<a href="http://sohowww.nascom.nasa.gov/home.html">Solar and Heliospheric Observatory (SOHO)</a><br />
<a href="http://sohowww.nascom.nasa.gov/data/realtime-images.html">The Very Latest SOHO Images</a><br />

<p>Powered by <a href="http://www.642weather.com/weather/scripts-space-weather.php">Space Weather PHP script</a> by Mike Challis</p>

</div><!-- end main-copy -->

<?php
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################

// ----------------------------functions -----------------------------------

function main_code() {

 global $cacheName;

 if (!$data = file_get_contents("$cacheName") ) {
 $string = gracefulerror('Error reading spaceweather current update data.');
 return $string;
 }

 preg_match('|3-day Solar-Geophysical Forecast</a>(.*)(</blockquote>{1})|Uis', $data, $betweenspan);
 $string = $betweenspan[1];

 $string = preg_replace('|</b>|is','</b><br />',$string);

 if ($string == '' || preg_match("|You don't have permission to access|i",$data)) {
 $string = '</h3><br />forecast not available';
 }

 // security feature
 $string = strip_tags($string, '<p><h3><b><br>');

 return $string;

}

// get contents from one URL and return as string
function GrabURLWithoutHangingSW($url,$useFopen) {
// thanks to Tom at Carterlake.org for this script fragment
 $Debug = '';
 $UA = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)';
 if (! $useFopen) {
 // Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed
 $numberOfSeconds = 4;

 // Suppress error reporting so Web site visitors are unaware if the feed fails
 error_reporting(0);

 // Extract resource path and domain from URL ready for fsockopen
 $FullUrl = $url;
 $url = str_replace("http://","",$url);
 $urlComponents = explode("/",$url);
 $domain = $urlComponents[0];
 $resourcePath = str_replace($domain,"",$url);
 $Debug .= "<!-- GET $resourcePath HTTP/1.1 \n Host: $domain -->\n";
 $time_start = microtime_float();

 // Establish a connection
 $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds);

 if (!$socketConnection){
 // You may wish to remove the following debugging line on a live Web site
 // print("<!-- Network error: $errstr ($errno) -->");
 }else {
 $xml = '';
 fputs($socketConnection, "GET $resourcePath HTTP/1.1\r\nHost: $domain\r\nUser-agent: $UA\r\nConnection: close\r\n\r\n");

 // Loop until end of file
 while (!feof($socketConnection)) {
 $xml .= fgets($socketConnection, 4096);
 }
 fclose ($socketConnection);
 }
 $time_stop = microtime_float();
 $total_time += ($time_stop - $time_start);
 $time_fetch = sprintf("%01.3f",round($time_stop - $time_start,3));
 $Debug .= "<!-- Time to fetch: $time_fetch sec -->\n";

 list($headers,$html) = explode("\r\n\r\n",$xml,2);
 echo $Debug;
 return($html);
 } else {
 $Debug .= "<!-- using file function -->\n";
 $time_start = microtime_float();
 $xml = implode('',file($url));
 $time_stop = microtime_float();
 $total_time += ($time_stop - $time_start);
 $time_fetch = sprintf("%01.3f",round($time_stop - $time_start,3));
 $Debug .= "<!-- Time to fetch: $time_fetch sec -->\n";
 echo $Debug;
 return($xml);
 }
}    // end fetchUrlWithoutHanging

function microtime_float() {
 list($usec, $sec) = explode(" ", microtime());
 return ((float)$usec + (float)$sec);
}

function gracefulerror($reason) {
 return "Space Weather Forecast Unavailable<br />$reason";
}

?>

&amp;nbsp;

WD/PHP/AJAX Website Template Site Navigation

This is a WordPress Weather Blog Add-on Theme that is custom tailored to add a blog feature to a WD/PHP/AJAX Website Template.

 

 

<?php
/**
 * @package WordPress
 * @subpackage Default_Theme
 */


$content_width = 450;

automatic_feed_links();

if ( function_exists('register_sidebar') ) {
 register_sidebar(array(
 'before_widget' => '<li id="%1$s">',
 'after_widget' => '</li>',
 'before_title' => '<h2>',
 'after_title' => '</h2>',
 ));
}

/** @ignore */
function kubrick_head() {
 $head = "<style type='text/css'>\n<!--";
 $output = '';
 if ( kubrick_header_image() ) {
 $url =  kubrick_header_image_url() ;
 $output .= "#header { background: url('$url') no-repeat bottom center; }\n";
 }
 if ( false !== ( $color = kubrick_header_color() ) ) {
 $output .= "#headerimg h1 a, #headerimg h1 a:visited, #headerimg .description { color: $color; }\n";
 }
 if ( false !== ( $display = kubrick_header_display() ) ) {
 $output .= "#headerimg { display: $display }\n";
 }
 $foot = "--></style>\n";
 if ( '' != $output )
 echo $head . $output . $foot;
}

add_action('wp_head', 'kubrick_head');

function kubrick_header_image() {
 return apply_filters('kubrick_header_image', get_option('kubrick_header_image'));
}

function kubrick_upper_color() {
 if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
 parse_str(substr($url, strpos($url, '?') + 1), $q);
 return $q['upper'];
 } else
 return '69aee7';
}

function kubrick_lower_color() {
 if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
 parse_str(substr($url, strpos($url, '?') + 1), $q);
 return $q['lower'];
 } else
 return '4180b6';
}

function kubrick_header_image_url() {
 if ( $image = kubrick_header_image() )
 $url = get_template_directory_uri() . '/images/' . $image;
 else
 $url = get_template_directory_uri() . '/images/kubrickheader.jpg';

 return $url;
}

function kubrick_header_color() {
 return apply_filters('kubrick_header_color', get_option('kubrick_header_color'));
}

function kubrick_header_color_string() {
 $color = kubrick_header_color();
 if ( false === $color )
 return 'white';

 return $color;
}

function kubrick_header_display() {
 return apply_filters('kubrick_header_display', get_option('kubrick_header_display'));
}

function kubrick_header_display_string() {
 $display = kubrick_header_display();
 return $display ? $display : 'inline';
}

add_action('admin_menu', 'kubrick_add_theme_page');

function kubrick_add_theme_page() {
 if ( isset( $_GET['page'] ) &amp;&amp; $_GET['page'] == basename(__FILE__) ) {
 if ( isset( $_REQUEST['action'] ) &amp;&amp; 'save' == $_REQUEST['action'] ) {
 check_admin_referer('kubrick-header');
 if ( isset($_REQUEST['njform']) ) {
 if ( isset($_REQUEST['defaults']) ) {
 delete_option('kubrick_header_image');
 delete_option('kubrick_header_color');
 delete_option('kubrick_header_display');
 } else {
 if ( '' == $_REQUEST['njfontcolor'] )
 delete_option('kubrick_header_color');
 else {
 $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
 update_option('kubrick_header_color', $fontcolor);
 }
 if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) &amp;&amp; preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) {
 $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0];
 $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0];
 update_option('kubrick_header_image', "header-img.php?upper=$uc&amp;lower=$lc");
 }

 if ( isset($_REQUEST['toggledisplay']) ) {
 if ( false === get_option('kubrick_header_display') )
 update_option('kubrick_header_display', 'none');
 else
 delete_option('kubrick_header_display');
 }
 }
 } else {

 if ( isset($_REQUEST['headerimage']) ) {
 check_admin_referer('kubrick-header');
 if ( '' == $_REQUEST['headerimage'] )
 delete_option('kubrick_header_image');
 else {
 $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&amp;lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
 update_option('kubrick_header_image', $headerimage);
 }
 }

 if ( isset($_REQUEST['fontcolor']) ) {
 check_admin_referer('kubrick-header');
 if ( '' == $_REQUEST['fontcolor'] )
 delete_option('kubrick_header_color');
 else {
 $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
 update_option('kubrick_header_color', $fontcolor);
 }
 }

 if ( isset($_REQUEST['fontdisplay']) ) {
 check_admin_referer('kubrick-header');
 if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
 delete_option('kubrick_header_display');
 else
 update_option('kubrick_header_display', 'none');
 }
 }
 //print_r($_REQUEST);
 wp_redirect("themes.php?page=functions.php&amp;saved=true");
 die;
 }
 add_action('admin_head', 'kubrick_theme_page_head');
 }
 add_theme_page(__('Custom Header'), __('Custom Header'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
}

function kubrick_theme_page_head() {
?>
<script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
<script type='text/javascript'>
// <![CDATA[
 function pickColor(color) {
 ColorPicker_targetInput.value = color;
 kUpdate(ColorPicker_targetInput.id);
 }
 function PopupWindow_populate(contents) {
 contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="<?php esc_attr_e('Close Color Picker'); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
 this.contents = contents;
 this.populated = false;
 }
 function PopupWindow_hidePopup(magicword) {
 if ( magicword != 'prettyplease' )
 return false;
 if (this.divName != null) {
 if (this.use_gebi) {
 document.getElementById(this.divName).style.visibility = "hidden";
 }
 else if (this.use_css) {
 document.all[this.divName].style.visibility = "hidden";
 }
 else if (this.use_layers) {
 document.layers[this.divName].visibility = "hidden";
 }
 }
 else {
 if (this.popupWindow &amp;&amp; !this.popupWindow.closed) {
 this.popupWindow.close();
 this.popupWindow = null;
 }
 }
 return false;
 }
 function colorSelect(t,p) {
 if ( cp.p == p &amp;&amp; document.getElementById(cp.divName).style.visibility != "hidden" )
 cp.hidePopup('prettyplease');
 else {
 cp.p = p;
 cp.select(t,p);
 }
 }
 function PopupWindow_setSize(width,height) {
 this.width = 162;
 this.height = 210;
 }

 var cp = new ColorPicker();
 function advUpdate(val, obj) {
 document.getElementById(obj).value = val;
 kUpdate(obj);
 }
 function kUpdate(oid) {
 if ( 'uppercolor' == oid || 'lowercolor' == oid ) {
 uc = document.getElementById('uppercolor').value.replace('#', '');
 lc = document.getElementById('lowercolor').value.replace('#', '');
 hi = document.getElementById('headerimage');
 hi.value = 'header-img.php?upper='+uc+'&amp;lower='+lc;
 document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/'+hi.value+'") center no-repeat';
 document.getElementById('advuppercolor').value = '#'+uc;
 document.getElementById('advlowercolor').value = '#'+lc;
 }
 if ( 'fontcolor' == oid ) {
 document.getElementById('header').style.color = document.getElementById('fontcolor').value;
 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value;
 }
 if ( 'fontdisplay' == oid ) {
 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
 }
 }
 function toggleDisplay() {
 td = document.getElementById('fontdisplay');
 td.value = ( td.value == 'none' ) ? 'inline' : 'none';
 kUpdate('fontdisplay');
 }
 function toggleAdvanced() {
 a = document.getElementById('jsAdvanced');
 if ( a.style.display == 'none' )
 a.style.display = 'block';
 else
 a.style.display = 'none';
 }
 function kDefaults() {
 document.getElementById('headerimage').value = '';
 document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
 document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
 document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/kubrickheader.jpg") center no-repeat';
 document.getElementById('header').style.color = '#FFFFFF';
 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '';
 document.getElementById('fontdisplay').value = 'inline';
 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
 }
 function kRevert() {
 document.getElementById('headerimage').value = '<?php echo esc_js(kubrick_header_image()); ?>';
 document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo esc_js(kubrick_upper_color()); ?>';
 document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo esc_js(kubrick_lower_color()); ?>';
 document.getElementById('header').style.background = 'url("<?php echo esc_js(kubrick_header_image_url()); ?>") center no-repeat';
 document.getElementById('header').style.color = '';
 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo esc_js(kubrick_header_color_string()); ?>';
 document.getElementById('fontdisplay').value = '<?php echo esc_js(kubrick_header_display_string()); ?>';
 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
 }
 function kInit() {
 document.getElementById('jsForm').style.display = 'block';
 document.getElementById('nonJsForm').style.display = 'none';
 }
 addLoadEvent(kInit);
// ]]>
</script>
<style type='text/css'>
 #headwrap {
 text-align: center;
 }
 #kubrick-header {
 font-size: 80%;
 }
 #kubrick-header .hibrowser {
 width: 780px;
 height: 260px;
 overflow: scroll;
 }
 #kubrick-header #hitarget {
 display: none;
 }
 #kubrick-header #header h1 {
 font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
 font-weight: bold;
 font-size: 4em;
 text-align: center;
 padding-top: 70px;
 margin: 0;
 }

 #kubrick-header #header .description {
 font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
 font-size: 1.2em;
 text-align: center;
 }
 #kubrick-header #header {
 text-decoration: none;
 color: <?php echo kubrick_header_color_string(); ?>;
 padding: 0;
 margin: 0;
 height: 200px;
 text-align: center;
 background: url('<?php echo kubrick_header_image_url(); ?>') center no-repeat;
 }
 #kubrick-header #headerimg {
 margin: 0;
 height: 200px;
 width: 100%;
 display: <?php echo kubrick_header_display_string(); ?>;
 }

 .description {
 margin-top: 16px;
 color: #fff;
 }

 #jsForm {
 display: none;
 text-align: center;
 }
 #jsForm input.submit, #jsForm input.button, #jsAdvanced input.button {
 padding: 0px;
 margin: 0px;
 }
 #advanced {
 text-align: center;
 width: 620px;
 }
 html>body #advanced {
 text-align: center;
 position: relative;
 left: 50%;
 margin-left: -380px;
 }
 #jsAdvanced {
 text-align: right;
 }
 #nonJsForm {
 position: relative;
 text-align: left;
 margin-left: -370px;
 left: 50%;
 }
 #nonJsForm label {
 padding-top: 6px;
 padding-right: 5px;
 float: left;
 width: 100px;
 text-align: right;
 }
 .defbutton {
 font-weight: bold;
 }
 .zerosize {
 width: 0px;
 height: 0px;
 overflow: hidden;
 }
 #colorPickerDiv a, #colorPickerDiv a:hover {
 padding: 1px;
 text-decoration: none;
 border-bottom: 0px;
 }
</style>
<?php
}

function kubrick_theme_page() {
 if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message"><p><strong>'.__('Options saved.').'</strong></p></div>';
?>
<div class='wrap'>
 <h2><?php _e('Customize Header'); ?></h2>
 <div id="kubrick-header">
 <div id="headwrap">
 <div id="header">
 <div id="headerimg">
 <h1><?php bloginfo('name'); ?></h1>
 <div><?php bloginfo('description'); ?></div>
 </div>
 </div>
 </div>
 <br />
 <div id="nonJsForm">
 <form method="post" action="">
 <?php wp_nonce_field('kubrick-header'); ?>
 <div><input type="submit" name="defaultsubmit" value="<?php esc_attr_e('Save'); ?>" /></div>
 <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo esc_attr(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br />
 <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo esc_attr(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
 <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo esc_attr(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
 <input type="hidden" name="hi" id="hi" value="<?php echo esc_attr(kubrick_header_image()); ?>" />
 <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php esc_attr_e('Toggle Text'); ?>" />
 <input type="submit" name="defaults" value="<?php esc_attr_e('Use Defaults'); ?>" />
 <input type="submit" name="submitform" value="&amp;nbsp;&amp;nbsp;<?php esc_attr_e('Save'); ?>&amp;nbsp;&amp;nbsp;" />
 <input type="hidden" name="action" value="save" />
 <input type="hidden" name="njform" value="true" />
 </form>
 </div>
 <div id="jsForm">
 <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo esc_attr($_SERVER['REQUEST_URI']); ?>">
 <?php wp_nonce_field('kubrick-header'); ?>
 <input type="button"  onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php esc_attr_e('Font Color'); ?>"></input>
 <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php esc_attr_e('Upper Color'); ?>"></input>
 <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php esc_attr_e('Lower Color'); ?>"></input>
 <input type="button" name="revert" value="<?php esc_attr_e('Revert'); ?>" onclick="kRevert()" />
 <input type="button" value="<?php esc_attr_e('Advanced'); ?>" onclick="toggleAdvanced()" />
 <input type="hidden" name="action" value="save" />
 <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo esc_attr(kubrick_header_display()); ?>" />
 <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo esc_attr(kubrick_header_color()); ?>" />
 <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo esc_attr(kubrick_upper_color()); ?>" />
 <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo esc_attr(kubrick_lower_color()); ?>" />
 <input type="hidden" name="headerimage" id="headerimage" value="<?php echo esc_attr(kubrick_header_image()); ?>" />
 <p><input type="submit" name="submitform" value="<?php esc_attr_e('Update Header'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
 </form>
 <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
 <div id="advanced">
 <form id="jsAdvanced" style="display:none;" action="">
 <?php wp_nonce_field('kubrick-header'); ?>
 <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo esc_attr(kubrick_header_color()); ?>" /><br />
 <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo esc_attr(kubrick_upper_color()); ?>" /><br />
 <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo esc_attr(kubrick_lower_color()); ?>" /><br />
 <input type="button" name="default" value="<?php esc_attr_e('Select Default Colors'); ?>" onclick="kDefaults()" /><br />
 <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php esc_attr_e('Toggle Text Display'); ?>"></input><br />
 </form>
 </div>
 </div>
 </div>
</div>
<?php } ?>

&amp;nbsp;

Color Theme Switcher for WD/PHP Navigation

This plugin for the WD/PHP/AJAX Website Template allows your web site users to select a color theme when they visit your site. It adds a “Style Options” selector on the web site navigation menu. When you select a style, it saves the setting in a cookie, so if you come back another time, the same style will be shown again. The Color Theme Switcher Plugin is packaged with many color styles of both narrow and wide layouts and is already included in the WD/PHP/AJAX Website Template as of March 08, 2008.

 

 

<?php
/*
PHP script by Mike Challis, www.642weather.com/weather/
Carterlake/AJAX/PHP Template - Color Theme Switcher Plugin PHP Script
Script available at: http://www.642weather.com/weather/scripts.php
Contact Mike: http://www.642weather.com/weather/contact_us.php
Live Demo: http://www.642weather.com/weather/template/
Download: http://www.642weather.com/weather/scripts/css-theme-switcher.zip

Version: 1.17  19-Dec-2008
- adjustment to cookie path setting

see changelog.txt for all change history

Support comes from MCHALLIS in this topic at the Weather-Watch.com forum:
http://www.weather-watch.com/smf/index.php/topic,30183.0.html

You are free to use and modify the code

This php code provided "as is", and Long Beach Weather (Michael Challis)
disclaims any and all warranties, whether express or implied, including
(without limitation) any implied warranties of merchantability or
fitness for a particular purpose.
*/


# session_start() must be processed before any other output
# or you might get a warning "headers already sent".
if( !isset( $_SESSION ) ) {
 session_start();
}

#################
# begin settings
# ##############

# note the style names in this array are intentionally missing
# the '-wide' and '-narrow' part of the file name, because it is automatically
# replaced by the program based on the user's setting for wide or narrow
# ie: a css file on the server has weather-screen-blue-wide.css
# but the name of it in this array is weather-screen-blue.css

# You can make new styles and add them, just add a new file to the server
# and add a new entry in the array below using the file name conventions noted above

# you can add or remove styles from this array
$CSSstyles = array(
'weather-screen-black.css'   => 'Black',
'weather-screen-blue.css'    => 'Blue',
'weather-screen-dark.css'    => 'Dark',
'weather-screen-fall.css'    => 'Fall',
'weather-screen-green.css'   => 'Green',
'weather-screen-icetea.css'  => 'Ice Tea',
'weather-screen-mocha.css'   => 'Mocha',
'weather-screen-orange.css'  => 'Orange',
'weather-screen-pastel.css'  => 'Pastel',
'weather-screen-purple.css'  => 'Purple',
'weather-screen-red.css'     => 'Red',
'weather-screen-salmon.css'  => 'Salmon',
'weather-screen-silver.css'  => 'Silver',
'weather-screen-spring.css'  => 'Spring',
'weather-screen-taupe.css'   => 'Taupe',
'weather-screen-teal.css'    => 'Teal',
);

############
# Use javascript 'OnChange' to post form
############
# if set to true, the style select will not need a "set" button
# if set to false, the style select show a "set" button
# There is a known issue with IE6 and the onchange feature,
# the ajax updates sometimes interfere causing the onchange not to change when changing a selection

# recommended setting: false
$use_onchange_submit = false; # set to true or false

############
# Use cookies to remember settings between site visits
############
# cookies are used to remember the users style settings on each visit to the web site
# you can disable use of cookies, but then the settings would have to be set by
# the user each visit to the web site

# recommended setting: true
$use_cookies = true; # set to true or false

# sets allowable user style select options: (can be overriden with $SITE['CSSsettings_mode'])
$settings_mode = 1; # user can select style and widescreen (show style select and screen width select)
//$settings_mode = 2; # user can select styles only (hide screen width select)
//$settings_mode = 3; # user can select screen width only (hide style select)


#################
# end settings
# ##############

global $SITE;

if (isset($SITE['CSSsettings_mode']) &amp;&amp; $SITE['CSSsettings_mode'] > 0 &amp;&amp; $SITE['CSSsettings_mode'] < 4) {
 $settings_mode = $SITE['CSSsettings_mode'];
}

function print_css_style_menu ($menubar = 0, $output = 'echo') {

$string = '';

/* ###

 # this function makes the form input html so a user can select a style
 # it can be called in menubar.php or on index.php

 # when using on on menubar.php, you can have it print narrow on a few lines this:
 #<div style="margin-left: 5px">
 #<?php print_css_style_menu(1); ?>
 #</div>

 # when using on on index.php, you can have it print horizontal on one line like this:
 #<?php print_css_style_menu(0); ?>

*/
###

 global $CSSstyles, $use_onchange_submit, $settings_mode;

$CSSstyle = '';
# was there a style selected from the form input
if (isset($_POST['CSSstyle']) &amp;&amp; preg_match("/^[a-z0-9-]{1,50}.css$/i", $_POST['CSSstyle'])) {
 $CSSstyle = $_POST['CSSstyle'];
} else if (isset($_SESSION['CSSstyle'])) {
 $CSSstyle = $_SESSION['CSSstyle'];
}

# was use widescreen template selected from the form input?
$CSSwscreenOnChecked = '';
$CSSwscreenOffChecked = '';
if (isset($_SESSION['CSSwidescreen']) &amp;&amp; $_SESSION['CSSwidescreen'] == 1) {
 $CSSwscreenOnChecked = ' checked="checked"';
} else if (isset($_SESSION['CSSwidescreen']) &amp;&amp; $_SESSION['CSSwidescreen'] == 0) {
 $CSSwscreenOffChecked = ' checked="checked"';
} else {
 $CSSwscreenOffChecked = ' checked="checked"';
}
$string .= '<p style="margin-left: -5px;">Style Options</p>';
$string .= '
<form method="post" name="style_select" action="">
<p>'
;

if ($settings_mode != 3) {  // style settings allowed
 $string .= '<label for="CSSstyle">Style:</label>';
 if ($menubar) $string .= '<br />';

 if($use_onchange_submit == false) {
 $string .= '
 <select id="CSSstyle" name="CSSstyle">'
;
 }
 else {
 $string .= '
 <select id="CSSstyle" name="CSSstyle" onchange="this.form.submit();">'
;
 }

 $CSSstyleSelected = '';
 foreach ($CSSstyles as $k => $v) {
 if ($CSSstyle == "$k") $CSSstyleSelected = ' selected="selected"';
 $string .= '<option value="'.$k.'"'.$CSSstyleSelected.'>'.$v.'</option>'."\n";
 $CSSstyleSelected = '';
 }
 $string .= '</select>';

 if ($menubar) {
 $string .= '<br />';
 }else{
 $string .= ' &amp;nbsp;&amp;nbsp; ';
 if($use_onchange_submit == false) {
 $string .= '<input type="submit" name="Set" value="Set" />';
 }
 }

 if (!$menubar) {
 $string .= ' &amp;nbsp;&amp;nbsp; ';
 }
}
if ($settings_mode != 2) {  // screen width settings allowed
 $string .= 'Widescreen:';
 if ($menubar) {
 $string .= '<br />';
 }else{
 $string .= ' ';
 }

 if($use_onchange_submit == true) {
 $string .= '<label for="CSSwidescreenOn">On</label> <input type="radio" id="CSSwidescreenOn" name="CSSwidescreen" value="1" '.$CSSwscreenOnChecked.' onchange="this.form.submit();" />
| <label for="CSSwidescreenOff">Off</label> <input type="radio" id="CSSwidescreenOff" name="CSSwidescreen" value="0" '
.$CSSwscreenOffChecked.' onchange="this.form.submit();" />';
 }
 else {
 $string .= '<label for="CSSwidescreenOn">On</label> <input type="radio" id="CSSwidescreenOn" name="CSSwidescreen" value="1" '.$CSSwscreenOnChecked.' />
| <label for="CSSwidescreenOff">Off</label> <input type="radio" id="CSSwidescreenOff" name="CSSwidescreen" value="0" '
.$CSSwscreenOffChecked.' />';
 }
}
if ($menubar) {
 $string .= '<br />';
}else{
 $string .= ' &amp;nbsp;&amp;nbsp; ';
}

if($use_onchange_submit == false) {
 $string .= '<input type="submit" name="Set" value="Set" />';
}

$string .= '</p>
</form>'
;

# can be printed right where you call it or loaded into a string for later print
# $menubottom .= print_css_style_menu(1,'string');
# print_css_style_menu(1);

if ($output == 'echo') {
 echo $string;
} else {
 return $string;
}

 # uncomment only for debugging
//echo '<p><b>COOKIE INFO:</b><br>';
 //print_r($_COOKIE).'</p>';
 //echo '<hr>';
 //echo '<p><b>SESSION INFO:</b><br>';
 //print_r($_SESSION).'</p>';
 //echo '<p>Style choice ' .$SITE['CSSscreen'] .'</p>';

}


function validate_style_choice() {

 # this function sets the working style based on user's input or not
# input can come from post, cookie, or session

 global $CSSstyles, $SITE, $use_cookies, $settings_mode;

 $wide_style = 0;
 $narrow_style = 0;
 $CSSstyle = '';

 // incase site admin sets up $SITE['CSSscreenDefault'] wrong
 $SITE['CSSscreenDefault'] = str_replace ('-narrow','',$SITE['CSSscreenDefault']);
 $SITE['CSSscreenDefault'] = str_replace ('-wide','',$SITE['CSSscreenDefault']);

 if ($settings_mode == 2) { // user can select styles only (screen width will be $SITE['CSSscreenDefault'])
 if ($SITE['CSSwideOrNarrowDefault'] == 'wide') {
 $_SESSION['CSSwidescreen'] = 1;
 $wide_style = 1;
 }else {
 $_SESSION['CSSwidescreen'] = 0;
 $narrow_style = 1;
 }
 }

 # is there a CSSstyle selection from the post, cookie, or session?
if (isset($_POST['CSSstyle']) &amp;&amp; preg_match("/^[a-z0-9-]{1,50}.css$/i", $_POST['CSSstyle'])) {
 $CSSstyle = $_POST['CSSstyle'];
 }
 else if ($use_cookies == true &amp;&amp; isset($_COOKIE['CSSstyle'])) {
 $_SESSION['CSSstyle'] = $_COOKIE['CSSstyle'];
 $CSSstyle = $_COOKIE['CSSstyle'];
 }
 else if (isset($_SESSION['CSSstyle'])) {
 $CSSstyle = $_SESSION['CSSstyle'];
 }

 if ($settings_mode == 3) { // widescreen on off only (user cannot select styles)
 $_SESSION['CSSstyle'] = $SITE['CSSscreenDefault'];
 $CSSstyle = $SITE['CSSscreenDefault'];
 }

 # was use CSSwidescreen template selected from the form post?
if (isset($_POST['CSSwidescreen']) &amp;&amp; $_POST['CSSwidescreen'] == 1) {
 if ($use_cookies == true) set_style_cookie ('CSSwidescreen', '1');
 $_SESSION['CSSwidescreen'] = 1;
 $wide_style = 1;
 }
 # was use CSSwidescreen template unselected from the form post?
else if (isset($_POST['CSSwidescreen']) &amp;&amp; $_POST['CSSwidescreen'] == 0) {
 if ($use_cookies == true) set_style_cookie ('CSSwidescreen', '0');
 $_SESSION['CSSwidescreen'] = 0;
 $narrow_style = 1;
 }

 //  fixed bug (default widescreen not being set)
 if (isset($_SESSION['CSSwidescreen']) &amp;&amp; $_SESSION['CSSwidescreen'] == 1) {
 $wide_style = 1;
 }

 # was use CSSwidescreen template selected from a stored cookie?
if ($wide_style == 0 &amp;&amp; $narrow_style == 0 &amp;&amp; $use_cookies == true &amp;&amp; isset($_COOKIE['CSSwidescreen']) &amp;&amp; $_COOKIE['CSSwidescreen'] == 1) {
 if ($use_cookies == true) set_style_cookie ('CSSwidescreen', '1');
 $_SESSION['CSSwidescreen'] = 1;
 $wide_style = 1;
 }
 # was use CSSwidescreen template unselected from a stored cookie?
if ($wide_style == 0 &amp;&amp; $narrow_style == 0 &amp;&amp; $use_cookies == true &amp;&amp; isset($_COOKIE['CSSwidescreen']) &amp;&amp; $_COOKIE['CSSwidescreen'] == 0) {
 if ($use_cookies == true) set_style_cookie ('CSSwidescreen', '0');
 $_SESSION['CSSwidescreen'] = 0;
 }

 # is the seletcted template or one in session one we really have?
if ($CSSstyle != '') {
 foreach ($CSSstyles as $k => $v) {
 if ($CSSstyle == "$k")  {
 $_SESSION['CSSstyle'] = $k;
 if ($use_cookies == true) {
 set_style_cookie ('CSSstyle', $k);
 set_style_cookie ('CSSwidescreen' , $wide_style);
 }
 if (isset($_SESSION['CSSwidescreen']) &amp;&amp; $_SESSION['CSSwidescreen'] == 1) {
 $CSSstyle = str_replace ('.css','-wide.css',$k);
 } else {
 $CSSstyle = str_replace ('.css','-narrow.css',$k);
 }
 return $CSSstyle;
 }
 }
 }else{
 # nothing was matched, show default, no set cookie
$_SESSION['CSSstyle'] = $SITE['CSSscreenDefault'];
 if ($SITE['CSSwideOrNarrowDefault'] == 'wide') {
 $_SESSION['CSSwidescreen'] = 1;
 $CSSstyle = str_replace ('.css','-wide.css',$SITE['CSSscreenDefault']);
 } else {
 $_SESSION['CSSwidescreen'] = 0;
 $CSSstyle = str_replace ('.css','-narrow.css',$SITE['CSSscreenDefault']);
 }
 return $CSSstyle;
 }

}

function set_style_cookie ($name, $val) {
 global $SITE;
 # this function sets a cookie
# set expiration date 6 months ahead
$expire = strtotime("+6 month");
 if ( isset($SITE['cookie_path']) ) {
 $path = $SITE['cookie_path']; // this can be set in Settings.php
 } else {
 $scripturlparts = explode('/', $_SERVER['PHP_SELF']);
 $scriptfilename = $scripturlparts[count($scripturlparts)-1];
 $scripturl = preg_replace("/$scriptfilename$/i", '', $_SERVER['PHP_SELF']);
 $path = $scripturl;
 }
 setcookie("$name",$val,$expire,$path);
}

?>

&amp;nbsp;

&amp;nbsp;