Cellphone / Mobile / iPhone Weather Script

Add the functions to the files where you get a problem e.g. cell_ajax-dashboard.php

oh…ok… thank you.

Here are the graphics required for the cell pages:
[http://www.bashewa.com/downloads/bws-icons-current.zip](http://www.bashewa.com/downloads/bws-icons-current.zip) ..... current conditions icons. [http://www.bashewa.com/downloads/bws-icons-wind.zip](http://www.bashewa.com/downloads/bws-icons-wind.zip) ........ wind rose icons. [http://www.bashewa.com/downloads/bws-icons-moon.zip](http://www.bashewa.com/downloads/bws-icons-moon.zip) ........ moon icons x 28 [http://www.bashewa.com/downloads/bws-icons-moonphase.zip](http://www.bashewa.com/downloads/bws-icons-moonphase.zip) ... moon phase, rising, falling, steady and sun/moon rise & set icons. [http://www.bashewa.com/downloads/bws-icons-forecast.zip](http://www.bashewa.com/downloads/bws-icons-forecast.zip) .... WU forecast icons.

I added that to the ajax script and it didnt work. Still getting that same error…

line 241… $monthname = langtransstr($monthname);

Here’s the code for the Gradient Thermometer:
Latest version available here:
http://discourse.weather-watch.com

Sample:

Just replace those function without the “function_exists”:


function langtransstr($word) { return $word; }

function langtrans($word) {
echo $word;
}


That did it… thanks… now to get everything working on it.

I’ve added the following lines to the cell_ajax-dashboard.php script in case common.php does not exist:


if ((include_once "common.php") == 0) { function langtransstr($word) { return $word; } function langtrans($word) { echo $word; } }
Get it here: [http://www.bashewa.com/cell_ajax-dashboard.php?sce=view](http://www.bashewa.com/cell_ajax-dashboard.php?sce=view)

Can I have a look at it?

lol… its still pretty messed up for the time being… most of it isnt even working yet…

How did you get yours so narrow in width?

You’ll need the handheld Style Sheet:
http://www.bashewa.com/handheld.css

Or you can do this:

<?php include_once("cell_ajax-dashboard.php"); ?>

Here is the full page code for cell.html:


<?php
$isBot    = keyMatch('Googlebot,msnbot,Yahoo! Slurp,Mediapartners-Google,AnanziSpider,ia_archiver,FreshCrawler',$_SERVER['HTTP_USER_AGENT'],true);
$isSearch = keyMatch('google,bing,yahoo,ananzi',$_SERVER['HTTP_REFERER'],true);
$isMobile = keyMatch('MIDP,iPhone,Google Wireless Transcoder,Windows CE',$_SERVER['HTTP_USER_AGENT'],true);

if (!isset($_GET["skip"]))
if ($isSearch && !$isBot && !$isMobile) {
// Reroute to Main page if comming from google search
	header("Location: http://www.bashewa.com/"); /* Redirect browser home page */
	exit;
} else
if (stripos($_SERVER['HTTP_USER_AGENT'],"MIDP")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"iPhone")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Google Wireless Transcoder")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Windows CE")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Mediapartners")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"GoogleBot")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"msnbot")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Slurp")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Twiceler")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Ask Jeeves")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Ananzi")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"TwoFour")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"archiver")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"Feedfetcher")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"PageFetcher")===false
&&  stripos($_SERVER['HTTP_USER_AGENT'],"W3C_Validator")===false) {
// Reroute to Opera Mini
	header("Location: http://www.bashewa.com/cell-demo.php?url=http://www.bashewa.com/cell.html"); /* Redirect browser to Opera Mini */
	exit;
}
############################################################################
require_once("Settings.php");
$TITLE = 'Bronberg Weather';
$DESC  = "Bronberg Weather Station: current weather, weather forecast, trends and history for Bashewa &amp; Tiegerpoort.";
$KEYW  = "Bronberg, Bashewa, Tiegerpoort, weather, current weather, weather forecast";
############################################################################
require_once("common.php");
include("cell_top.php");
############################################################################
if (isset($_GET["skip"]))
	  $skip = "?skip=1";
else $skip = "";
?>
<style type="text/css">
.ForecastDetails {
  padding-top: 3px;
  padding-left: 0	px;
  height: 37px;
  line-height: 14px;
  background-position: left;
  background-repeat: no-repeat;
  text-align: right;
  font: 12px Arial;
}
.Sun {
  background-image: url(ajax-images/sun.png);
}

.Moon {
  background-image: url(ajax-images/moon.png);
}
.Field {
  font: bold 11px Arial;
}
</style>
</head>
<body>
<div align="center"><div id="container">

<div class="top"><h1>BRONBERG WEATHER</h1>
<div style="color:yellow; font: bold 10px Arial;">Tiegerpoort &amp; Bashewa Weather</div>
</div>
<div class="toplinkscell">
<div style="float:left">
<a href="cell.html<?php echo $skip; ?>" title="Mobile Weather"><b>Home</b></a>&nbsp;&nbsp;
<a href="cell-forecast.php<?php echo $skip; ?>" title="Mobile Forecast"><b>Forecast</b></a>&nbsp;&nbsp;
</div>
<div style="float:right">
<a href="forum/archive/<?php echo $skip; ?>"><b>Crime</b></a>
</div></div>

<div id="content" style="clear:both; margin-bottom: 10px;">
<?php include_once("cell_ajax-dashboard.php"); ?>
</div>

<div id="footer">
<div id="fullversion"><strong>Full Version:</strong></div>
<div id="infobox">You're currently viewing a stripped down version of our content.

<a href="http://www.bashewa.com/">View the full version</a>.</div>
</div>

</div></div>
</body>
</html>
<?php
############################################################################
# End of HTML Page
############################################################################

function keyMatch($needles,$haystack,$first=false) { // if "first" then break after 1st find
   if ($needles == '') return 100;
   $stac = ' '.$haystack;
   $nArray=explode(",",$needles);
   $found=0;
   $best=count($nArray);
     for($i=0;$i<count($nArray);$i++) {
       $pzn=stripos($stac,trim($nArray[$i]));
       if ($pzn>-1) {
	   	  $found++;
		  if ($first) break;
		  }
       }
//   echo('find #'.$found.'/'.$best.'
');
   $pct=($found*100)/$best;
   return round($pct);
}
?>

Code for cell_top.php:


<?php
require_once("Settings.php");
require_once("common.php");
include_once($SITE['WXtags']);
############################################################################
if (stripos($_SERVER['HTTP_USER_AGENT'],"Opera Mini")!==false)
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
else
echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
   "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">';
?>
<html xmlns="http://www.w3.org/1999/xhtml"<?php
if (false and isset($SITE['lang'])) { // disabled.. seems to be a problem with it
	$lang = substr($SITE['lang'],0,2);
	echo ' lang="'.$lang.'" xml:lang="'.$lang.'"';
}?>>
<head>
<?php
if ( !empty($TITLE) )
	  echo "<title>" . $TITLE . "</title>\n";
else echo "<title>" . $SITE['organ'] . "</title>\n";

if ( !empty($DESC) )
	  echo "<meta name=\"description\" content=\"" . $DESC . "\" />\n";
else echo "<meta name=\"description\" content=\"" . $SITE['organ'] . "\" />\n";

if ( !empty ($KEYW) )
	  echo "<meta name=\"keywords\" content=\"" . $KEYW . "\" />\n";
else echo "<meta name=\"keywords\" content=\"" . str_replace(" ",",",$SITE['organ']) . "\" />\n";
?>
<meta http-equiv="Content-Language" content="<?php echo $SITE['lang']; ?>" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=<?php echo strtoupper($SITE['charset']); ?>" />
<link rel="stylesheet" type="text/css" href="handheld.css" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<!-- script type="text/javascript" src="ajaxWDwx.js"></script -->
<!-- end of top -->

Replace www.bashewa.com with your website url.

Here’s the code for cell-demo.php which brings up the page in the Opera Mini Simulator:


<?php
if (isset($_GET["url"]))
     $url = $_GET["url"];
else $url = "http://www.bashewa.com/cell.html";
?>
<!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">
<head><title>Mobile Weather</title>
</head><body style="font:10px Arial;margin:0px;"><div align="center" style="margin-bottom: 50px;">

<p style="margin:0px;">Below is a live demo of the Bronberg Weather that

functions like it would when viewed on a mobile.</p>

<object height="484" width="240" type="text/html"
 data="http://demo.opera-mini.net/demo.html?<?php echo $url; ?>">
 <div style="margin:7px 0px;text-align:left;border:1px solid gray;background:#F5F5F5;padding:7px;">
    
The Opera Mini demo requires Java enabled in your browser.
    You may need to download the latest
    <a href="http://java.com/en/download/index.jsp">Java Runtime Environment</a>.
 </div>
</object>
<div align="center" style="color:red">Click here if you can't see the Opera Mini phone browser:</div>
<div align="center" style="font:bold 12px Arial;color:blue;"><a href="<?php echo $url; ?>?skip=1" title="Click here if the simulator does not work"><?php echo $url; ?></a></div>

<div style="width:240px; text-align:left;border:1px solid gray;background:#F5F5F5;padding:7px;margin-top:7px;">
 <h3 align="center" style="margin:3px;">Mobile Simulator Tips</h3>
 <p>Use your mouse or keyboard to control the simulator
 (<kbd>F1</kbd>, <kbd>F2</kbd> function keys, <kbd>arrow keys</kbd> and <kbd>Enter</kbd> to navigate).</p>
 <p>Drag the scrollbar or the screen to scroll the page.</p>
 <p>Click on the screen if it goes blank.</p>
</div>

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

wow… thanks… ill mess with it more tomorrow.

Im gaining ground on this script, But has a few minor issues. Im using these settings in the ajax-cell script, but everything is still showing in the script as C, kts… Any ideas?

$Lang = ‘en’;
$uomTemp = ‘°F’;
$uomBaro = ’ inHg’;
$uomWind = ’ mph’;
$uomRain = ’ in’;
$uomPerHour = ‘/hr’;

I’m noticing some conflicts. Since this script also uses the common.php and settings.php file, the data that the cell script wants cant be changed. if I did change some of the directories in those files, then some of my site wouldn’t work right.

Ive also change everything to F, MPH, etc… but its still somehow using C,kts for some reason.

Grab the latest Clientraw Parser here:
http://www.bashewa.com/clientraw-parser.php?sce=view

Then set $useUOM=‘E’; at the top.

got that changed… the temp is still showing in C, even though it has a F next to it

Nah … you need the full new version of the Clientraw parser.
I’ve made lots of changes to it.
Looks like you’re getting cached copy from the proxy.

http://www.bashewa.com/clientraw-parser.php?sce=view&buster=123