TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 01, 2024, 01:52:40 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 120
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 117
  • Total: 117

TP and phpraider block

Started by RebelRose, June 05, 2007, 01:57:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hakker

Quote from: Omniverse on August 23, 2007, 06:55:23 PM
Ok, here is one I got working, found from spiffy's site.



$rootlink = "your link to phpraider/index.php?option=com_view&id";

function raidernewDate( $format, $timestamp, $tz ) {
$offset = (60 * 60) * ($tz / 100); // Seconds from GMT
    $timestamp = $timestamp + $offset;
    return gmdate( $format, $timestamp );
}

$maxraids = 5;
$content = "";
$pConfig_timezone = -800;
$offset = (60 * 60) * ($pConfig_timezone/100);
$time_buffer = (60 * 60) * 2;
$rightnow = time() + $offset;
$future = $rightnow - $time_buffer;

global $db_prefix, $scripturl, $txt,$settings,$modSettings, $sourcedir;

        $result = mysql_query("SELECT raid_id, location, start_time, raid_leader  FROM phpraider_raid WHERE start_time > ".$future." ORDER BY start_time ASC");
$sep = ",";
$totalraids = 0;


while ($raids = mysql_fetch_assoc($result)) {

$year = raidernewDate( "Y", $raids['start_time'], $pConfig_timezone);
$month = raidernewDate( "m", $raids['start_time'], $pConfig_timezone );
$day = raidernewDate( "d", $raids['start_time'], $pConfig_timezone );
$today_month = raidernewDate( "m", time(), $pConfig_timezone );
$today_day = raidernewDate( "d", time(), $pConfig_timezone );

if($totalraids >= $maxraids) continue;
$today = "";
$timedone = $raids['start_time'] + $time_buffer;
$hour = gmdate( "H", $raids['start_time'] );
$suffix="";
if($hour > 12){
$hour = $hour - 12;
$suffix = "pm";
}else {
$suffix = "am";
}
$mins = gmdate( "i", $raids['start_time'] );
$hour2 = gmdate( "H:i", $rightnow );
$hour3 = gmdate( "H:i", $timedone );
//echo "{$hour} {$hour2} {$hour3} -";
if( $today_month == $month && $today_day == $day &&
    $raids['start_time'] < $rightnow && $rightnow < $timedone) {
$today = "     <span style='color:blue'>(IN PROGRESS)</span>";
} elseif( $today_month == $month && $today_day == $day ) {
$today = "     <span style='color:green'><blink>(TODAY)</blink></span>";
}
$link ="<span style='color:red'> {$month}/{$day} - <a href=\"$rootlink={$raids['raid_id']}\">{$hour}:{$mins}{$suffix}(PST): {$raids['location']}</a>{$today}</span><br>";

    $activeu .= $link." ";
$totalraids = $totalraids + 1;
}
if ( $totalraids ==  0){
$activeu = "No upcoming events.   ";
}
$activeu = substr($activeu, 0, (strlen($activeu) -2));
$myhtml = "<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">
<tr>
  <td width=\"100%\">
    <table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">
      <tr>
<td class=\"tdblock\">
<span class=\"mktxtcontr\">$totalraids</span> <b>Event(s)</b>
</td>
      </tr>
      <tr>
<td class=\"tdglobal\">
$activeu
</td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td class=\"tdblock\">
  <img src=\"http://your link to phpraider/templates/default/images/icons/icon_signed_up.png\" style=\"vertical-align: middle;\" alt=\"\" /> <a class=\"uno\" href=\"your link to phpraider\">Event Calendar</a>
  </td>
</tr>
</table>
      ";

echo $myhtml;
unset($totalraids);
unset($rootlink);
unset($rightnow);





Remember to edit the URL's. :)
Well it shows something but not my raids... It keeps standing on 0 :(

hebxi1

block code works nicely, but I also have my phpRaider info in a separate DB so it's just not pulling the right info ... if someone could tweak this code to work for either/or that would simply be awesome.

laric

Here is my current phpraider block.

$rootlink = "http://your link to phpraider/index.php?option=com_view&id";

function raidernewDate( $format, $timestamp, $tz ) {
    $offset = (60 * 60) * ($tz / 100); // Seconds from GMT
    $timestamp = $timestamp + $offset;
    return gmdate( $format, $timestamp );
}
$activeu = "";
$maxraids = 5;
$content = "";
$pConfig_timezone = -500;
$offset = (60 * 60) * ($pConfig_timezone/100);
$time_buffer = (60 * 60) * 2;
$rightnow = time() + $offset;
$future = $rightnow - $time_buffer;

$phpraider_prefix = 'phpraider_';

global $db_prefix, $scripturl, $txt,$settings,$modSettings, $sourcedir;

$link = mysql_connect('your raid db host', 'your raid db user', 'your raid db pass');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

$db_selected = mysql_select_db('your raid db', $link);
if (!$db_selected) {
    die ('Can\'t use phpraider : ' . mysql_error());
}


$result = mysql_query("SELECT t1.raid_id, location, start_time, raid_leader,IFNULL(antall,0) as antall,maximum,IFNULL(queue,0) as queue,icon_name  FROM phpraider_raid as t1 left join (SELECT `raid_id`,count(*) as antall FROM `phpraider_signups` where `cancel`=0 and `queue`=0 group by `raid_id`) as t2 on t1.raid_id=t2.raid_id left join (SELECT `raid_id`,count(*) as queue FROM `phpraider_signups` where `cancel`=0 and `queue`=1 group by `raid_id`) as t3 on t1.raid_id=t3.raid_id WHERE start_time > ".$future." ORDER BY start_time ASC");
$sep = ",";
$totalraids = 0;

while ($raids = mysql_fetch_assoc($result)) {
$year = raidernewDate( "Y", $raids['start_time'], $pConfig_timezone);
$month = raidernewDate( "m", $raids['start_time'], $pConfig_timezone );
$day = raidernewDate( "d", $raids['start_time'], $pConfig_timezone );
$daystr = raidernewDate( "D", $raids['start_time'], $pConfig_timezone );

$today_month = raidernewDate( "m", time(), $pConfig_timezone );
$today_day = raidernewDate( "d", time(), $pConfig_timezone );

$udda="";
       if(($totalraids+2)%2) $udda="2";
       if($totalraids >= $maxraids) continue;
$today = "";
$timedone = $raids['start_time'] + $time_buffer;
$hour = gmdate( "H", $raids['start_time'] );
$suffix="";
$mins = gmdate( "i", $raids['start_time'] );
$hour2 = gmdate( "H:i", $rightnow );
$hour3 = gmdate( "H:i", $timedone );
        $link ="
          <table width=\"175\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"29\" rowspan=\"3\" valign=\"top\">
          <div align=\"center\"><span><img src=\"http://your link to phpraider/games/WoW/images/raids/{$raids['icon_name']}\"/></span></div></td>
          <td width=\"175\" height=\"10\" valign=\"top\"><a href=\"$rootlink={$raids['raid_id']}\"><b>{$raids['location']}</b></a><br /> <span><a href=\"$rootlink={$raids['raid_id']}\">{$raids['antall']}/{$raids['maximum']}({$raids['queue']})  RL: {$raids['raid_leader']}</a></span><br/><a href=\"$rootlink={$raids['raid_id']}\">{$daystr} {$month}/{$day} {$hour}:{$mins}{$suffix}</a></td>
          </tr>
          </table>";
        $activeu .= $link."\n";
$totalraids = $totalraids + 1;
}
if ( $totalraids ==  0){
$activeu = "No upcoming events.   ";
}
$myhtml = "<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">
<tr>
  <td width=\"100%\">
    <table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">
      <tr>
<td class=\"tdblock\">
<span class=\"mktxtcontr\">$totalraids</span> <b>Event(s)</b>
</td>
      </tr>
      <tr>
<td class=\"tdglobal\">
$activeu
</td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td class=\"tdblock\">
  <img src=\"http://your link to phpraider/templates/default/images/icons/icon_signed_up.png\" style=\"vertical-align: middle;\" alt=\"\" /> <a href=\"your link to phpraider\">Event Calendar</a>
  </td>
</tr>
</table>
";
echo $activeu;
unset($totalraids);
unset($rootlink);
unset($rightnow);


Omniverse

That works perfect Laric. :) Thank you.

2 questions...

How can I get the event calendar link to show back up? Was a link at the bottom of the block to phpraider. Looks like the code is there, but doesn't do it.

How do I change from 24 hour clock to 12 hour clock?

microbone

#34
before:

$hour2 = gmdate( "H:i", $rightnow );

insert this:

if($hour > 12){
$hour = $hour - 12;
$suffix = "pm";
}else {
$suffix = "am";
}


then you´ll get 12 hour showings..

the thing isn´t showing correctly because

echo $activeu <------;
unset($totalraids);
unset($rootlink);
unset($rightnow);


needs to be changed to:
echo $myhtml;

finally I did like the "in progress" "today" feature....
so if you want that back

after:
$hour3 = gmdate( "H:i", $timedone );

insert
if( $today_month == $month && $today_day == $day &&
    $raids['start_time'] < $rightnow && $rightnow < $timedone) {
$today = "     <span style='color:blue'>(Now)</span>";
} elseif( $today_month == $month && $today_day == $day ) {
$today = "     <span style='color:grey'><blink>Today</blink></span>";
}


change:
<table width=\"175\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"29\" rowspan=\"3\" valign=\"top\">
          <div align=\"center\"><span><img src=\"http://www.microbone.dk/raid/games/WoW/images/raids/{$raids['icon_name']}\"/></span></div></td>
          <td width=\"175\" height=\"10\" valign=\"top\"><a href=\"$rootlink={$raids['raid_id']}\"><b>{$raids['location']}</b></a><br /> <span><a href=\"$rootlink={$raids['raid_id']}\">{$raids['antall']}/{$raids['maximum']}({$raids['queue']})  RL: {$raids['raid_leader']}</a></span><br/><a href=\"$rootlink={$raids['raid_id']}\">{$daystr} {$month}/{$day} {$hour}:{$mins}{$suffix}</a></td>
          </tr>
          </table>";


to:

<table width=\"175\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"29\" rowspan=\"3\" valign=\"top\">
          <div align=\"center\"><span><img src=\"http://www.microbone.dk/raid/games/WoW/images/raids/{$raids['icon_name']}\"/></span></div></td>
          <td width=\"175\" height=\"10\" valign=\"top\"><a href=\"$rootlink={$raids['raid_id']}\"><b>{$raids['location']}</b></a>{$today}<br /> <span><a href=\"$rootlink={$raids['raid_id']}\">{$raids['antall']}/{$raids['maximum']}({$raids['queue']})  RL: {$raids['raid_leader']}</a></span><br/><a href=\"$rootlink={$raids['raid_id']}\">{$daystr} {$month}/{$day} {$hour}:{$mins}{$suffix}</a></td>
          </tr>
          </table>";


but laric thnx a lot for your code, looks so nice :)

Now I have a question...

I would really like to somehow integrate theme so that whenever a new raid is listed it makes use of the theme paragraph/linebreak. Sorry not sure what´s it called but have attached a pic to show what i mean..

I now i have to work with windowbg reference but it simply wont do it or look right!

But I hope some of you can help explain how it´s done :)

laric

I am probably gonna redo all of it to use css so it is looking better on any theme.

But I am really sucky at css. I still haven't found any good tutorial for css.

microbone

same here i guess..... :)

but put a h. ruler inbetween maybe it gives a better overview..
<td width=\"175\" height=\"10\" valign=\"top\"><a href=\"$rootlink={$raids['raid_id']}\"><b>{$raids['location']}</b></a>{$today}<br/> <span><a href=\"$rootlink={$raids['raid_id']}\">{$raids['antall']}/{$raids['maximum']}({$raids['queue']})  RL: {$raids['raid_leader']}</a></span><br/><a href=\"$rootlink={$raids['raid_id']}\">{$daystr} {$month}/{$day} {$hour}:{$mins}{$suffix}</a><hr width=\"125\" align=\"left\"</td>