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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 695
  • Total: 695

[Bloc] PHPraider

Started by bigor, February 18, 2010, 10:35:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bigor

Bonjour,
Voici un petit bloc sympa qui affiche les prochains raids, en allant chercher les infos dans Phpraider, il afiche le statut de l'utilisateur connecté:
Voici le code à mettre dans le bloc:
$rootlink = "http://deathangelz.free.fr/phpRaider/index.php?option=com_view&id";
$urlBase = "http://deathangelz.free.fr/phpRaider/";


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

$login = $GLOBALS['context']['user']['username'];
$dbname=$GLOBALS["db_name"];
$username=$GLOBALS["db_user"];
$password=$GLOBALS['db_passwd'];
$hostname=$GLOBALS["db_server"];

$template = 'lichking';
$prefix="phpraider_";
$erreur=false;

//open connection
$db = false;
$connection = mysql_connect("$hostname", "$username", "$password");

if ($connection === false) $erreur = true;
else $db = mysql_select_db("$dbname", $connection);
if ($db === false) $erreur = true;

if ($erreur === false)
{
$link="";
$activeu="";
$maxraids = 4;
$content = "";
$pConfig_timezone = +100;
$offset = (60 * 60) * ($pConfig_timezone/100);
$time_buffer = (60 * 60) * 2;
$rightnow = time() + $offset;
$future = $rightnow - $time_buffer;
$totalraids = 0;
$arrJour= array("Dim","Lun","Mar","Mer","Jeu","Ven","Sam","Dim");

$result = mysql_query("SELECT raid_id, location, start_time,raid_leader, icon_name, maximum FROM ".$prefix."raid WHERE start_time > ".$future." ORDER BY start_time ASC");


if ($result !== false)
{
$sep='';
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 );
$dayAff = $arrJour[raidernewDate( "N", $raids['start_time'],$pConfig_timezone )];
$today_month = raidernewDate( "m", time(),$pConfig_timezone );
$today_day = raidernewDate( "d", time(),$pConfig_timezone );

//query for approved
$query = 'SELECT * FROM '.$prefix.'signups where queue = 0 and cancel = 0 and raid_id = '.$raids['raid_id'];
$result2 = mysql_query($query);
if ($result2 == false)
{
$erreur = true;
break;
}
$apprvd = mysql_num_rows($result2);

//query for Queued
$query = 'SELECT * FROM '.$prefix.'signups where queue = 1 and cancel = 0 and raid_id = '.$raids['raid_id'];
$result3 = mysql_query($query);
if ($result3 == false)
{
$erreur = true;
break;
}

$que = mysql_num_rows($result3);

//query for Indispo
$query = 'SELECT * FROM '.$prefix.'signups where queue = 0 and cancel = 1 and raid_id = '.$raids['raid_id'];
$result4 = mysql_query($query);
if ($result4 == false)
{
$erreur = true;
break;
}

$indis = mysql_num_rows($result4);

//query for user status
$query = 'SELECT * FROM '.$prefix.'signups INNER JOIN '.$prefix.'character on  '.$prefix.'signups.character_id = '.$prefix.'character.character_id INNER JOIN '.$prefix.'profile on  '.$prefix.'signups.profile_id = '.$prefix.'profile.profile_id WHERE raid_id = '.$raids['raid_id'].' and username=\''.$login.'\'';
$result5 = mysql_query($query);
if ($result5 == false)
{
$erreur = true;
break;
}

$lineStatus = mysql_fetch_array($result5,MYSQL_ASSOC);

if ($lineStatus === false)
{
$status = "icon_signup.png";
$statusLib = "Inscrivez-vous";
}
elseif ($lineStatus['cancel'] == 0 && $lineStatus['queue'] == 0)
{
$status = "icon_signed_up.png";
$statusLib = "Disponible";
}
elseif ($lineStatus['cancel'] == 1 && $lineStatus['queue'] == 0)
{
$status = "icon_cancel_signup.png";
$statusLib = "Indisponible";
}
elseif ($lineStatus['cancel'] == 0 && $lineStatus['queue'] == 1)
{
$status = "icon_queue.png";
$statusLib = "En file d'attente";
}

if($totalraids >= $maxraids) continue;
$today = "";
$timedone = $raids['start_time'] + $time_buffer;
$hour = gmdate( "H", $raids['start_time'] );
$mins = gmdate( "i", $raids['start_time'] );

if( $today_month == $month && $today_day == $day && $raids['start_time'] < $rightnow && $rightnow < $timedone)
{
$today = "<br><span  style=\"font-size:9px; color:blue;\">EN COURS</span>";
}
elseif( $today_month == $month && $today_day == $day ) {
$today = "<br><span style=\"font-size:9px; color:red;\"><blink>AUJOURD'HUI</blink></span>";
}

$link ="<tr>
<td rowspan=\"3\" align=\"center\">
<a href=\"$rootlink={$raids['raid_id']}\"><img src='".$urlBase."games/WoW/images/raids/{$raids['icon_name']}' border=\"0\"/></a>
{$today}
</td>
<td align=\"center\"><b>{$raids["location"]}</b></td>
</tr>
<tr>
<td align=\"center\" style=\"font-size:9px;\">{$hour}:{$mins} - {$dayAff} {$day}/{$month}/{$year}</td>
</tr>
<tr>
<td align=\"center\">
<table cellpadding=\"0\" cellspacing=\"0\" width=\"90%\" style=\"font-size:9px;\">
<tr>
<td align=\"center\" style=\"background-color:white; border-left:1px solid #000000; border-top:1px solid #000000;\"\"><img hspace=\"2\" src=\"".$urlBase."templates/".$template."/images/icons/icon_signed_up.png\"/></td>
<td align=\"center\" style=\"background-color:white; border-left:1px solid #000000; border-top:1px solid #000000;\"\"><img hspace=\"2\" src=\"".$urlBase."templates/".$template."/images/icons/icon_queue.png\"/></td>
<td align=\"center\" style=\"background-color:white; border-left:1px solid #000000; border-top:1px solid #000000;\"><img hspace=\"2\" src=\"".$urlBase."templates/".$template."/images/icons/icon_cancel_signup.png\"/></td>
<td align=\"center\" valign=\"middle\" rowspan=\"2\" style=\"background-color:white; width:30px; padding:5px; border:1px solid #000000; background-image:url('".$urlBase."templates/".$template."/images/icons/icon_classleader.png'); background-repeat:no-repeat;background-position:25% 30%;\"><a href=\"$rootlink={$raids['raid_id']}\"><img style=\"padding-left:10px;\" border=\"0\" src=\"".$urlBase."templates/".$template."/images/icons/".$status."\" title=\"".$statusLib."\"/></a></td>
</tr>
<tr>
<td align=\"center\" style=\"background-color:white; border-left:1px solid #000000; border-bottom:1px solid #000000; font-size:9px;\">".$apprvd."/".$raids['maximum']."</td>
<td align=\"center\" style=\"background-color:white; border-left:1px solid #000000; border-bottom:1px solid #000000; font-size:9px;\">".$que."</td>
<td align=\"center\" style=\"background-color:white; border-left:1px solid #000000; border-bottom:1px solid #000000; font-size:9px;\">".$indis."</td>
<td></td>
</tr>
</table>
</td>
</tr>";


$activeu .= $sep.$link;

$sep = "<tr style=\"height:5px;\"><td colspan=\"2\"><hr style=\"border-top:1px solid #000000;\"></td></tr>";

$totalraids = $totalraids + 1;
}
}
if ($erreur === true) $activeu = "Une erreur est survenue";
elseif ($totalraids == 0) $activeu = "Aucun raid";
}
else $activeu = "Une erreur est survenue";

$myhtml = " <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td width=\"100%\" valign=\"middle\">
<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">
<tr>
<td align=\"center\"><span><b>$totalraids Raid</b>(s) <span style=\"font-size:9px;\"> - <a href=\"".$urlBase."index.php?page=wowevents\">voir l'agenda</a></span></span>
</td>
</tr>
<tr>
<td valign=\"middle\">
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">
$activeu
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>";

echo $myhtml;



Ci joint, un petit screen de ce que ca donne:

MkC

Bonjour,

Code interessant, mais il s'agit là uniquement d'une interrogation de base, je suppose qu'il faut le produit phpraider : http://forums.phpraider.com/local_links.php?catid=1
Peut être le préciser.
Au niveau du code tu as 3 requêtes sur la table signups que tu peux regrouper en une et utiliser un filtre dans un while pour dépiler le contenu de ta requête soit dans des tableaux soit dans un tableau multi. Après un simple count sur la partie qui t'intéresse sera beaucoup moins coûteux en temps et ressource.   ;)

Quote$rootlink = "http://deathangelz.free.fr/phpRaider/index.php?option=com_view&id";
$urlBase = "http://deathangelz.free.fr/phpRaider/";
Les urls servent je pense uniquement pour récupérer les images, qu'il serait peut être intéressant de joindre à ton topic pour économiser ta bande passante  ;)

Enfin merci pour ce partage.

This website is proudly hosted on Crocweb Cloud Website Hosting.