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: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 321
  • Total: 321

phpRaider Center Block

Started by SMFnub, May 25, 2008, 11:46:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SMFnub

Apology for being messy.  I am not a programmer nor am I any good at php.  This has been from a lot of experimentation.  But I assure you, that it does work.

See it in action
My site:  http://contemptsc.org/index.php

Credit to all who worked on this @ phpraider.com

Shows the week's raid with who has been signed up, Invite Time and Start time.  Has link for sign up.

Time is not perfect, you'll have to experiment with the timezone $timezone = -5;

Also for Signup For Raids link, edit line

InsertText("<a href=\"?offset=<?=$prev;?>\">&lt;&lt; Previous</a> - <a href=\"?offset=0\">Current</a> - <a href=\"?offset=<?=$next;?>\">Next &gt;&gt;</a><a href=\"YOUR_SIGNUP_URL" class=\"raid_calendar\" target=\"_parent\">Sign Up Here</a></td></tr></table>");


Create a php file named raidweek and upload this into your phpraider directory.

<?
// Copyright Eternal Souls, Created by Zemathar of the Eternals Souls Guild on EU Scarhield Legion server,
// feel free to use this code as long as you do not remove this message.
// Here are the config for this page.

// Version 1.1.1
// Color & layout tweaked by Dracula
//

// Version 1.1.0
// Implemented the "no raid" function.
// You can now display an image or text if there is no raid that day.
// You can of cause have it like standard where nothing will be displayed.

// Version 1.0.1
// Implemented $timezone
// There you can change the output time to be in your timezone. You will have to calculate by yourself how many
// hours plus or minus you need.
//
// $db_table_raid is a value pointed to where the xxx_raid tabel is located. You will have to check in the database for the
// right value.

// Version 1.0
// I made this addon just because we needed it.
// It has it flaws and buggs but I will try to fix them as soon as possible


//NOTE! we have put the phpraiderfiles in a folder that we have named raids,
//if you do not want do go thru the code and change to much we advice you to
//do the same.
// ******************************************************
// START OF CONFIGURATION
//

// Where the raidcalender's index.php is located
$raid_cal_index = 'http://yourhost/phpraider/';

// Where the raidcalenders raid-icons are located
$raid_icon_folder = '/phpraider/games/WoW/images/raids/';

// MySQL- settings. Note that db_table_prefixes can vary depending on what you choose when you install phpraider.
$db_raid_server = '';
$db_raid_database_name = '';
$db_raid_database_user = '';
$db_raid_database_pwd = '';
$db_table_raid = 'phpraider_raid';
$db_table_signups = 'phpraider_signups';

// How many hours + or - the viewer should calculate. Some do have to edit this to make
// the timedisplay to be correct.
// For example $timezone = 3  or  $timezone = -4
$timezone = -7;

// Layout. The size of the windows of the days displayed.
//$layout_frame_width = 100;
$layout_frame_width     = 75;
$layout_frame_height = 54;
$layout_frame_raidinfo = 20;

// How many raid icons fit in the table cell?
$max_raids_per_day = 2;

// What will be displayed when no raids are planned for that particular day.
// You can choose to have a text or an icon.
// $no_raid_type = 'image';
// $no_raid_type = 'text';
// $no_raid_type = 'none';
$no_raid_type = 'none';                                                // What mode do you want?
$no_raid_text = 'No raid today';                                // What text to be shown
$no_raid_image = '/phpraider/games/WoW/images/raids/unknown.png';        // link to your icon if you use that.

$no_raid_txt = 'No raid today';
//
// END OF CONFIGURATION
// ******************************************************

$db = mysql_connect($db_raid_server, $db_raid_database_user, $db_raid_database_pwd);
mysql_select_db($db_raid_database_name, $db);

//CHECK OFFSET FROM CURRENT WEEK AND SETS VARIABLES
if ($_GET["offset"]) {
   $weekoffset = $_GET["offset"]*604800;
   $wo = $_GET["offset"];
}
else {
   $weekoffset = 0;
   $wo = 0;
}
$prev = $wo-1;
$next = $wo+1;

$weekstart = (date('U')-(date('w')+6)%7*86400)+$weekoffset;        // sets start date of displayed week
$timezone = $timezone * 3600;                                        // Calculates the timezone-diff.

?>

<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
background-color: #000000;
color: #b0b0b0;
font-family: Arial, Verdana, sans-serif;
}
table {
border: 1px solid #282828;
}
td {
border: 1px solid #404040;
}
td.today {
background-color: #202020;
border: 1px solid #407040;
}
a:link,a:active,a:visited {
text-decoration: none;
color: #006699;
}
a:hover {
text-decoration: underline;
color: #4080b0;
}
.daycontent {
clear: both;
text-align: center;
margin: 0px;
padding-bottom: 0px;
padding-top: 2px;
}
.day {
color: #ffcc33;
font-size: 10pt;
padding-left: 4px;
font-weight: bold;
float: left;
}
.date {
color: #808080;
font-size: 8pt;
padding-top: 2px;
padding-right: 4px;
float: right;
}
#info {
color: #c0b050;
font-size: 8pt;
text-align: center;
}
.available    { color: #80d080; }
.unavailable  { color: #f08080; }
.field        { color: #60b0b0; }

</style>
<script type="text/javascript">
function InsertText(str) {
var oDiv=document.getElementById("info");
oDiv.innerHTML=str;
}
function ClearText() {
InsertText("<a href=\"?offset=<?=$prev;?>\">&lt;&lt; Previous</a> - <a href=\"?offset=0\">Current</a> - <a href=\"?offset=<?=$next;?>\">Next &gt;&gt;</a><a href=\"YOUR_SIGNUP_URL" class=\"raid_calendar\" target=\"_parent\">Sign Up Here</a></td></tr></table>");
}
</script>
</head>
<body onload='javascript:ClearText()'>

<!-- PHP -->
<?

// Lets deal with the output

echo "\t<table width='" . (7 * ($layout_frame_width+2) + 2) . "px' border='0' cellspacing='0' cellpadding='0'>\n";
echo "\t<tr height='" . $layout_frame_height . "'>\n";

$now_timestamp = time( date("H,i") );
$now = date(dm, $now_timestamp);

// Loops through the week
for ( $i = 0; $i < 7; $i++ ) {

$raidscheduled = 0;

$current = $weekstart + (86400*($i) );
$xday = date('D', $current);
$xdate = date('d', $current);
$currdate = date('dm', $current);

if ($now == $currdate) {
$today = " class='today'";
} else {
$today = "";
}

echo "\t\t<td{$today} valign='top' width='" . $layout_frame_width . "px'>\n";
echo "\t\t\t<div class='day'>" . $xday . "</div><div class='date'>" . $xdate . "</div>\n";
echo "\t\t\t<div class='daycontent'>";

// Getting raid start dates
$sql = mysql_query("SELECT * FROM $db_table_raid ORDER by start_time", $db);

while ($check = mysql_fetch_array($sql)){

// Checks if the date of the raid is equal to displayed day
        if ($currdate == date('dm', $check["start_time"])) {

// We need to have a maximum number of raids per day (otherwise layout becomes a mess)
if ($raidscheduled < $max_raids_per_day) {

// Count the signups
$sql2 = mysql_query("SELECT COUNT(*) FROM $db_table_signups WHERE raid_id=".$check['raid_id']." AND cancel=0");
$signupcount = mysql_result($sql2, 0);

// Count the cancels
$sql2 = mysql_query("SELECT COUNT(*) FROM $db_table_signups WHERE raid_id=".$check['raid_id']." AND cancel=1");
$cancelcount = mysql_result($sql2, 0);

            $invite_time = date("H:i",($check["invite_time"]+$timezone));
            $start_time = date("H:i",($check["start_time"]+$timezone));
            $freeze_time = date("H:i",$check["start_time"]-(($check["freeze_time"]*3600)+$timezone));
                 
            $img_txt = $check['location'];
$img_txt .= " (<span class='available'>" . $signupcount . "</span>,<span class='unavailable'>" . $cancelcount . "</span>)";
            if ($now_timestamp <= $freeze_timestamp) {
$img_txt .= " Freeze: <span class='field'>" . $freeze_time . "</span>";
            } else {
            $img_txt .= " <span class='field'>Frozen</span>";
            }
$img_txt .= " Invite: <span class='field'>" . $invite_time . "</span>";
$img_txt .= " Start: <span class='field'>" . $start_time . "</span>";

echo "<img src='" . $raid_icon_folder . $check['icon_name']."' onmouseover=\"InsertText('" . addslashes($img_txt) . "');\" onmouseout='ClearText();' border='0'>";
echo "</a>";
}

        $raidscheduled = $raidscheduled + 1;
}
}

if (!$raidscheduled) {
switch ($no_raid_type) {
case text:
        echo $no_raid_txt . "";
        break;
case image:
        echo "<img src='" . $no_raid_image . "'>";
        break;
default:
        echo "";
        break;
}
}
echo "</div>\n";
    echo "\t\t</td>\n";
}

echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<td colspan='7' height='" . $layout_frame_raidinfo . "'><div id='info'></div></td>\n";
echo "\t</tr>\n";
echo "\t</table>\n";
?>
<!-- ENDPHP -->

</body>
</html>



Create html/bbc Center Block

<p align="center"><iframe src="YOURSITE/phpraider/raidweek.php" frameborder="0" width="540" scrolling="no" height="70" allowtransparency="allowtransparency"></iframe></p>

Signedx

Can't get the Center block to display properly, it just shows the code. I have html+BBC block as the type.

JPDeni


Signedx


Lucutious

Could this same thing be done, but instead pull from the built-in calendar instead of phpraider?

IchBin

Anything is possible, but thats more than just a slight change. Thats pretty much a whole separate modification.

Lucutious

Quote from: IchBinâ,,¢ on July 09, 2008, 05:37:44 PM
Anything is possible, but thats more than just a slight change. Thats pretty much a whole separate modification.
Thanks, I'll do a request in a new topic.

Lucutious

I actually took a look at this phpRaider software, and it's something that I decided to install, so this block code works awesome!

Being a complete code idiot however, I can't figure out how to change 2 things.

First, I would like the calendar to display the week starting on Sunday instead of Monday.

Next, I would like the "Sign up for raids" link to open in a new window.

I've tried several things to make both changes, but it seems any time I change anything the code completely breaks.

Anyone mind looking at this?

(Request also posted at phpraider.com, but it seems the person that originally made this is no longer in the game and thus not developing this at all, and the phpraider program itselt is in a bit of a lul for programming, so posting here as a last resort type of thing.)

bradfrank

I know it's a month later, but...
Quote from: Lucutious on July 12, 2008, 06:31:10 AM
First, I would like the calendar to display the week starting on Sunday instead of Monday.

$weekstart = (date('U')-(date('w')+7)%7*86400)+$weekoffset;

Also, I'm not sure if my version of phpRaider is new, old, but I had to make the following change:


while ($check = mysql_fetch_array($sql)){
// Checks if the date of the raid is equal to displayed day
        if ($currdate == date('dm', strtotime($check["start_time"]))) {


Thanks for taking the time to write this!

Azphat12

#9
Ok got the display.  Images show up, but have 2 problems...

http://www.darkaftermath.org

{SOLVED}-->1.  How do I make it Sun - Sat?  I saw another post stating the line to adjust, but its all code and I dont understand it. 

$weekstart = (date('U')-(date('w')+6)%7*86400)+$weekoffset;        // sets start date of displayed week

2.  The other thing is the next, current, previous etc links are not showing up...

Here is my code I am using.

<?
// Copyright Eternal Souls, Created by Zemathar of the Eternals Souls Guild on EU Scarhield Legion server,
// feel free to use this code as long as you do not remove this message.
// Here are the config for this page.

// Version 1.1.1
// Color & layout tweaked by Dracula
//

// Version 1.1.0
// Implemented the "no raid" function.
// You can now display an image or text if there is no raid that day.
// You can of cause have it like standard where nothing will be displayed.

// Version 1.0.1
// Implemented $timezone
// There you can change the output time to be in your timezone. You will have to calculate by yourself how many
// hours plus or minus you need.
//
// $db_table_raid is a value pointed to where the xxx_raid tabel is located. You will have to check in the database for the
// right value.

// Version 1.0
// I made this addon just because we needed it.
// It has it flaws and buggs but I will try to fix them as soon as possible


//NOTE! we have put the phpraiderfiles in a folder that we have named raids,
//if you do not want do go thru the code and change to much we advice you to
//do the same.
// ******************************************************
// START OF CONFIGURATION
//

// Where the raidcalender's index.php is located
$raid_cal_index = 'http://www.darkaftermath.org/phpraider/';

// Where the raidcalenders raid-icons are located
$raid_icon_folder = '/phpraider/games/WoW/images/raids/';

// MySQL- settings. Note that db_table_prefixes can vary depending on what you choose when you install phpraider.
$db_raid_server = 'localhost';
$db_raid_database_name = '';
$db_raid_database_user = '';
$db_raid_database_pwd = '';
$db_table_raid = '';
$db_table_signups = '';

// How many hours + or - the viewer should calculate. Some do have to edit this to make
// the timedisplay to be correct.
// For example $timezone = 3  or  $timezone = -4
$timezone = -7;

// Layout. The size of the windows of the days displayed.
//$layout_frame_width = 100;
$layout_frame_width     = 75;
$layout_frame_height = 54;
$layout_frame_raidinfo = 20;

// How many raid icons fit in the table cell?
$max_raids_per_day = 2;

// What will be displayed when no raids are planned for that particular day.
// You can choose to have a text or an icon.
// $no_raid_type = 'image';
// $no_raid_type = 'text';
// $no_raid_type = 'none';
$no_raid_type = 'none';                                                // What mode do you want?
$no_raid_text = 'No raid today';                                // What text to be shown
$no_raid_image = '/phpraider/games/WoW/images/raids/unknown.png';        // link to your icon if you use that.

$no_raid_txt = 'No raid today';
//
// END OF CONFIGURATION
// ******************************************************

$db = mysql_connect($db_raid_server, $db_raid_database_user, $db_raid_database_pwd);
mysql_select_db($db_raid_database_name, $db);

//CHECK OFFSET FROM CURRENT WEEK AND SETS VARIABLES
if ($_GET["offset"]) {
   $weekoffset = $_GET["offset"]*604800;
   $wo = $_GET["offset"];
}
else {
   $weekoffset = 0;
   $wo = 0;
}
$prev = $wo-1;
$next = $wo+1;

$weekstart = (date('U')-(date('w')+6)%7*86400)+$weekoffset;        // sets start date of displayed week
$timezone = $timezone * 3600;                                        // Calculates the timezone-diff.

?>

<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
background-color: #000000;
color: #b0b0b0;
font-family: Arial, Verdana, sans-serif;
}
table {
border: 1px solid #282828;
}
td {
border: 1px solid #404040;
}
td.today {
background-color: #202020;
border: 1px solid #407040;
}
a:link,a:active,a:visited {
text-decoration: none;
color: #006699;
}
a:hover {
text-decoration: underline;
color: #4080b0;
}
.daycontent {
clear: both;
text-align: center;
margin: 0px;
padding-bottom: 0px;
padding-top: 2px;
}
.day {
color: #ffcc33;
font-size: 10pt;
padding-left: 4px;
font-weight: bold;
float: left;
}
.date {
color: #808080;
font-size: 8pt;
padding-top: 2px;
padding-right: 4px;
float: right;
}
#info {
color: #c0b050;
font-size: 8pt;
text-align: center;
}
.available    { color: #80d080; }
.unavailable  { color: #f08080; }
.field        { color: #60b0b0; }

</style>
<script type="text/javascript">
function InsertText(str) {
var oDiv=document.getElementById("info");
oDiv.innerHTML=str;
}
function ClearText() {
InsertText("<a href=\"?offset=<?=$prev;?>\">&lt;&lt; Previous</a> - <a href=\"?offset=0\">Current</a> - <a href=\"?offset=<?=$next;?>\">Next &gt;&gt;</a><a href=\"http://www.darkaftermath.org/phpraider" class=\"raid_calendar\" target=\"_parent\">Raid Signups</a></td></tr></table>");
}
</script>

</head>
<body onload='javascript:ClearText()'>

<!-- PHP -->
<?

// Lets deal with the output

echo "\t<table width='" . (7 * ($layout_frame_width+2) + 2) . "px' border='0' cellspacing='0' cellpadding='0'>\n";
echo "\t<tr height='" . $layout_frame_height . "'>\n";

$now_timestamp = time( date("H,i") );
$now = date(dm, $now_timestamp);

// Loops through the week
for ( $i = 0; $i < 7; $i++ ) {

$raidscheduled = 0;

$current = $weekstart + (86400*($i) );
$xday = date('D', $current);
$xdate = date('d', $current);
$currdate = date('dm', $current);

if ($now == $currdate) {
$today = " class='today'";
} else {
$today = "";
}

echo "\t\t<td{$today} valign='top' width='" . $layout_frame_width . "px'>\n";
echo "\t\t\t<div class='day'>" . $xday . "</div><div class='date'>" . $xdate . "</div>\n";
echo "\t\t\t<div class='daycontent'>";

// Getting raid start dates
$sql = mysql_query("SELECT * FROM $db_table_raid ORDER by start_time", $db);

while ($check = mysql_fetch_array($sql)){

// Checks if the date of the raid is equal to displayed day
            if ($currdate == date('dm', $check["start_time"])) {

// We need to have a maximum number of raids per day (otherwise layout becomes a mess)
if ($raidscheduled < $max_raids_per_day) {

// Count the signups
$sql2 = mysql_query("SELECT COUNT(*) FROM $db_table_signups WHERE raid_id=".$check['raid_id']." AND cancel=0");
$signupcount = mysql_result($sql2, 0);

// Count the cancels
$sql2 = mysql_query("SELECT COUNT(*) FROM $db_table_signups WHERE raid_id=".$check['raid_id']." AND cancel=1");
$cancelcount = mysql_result($sql2, 0);

            $invite_time = date("H:i",($check["invite_time"]+$timezone));
            $start_time = date("H:i",($check["start_time"]+$timezone));
            $freeze_time = date("H:i",$check["start_time"]-(($check["freeze_time"]*3600)+$timezone));
                
            $img_txt = $check['location'];
$img_txt .= " (<span class='available'>" . $signupcount . "</span>,<span class='unavailable'>" . $cancelcount . "</span>)";
            if ($now_timestamp <= $freeze_timestamp) {
$img_txt .= " Freeze: <span class='field'>" . $freeze_time . "</span>";
            } else {
            $img_txt .= " <span class='field'>Frozen</span>";
            }
$img_txt .= " Invite: <span class='field'>" . $invite_time . "</span>";
$img_txt .= " Start: <span class='field'>" . $start_time . "</span>";

echo "<img src='" . $raid_icon_folder . $check['icon_name']."' onmouseover=\"InsertText('" . addslashes($img_txt) . "');\" onmouseout='ClearText();' border='0'>";
echo "</a>";
}

        $raidscheduled = $raidscheduled + 1;
}
}

if (!$raidscheduled) {
switch ($no_raid_type) {
case text:
        echo $no_raid_txt . "";
        break;
case image:
        echo "<img src='" . $no_raid_image . "'>";
        break;
default:
        echo "";
        break;
}
}
echo "</div>\n";
    echo "\t\t</td>\n";
}

echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<td colspan='7' height='" . $layout_frame_raidinfo . "'><div id='info'></div></td>\n";
echo "\t</tr>\n";
echo "\t</table>\n";
?>
<!-- ENDPHP -->

</body>
</html>

This website is proudly hosted on Crocweb Cloud Website Hosting.