PHP Web Host - Quality Web Hosting For All PHP Applications Clan Themes! We make clans look good!!
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Tue Mar 30, 2004 10:29 am Reply with quote Back to top

Hi,

I've tried to get a script together that should explode this page (
Only registered users can see links on this board!
Get registered or login to the forums!
), 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.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Mar 30, 2004 11:06 am Reply with quote Back to top

In going over your script, I see you have a typo that may be contributing to your problem, or not Smile. But before I go any further, find this line
Code:
$boom = explode("<br>", $file = file_get_contentss
and correct it to
Code:
$boom = explode("<br>", $file = file_get_contents
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Tue Mar 30, 2004 1:54 pm Reply with quote Back to top

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. Smile
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Mar 30, 2004 4:59 pm Reply with quote Back to top

Yep.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Thu Apr 01, 2004 3:33 pm Reply with quote Back to top

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 -
Only registered users can see links on this board!
Get registered or login to the forums!


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. >.<;
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Sat Apr 03, 2004 1:57 am Reply with quote Back to top

Yes, Id like to add this quick reply hack .........real helpful addon
View user's profile Send private message
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Mon Apr 12, 2004 7:11 pm Reply with quote Back to top

Anyone? Embarassed HitsFan
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon Apr 12, 2004 8:54 pm Reply with quote Back to top

I just spent some time on that original code and it suddenly Rolling Eyes 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 to
Code:
<?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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum