Ken7 Wrote:Will there be a fix for this that we can upload?
i dont know. i didn't write the mod. just tried to modify it myself (my first php attempt,and i think it worked)
anyway. this is what my
submit.php looks like right now....
<?php
/**
* Game Section for MyBB
* Copyright © 2006-2007 Online - Urbanus
*
* Website: http://www.Online-Urbanus.be
*
* Support in each language with a translation: http://www.Online-Urbanus.be/Forum
* English support: http://community.mybboard.net/showthread.php?tid=12413
*
* License: GNU/GPL v2
*
* Last modifed: 25/03/2007
*/
//Is this an old PHP version
if(!isset($_SERVER))
{
$_SERVER = $HTTP_SERVER_VARS;
}
//Is this a direct use
$test_file = strpos($_SERVER['PHP_SELF'], "/games/submit.php");
if($test_file !== false)
{
die("You don't have acces to this page.");
}
//Define MyBB
define("IN_MYBB", 1);
require_once "./global.php";
$plugins->run_hooks("games_submit_start");
//Variabels
$gid = intval($_COOKIE['mybb_games_gid']);
$name = addslashes($mybb->input['gname']);
$uid = intval($mybb->user['uid']);
$score = intval($mybb->input['gscore']);
//Is this correctly?
if(!intval($_COOKIE['mybb_games_gid']) || !intval($mybb->input['gscore']) || !isset($mybb->input['gname']))
{
if(intval($_COOKIE['mybb_games_gid']) || intval($mybb->input['gscore']) || isset($mybb->input['gname']))
{
if($mybb->input['gscore'] === 0)
{
redirect("games.php?action=scores&gid=".$gid, $lang->scoreis0);
}
else
{
error($lang->noinput, $lang->error);
}
}
else
{
error($lang->noinput, $lang->error);
}
}
else
{
//Information of the game
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games WHERE name='".$mybb->input['gname']."'");
$games_test = $db->num_rows($query);
//How many games with that file
if($games_test == 0)
{
error($lang->gamedoesntexist, $lang->error);
}
elseif($games_test == 1)
{
$game = $db->fetch_array($query);
}
else
{
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games WHERE name='".$mybb->input['gname']."' AND gid='".$_COOKIE['mybb_games_gid']."'");
$game = $db->fetch_array($query);
$game_test = $db->num_rows($query);
if($game_test == 0)
{
error($lang->gamedoesntexist, $lang->error);
}
}
$gid = $game['gid'];
$plugins->run_hooks("games_submit_pre");
//Strip ASC and DESC
if($game['score_type'] == DESC)
{
$score_type = "<";
}
if($game['score_type'] == ASC)
{
$score_type = ">";
}
//Is there all a score?
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE uid='".$uid."' AND gid='".$gid."' ORDER BY score ".$game['score_type']." LIMIT 0,1");
$score_test = $db->num_rows($query);
if($score_test == 1)
{
//Yes, Is the score higher then the old one?
$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE uid='".$uid."' AND gid='".$gid."' AND score".$score_type."'".$score."' ORDER BY score ".$game['score_type']." LIMIT 0,1");
$score_update_test = $db->num_rows($query2);
if($score_update_test == 1)
{
$update_score = array(
'gid' => intval($gid),
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'score' => intval($score),
'dateline' => time(),
'ip' => get_ip()
);
$db->update_query(TABLE_PREFIX."games_scores", $update_score, "gid='".$gid."' AND uid='".$uid."'");
$plugins->run_hooks("games_submit_update_score");
//Are you a champion?
$query3 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."'");
$champ_test = $db->num_rows($query3);
if($champ_test == 1)
{
$query4 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."' AND score".$score_type."'".$score."'");
$champ_update_test = $db->num_rows($query4);
if($champ_update_test == 1)
{
$update_champ = array(
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'score' => intval($score),
'dateline' => time()
);
$db->update_query(TABLE_PREFIX."games_champions", $update_champ, "gid='".$gid."'");
$plugins->run_hooks("games_submit_update_champ");
}
}
else
{
$insert_champ = array(
'gid' => intval($gid),
'title' => addslashes($game['title']),
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'score' => intval($score),
'dateline' => time()
);
$db->insert_query(TABLE_PREFIX."games_champions", $insert_champ);
$plugins->run_hooks("games_submit_insert_champ");
}
//repair champions///////////////////////////////////////////////
//Load the games
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games");
while($champs_games = $db->fetch_array($query))
{
//Load best score
$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE gid='".$champs_games['gid']."' ORDER BY score ".$champs_games['score_type']." LIMIT 0,1");
$champs_scores = $db->fetch_array($query2);
$champs_scores_test = $db->num_rows($query2);
//Set champ
if($champs_scores_test == 1)
{
$champs_array = array(
'uid' => intval($champs_scores['uid']),
'username' => addslashes($champs_scores['username']),
'score' => addslashes($champs_scores['score']),
'dateline' => addslashes($champs_scores['dateline']),
);
$db->update_query(TABLE_PREFIX."games_champions", $champs_array, "gid='".$champs_scores['gid']."'");
}
}
//cpredirect("games.php?".SID, $lang->repaired_champs);
//////////////////////////////////
redirect("games.php?action=newscore&gid=$gid", $lang->scoreadded);
}
else
{
redirect("games.php?action=scores&gid=$gid", $lang->scoredontadded);
}
}
else
{
//No, insert the score then.
$insert_score = array(
'sid' => NULL,
'gid' => intval($gid),
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'score' => intval($score),
'dateline' => time(),
'ip' => get_ip()
);
$db->insert_query(TABLE_PREFIX."games_scores", $insert_score);
$plugins->run_hooks("games_submit_insert_score");
//Are you a champion?
$query3 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."'");
$champ_test = $db->num_rows($query3);
if($champ_test == 1)
{
$query4 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_champions WHERE gid='".$gid."' AND score".$score_type."'".$score."'");
$champ_update_test = $db->num_rows($query4);
if($champ_update_test == 1)
{
$update_champ = array(
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'score' => intval($score),
'dateline' => time()
);
$db->update_query(TABLE_PREFIX."games_champions", $update_champ, "gid='".$gid."'");
$plugins->run_hooks("games_submit_update_champ");
}
}
else
{
$insert_champ = array(
'gid' => intval($gid),
'title' => addslashes($game['title']),
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'score' => intval($score),
'dateline' => time()
);
$db->insert_query(TABLE_PREFIX."games_champions", $insert_champ);
$plugins->run_hooks("games_submit_insert_champ");
}
//repair champions///////////////////////////////////////////////
//Load the games
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games");
while($champs_games = $db->fetch_array($query))
{
//Load best score
$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."games_scores WHERE gid='".$champs_games['gid']."' ORDER BY score ".$champs_games['score_type']." LIMIT 0,1");
$champs_scores = $db->fetch_array($query2);
$champs_scores_test = $db->num_rows($query2);
//Set champ
if($champs_scores_test == 1)
{
$champs_array = array(
'uid' => intval($champs_scores['uid']),
'username' => addslashes($champs_scores['username']),
'score' => addslashes($champs_scores['score']),
'dateline' => addslashes($champs_scores['dateline']),
);
$db->update_query(TABLE_PREFIX."games_champions", $champs_array, "gid='".$champs_scores['gid']."'");
}
}
//cpredirect("games.php?".SID, $lang->repaired_champs);
//////////////////////////////////
redirect("games.php?action=newscore&gid=$gid", $lang->scoreadded);
}
}
$plugins->run_hooks("games_submit_end");
?>
keep in mind that i am not familiar w/ php, but it seems to be working for now.
hope this helps.