PDA

View Full Version : Extract a line from a file more quickly?


Scriptdaemon
04-29-2007, 10:15 AM
I've made a basic code to load my Xfire profile so I can determine whether I am online or offline on my own site, but it seems my way of doing it is inefficient, as it loads rather slow. Anyone have any tips as to how I can tweak this to make it a lot faster? (This function is taken from a class I put it in, hence the $this variables.)


function xfire_status() {
if($this->xfile = @file('http://www.xfire.com/profile/scriptdaemon')) {
$status = implode('', $this->xfile);
if(strpos($status, '<strong>Last Seen</strong>')) {
echo '<img alt="Online" border="0" src="images/offline.png" />';
} else {
echo '<img alt="Offline" border="0" src="images/online.png" />';
}
} else {
echo '<img alt="Offline" border="0" src="images/offline.png" />';
}
}

iLLin
04-29-2007, 03:38 PM
Xfire already has tools to show you online of offline. Just use theirs.

Scriptdaemon
04-29-2007, 05:41 PM
Xfire already has tools to show you online of offline. Just use theirs.

I don't want to, because it would make this page pretty ugly.

http://moth.homelinux.com/~scriptdaemon/contact.php

Edit: Unless you mean they have tools that will show exactly what I want to show that I am unaware of?

iLLin
04-29-2007, 05:43 PM
I don't want to, because it would make this page pretty ugly.

http://moth.homelinux.com/~scriptdaemon/contact.php

Edit: Unless you mean they have tools that will show exactly what I want to show that I am unaware of?

yes i will try andfind

iLLin
04-29-2007, 05:47 PM
http://www.xfire.com/xfire_urls/

Scriptdaemon
04-29-2007, 06:32 PM
http://www.xfire.com/xfire_urls/

None of those do what this script does. I am aware of those.

iLLin
04-29-2007, 10:57 PM
http://xfireplus.com/page.php?26

try this