|
<?php
error_reporting(7);
require('global.php');
require('_header.php');
$version = "1.3.2";
$action = $_REQUEST['action'];
$game = $_REQUEST['game'];
$score = $_REQUEST['score'];
// little debug thing
if (isset($showallheaders)) {
$headers = getallheaders();
foreach ($headers as $name => $content)
echo "headers[$name] = $content<br>\n";
}
// get userid/username from session data
$username = $user_name;
$userid = $user_id;
// access check (here for future expansion)
switch($action) {
case "arcade":
case "scoreboard":
case "topscoreboard":
break;
case "play":
case "gameover":
break;
default:
// if no action specified, go to arcade page
$action = "arcade";
break;
}
// admin access check (here for future expansion)
switch($bbuserinfo[usergroupid]) {
// Dodo
// case 6:
case 1:
//
$allaccess = true;
break;
default:
$allacess = false;
break;
}
// game checks
if (!isset($game) and ($action != "arcade")) {
echo "vbProArcade Error: No game specified (todo: put something pretty here later)";
exit();
}
// Infos holen über das Spiel was gespielt werden soll
$arcadeinfo = $db_zugriff->query_first("SELECT * FROM bb".$n."_arcadeconfig");
if($userdata[userposts] >=$arcadeinfo[anzahlposts]){
$anzahl = $arcadeinfo[anzahl];
$gamesperpage = $arcadeinfo[gamesshowpage];
$gameinfo = $db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if (!arcadeinfo) {
echo "vbProArcade Error: Arcade configuration information could not be retrieved from the database.";
exit();
}
if (!gameinfo) {
echo "vbProArcade Error: Invalid game name specified (todo: put something pretty here later)";
exit();
}
// get the score value
eval("\$thescore = \"$gameinfo[scorevar]\";");
// get the path to the arcade games
$gamepath = $arcadeinfo[path];
// get the title of the game
$gametitle = $gameinfo[title];
// reduce a url to everything following the "http://something.com"
function reduceurl($php_path) {
if (strpos($php_path,"http://") === false) {
$test = strpos($php_path,"/");
if ($test === false)
$zv = "";
else
$zv = substr($php_path,$test);
} else {
$xv = explode("//",$php_path);
$yv = $xv[count($xv)-1];
$test = strpos($yv,"/");
if ($test === false)
$zv = "";
else
$zv = substr($yv,$test);
}
return $zv;
}
// we are playing
if ($action == "play") {
if($user_id){
$gh = guthaben_user_summe($user_id,'profile');
$gh_summe = $gh[0] + $gh[1] + $gh[2] + $gh[3] + $gh[5] - $gh[4];
// Angemeldeter User möchte spielen... kostet das was und wenn ja wieviel?
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if ($row['preisonoff']=='1') { // Muss er fürs Zocken abdrücken?
// JA
$kaufpreis = $row['preis']; // Da ham wir's!
// Dodo
$do = $_GET['do'];
//
// User wird auf den Kaufpreis aufmerksam gemacht.
if(!$do=="send") { //Einverständnis wurde noch nicht erteilt, Hinweisen!
// Wir übergeben die ausgewählten Parameter an das Bestätigungsformular
// kosten_bestaetigen.htm
// Daran kann man Kaufpreis, Aktion bei Bestätigung und Aktion bei Ablehnung
// übergeben.
$mygame=$game; // Welches Spiel soll bestätigt werden?
$originalaktion = "proarcade.php?action=play&do=send&sid=$session&game=$mygame"; //Welche Aktion sollte stattfinden?
$ablehnungsaktion= "proarcade.php"; // Wo geht es hin, wenn der User nicht zahlen möchte?
eval("dooutput(\"".gettemplate("kosten_bestaetigen")."\");"); // Wir zeigen das Bestätigungsformular.
exit(); // Und verlassen diese Schleife. Jetzt muss der User was tun.
}
else { // User hat was getan: Einverständnis wurde gegeben
// Nur Bares ist Wahres... Hat der Mann Kredit?
if($gh_summe<$row['preis']) {
// Weniger Guthaben, als das Game kostet? Sorry Mann! Geh und verdien es Dir.
eval("dooutput(\"".gettemplate('keingeld_error')."\");");
exit(); // Looser-Meldung anzeigen und ab dafür....
}
else { // OK, Zaster ist da, dann buchen wir mal ab.
// Und schreiben den neuen Kontostand zurück in die user_table
// Dodo
// $kaufpreis2 =$kaufpreis/2;
$kaufpreis2 =$kaufpreis;
// Dodo
$db_zugriff->query("UPDATE bb".$n."_user_table SET minus=minus+'$kaufpreis2' WHERE userid='".$userdata['userid']."'");
// Von hier an geht es ganz normal weiter, als ob er umsonst spielt...
}
}
}
// Nee, Er kann umsonst spielen...
$highscore_q = $db_zugriff->query("SELECT * FROM bb".$n."_arcade WHERE game='$game' ORDER BY score DESC LIMIT 1");
$highscore_a = $db_zugriff->fetch_array($highscore_q);
$highscore = $highscore_a[score];
// get the information to call the game with
$vpa_filename = $gamepath . $gameinfo[filename];
$vpa_width = $gameinfo[width];
$vpa_height = $gameinfo[height];
$vpa_codebase = $gameinfo[codebase];
$oparams = addslashes($gameinfo[objectparam]);
$eparams = addslashes($gameinfo[embedparam]);
//Dodo
// get the relative URL of the forum
// $vpa_bburl = reduceurl($php_path);
$vpa_bburl = "$php_path";
//
// query string and param lists must be eval'd since it contains PHP vars
eval("\$vpa_qstring = \"$gameinfo[querystring]\";");
eval("\$vpa_oparams = \"$oparams\";");
eval("\$vpa_eparams = \"$eparams\";");
// get the code to call the game, then send the page
eval ("\$threadbit .= \"".gettemplate("vbproarcade_playgame_flashcode")."\";");
eval("dooutput(\"".gettemplate("vbproarcade_playgame")."\");");
}
else header("LOCATION: misc.php?action=access_error&boardid=$boardid&styleid=$styleid$session");
}
// register a new score
if ($action == "gameover") {
// Counter
$gamecounter = $gameinfo[gamecounter];
$gamecounter++;
$gamecounterupdate = $db_zugriff->query("UPDATE bb".$n."_arcadegames SET gamecounter='$gamecounter' WHERE name='$game'");
// --- Highscore User
if ($arcadeinfo[scoresave]==1){
$Namescore = $db_zugriff->query("SELECT max(score) as maxscore FROM bb".$n."_arcade WHERE game='$game' AND userid ='$userid'");
$Namescore_a = $db_zugriff->fetch_array($Namescore);
$NameHighscore = $Namescore_a[maxscore];
}else{
$NameHighscore = 0;
}
// --- Score ende
if (($thescore != 0)AND($thescore>$NameHighscore)) {
// --- score speichern
// fetch and store date as DD-MM-YYYY and time as HH:MM:SS
if (!$currYear) { $currYear = date("Y"); }
if (!$currMonth) { $currMonth = date("n"); }
if (!$currDay) { $currDay = date("j"); }
if (!$currTime) { $currTime = date("H:i:s"); }
$currDate = $currYear . "-" . sprintf("%02d", $currMonth) . "-" . $currDay;
$score_update = $db_zugriff->query("INSERT INTO bb".$n."_arcade (game,date,time,userid,username,score)
VALUES ('$game','$currDate','$currTime','$userid','$username','$thescore')");
$newscoreid = mysql_insert_id();
$newscorequery = $db_zugriff->query("SELECT scoreid,score FROM bb".$n."_arcade WHERE game='$game' ORDER BY score DESC");
$position = 0;
$foundscore = 0;
while (($newscoreloop=$db_zugriff->fetch_array($newscorequery)) && ($foundscore == 0)) {
$thisid = $newscoreloop['scoreid'];
$position++;
if ($newscoreid==$thisid) {
$foundscore = 1;
}
}
// we have a new champion!
if ($position == 1) {
$champupdate = $db_zugriff->query("UPDATE bb".$n."_arcadegames SET championid='$userid' WHERE name='$gameinfo[name]'");
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if ($row['topbonusonoff']=='1') {
$topbonus=$row['topbonus'];
// Und schreiben den neuen Kontostand zurück in die user_table.
$db_zugriff->query("UPDATE bb".$n."_user_table SET plus=plus+'$topbonus' WHERE userid='".$userdata['userid']."'");
$zusatz=$topbonus;
$zeichen=$gh_waehrung;
}
}
if($position == 2) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['placebonusonoff']=='1') {
$placebonus=$row['placebonus'];
$db_zugriff->query("UPDATE bb".$n."_user_table SET plus=plus+'$placebonus' WHERE userid='".$userdata['userid']."'");
$zusatz=$placebonus;
$zeichen=$gh_waehrung;
}
}
if($position == 3) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['placebonusonoff']=='1') {
$placebonus=$row['placebonus'];
$db_zugriff->query("UPDATE bb".$n."_user_table SET plus=plus+'$placebonus' WHERE userid='".$userdata['userid']."'");
$zusatz=$placebonus;
$zeichen=$gh_waehrung;
}
}
if($position == 4) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['bonusonoff']=='1') {
$bonus=$row['bonus'];
$db_zugriff->query("UPDATE bb".$n."_user_table SET plus=plus+'$bonus' WHERE userid='".$userdata['userid']."'");
$zusatz=$bonus;
$zeichen=$gh_waehrung;
}
}
if($position == 5) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['bonusonoff']=='1') {
$bonus=$row['bonus'];
$db_zugriff->query("UPDATE bb".$n."_user_table SET plus=plus+'$bonus' WHERE userid='".$userdata['userid']."'");
$zusatz=$bonus;
$zeichen=$gh_waehrung;
}
}
if($position >=6) {
$zusatz="leider nichts";
$zeichen="";
}
if($position >=1) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['topbonusonoff']=='0') {
$zusatz="leider nichts";
$zeichen="";
}
}
if($position >=1) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['placebonusonoff']=='0') {
$zusatz="leider nichts";
$zeichen="";
}
}
if($position >=1) {
$row=$db_zugriff->query_first("SELECT * FROM bb".$n."_arcadegames WHERE name='$game'");
if($row['bonusonoff']=='0') {
$zusatz="leider nichts";
$zeichen="";
}
}
// set up vars for leader_bit template
$lb_userid = $userid;
$lb_username = $username;
$lb_score = number_format($thescore);
$lb_position = number_format($position);
// make date/time look good
$lb_date = date("d.m Y", strtotime($currDate));
$lb_time = date("H:i ", strtotime($currTime));
//$suffix = suffixlogic($position,1);
$position = $position.".";
$position = number_format($position);
eval("\$lb_comment = \"".gettemplate("vbproarcade_gameover_comment")."\";");
eval("\$scorebit .= \"".gettemplate("vbproarcade_scorebit")."\";");
eval("dooutput(\"".gettemplate('vbproarcade_gameover')."\");");
// --- ende score speichern
} else {
// score of zero; just go to the scoreboard
$subaction = "";
$action = "scoreboard";
}
}
// display the scoreboard
if ($action == "scoreboard") {
// here we are adding a comment
if ($subaction=="addcomment") {
// comment is left blank
if ($comment == "") {
$comment = "kein Kommentar";
}
$comment = addslashes($comment);
$comment_insert = $db_zugriff->query("UPDATE bb".$n."_arcade SET comment='$comment' WHERE scoreid='$newscoreid' AND userid='$user_id'");
}
// find out how many scores we have in the database for this game
$scorecount_q = $db_zugriff->query_first("SELECT COUNT(*) AS scorecount FROM bb".$n."_arcade WHERE game='$game' AND score > 0");
$scoreboard_q = $db_zugriff->query("SELECT * FROM bb".$n."_arcade WHERE game='$game' ORDER BY score DESC LIMIT 0, $anzahl");
while ($sb_loop=$db_zugriff->fetch_array($scoreboard_q)) {
// rotate background colors for scoreboard
if (($counter++ % 2) != 0)
$backcolor="{firstaltcolor}";
else
$backcolor = "{secondaltcolor}";
// set up vars for templates to grab
$lb_userid = $sb_loop[userid];
$lb_username = $sb_loop[username];
$lb_score = number_format($sb_loop[score]);
$lb_comment = $sb_loop[comment];
// make date/time look good
$pre_date = $sb_loop[date];
$pre_time = $sb_loop[time];
$lb_date = date("d.m Y", strtotime($pre_date));
$lb_time = date("H:i ", strtotime($pre_time));
// increase position by one
$position++;
// display king icon instead of "1" if king icon is turned on
if (($arcadeinfo[usekingicon] == 1) and ($position == 1))
$lb_position = "<img src=\"$arcadeinfo[kingiconname]\"><br>";
else
$lb_position = number_format($position);
eval ("\$scorebit .= \"".gettemplate("vbproarcade_scorebit")."\";");
}
eval("dooutput(\"".gettemplate("vbproarcade_scoreboard")."\");");
}
// display the top score board
if ($action == "topscoreboard") {
// get the count
$scorecount_q = $db_zugriff->query("SELECT DISTINCT username FROM bb".$n."_arcade WHERE game='$game'");
$scorecount = mysql_num_rows($scorecount_q);
// get the average
$average_q = $db_zugriff->query("SELECT game,username,max(score) as maxscore
FROM bb".$n."_arcade
WHERE game='$game'
GROUP BY username");
while ($avgloop = $db_zugriff->fetch_array($average_q))
$average += $avgloop['maxscore'];
if ($scorecount > 0)
$average = number_format(floor($average/$scorecount));
else
$average = 0;
// get the data
$topscoreboard_q = $db_zugriff->query("SELECT game,userid,username,date,time,comment,max(score) as maxscore
FROM bb".$n."_arcade
WHERE game='$game'
GROUP BY username
ORDER BY maxscore DESC");
while ($tsb_loop=$db_zugriff->fetch_array($topscoreboard_q)) {
// rotate background colors for scoreboard
if (($counter++ % 2) != 0)
$backcolor="{firstaltcolor}";
else
$backcolor = "{secondaltcolor}";
// set up vars for templates to grab
$topscoreboard_n = $db_zugriff->query_first("SELECT comment
FROM bb".$n."_arcade
WHERE score='$tsb_loop[maxscore]' AND game='$game'");
$lb_userid = $tsb_loop[userid];
$lb_username = $tsb_loop[username];
$lb_score = number_format($tsb_loop[maxscore]);
$lb_comment = $topscoreboard_n[comment];
// make date/time look good
$pre_date = $tsb_loop[date];
$pre_time = $tsb_loop[time];
$lb_date = date("d.m Y", strtotime($pre_date));
$lb_time = date("H:i ", strtotime($pre_time));
// increase position by one
$position++;
// display king icon instead of "1" if king icon is turned on
if (($arcadeinfo[usekingicon] == 1) and ($position == 1))
$lb_position = "<img src=\"$arcadeinfo[kingiconname]\"><br>";
else
$lb_position = $position;
eval("\$scorebit .= \"".gettemplate("vbproarcade_scorebit")."\";");
}
eval("dooutput(\"".gettemplate('vbproarcade_topscoreboard')."\");");
}
// the main arcade page
if ($action == "arcade") {
// get games info
// ###### Seitennavigation ######
// find out how many games we have in the database
$gamecount_q = $db_zugriff->query_first("SELECT COUNT(*) AS gamecount FROM bb".$n."_arcadegames WHERE active=1");
// figure out the correct # of pages
$gamenumpages = $gamecount_q[gamecount] / $gamesperpage;
$gamenumpages = ceil($gamenumpages);
// if no argument is passed in, or pagenum is out of range, go to page 1
if (!isset($gamepagenumber) or ($gamepagenumber < 1) or ($gamepagenumber > $gamenumpages))
$gamepagenumber = 1;
if ($gamenumpages > 1){
// create the pagenavigation
$gamepagenav ="Seiten(".$gamenumpages."): ";
for($g=1;$g<=$gamenumpages;$g++){
if($g == $gamenumpages) $spaceholder = "";
else $spaceholder = ", ";
if($g == $gamepagenumber) $gamepagenav .= "[".$g."]".$spaceholder;
else $gamepagenav .= "<a href=\"proarcade.php?action=arcade&gamepagenumber=".$g."&game=\">".$g."</a>
".$spaceholder;
}
//$gamepagenav .= "</b></font>";
}
// get the page navigation going
// start at the correct position
$gameposition = ($gamepagenumber-1) * $gamesperpage;
// ########### ende Seitennavigationn ############
Dieser Beitrag wurde 1 mal editiert, zum letzten Mal von DirtyJay: 14.12.2007 19:26.
|
|