Author |
Message |
bretonmage
Hangin' Around

Joined: Mar 30, 2004
Posts: 34
|
Posted:
Tue Mar 30, 2004 10:29 am |
|
Hi,
I've tried to get a script together that should explode this page ( http://www.wulfram.com/wws/nextWar.php?squ...hables&limit=50 ), then output the times listed in both PST and GMT format. Unfortunately, when the data is input as 'AM PST', the script just adds 20 hours. I have no idea why this happens (this script isn't mine, and I'm a PHP newbie). Hasn't someone already created a time zone changing function that I could use for this purpose?
Here's the code:
Code:
<?php
if (eregi("block-upcoming_events.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
$boom = explode("<br>", $file);
function file_get_contentss($filename, $use_include_path = 0) {
$data = ""; // just to be safe. Dunno, if this is really needed
$file = @fopen($filename, "rb", $use_include_path);
if ($file) {
while (!feof($file)) $data .= fread($file, 1024);
fclose($file);
}
return $data;
}
function getBetween($getAfter, $getBefore, $array) {
$stepOne = explode($getAfter, $array);
$stepTwo = explode($getBefore, $stepOne[1]);
return $stepTwo[0];
};
$boom = explode("<br>", $file = file_get_contentss("http://www.wulfram.com/wws/nextWar.php?squadName=Deadly%20Untouchables&limit=50"));
array_pop($boom);
foreach ($boom as $array) {
$array = explode("at", $array);
$time = explode("PM PST", $array[1]);
if ($time[0] != "") {
$time[0] += "12";
} else {
$time = explode("AM PST", $array[1]);
};
$time[0] += 8;
$content .= "$array[0] at $time[0]:00 GMT<BR>";
};
?>
|
Thanks in advance. |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Mar 30, 2004 11:06 am |
|
In going over your script, I see you have a typo that may be contributing to your problem, or not . But before I go any further, find this lineCode:$boom = explode("<br>", $file = file_get_contentss
| and correct it toCode:$boom = explode("<br>", $file = file_get_contents
|
|
|
|
|
 |
bretonmage

|
Posted:
Tue Mar 30, 2004 1:54 pm |
|
Wow... Well spotted... I will upload the changed file soon - my site seems to be down. In the meantime, just a slight clarification - Do you mean to change both of the 'file_get_contentss' in the file (there are two)?
Thanks for the quick reply.  |
|
|
|
 |
Raven

|
Posted:
Tue Mar 30, 2004 4:59 pm |
|
|
|
 |
bretonmage

|
Posted:
Thu Apr 01, 2004 3:33 pm |
|
Well, when I took out the extra 's', the block decided not to work at all... O.o
But in the meantime, I was given another piece of code for a block that does work. ^_^
I have asked the original author, but he doesn't seem to be around anymore... Do you know how to make this script display both the GMT and PST times (it displays GMT times fine at the moment)?
Just in case you need to view the block output - http://www.untouchablesite.com/
Here's the block's code:
Code:<?php
if (eregi("block-upcoming_events.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
$monthArr = array('Jan', 'Feb', 'Mar', 'Apr',
'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec');
$monthArr = array_flip($monthArr);
$testFile = 'http://www.wulfram.com/wws/nextWar.php?squadName=Deadly%20Untouchables&limit=50';
$file = file_get_contents($testFile, 0);
$fileArr = explode('<br>', $file);
foreach ($fileArr as $key => $value) {
if (strlen($value) < 10) {
continue;
}
$lineArr = explode(':', $value);
$hour = substr($lineArr[3], -8, 2);
$ampm = substr($lineArr[3], -6, 2);
if ($ampm == 'PM') {
$hour = $hour + 12;
}
$itemArr = explode(',', $value);
$itemArr[1] = ltrim($itemArr[1]);
$monthAlph = substr($itemArr[1], 0, 3);
$monthNum = $monthArr[$monthAlph] + 1;
$day = substr($itemArr[1], 4, 2);
$year = '2004';
$tStamp = mktime($hour, 0, 0, $monthNum, $day, $year);
$adjustedDate = date('l, M\. j \a\\t g:00 a \G\M\T',
$tStamp + (8 * 60 * 60));
$content .= trim($lineArr[0]) . ' : ' .
trim($lineArr[1]) . ' : ' .
trim($lineArr[2]) . ' : ' .
$adjustedDate . '<br />';
}
?>
|
EDIT: Another question; how did you install that Advanced Quick Reply Hack(if it is)? It never worked for me, I now use the basic one. >.<; |
|
|
|
 |
Rikk03
Worker


Joined: Feb 16, 2004
Posts: 164
|
Posted:
Sat Apr 03, 2004 1:57 am |
|
Yes, Id like to add this quick reply hack .........real helpful addon |
|
|
|
 |
bretonmage

|
Posted:
Mon Apr 12, 2004 7:11 pm |
|
Anyone?  |
|
|
|
 |
Raven

|
Posted:
Mon Apr 12, 2004 8:54 pm |
|
I just spent some time on that original code and it suddenly dawned on me why it had the extra 's'. It's because they were rewriting the php function file_get_contents and php does not allow you to name your function the same as a php function; thus the extra 's'. I scaled it down toCode:<?php
if (eregi("block-upcoming_events.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
$filename = "http://www.wulfram.com/wws/nextWar.php?squadName=Deadly%20Untouchables&limit=50";
$boom = explode("<br>", file_get_contents($filename));
foreach ($boom as $boomArray) {
$boomArray = explode("at", $boomArray);
$time = explode("PM PST", $boomArray[1]);
if ($time[0] != "") {
$time[0] += "12";
} else {
$time = explode("AM PST", $boomArray[1]);
}
$time[0] += 8;
$content .= "$boomArray[0] at $time[0]:00 GMT<BR>";
}
?>
| The reason it adds the 20 hours is because the time it is reading appears to always be "" so it adds the 12. Then right after that is a piece of code that adds 8 more. It does exactly what it is told to do. Regardless, that's not your problem anymore as you found another piece of code.
As to the quick reply hack, I installed that quite a while ago and as I remember it, I did have to move 1 or 2 files to a different location but I honestly don't remember. I know that doesn't help you but maybe someone else can help you there. I just don't have time right now to try to back-track. |
|
|
|
 |
|