TinyPortal

Development => Block Codes => Topic started by: Karma on January 29, 2009, 05:12:41 AM

Title: [Block] WoW Login Information Block
Post by: Karma on January 29, 2009, 05:12:41 AM
So I got bored at work today, and threw together a block which will display the login information shown on the World of Warcraft login screen. Downtimes, etc. You know what I'm talking about. I'd recommend putting it in either an upper or lower block, it's a lot of information that will probably look terribad in a side block. Ultimately, it's up to you :p

It's my first PHP, and my first interaction with SMF really, so any improvements/suggestions are welcome. When I can be bothered I'll move from file to DB storage, but one step at a time ;o)

Edit: Have done database storage, pretty much a rewrite, two posts down.

Configurables allow you to cache the data to a file, or pull it from the WoW servers every time it's loaded, and give your users an option to refresh the file. You'll need to change the url variable if you're not using US servers.

Enjoy <3

// Code to display the World of Warcraft login information in a TP block.
// Revision 0.01

global $boarddir, $scripturl;

$jlk_sacf = array(
// Configurables: //////////////////////////////////
// Local file to cache to (Blank = no cache)
'cachefile' => $boarddir . '/attachments/jlk_srvalert.html',
// Url to ServerAlert:
// http://status.wow-europe.com/en/alert for Europe (English)
// http://status.wow-europe.com/de/alert for Europe (German)
// http://status.wow-europe.com/fr/alert for Europe (French) etc..
'url' => 'http://launcher.worldofwarcraft.com/alert',
// Maximum age (Minutes) of cache.
'expiry' => 60,
// Minimum age (Minutes) to allow user refresh.
// Set above expiry to disable, 0 = always allow.
'minlife' => 5);
// End of Configurables /////////////////////////////////////////////////////
// The working Parts: /////////////////////////////////////////////////////
jlk_dispServerAlert($jlk_sacf);

function jlk_dispServerAlert($jlk_sacf)
{
  global $scripturl;
  $dsa_data = '';
  $dsa_fdate = 0;
  $dsa_sdate = time();
  $dsa_fetch = 0;
  $dsa_giveurl = 0;
  $dsa_age = '';

  if (empty($jlk_sacf['cachefile']))
  {
    echo jlk_getServerAlert($jlk_sacf['url']) . '<div style="text-align: right; font-style: italic; font-size: 8pt">Data is live.</div>';
    return;
  }
  if (file_exists($jlk_sacf['cachefile']))
    $dsa_data = file_get_contents($jlk_sacf['cachefile']);

  if (empty($dsa_data) || (strlen($dsa_data) < 17))
  {
    $dsa_data = str_pad(time(), 16) . "\n" . jlk_getServerAlert($jlk_sacf['url']);
    $dsa_fetch = 1;
    $dsa_fdate = $dsa_sdate;
  }
  if ($dsa_fetch == 0)
  {
    $dsa_fdate = trim(substr($dsa_data,0,16));
    $dsa_ddiff = $dsa_sdate - $dsa_fdate;
    $dsa_ddiffS = $dsa_ddiff % 60;
    $dsa_ddiffM = floor($dsa_ddiff / 60);
    $dsa_ddiffH = floor($dsa_ddiffM / 60);
    if (($dsa_ddiffM >= $jlk_sacf['expiry']) ||
        (!empty($_GET['jlksar']) && $_GET['jlksar'] == 1 &&
         $dsa_ddiffM >= $jlk_sacf['minlife']))
    {
      $dsa_fetch = 1;
      // Thx "odsign" for pointing this out & fixing.
      $dsa_fdate = $dsa_sdate;
      $dsa_data = str_pad(time(), 16) . "\n" . jlk_getServerAlert($jlk_sacf['url']);
    } else if ($dsa_ddiffM >= $jlk_sacf['minlife'])
      $dsa_giveurl = 1;
    $dsa_ddiffM = $dsa_ddiffM % 60;
    if ($dsa_fetch == 0)
      $dsa_age = ($dsa_ddiffH > 0 ? $dsa_ddiffH . 'h' : '') .
                 ($dsa_ddiffM > 0 ? $dsa_ddiffM . 'm' : '') .
                 (($dsa_ddiffS > 0 && $dsa_ddiffH < 1) ? $dsa_ddiffS . 's' : '');
  }
  if ($dsa_fetch == 1)
  {
    file_put_contents($jlk_sacf['cachefile'], $dsa_data);
    echo substr($dsa_data, 17) . '<div style="text-align: right; font-style: italic; font-size: 8pt">Data was fetched from server.</div>';
    return;
  }
  echo substr($dsa_data, 17) .  '<div style="text-align: right; font-style: italic; font-size: 8pt">Data is ' .  $dsa_age . ' old.' .  ($dsa_giveurl == 1 ? '   (<A HREF="'. $scripturl . ((empty($_SERVER['QUERY_STRING'])) ? '?jlksar=1' : '?' . trim($_SERVER['QUERY_STRING']) . ((strpos($_SERVER['QUERY_STRING'], 'jlksar=1') === FALSE) ? '&jlksar=1' : '')) . '">Refresh</A>)' : '');
  return;
}

function jlk_getServerAlert($gsa_url)
{
  $gsa_ret = '';
  $gsa_ch = curl_init();
  curl_setopt($gsa_ch, CURLOPT_URL, $gsa_url);
  curl_setopt($gsa_ch, CURLOPT_HEADER, false);
  curl_setopt($gsa_ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($gsa_ch, CURLOPT_FAILONERROR, true);
  $gsa_sares = curl_exec($gsa_ch);
  if (curl_errno($gsa_ch))
  {
    if ((curl_errno($gsa_ch) == 22) && (substr(trim(curl_error($gsa_ch)), -3) == '404'))
    {
      $gsa_ret = 'No notifications to display.';
    } else {
      $gsa_ret = 'Unable to retrieve Server Alert:<BR>' .
                       curl_error($gsa_ch);
    }
  } else {
    $gsa_sares = str_replace('SERVERALERT:', '', $gsa_sares);
    $gsa_sares = str_replace("\r", '', $gsa_sares);
    $gsa_sares = str_replace("\n", "<br />\n", trim($gsa_sares));
    $gsa_ret = $gsa_sares;
  }
  curl_close($gsa_ch);
  return $gsa_ret;
}
Title: Re: [Block] WoW Login Information Block
Post by: Dramber on February 01, 2009, 07:30:02 PM
Very nice! Just added to my site and it works great. Thanks!
Title: Re: [Block] WoW Login Information Block
Post by: Karma on February 04, 2009, 03:14:32 AM
Glad it's working for someone other than me ;o)

So I finally re-wrote it to store in the database.. Added a couple of other things like height limitations, error handling, meh.

This is quite lengthy, sorry.

// Code to display the World of Warcraft login information in a TP block.
// Revision 0.4.2
global $db_prefix, $scripturl;

$jlk_sacf = array(
// Configurables: //////////////////////////////////
// Cache Locally (0: Never; 1: Current+Previous; 2: All)
'cache' => 2,
// Url to ServerAlert:
// http://status.wow-europe.com/en/alert for Europe (English)
// http://status.wow-europe.com/de/alert for Europe (German)
// http://status.wow-europe.com/fr/alert for Europe (French) etc..
'url' => 'http://launcher.worldofwarcraft.com/alert',
// Maximum age (Minutes) of cache.
'expiry' => 60,
// Maximum age (Minutes) before retrying on error (0 = always retry).
'expiry-error' => 5,
// Minimum age (Minutes) to allow user refresh.
// Set above expiry to disable, 0 = always allow.
'minlife' => 5,
// Maximum height of text (Browsers that support css overflow ;o)
'max-height' => '300px',
// Table name to cache in:
'cache_table' => $db_prefix . 'jlk_srvalert',
// Set this to 1 to remove database entries.
'uninstall' => 0,
// Verbose Curl Errors? (0 = No, 1 = Admins, 2 = Everyone)
// Note: Not used for cache-less operation.
'verbose-errors' => 1
);
// End of Configurables /////////////////////////////////////////////////////
// The working Parts: /////////////////////////////////////////////////////
$jlk_sacf['txt-refresh'] = '   (<A HREF="' . $scripturl . (empty($_SERVER['QUERY_STRING']) ? '?jlksar=1' : '?' . trim($_SERVER['QUERY_STRING']) . (strpos($_SERVER['QUERY_STRING'], 'jlksar=1') === FALSE ? '&jlksar=1' : '')) . '">Refresh</A>)';
$q = db_query("SELECT UNIX_TIMESTAMP(NOW())", __FILE__, __LINE__);
$r = mysql_fetch_row($q);
$jlk_sacf['now'] = $r[0];
mysql_free_result($q);

echo '<div class="smalltext" style="max-height: ' . $jlk_sacf['max-height'] .
     '; overflow: auto; position: relative">';
jlk_dispServerAlert($jlk_sacf);
echo '</div>';

function jlk_dispServerAlert($cf)
{
  // No Cache
  if (empty($cf['cache']) || $cf['cache'] == 0)
  {
    echo jlk_parseServerAlert(jlk_liveServerAlert($cf['url'])) .
         '<div style="text-align: right; font-style: italic; font-size: 8pt">Data is live.</div>';
    return;
  }

  // Uninstall.
  if ($cf['uninstall'] === 1)
  {
    db_query('DROP TABLE IF EXISTS `' . $cf['cache_table'] . '`', __FILE__,
             __LINE__);
    echo 'Server Alerts are no longer enabled.';
    return;
  }

  list($dsa, $pdsa) = jlk_getDBServerAlert($cf);

  if (empty($dsa))
  { // First Entry Ever:
    $dsa = array('original' => '', 'parsed' => '', 'added' => 0,
                 'updated' => 0, 'oldage' => '', 'age' => '', 'ageM' => 0,
                 'giveurl' => ($cf['minlife'] == 0 ? 1 : 0), 'SAID' => 0);
    $dsa['updated'] = $cf['now'];
    $dsa['added'] = $cf['now'];
    $dsa['original'] = jlk_liveServerAlert($cf['url']);
    $dsa['parsed'] = jlk_parseServerAlert($dsa['original']);
    $dsa['SAID'] = jlk_writeDBServerAlert($cf, $dsa);
    jlk_sendServerAlert($cf, $dsa, null);
    return;
  }
  // Lets determine if we're getting a new one.
  if (strcmp(substr($dsa['original'], 0, 9), 'CURLERROR') == 0)
  {
    if (($dsa['ageM'] >= $cf['expiry-error']) ||
        ($dsa['ageM'] >= $cf['minlife'] && !empty($_GET['jlksar'])))
    {
      $dsatmporig = jlk_liveServerAlert($cf['url']);
      if (strcmp(substr($dsatmporig, 0, 9), 'CURLERROR') == 0)
      {
        $dsa['original'] = $dsatmporig;
        $dsa['parsed'] = jlk_parseServerAlert($dsatmporig);
        $dsa['age'] = '';
        $dsa['updated'] = $cf['now'];
        $q = db_query('UPDATE `' . $cf['cache_table'] . '` SET Date_Updated=FROM_UNIXTIME(' . $cf['now'] . '), Original=\'' . addslashes__recursive($dsa['original']) . '\', Parsed=\'' . addslashes__recursive($dsa['parsed']) . '\' WHERE SAID=' . $dsa['SAID'], __FILE__, __LINE__);
        mysql_free_result($q);
        jlk_sendServerAlert($cf, $dsa, $pdsa);
        return;
      }
      $dsa = array('original' => '', 'parsed' => '', 'added' => 0,
                   'updated' => 0, 'oldage' => '', 'age' => '', 'ageM' => 0,
                   'giveurl' => ($cf['minlife'] == 0 ? 1 : 0), 'SAID' => 0);
      $dsa['updated'] = $cf['now'];
      $dsa['added'] = $cf['now'];
      $dsa['original'] = $dsatmporig;
      $dsa['parsed'] = jlk_parseServerAlert($dsa['original']);
      $dsa['SAID'] = jlk_writeDBServerAlert($cf, $dsa);
      jlk_sendServerAlert($cf, $dsa, null);
      return;
    }
  } else if (($dsa['ageM'] >= $cf['expiry']) ||
    (!empty($_GET['jlksar']) && $dsa['ageM'] >= $cf['minlife']))
  {
    // Get New (Old was OK)
    $pdsa = $dsa;
    $dsatmporig = jlk_liveServerAlert($cf['url']);
    $dsa['ageM'] = 0;
    $dsa['age'] = '';
    $dsa['giveurl'] = ($cf['minlife'] == 0 ? 1 : 0);
    if (strcmp($dsatmporig, $dsa['original']) == 0)
    {
      $dsa['updated'] = $cf['now'];
      jlk_writeDBServerAlert($cf, $dsa);
      jlk_sendServerAlert($cf, $dsa, null);
      return;
    }
    $dsa = array('original' => $dsatmporig,
                 'parsed' => jlk_parseServerAlert($dsatmporig),
                 'added' => $cf['now'], 'updated' => $cf['now'],
                 'oldage' => '', 'age' => '', 'ageM' => 0,
                 'giveurl' => ($cf['minlife'] == 0 ? 1 : 0), 'SAID' => 0);
    jlk_writeDBServerAlert($cf, $dsa);
    jlk_sendServerAlert($cf, $dsa, $pdsa);
    return;
  }
  // Just display what we had in the database.
  jlk_sendServerAlert($cf, $dsa, $pdsa);
}

// Actually send the server alert to the client.
function jlk_sendServerAlert($cf, $curr, $prev)
{
  global $context;
  // Current was an Error:
  if (strcmp(substr($curr['original'], 0, 9), 'CURLERROR') == 0)
  {
    if (!empty($prev))
    {
      echo $prev['parsed'] . '<div style="text-align: right; font-style: italic">Data is ' . $prev['oldage'] . ' old. Last checked ' . $prev['age'] . ' ago.<br />';
      if (($context['user']['is_admin'] && $cf['verbose-errors'] == 1) ||
          ($cf['verbose-errors'] == 2))
        echo $curr['parsed'];
      else
        echo 'Check failed';
      if (empty($curr['age']))
        echo ' just now.';
      else
        echo ' ' . $curr['age'] . ' ago.';
    } else {
      if (($context['user']['is_admin'] && $cf['verbose-errors'] == 1) ||
          ($cf['verbose-errors'] == 2))
        echo $curr['parsed'];
      else
        echo 'Check failed.';
      echo ' <div style="text-align: right; font-style: italic">Attempted ' . ($curr['age'] == '' ? 'just now.' : $curr['age'] . ' ago.');
    }
    if ($curr['giveurl'] == 1)
      echo $cf['txt-refresh'];
    echo '</div>';
    return;
  }
  // Current was good.
  echo $curr['parsed'] . '<div style="text-align: right; font-style: italic">';
  if ($curr['oldage'] == '')
    echo 'Data was fetched from the server.';
  else
  {
    echo 'Data is ' . $curr['oldage'] . ' old. Checked ' .
         ($curr['age'] == '' ? 'now.' : $curr['age'] . ' ago.');

    if ($curr['giveurl'] == 1)
      echo $cf['txt-refresh'];
  }
  echo '</div>';
}

// Write the values to the database.
function jlk_writeDBServerAlert($cf, $dsa, $pdsa)
{
  // Insert or Update?
  if ($dsa['SAID'] == 0)
  {
    $q = db_query('INSERT INTO `' . $cf['cache_table'] . '` (
                    `Date_Added`, `Date_Updated`, `Original`, `Parsed`)
                    VALUES (FROM_UNIXTIME('.$dsa['added'].'), FROM_UNIXTIME('.
                      $dsa['updated'] .'), \''.
                      addslashes__recursive($dsa['original']) .'\', \''.
                      addslashes__recursive($dsa['parsed']) . '\')', __FILE__,
                  __LINE__);
    $newid = db_insert_id();
    mysql_free_result($q);
    // Caching only current and previous? Get rid of old news.
    if ($cf['cache'] == 1 && !empty($pdsa) && $pdsa['SAID'] != 0)
    {
      $q = db_query('DELETE FROM `' . $cf['cache_table'] . '` WHERE `SAID` < ' . $pdsa['SAID'], __FILE__, __LINE__);
      mysql_free_result($q);
    }
    return($newid);
  }
  $q = db_query('UPDATE `' . $cf['cache_table'] . '`
                   SET `Date_Updated`=FROM_UNIXTIME('.$dsa['updated'].
                   ') WHERE `SAID`=' . $dsa['SAID'], __FILE__, __LINE__);
  mysql_free_result($q);
  return $dsa['SAID'];
}

// Get the values from the database.
function jlk_getDBServerAlert($cf)
{
  // Create The Table on First Use.
  $q = db_query('CREATE TABLE IF NOT EXISTS `' . $cf['cache_table'] . '` (
    `SAID` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
    `Date_Added` DATETIME NOT NULL,
    `Date_Updated` DATETIME NOT NULL,
    `Original` Text,
    `Parsed` Text,
    PRIMARY KEY (SAID)
  )', __FILE__, __LINE__);
  mysql_free_result($q);

  $dsa = array ('original' => '', 'parsed' => '', 'added' => 0,
                'updated' => 0, 'oldage' => '', 'age' => '', 'ageM' => 0,
                'now' => $cf['now'],
                 'giveurl' => ($cf['minlife'] == 0 ? 1 : 0), 'SAID' => 0);
  $pdsa = array ('original' => '', 'parsed' => '', 'added' => 0,
                 'updated' => 0, 'oldage' => '', 'age' => '', 'ageM' => 0,
                 'now' => $dsa['now'],
                 'giveurl' => ($cf['minlife'] == 0 ? 1 : 0), 'SAID' => 0);
  $q = db_query('SELECT SAID, UNIX_TIMESTAMP(Date_Added),
                              UNIX_TIMESTAMP(Date_Updated), Original, Parsed
                   FROM `'.$cf['cache_table'].'`
                   ORDER BY SAID DESC LIMIT 2', __FILE__, __LINE__);

  if (mysql_num_rows($q) < 1)
    return array(null, null);

  $r = mysql_fetch_row($q);
  $dsa['SAID'] = $r[0];
  $dsa['added'] = $r[1];
  $dsa['updated'] = $r[2];
  $dsa['original'] = $r[3];
  $dsa['parsed'] = $r[4];
  list($dsa['ageM'], $dsa['age']) = jlk_dateDiff($cf['now'], $dsa['updated']);
  if ($dsa['ageM'] >= $cf['minlife'])
    $dsa['giveurl'] = 1;
  list(,$dsa['oldage']) = jlk_dateDiff($cf['now'], $dsa['added']);

  if (mysql_num_rows($q) < 2)
  {
    mysql_free_result($q);
    return array($dsa, null);
  }

  $r = mysql_fetch_row($q);
  $dsa['error'] = $r[0];
  $pdsa['SAID'] = $r[0];
  $pdsa['added'] = $r[1];
  $pdsa['updated'] = $r[2];
  $pdsa['original'] = $r[3];
  $pdsa['parsed'] = $r[4];
  list($pdsa['ageM'], $pdsa['age']) = jlk_dateDiff($cf['now'], $pdsa['updated']);
  list(,$pdsa['oldage']) = jlk_dateDiff($cf['now'], $pdsa['added']);

  mysql_free_result($q);
  return array($dsa, $pdsa);
}

// Determine the difference between two dates.
// Returns Array (Total Minutes, #d#h#m#s)
function jlk_dateDiff($jddx, $jddy)
{
  if ($jddx == $jddy)
    return array(0, '');
  $jddm = 0;
  $jddiff = ($jddx > $jddy ? $jddx - $jddy : $jddy - $jddx);
  $jddiffS = $jddiff % 60;
  $jddiffM = floor($jddiff / 60);
  $jddm = $jddiffM;
  $jddiffH = floor($jddiffM / 60);
  $jddiffD = floor($jddiffH / 24);
  $jddiffM %= 60;
  $jddiffH %= 24;
  return array($jddm, ($jddiffD > 0 ? $jddiffD . 'd' : '') .
                      ($jddiffH > 0 ? $jddiffH . 'h' : '') .
                      (($jddiffM > 0 && $jddiffD < 1) ? $jddiffM . 'm' : '') .
                      (($jddiffS > 0 && $jddiffD < 1 && $jddiffH < 1) ? $jddiffS . 's' : ''));
}

function jlk_parseServerAlert($source)
{
  if (strcmp($source, 'NOALERT') == 0)
    return 'No current Server Alert posted.';
  if (strcmp(substr($source, 0, 9), 'CURLERROR') == 0)
    return 'Unable to retrieve Server Alert: ' . substr($source, 11);
  $source = trim($source);
  if (strcasecmp(substr($source, 0, 11), 'SERVERALERT') == 0)
    $source = trim(substr($source,12));
  return(str_replace("\n", '<br />', str_replace("\r", '', trim($source))));
}

function jlk_liveServerAlert($gsa_url)
{
  $gsa_ret = '';
  $gsa_ch = curl_init();
  curl_setopt($gsa_ch, CURLOPT_URL, $gsa_url);
  curl_setopt($gsa_ch, CURLOPT_HEADER, false);
  curl_setopt($gsa_ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($gsa_ch, CURLOPT_FAILONERROR, true);
  $gsa_sares = curl_exec($gsa_ch);
  if (curl_errno($gsa_ch))
  {
    if ((curl_errno($gsa_ch) == 22) &&
        (strcmp(substr(trim(curl_error($gsa_ch)), -3), '404') == 0))
    {
      $gsa_ret = 'NOALERT';
    } else {
      $gsa_ret = 'CURLERROR: '. curl_error($gsa_ch);
    }
  } else {
    if (empty($gsa_sares) || (strlen(trim($gsa_sares)) < 10))
      $gsa_ret = 'NOALERT';
    else
      $gsa_ret = $gsa_sares;
  }
  curl_close($gsa_ch);
  return $gsa_ret;
}

Title: Re: [Block] WoW Login Information Block
Post by: Dramber on February 04, 2009, 05:04:28 AM
Very nice! Works like a charm.  8)
Title: Re: [Block] WoW Login Information Block
Post by: Dark-Wolf on March 03, 2009, 01:18:40 AM
Someone can post a screenshot please?
Title: Re: [Block] WoW Login Information Block
Post by: Inny on March 03, 2009, 09:20:14 PM
Quote from: Dark-Wolf on March 03, 2009, 01:18:40 AM
Someone can post a screenshot please?

Here (http://www.epu-wow.com/smf/index.php?page=WoWLoginNews) - Tho i dont remember which one of the 2 codes i use.
Title: Re: [Block] WoW Login Information Block
Post by: Karma on March 03, 2009, 11:06:24 PM
Sorry guys, my bad.. I missed the topic reply notification :p..

I fudged it a little bit (there's no ServerAlert posted atm) to pull out some old data.. Usually I have the ServerAlert on a Lower Panel, the SS is for demonstration purposes only.

Apologies for not just linking the forums, only displaying the alert for guild members ;p.

Attached.
Title: Re: [Block] WoW Login Information Block
Post by: Karma on April 10, 2009, 08:29:02 AM
Updated in This Post (http://www.tinyportal.net/index.php/topic,28072.msg224190.html#msg224190) (A link, if it's not obvious in your skin)

Revision 0.4:

* Fixed a bug where the first 12 characters would be trimmed from messages not beginning with 'SERVERALERT:'
* All time conversions and reads are now being done on the MySQL server. DST caused some time compares to be an hour out. Also means good news for people with MySQL servers in different timezones to their web servers (wtf? :o).

Enjoy.
Title: Re: [Block] WoW Login Information Block
Post by: mekon on April 10, 2009, 12:21:45 PM
Great block, but I am receiving the following code errors in the error log once the block is enabled.

2: Missing argument 2 for db_query(), called in /home/nomekcou/public_html/tsbguild/Sources/Load.php(1735) : eval()'d code(48) : eval()'d code on line 235 and defined
File: home/********/public_html/tsbguild/Sources/Subs.php
Line: 238
Title: Re: [Block] WoW Login Information Block
Post by: Kazie on April 13, 2009, 06:50:03 PM
How come it doesn't show all the breaking news?

I just checked for fun, and it's not including migration news and stuff..
Is this intentional, or you just didn't notice? :)

Brilliant block btw.
Title: Re: [Block] WoW Login Information Block
Post by: Inny on April 13, 2009, 07:16:17 PM
It shows everything, its different for EU and US.

Title: Re: [Block] WoW Login Information Block
Post by: Karma on April 14, 2009, 02:05:14 AM
Quote from: mekon on April 10, 2009, 12:21:45 PM
Great block, but I am receiving the following code errors in the error log once the block is enabled.

2: Missing argument 2 for db_query(), called in /home/nomekcou/public_html/tsbguild/Sources/Load.php(1735) : eval()'d code(48) : eval()'d code on line 235 and defined
File: home/********/public_html/tsbguild/Sources/Subs.php
Line: 238

I don't expect it to make a difference, but humour me anyway ;o).. I've updated (Rev 0.4.1) to include the (supposedly optional) __FILE__ and __LINE__ parameters to db_query.

If this doesn't fix it, what version of SMF are you running? I'm running the block on 1.1.8, personally.

Quote from: Kazie on April 13, 2009, 06:50:03 PM
How come it doesn't show all the breaking news?
Have you set the url to the correct localised site? If so, which site are you using, and if the message is not still currently displayed, would it be possible for you (assuming cache=2) to dig through the smf_jlk_srvalert table for the record, and provide me the original and parsed field values? I'm interested if something is causing text to be truncated =)

e:
0.4.2 - Anything less than 12 chars in length will be considered not an alert.
Title: Re: [Block] WoW Login Information Block
Post by: odsign on June 11, 2009, 04:16:28 PM
Hello Karma,

I'm getting this error in my forum error log:

8: Undefined variable: dsa_sysdate (line 83)

shouldn't it be dsa_sdate ?

I'm using your first code.

edit: changing $dsa_sysdate to $dsa_sdate fixed the problem.
Title: Re: [Block] WoW Login Information Block
Post by: Karma on June 12, 2009, 01:15:33 AM
Quote from: odsign on June 11, 2009, 04:16:28 PMshouldn't it be dsa_sdate ?

I'm using your first code.

edit: changing $dsa_sysdate to $dsa_sdate fixed the problem.
You're probably right ;o). I've modified the OP to reflect your change - Thanks :o)

I haven't been playing WoW for a while, my old guild has disbanded, so the only way I'm going to know if there's a problem is if someone mentions it here ;o)
Title: Re: [Block] WoW Login Information Block
Post by: beetroot on October 02, 2009, 04:37:58 PM
hey there Karma,
Thank you for the great Block, but I can not seem to get it to work for me, All I get is an empty PHP block at the top of my forum.

I play on the Wow EU servers (English)

All I have done is "copy/paste" your first code into a PHP box and then replaced

Quote'url' => 'http://status.wow-europe.com/en/alert',

with

Quote'url' => 'http://status.wow-europe.com/en/alert',

is this all I needed to do? Sorry, I really dont know any coding and am beginning to wonder why I agreed to run the guild forum..

Thanks for any help,


Title: Re: [Block] WoW Login Information Block
Post by: beetroot on October 02, 2009, 04:56:29 PM
hi there,

I have gotten it to work, not sure how, but its working like a charm now!!!

Thank you
Title: Re: [Block] WoW Login Information Block
Post by: mOOwalker on October 01, 2010, 10:30:19 AM
Hi,

I don't know if this block is supposed to still work, but I installed it and I get the following error

QuoteFatal error: Call to undefined function addslashes__recursive() in /home/*******/domains/infinite-guild.eu/public_html/Sources/Load.php(2105) : eval()'d code(112) : eval()'d code on line 193

Line 193 of the block is
Quoteaddslashes__recursive($dsa['original']) .'\', \''.

So, I am guessing this function is missing.

I am using SMF 2.0RC3 and TinyPortal RC1

Thanks,
mOOwalker
Title: Re: [Block] WoW Login Information Block
Post by: IchBin on October 01, 2010, 04:26:20 PM
Yea it looks like that function is missing. Having no idea what it did, I don't think you'll get this block to work.
Title: Re: [Block] WoW Login Information Block
Post by: Karma on December 01, 2010, 07:13:44 AM
Quote from: IchBin on October 01, 2010, 04:26:20 PM
Yea it looks like that function is missing. Having no idea what it did, I don't think you'll get this block to work.
Seems my forum account had disappeared, so I wasn't getting notified of replies.. Oops!

That appears to have been a function of SMF 1.1.x that's removed in 2.x, I've just copy/pasted the block into a vanilla SMF 1.1.12/TP 1.0RC1, and had no issues.
http://support.simplemachines.org/function_db/index.php?action=view_function;id=358

If there's a function that's acceptable to both SMF 1.1.x and 2.x, I'm happy to replace it ;o)