Code:<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* pnFlashGames for PHPNUKE BLOCK */
/* Copyright (c) 2005 by Kent Patfield */
/* http://www.xbox-hq.com */
/* */
/* Note: If you need more than one flash games block, just copy this */
/* file with another name */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (eregi("block-FlashGames-Arcade.php",$_SERVER[PHP_SELF])) {
Header("Location: ../index.php");
die();
}
$usemarquee = 1;
$module_name = "Flash_Games";
global $prefix, $db, $dbi, $nukeurl;
// select random game code
$numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_flashgames_games"));
if ($numrows>1) {
$numrows = $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum = mt_rand(0, $numrows);
} else {
$bannum = 0;
}
$content .= "<table width=\"100%\" border=0><tr><td width=\"33%\" align=center>";
$content .= " <b><u>Random Game</u></b>:<Br><br><center>";
// Latest Games
$a = 1;
$result = sql_query("select gid, gname, gdescription, gimage, hits from ".$prefix."_flashgames_games LIMIT $bannum,1", $dbi);
while(list($gid, $gname, $gdescription, $gimage, $hits) = sql_fetch_row($result, $dbi)) {
$ggid = ereg_replace("_", " ", $gid);
$gname = ereg_replace("_", " ", $gname);
$gimage = $gimage;
$gdescription = ereg_replace("_", " ", $gdescription);
$ghits = ereg_replace("_", " ", $hits);
$content .= "<a href=\"modules.php?name=$module_name&func=play&gid=$gid\"><img src=\"modules/$module_name/images/screenshot/$gimage\" width=\"100\ height\"100\" border=0 alt=\"$gdescription\"></a><br><B>$gname</b><br><Br>";
$a++;
}
$content .= "<i>High Score set by</i>:<br><br>";
$result = sql_query("select gid, gamename, playername, playerscore, date from ".$prefix."_flashgames_hiscores WHERE gid=$ggid order by playerscore DESC limit 0,1", $dbi);
while(list($gid, $gamename, $playername, $playerscore, $date) = sql_fetch_row($result, $dbi)) {
$date = date("F j, Y",$date);
$content .= "<center><img src=\"modules/$module_name/images/stats/icon_award_gold.gif\"><b>$playername</b><br><i>$date</i><br>[Score: <b>$playerscore</b>]<br>";
}
$content .= "<br>This game has been played <b>$ghits</b> times.";
$content .= "</td><td width=\"33%\" align=center>";
$content .= " <b><u>Latest Games</u></b>:<br><br><center>";
// Latest Games
if ($usemarquee == 1) {
$content .= "<Marquee Behavior=\"Scroll\" Direction=\"up\" Height=\"240\" ScrollAmount=\"2\" ScrollDelay=\"100\" onMouseOver=\"this.stop()\" onMouseOut=\"this.start()\"><br>";
}
$a = 1;
$result = sql_query("select gid, gname, gdescription, gimage, hits from ".$prefix."_flashgames_games order by gid DESC limit 0,5", $dbi);
while(list($gid, $gname, $gdescription, $gimage, $hits) = sql_fetch_row($result, $dbi)) {
$gname = ereg_replace("_", " ", $gname);
$gimage = $gimage;
$gdescription = ereg_replace("_", " ", $gdescription);
$content .= "<center><a href=\"modules.php?name=$module_name&func=play&gid=$gid\"><img src=\"modules/$module_name/images/screenshot/$gimage\" width=\"100\ height\"100\" border=0 alt=\"$gdescription\"></a><br><b>$gname</b><br><Br><br>";
$a++;
}
$content .= "</td>";
$content .= "<td width=\"33%\" align=\"center\">";
// Most Popular Games
$content .= "<b><u>Most Popular Games</u></b>:<br><br>";
if ($usemarquee == 1) {
$content .= "<Marquee Behavior=\"Scroll\" Direction=\"up\" Height=\"240\" ScrollAmount=\"2\" ScrollDelay=\"100\" onMouseOver=\"this.stop()\" onMouseOut=\"this.start()\"><br><center>";
}
$a = 1;
$result = sql_query("select gid, gname, gscore, gratings, hits from ".$prefix."_flashgames_games order by hits DESC limit 0,10", $dbi);
while(list($gid, $gname, $gscore, $gratings, $hits) = sql_fetch_row($result, $dbi)) {
$gname = ereg_replace("_", " ", $gname);
$score = $gscore;
$ratings = $gratings;
if ($ratings != 0) {
$rate = substr($score / $ratings, 0, 4);
$r_image = round($rate);
if ($r_image == 1) {
$the_image = "<img src=\"images/articles/stars-1.gif\" border=\"0\" alt=\"$gamename "._FGAMES_1STAR."\">";
} elseif ($r_image == 2) {
$the_image = "<img src=\"images/articles/stars-2.gif\" border=\"0\" alt=\"$gamename "._FGAMES_2STAR."\">";
} elseif ($r_image == 3) {
$the_image = "<img src=\"images/articles/stars-3.gif\" border=\"0\" alt=\"$gamename "._FGAMES_3STAR."\">";
} elseif ($r_image == 4) {
$the_image = "<img src=\"images/articles/stars-4.gif\" border=\"0\" alt=\"$gamename "._FGAMES_4STAR."\">";
} elseif ($r_image == 5) {
$the_image = "<img src=\"images/articles/stars-5.gif\" border=\"0\" alt=\"$gamename "._FGAMES_5STAR."\"> ";
}
}
$content .= " $a- <a href=\"modules.php?name=$module_name&func=play&gid=$gid\">$gname</a><br> [Played: <b>$hits</b> times]<br>$the_image<br><br>";
$a++;
}
$content .= "</td>";
$content .= "</tr></table>";
$content .= "<br><center><b>5 Latest Hi-Scores</b></center><br>";
$content .= "<table width=\"100%\" border=0><tr><td width=\"20%\">";
$content .= "<i>Game</i></td><td width=\"20%\"><i>Username</i></td><td width=\"20%\"><i>Score</i></td><td width=\"20%\"><i>Date</i>";
$content .= "</td></tr></table>";
$content .= "<table width=\"100%\" border=0>";
$result = sql_query("select gid, gamename, playername, playerscore, date from ".$prefix."_flashgames_hiscores order by date DESC limit 0,5", $dbi);
while(list($gid, $gamename, $playername, $playerscore, $date) = sql_fetch_row($result, $dbi)) {
$gid = ereg_replace("_", " ", $gid);
$gamename = ereg_replace("_", " ", $gamename);
$date = ereg_replace("_", " ", $date);
$date = date("F j, Y",$date);
$playerscore = ereg_replace("_", " ", $playerscore);
$playername = ereg_replace("_", " ", $playername);
$content .= "<tr><td width=\"20%\"><a href=\"modules.php?name=$module_name&func=play&gid=$gid\">$gamename</a></td><td width=\"20%\"><img src=\"modules/$module_name/images/stats/icon_member.gif\"><b>$playername</b></td><td width=\"20%\">$playerscore</td><td width=\"20%\">$date</td></tr>";
}
$content .= "</table>";
$content .= "<br><center><b>Detailed Statistics</b></center><br>";
$content .= "<table width=\"100%\" border=0><tr>";
$result = sql_query("select gid, gname, hits from ".$prefix."_flashgames_games order by hits DESC limit 0,1", $dbi);
while(list($gid, $gname, $hits) = sql_fetch_row($result, $dbi)) {
$gid = ereg_replace("_", " ", $gid);
$gamename = ereg_replace("_", " ", $gname);
$ghits = ereg_replace("_", " ", $hits);
$content .= "<td width=\"50%\" align=\"center\">Most Popular: <a href=\"modules.php?name=$module_name&func=play&gid=$gid\">$gamename</a><br><i>with <b><a href=\"modules.php?name=$module_name&func=play&gid=$gid\">$ghits</a></b> plays</i></td>";
}
$result = sql_query("select gid, gname, hits from ".$prefix."_flashgames_games order by hits ASC limit 0,1", $dbi);
while(list($gid, $gname, $hits) = sql_fetch_row($result, $dbi)) {
$gid = ereg_replace("_", " ", $gid);
$gamename = ereg_replace("_", " ", $gname);
$ghits = ereg_replace("_", " ", $hits);
$content .= "<td width=\"50%\" align=\"center\">Least Popular: <a href=\"modules.php?name=$module_name&func=play&gid=$gid\">$gamename</a><br><i>with <b><a href=\"modules.php?name=$module_name&func=play&gid=$gid\">$ghits</a></b> plays</i></td>";
}
// Total Downloads
$result = sql_query("select gid, gname,hits from ".$prefix."_flashgames_games", $dbi);
while(list($gid, $gname, $hits) = sql_fetch_row($result, $dbi)) {
$a = 1;
$total_hits = $total_hits + $hits;
$a++;
}
$total_served = $total_hits;
$content .= "</tr></table>";
$content .= "<table width=\"100%\" border=0><tr><td width=\"33%\" align=\"center\">";
// Total Games in Database
$result = sql_query("select * from ".$prefix."_flashgames_games", $dbi);
$games = sql_num_rows($result, $dbi);
// Total comments in Database
$result = sql_query("select * from ".$prefix."_flashgames_comments", $dbi);
$comments = sql_num_rows($result, $dbi);
$result = sql_query("select * from ".$prefix."_flashgames_activeusers WHERE module='$module_name'", $dbi);
$activemembers = sql_num_rows($result, $dbi);
$content .="<a href=\"http://www.xbox-hq.com/html/modules.php?name=Flash_Games&refferer=$nukeurl\"><img src=\"modules/$module_name/images/powered/powered_xboxhq.gif\" border=0 alt=\"Xbox-Hq.Com - pnFlashGames module for PHPNUKE\"></a></td><td>";
$content .="<center><a href=\"modules.php?name=$module_name\">Browse Categories</a><br><Br>";
if ($activemembers >1){
$content .="<center><a href=\"modules.php?name=Flash_Games&func=ActiveGamers\"><B>$activemembers</b></a> <i>Active Gamer</i>";
}else{
$content .="<center><a href=\"modules.php?name=Flash_Games&func=ActiveGamers\"><B>$activemembers</b></a> <i>Active Gamers</i>";
}
// Games Available and Games Served
$content .= "<center>Games Available: <b>$games</b><br>Games Served: <B>$total_served</b><br>Comments Available:<B>$comments</b><br><br><a href=\"modules.php?name=$module_name&func=ViewAll\">View All Games</a></center>";
$content .="</td><td><a href=\"http://pnflashgames.com/linkback.php?type=phpnuke?refferer=$nukeurl\"><img src=\"modules/$module_name/images/powered/powered_pnflashgames.gif\" border=0></a></td></tr></table>";
// Show all Categories
$content .= "<Marquee Behavior=\"Scroll\" Direction=\"Left\" Height=\"10\" ScrollAmount=\"2\" ScrollDelay=\"100\" onMouseOver=\"this.stop()\" onMouseOut=\"this.start()\"><br>";
$content .= "";
$result = sql_query("select cid, cname, hits from ".$prefix."_flashgames_cat order by cid ASC", $dbi);
while(list($cid, $cname, $hits) = sql_fetch_row($result, $dbi)) {
$cid = ereg_replace("_", " ", $cid);
$cname = ereg_replace("_", " ", $cname);
$chits = ereg_replace("_", " ", $hits);
$content .= "<a href=\"modules.php?name=Flash_Games&func=view&cid=$cid\">$cname</a> - ";
}
$content .= "";
?>
|