Lottery Show in Points Mod

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Lottery Show in Points Mod
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
Hey Telli,

I noticed you modded the points module to show who was the latest winner of the lottery. Any chance you'll be releasing that mod in your downloads section? Just curious.




_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,430
   
The language definitions:


define("_LOTTERY","Lottery");
define("_LOTTERYDESC","Buy tickets to win the jackpot in the <a href=\"modules.php?name=Forums&file=lottery\">Lottery</a>. ");
define("_LOTTERYLASTWIN"," Latest Winner: ");


And the index.php:

        //Start lottery functions
    $sql = "SELECT * FROM ".$prefix."_bbconfig";
       $result = $db->sql_query($sql);
       while ( $row = $db->sql_fetchrow($result) )
       {
       $board_config[$row['config_name']] = $row['config_value'];
       }
       if ( !($result = $db->sql_query("select * from ".$prefix."_lottery")) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Drawing User!'); }
       if (mysql_num_rows($result) > 0) {
       //get prizepool
       $lotteryentries = mysql_num_rows($result);
       $poola = $lotteryentries * $board_config['lottery_cost'];
       $pool = $board_config['lottery_base'] + $poola;
       $pool = number_format($pool, 0);
       $pname = $board_config['points_name'];
     } //End lottery functions

      //Start last lottery winner
      $sql = "SELECT t1.*, t2.username
            FROM ".$prefix."_lottery_history as t1, ".$prefix."_users as t2
            WHERE t2.user_id = t1.user_id
            ORDER BY time DESC
            LIMIT 0, 1";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $user_id = intval($row['user_id']);
      $lastwinner = $row['username'];
      if ($board_config['lottery_status'] == "off") {
     } else {
      echo "<table border=\"0\" width=\"100%\" cellpadding=\"3\">\n";
      echo "<tr><td align=\"left\" nowrap>"._LOTTERY."</td>\n";
      echo "<td align=\"left\">"._LOTTERYDESC." "._LOTTERYLASTWIN."<b><a href=\"mo dules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\">$lastwinner</b></td>\n"
          ."<td align=\"center\">$pool</td></tr></table>\n";
     } //End last lottery winner



Remove the space in the last link.



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: Lottery Show in Points Mod
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
Sweet, thanks a lot! Did some very minor tweaking and here's what I came up with:

Language
define("_LOTTERYDESC","Buy tickets to win the jackpot in the <a href=\"modules.php?name=Forums&file=lottery\">Lottery</a>.   ");
define("_LOTTERYLASTWIN","Our Latest Winner: ");


Full index.php file
<?php
/********************************************************/
/* Site Points Addon Module for PHP-Nuke                */
/* Version 1.0.0         5-03-04                        */
/* By: Telli (telli@codezwiz.com)                       */
/* http://codezwiz.com/                                 */
/* Copyright © 2000-2004 by Codezwiz                    */
/********************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}
//Configure how many users you want to show!
$toshow = 25;
//"1"=Right blocks on "0"=right blocks off!
$index = 1;
//Thats all you need to configure!

/*********************************************************/
/* Index                                                 */
/*********************************************************/
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
      global $bgcolor2, $prefix, $db, $sitename, $admin, $user;
      OpenTable();
      echo "<center><br><font class=\"title\"><b>$sitename "._POINTSSYSTEM."</b></font><br><br>\n";
      CloseTable();
      getusrinfo($user);
      cookiedecode($user);
      $uname = $cookie[1];
      if (is_user($user)) {
      echo "<br>\n";
      Opentable();
      $numpoints = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_users WHERE username='$uname'"));
      $npoints = intval($numpoints['points']);
      echo "<table border=\"0\" cellpadding=\"5\" width=\"100%\"><tr>\n";
      echo "<td width=\"100%\" align=\"center\"><b>"._PWELCOME." $uname "._PCURRENT." $npoints "._PPOINTS."!</b></td>";
      echo "</tr></table><br>\n";
      Closetable();
    }
      echo "<br>\n";
     
            OpenTable();
              //Start lottery functions
    $sql = "SELECT * FROM ".$prefix."_bbconfig";
       $result = $db->sql_query($sql);
       while ( $row = $db->sql_fetchrow($result) )
       {
       $board_config[$row['config_name']] = $row['config_value'];
       }
       if ( !($result = $db->sql_query("select * from ".$prefix."_lottery")) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Drawing User!'); }
       if (mysql_num_rows($result) > 0) {
       //get prizepool
       $lotteryentries = mysql_num_rows($result);
       $poola = $lotteryentries * $board_config['lottery_cost'];
       $pool = $board_config['lottery_base'] + $poola;
       $pool = number_format($pool, 0);
       $pname = $board_config['points_name'];
     } //End lottery functions

      //Start last lottery winner
      $sql = "SELECT t1.*, t2.username
            FROM ".$prefix."_lottery_history as t1, ".$prefix."_users as t2
            WHERE t2.user_id = t1.user_id
            ORDER BY time DESC
            LIMIT 0, 1";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $user_id = intval($row['user_id']);
      $lastwinner = $row['username'];
      if ($board_config['lottery_status'] == "off") {
     } else {
      echo "<table border=\"0\" width=\"100%\" cellpadding=\"3\">\n";
      echo "<tr><td align=\"left\" nowrap><b>"._LOTTERY."</b></td>\n";
      echo "<td align=\"center\">"._LOTTERYDESC." "._LOTTERYLASTWIN."<b><a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\">$lastwinner</b></td>\n"
          ."<td align=\"right\"><b>Points Won: $pool</b></td></tr></table>\n";
     } //End last lottery winner
      CloseTable();
      echo "<br>";
     
     
      Opentable();
      echo "<br>\n"
       ."<table border=\"0\" width=\"100%\" cellpadding=\"3\"><tr>\n"
       ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._NAME."</b></td>\n"
       ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._DESCRIPTION."</b></td>\n"
       ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._POINTS."</b></td></tr>\n";

     
      //Start Points output
      $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='1'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS01."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC01."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='2'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS02."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC02."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";     
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='3'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS03."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC03."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='4'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS04."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC04."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='5'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS05."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC05."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='6'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS06."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC06."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='7'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<td align=\"left\" nowrap>&nbsp;"._POINTS07."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC07."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='8'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS08."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC08."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }   
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='9'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
      echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS09."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC09."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='10'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS10."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC10."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='11'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS11."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC11."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='12'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS12."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC12."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='13'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {     
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS13."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC13."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='14'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS14."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC14."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='15'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS15."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC15."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='16'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS16."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC16."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='17'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS17."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC17."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='18'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS18."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC18."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='19'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS19."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC19."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='20'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS20."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC20."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }
   $row = $db->sql_fetchrow($db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='21'"));
      $npoints = intval($row['points']);
      if ($npoints == 0) {
     } else {
   echo "<tr><td align=\"left\" nowrap>&nbsp;"._POINTS21."&nbsp;</td>\n"
       ."<td align=\"left\">"._DESC21."</td>\n"
          ."<td align=\"center\">$npoints</td></tr>\n";
     }

   echo "</table>\n";
      //End Points output
      CloseTable();
     
      OpenTable();
      echo "<center><font class=\"title\"><b>$sitename "._PTOP." $toshow "._PHOLDERS."</b></font><br>";
      CloseTable();
      echo "<br>";
     
      OpenTable();
      /* Top Points */
      $sql = "SELECT * FROM ".$prefix."_users ORDER BY points DESC limit 0,$toshow";
      $tpoints = $db->sql_query($sql);
      echo "<table border=\"0\" cellpadding=\"2\" width=\"100%\"><tr>\n";
       echo "<td width=\"25%\" bgcolor=\"$bgcolor2\" align=\"center\"><b>"._PUSERNAME."</b></td>\n";
      echo "<td width=\"25%\" bgcolor=\"$bgcolor2\" align=\"center\"><b>"._PUSERRANK."</b></td>\n";
      echo "<td width=\"25%\" bgcolor=\"$bgcolor2\" align=\"center\"><b>"._PUSERPOINTS."</b></td>\n";   
      echo "<td width=\"25%\" bgcolor=\"$bgcolor2\" align=\"center\"><b>"._PUSERPOSTS."</a></td>\n";
      echo "</tr></table>\n";
      echo "<table border=\"0\" cellpadding=\"2\" width=\"100%\">\n";
      $cz=1;
      while ($row = $db->sql_fetchrow($tpoints)) {
   $user_id = $row['user_id'];
   $username = $row['username'];
   $user_posts = $row['user_posts'];
      $points = $row['points'];
      $sql = "SELECT * FROM $prefix"._users." WHERE user_id='$user_id'";
      $rank_result =  $db->sql_query($sql);
      $rank_result2 = $db->sql_fetchrow($rank_result);
      $rankinfo = $rank_result2[username];
      $sql = "SELECT * FROM ".$prefix."_bbranks ORDER BY rank_special, rank_min";
      if ( !($result = $db->sql_query($sql)) )
     {
      message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
}
      $ranksrow = array();
      while ( $row = $db->sql_fetchrow($result) )
     {
      $ranksrow[] = $row;
}
      $db->sql_freeresult($result);
      $poster_rank = '';
      if ($rank_result2['user_id'] == ANONYMOUS )
     {
}
      else if ( $rank_result2['user_rank'] )
{
      for($j = 0; $j < count($ranksrow); $j++)
     {
      if ( $rank_result2['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
     {
      $ranktitle = $ranksrow[$j]['rank_title'];
                 }
             }
         }
       else
       {
       for($j = 0; $j < count($ranksrow); $j++)
         {
       if ( $rank_result2['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
             {
       $ranktitle = $ranksrow[$j]['rank_title'];
                 }
             }
         }
 
       if ($cz < 10) $czi = "0$cz";
       else $czi = $cz;
        echo "<tr><td width=\"25%\" align=\"left\">$czi.&nbsp;<a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\"><b>$username</a></b></td>\n";
       echo "<td width=\"25%\" align=\"left\"><b>$ranktitle</b></td>\n";
       echo "<td width=\"25%\" align=\"center\"><b>$points</b></td>\n";   
       echo "<td width=\"25%\" align=\"center\"><a href=\"modules.php?name=Forums&file=search&search_author=$username\">$user_posts</a></td></tr>\n";
           
       $cz++;
       
    }
       echo "</table><br>\n";
CloseTable();
      if (is_admin($admin)) {
      echo "<br>\n";
      OpenTable(); 
      echo "<center>"._ADMINLINK."</center>";
      CloseTable();
     }
   include("footer.php");

?>


Check it out at [ Register or login to view links on this board. ]

Thanks again Telli! icon_rolleyes.gif



_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum