WeatherCenter Module Fix

I think I finally figured out why the WeatherCenter module keeps breaking with blank images and no data. Unfortunately, I am not a programmer....just a network guy. It seems that the module breaks when the fputs($fa,"GET http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=$accid... in the userapi.php returns a blank value (common in Baro ie. Pressure). I have tested this extensively and I know this is the cause. I have switched my city numerous times and the only ones that worked and showed up in the nuke_wthr_cache table are the ones without null values. The ones that didn't work only had the accid and time in the cache table. This has to be the problem. Unfortunately, I do not have the knowledge to re-code this but I would be very appreciative if someone could fix this. I have trying to fix this for months....seems like an awesome module to throw to the waste side. Please PM me if you are able to fix this based on my proposed solution.
I think maybe the ploplem is on msnbc.Sometimes it can fecth data from msnbc,but not always.so,I set cachetime to 50000,at least,it seems to work.
The path to msnbc database is correct(you can try it just in browse window,and everything is ok).Then I think the ploplem is easy to solve.I'll try .
I found the ploplem!the msnbc change the result words as below:
function makeWeatherObj() { this.swCity = "Jinan"; this.swSubDiv = ""; this.swCountry = "China"; this.swRegion = "Asia"; this.swTemp = "61"; this.swTempCel = Math.round((5/9)*(this.swTemp-32)); this.swCIcon = "26"; this.swWindS = "4"; this.swWindD = "N"; this.swBaro = ""; this.swHumid = "52"; this.swReal = "61"; this.swUV = "1"; this.swVis = "999.00"; this.swLastUp = "10/01/2003 22:00:00"; this.swConText = "Cloudy"; this.swFore = "4|5|6|7|1|10/01/2003|10/02/2003|10/03/2003|10/04/2003|10/05/2003|28|30|30|30|30|3|4|4|4|4|61|65|67|68|70|10|0|0|0|0|29|29|29|29|29|4|4|4|4|4|53|54|51|55|56|"; this.swAcid = "CHXX0064"; }
OK!Done!Go mysite take a look.the new code is below:(just instead from line 659 to 700)
$v_City = "";
$v_SubDiv = "";
$v_Country = "";
$v_Region = "";
$v_Temp = "";
$v_TempCel = "";
$v_CIcon = "";
$v_WindS = "";
$v_WindD = "";
$v_Baro = "";
$v_Humid = "";
$v_Real = "";
$v_UV = "";
$v_Vis = "";
$v_LastUp = "";
$v_ConText = "";
$v_Fore = "";
$v_Acid = "";


while (!feof($fa)) {
$grabline = fgets($fa, 4096);
$grabline= trim($grabline) . "\n";
if (substr($grabline,7,4) == "City") { $v_City = substr($grabline,15,20); }
if (substr($grabline,7,6) == "SubDiv") { $v_SubDiv = substr($grabline,17,20); }
if (substr($grabline,7,7) == "Country") { $v_Country = substr($grabline,18,20); }
if (substr($grabline,7,6) == "Region") { $v_Region = substr($grabline,17,20); }
if (substr($grabline,7,5) == "Temp ") { $v_Temp = substr($grabline,15,5); }
if (substr($grabline,7,7) == "TempCel") { $v_TempCel = substr($grabline,18,60); }
if (substr($grabline,7,5) == "CIcon") { $v_CIcon = substr($grabline,16,20); }
if (substr($grabline,7,5) == "WindS") { $v_WindS = substr($grabline,16,20); }
if (substr($grabline,7,5) == "WindD") { $v_WindD = substr($grabline,16,20); }
if (substr($grabline,7,4) == "Baro") { $v_Baro = substr($grabline,15,20); }
if (substr($grabline,7,5) == "Humid") { $v_Humid = substr($grabline,16,20); }
if (substr($grabline,7,4) == "Real") { $v_Real = substr($grabline,15,20); }
if (substr($grabline,7,2) == "UV") { $v_UV = substr($grabline,13,20); }
if (substr($grabline,7,3) == "Vis") { $v_Vis = substr($grabline,14,20); }
if (substr($grabline,7,6) == "LastUp") { $v_LastUp = substr($grabline,17,20); }
if (substr($grabline,7,7) == "ConText") { $v_ConText = substr($grabline,18,40); }
if (substr($grabline,7,4) == "Fore") { $v_Fore = substr($grabline,15,200); }
if (substr($grabline,7,4) == "Acid") { $v_Acid = substr($grabline,15,20); }
}
www.top100cn.com
or 61.145.112.100
you can try it!It's very well!
MSNBC changing the result words is not the problem. First, the module works some of the time and some of the time, NOT. If this was the problem, the module would never work. Secondly, I thought the same thing, so I dug through all of the code and changed the variable to match MSN's results...still same results...fixs have of the time. I'm telling you, the problem is when the results of the GET from MSNBC has blank values in it....usually Baro|Pressure. See my original post why. Also, I went to dozens of sites that had data and dozens that were broken. The sites that worked had a value for Baro|Pressure....the sites that were broken didn't have any data for Baro|Presure. The problem is that the WC code doesn't know what to do if MSNBS returns empty values. I tried changing the values in the cahe table to allow blank data but still didn't fix it. Someone with extensive PHP scripting ability needs to go through the code and fix it so the module knows what to do with empty fields from MSNBC. This is a awesome module and I really hate to see it go to the waste side.

BTW, does anyone know where I can find WeatherCenter 1.28. I seen it a few months ago and cannot find it now. There is also a version out there that shows a radar window in the 'Detailed Forecast'...which version is this? I saw it on a Mexican site and cannot find it now.
ccm111. This didn't work for me. Probably because there are many other places throughout the code that uses the variables from MSNBC. If you add 2 more fields from MSNBC to the results, you got to make the neccesary changes in the rest of the code. Also need to make the appropriate changes in the nuke_wthr_cache table. It may be working for you because MSNBC is returning a value in the Baro variable. What is your accid or location?
I'm from china.the accid of msnbc is now eight number.you can go to msnbc and check your local accid.I's a very easy thing.then, change your accid data file.that's ok.
something like CHXX0028
you should have weather 1.28
I am running the new accids. Please, try using these two accids in your module: USOH0557 and USOH0212. My town, USOH0557 comes up empty data missing images because the Baro variable from MSNBC is empty. Now, USOH0212 works because the Baro field has data.

Also try these:
http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=USOH0557 --- returns empty Baro variable

http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=OSOH0212. --- has data in the Baro variable.

Let me know
Can't find WeatherCenter 1.28. Do you know where I can get it?
I can give you!wait a moment,you can download from mysite.first line the third button.
OK!I have improved for you.
Thanks...got it. I will put in place and test to see if it works. Did you try my accids mentioned above? Did USOH0557 work in your site?
no ploplem.wait a moment.could you tell me your city name?
This module broke my site. I am now getting these 2 errors:

when go to site:
Fatal error: Call to a member function on a non-object in sys:/apache/htdocs/postnuke/html/includes/advblocks.php on line 72

When go to blocks in administration:
Fatal error: Call to a member function on a non-object in sys:/apache/htdocs/postnuke/html/modules/Blocks/pnadmin.php on line 87

Can't get to anything to fix this....any ideas
try move the module first.my postnuke is 0.723
Can't open block table either...get this message:

Can't open file: 'nuke_blocks.MYI'. (errno: 145)


Using MyPHPAdmin
use phpMyAdmin ,open the data table,then delete anything involve the module.in block database.
something like nuke_blocks
I got it. The module corrupted my block table. Had to run a REPAIR table nuke_blocks; fixed it. I still can't create a new block when this module is activated. I too am runn PN 723. Wonder why it wouldn't work?
I get this eror when I try to create a new block when this module is activated:

Fatal error: Cannot redeclare weather_weatherblock_init() (previously declared in sys:/apache/htdocs/postnuke/html/modules/weather/pnblocks/weather.php:42) in sys:/apache/htdocs/postnuke/html/modules/oldweather/pnblocks/weather.php on line 39

Deactivate the module and all works fine.
normally,It's no ploplem.did you do something wrong?
Take a look at this thread for an explaination of why you see this error in the the blocks admin panel.

-Mark

--
Visit My homepage and Zikula themes.
Figured it out. I renamed my old module oldweather but left it in the modules directory. I guess PN doesn't like that. Did you try using my accid in your module?
Just the blocks function will object as it enumerates the available blocks and you then have two blocks with the same function names hence the error.

-Mark

--
Visit My homepage and Zikula themes.
you could use the same file of weather1.26 instead.try again
Sorry, your module doesn't work either. Actually it did for the first load, but now doesn't after refreshing cache. Don't understand why this is. I just know that if MSNBC returns a blank value in any of the fields, it breaks. I have tested this time and time again. Try my accid in your module. BTW, my city is Marion Ohio US.
Hey Mark, have you tried my earlier suggestion? Would like to have a few people try this to prove this is the problem.
No - I don't use a weather module anywhere. I was just explaining the error your seeing but have no interest in the rest of the thread - Sorry.

-Mark

--
Visit My homepage and Zikula themes.
OK Thanks for the explaination anyway.
ok!
take a look www.top100cn.com
ccm111....hold the phone. This just may be working. I dumped the cache table went to site, which took forever for the initial. Then the images came up with data. Did this 3 times and all worked. I will definitely know after a coupld of hours or first thing tomorrow. Will you keep an eye on this thread for the next couple of days so we can work this through together? Did you try my accid on your site? How did it go?
Great, site looks good (with Marion, Oh weather...LOL). It would be awesome if your version fixed this pain in the neck problem. If you would, stick around this thread for a couple of days...see my previous post. BTW go to 206.21.12.10...this site is in development. Most of the content requires a user account. This site will be used for an employee portal my the college I work at.
just look it!by the way,change the $Temp to 6(where is now 5)
ok!you can e-mail me to :top100cn@top100cn.com
we are friend.
Not sure what you are talking about change $Temp 6 from 5. I do see that in the 'Detailed forecast' the word temp doesn't show up the the degree's. Is this what you are talking about?
No.I mean the code in pnuserapi.php in line 686.in summer time temp would high than 100 ,so the reasion
Is it working?
Sorry, still don't know where. Can you paste what line to change? I really appreciate your help. I will shoot you an email soon to give you my email address.
By the way, have you seen the version of this module that has a radar screen at the bottom of the 'Detailed Forecast'? If not, I'll try to find the link again and forward to you.
some modules are not free.you should pay for one year data fee
I have some weather modules.But I have not try them,If you need
I could give you.But I think the weather 1.28 is best free one.
In fact.the weather1.28 have bugs in it.so few people can use it.
I will help you if there is anything wrong with the module.
I really like the look of this module. The module I was talking about was WeatherCenter but I think someone moded it to show the radar. Give me a few minutes and I'll find the link.
OK. The one I am talking about is here: http://www.soweluautomation.net

The site is currently down so check it out when you can. Go to 'Detailed Forecast' and see the radar. The site is in Spanish though.
A germeny module is very beautiful,but not meet me because of the
datas.and werther.com also have beautiful module.but It should pay for the datas.Only the msnbc offer the worldwide datas.
OK. This module seems to be working...has cached a few times without missing data and images. Awesome. But now I have another small issue maybe you can help me with. The first time I open my site after the cache has experired. it takes several minutes to load. After the first load, the site opens very quickly until the cahe expires again. I could always set higher cache setting but I would like to at least have the current weather every 3 hours. Have any ideas?
He set the load time to 30 sec.but I saw it could be fast.you can try it to 15sec.I think 3 hours is enough.THe weather won't change too fast.
msnbc has radar and satellite datas,but I don't kown how to get it.
How do you set the load time? Are you talking about the cache setting within PN administration? Mine is set to 1 hour. I still haven't changed $Temp you suggested earlier. Can you tell me which lines (not by number but by line syntax) to change to set load and $temp?
Damn, module broke again. Check it at 206.21.12.10.
My nuke_wthr_cache table only has accid and time data. All of the rest of the fields are empty.
don't worry!you follow the steps to re-set the local weather.this is because it can't load datas in 30 sec at the moment.
don't worry!you follow the steps to re-set the local weather.this is because it can't load datas in 30 sec at the moment.
I can clear the cache table to fix this but I would hate to have to do this several times per day. Can I change the 30 secs to a longer time to fix this? How?

BTW, get my email?
the code in pnuserapi.php in line 686 . change 5 to 20 to fit the hot weather.
the load time setting also in pnuserapi.php .something like xxxx(xxx,80,xx,xx,30).
Thanks, I'll try these in a little bit. I have to go for a couple of hours. Got a doctor's appointment. I'll check in with you later. BTY, your English is a lot better than my Chinese...LOL.
OK Peter, I changed the $Temp. Not sure what that changed....Anyway, there is still something wrong with this module. It works better than the others I've used but it still comes up with blank data and missing images a few times a day. I can dump the cache table and go to the site and the module works until the next time the cache expires. Do you ever have problems with this module. If not, I wonder what might be different between our site. We're both running 723. Which version of MySQL are you running. The problem is either with the data recieved from MSNBC of with the data being written to the cache table in MySQL.
5-3=2,but 100F has three characters,so the reasion.20 is no ploplem.
the module working in mysite is very good.my cachetime set to three hours.the focus is the efficiency of internet connecting to msnbc.If the ploplems is offen.you can set load timeout to 60sec.
I did set the time to 60 secs. Still having problems. See my email I sent to you.

I really appreciate your help.
I've fix two more ploplems.this time you can test 10 cities to see if it's working normally.BTW the cachetime is not the only vars it check,it will check the database for renew which has bugs in this function(now I fixed).you only need replace the pnuserapi.php file whith is now in new zipfile(weather1.28) in my site.

ccm111

OK!I have improved for you.
Hi ccm111 - I downloaded a copy of WC1.28 from your site, One thought here, this doesn't cater for the new code format, for example to add a new town you woul need to add a code like UKXX0257, your copy does not allow for this number of digits? There was a hack around to extend the table functions?

OOPS! Just missed your post above! I will have another look
you should mannully add the city accid witch can find at msnbc.the accid table allready set to 9 characters.so no ploplem