Common.php after upgrade to 2.0.9 problem with other file

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Common.php after upgrade to 2.0.9 problem with other file
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
I installed the 2.0.9 upgrade and then the next fix that was released to common.php Everything works great except one thing. I had created a file to automatically install arcade game but now it stopped working. Does anyone have any ideas?

This the code that is causing the conflict. I know this because when I remove this code the file works fine.

function unset_vars(&$var)
{
  while (list($var_name, $null) = @each($var))
  {
    if ( ! ( $var_name == 'phpbb_root_path' || $var_name == 'no_page_header' || $var_name == 'phpEx' || $var_name == 'admin' || $var_name == 'user' || $var_name == 'name' ) )
    {
      unset($GLOBALS[$var_name]);
    }
  }
  return;
}


$ini_val = (@phpversion() >= '4.0.0') ? 'ini_get' : 'get_cfg_var';

// Unset globally registered vars - PHP5 ... hhmmm
if (@$ini_val('register_globals') == '1' || strtolower(@$ini_val('register_globals')) == 'on')
{
$var_prefix = 'HTTP';
$var_suffix = '_VARS';

$test = array('_GET', '_POST', '_SERVER', '_COOKIE', '_ENV');

foreach ($test as $var)
{
if (is_array(${$var_prefix . $var . $var_suffix}))
{
unset_vars(${$var_prefix . $var . $var_suffix});
}

if (is_array(${$var}))
{
unset_vars(${$var});
}
}

if (is_array(${'_FILES'}))
{
unset_vars(${'_FILES'});
}

if (is_array(${'HTTP_POST_FILES'}))
{
unset_vars(${'HTTP_POST_FILES'});
}
}


This is the installer file that will not work now.

<?php
/************************************************************************/
/* V2 Arcade Game Installer  */
/* ================================ */
/* */
/* Copyright (c) 2004 by JRSweets */
/* http://jeffrusso.net/ */
/* */
/* ALL GAMES ARE COPYRIGHTED BY THEIR OWNERS*/
/* */
/* */
/* 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 */
/************************************************************************/

global $prefix;

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}

require("modules/Forums/nukebb.php");
define('IN_PHPBB', true);
$phpbb_root_path = 'modules/Forums/';   
include($phpbb_root_path .'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include('includes/functions_selects.php');

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX, $nukeuser);
init_userprefs($userdata);
//
// End session management
//

include("includes/page_header.php");

//EDIT VARIABLES BELOW THIS LINE
//Enter the name of the game below.
//Use a \ before all single quotes
$game_name = '';

//Enter the flash file name below.
$game_swf = '';

//Enter the picture of the game below.
$game_pic = '';

//Enter a short description of the game below.
//Use a \ before all single quotes
$game_desc = '';

//Enter the name of the scoring variable below.
$game_scorevar = '';

//Enter the game type below.
$game_type = '';

//Enter the game width below.
$game_width = '';

//Enter the game height below.
$game_height = '';
//DO NOT EDIT ANYTHING ELSE BELOW THIS LINE

if($mode == "install")
   {
         $arcade_catid = $HTTP_POST_VARS['cat_type'];

                    $sql = "SELECT MAX(game_order) AS max_order
            FROM " . GAMES_TABLE;
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Impossible to obtain the last sequence number of the table plays", "", __LINE__, __FILE__, $sql);
         }
         $row = $db->sql_fetchrow($result);

         $max_order = $row['max_order'];
         $next_order = $max_order + 10;

         $sql = "INSERT INTO " . GAMES_TABLE . " ( game_order, game_pic, game_desc, game_highscore, game_highdate, game_highuser, game_name, game_swf, game_width, game_height, game_scorevar, game_type, arcade_catid ) " .
            "VALUES ($next_order, '$game_pic', '" . str_replace("'", "\'", $game_desc) . "', 0, 0, 0, '" . str_replace("'", "\''", $game_name) . "', '$game_swf', '$game_width', '$game_height', '$game_scorevar','$game_type','$arcade_catid')";            
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't insert row in games table", "", __LINE__, __FILE__, $sql);
         }

         $sql = "UPDATE " . ARCADE_CATEGORIES_TABLE . " SET arcade_nbelmt = arcade_nbelmt + 1 WHERE arcade_catid = $arcade_catid";            
         if( !$db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't update categories table", "", __LINE__, __FILE__, $sql);
         }

         
         message_die(GENERAL_MESSAGE, "The game of $game_name has been successfully installed. Make sure this file is deleted from your server.  Enjoy!!");

   }


$link   = "install_game";   
   

echo "<table align ='center' width='75%' border='0' cellpadding='0' cellspacing='1' class='bodyline'>";

echo "<tr><th class='row4' colspan='2'><span class='thTop'><b>V2 Arcade Game Installer - $game_name</b></span></th> </tr>";
echo "<tr><td align='center' class='row2'><b>Game Description:</b> $game_desc</td></tr>";
echo "<tr><td align='center' class='row2'><b>Game Type:</b> $game_type</td></tr>";
echo "<tr><td align='center' class='row2'><b>Score Variable:</b> $game_scorevar</td></tr>";
$install = append_sid("$link?mode=install");
echo "<form method='post' name='install' action='$install'>";   
echo "<tr><td align='center' class='row2'>Select category and click install.</td></tr>";
echo "<tr>";
echo "<td align='center' class='row2'>";
echo "<select name='cat_type' class='post'>";


      $sql = "SELECT arcade_cattitle, arcade_catid FROM " . ARCADE_CATEGORIES_TABLE . " ORDER BY arcade_cattitle ASC";
      if( !($result = $db->sql_query($sql)) )
         {
         message_die(GENERAL_ERROR, "Error retrieving categories", '', __LINE__, __FILE__, $sql);
         }

      while ( $row = $db->sql_fetchrow($result))
         {
          echo "<option value='" . $row['arcade_catid'] . "' >" . $row['arcade_cattitle'] . "</option>\n";

         }
echo "</select>";
echo "</td></tr>";
echo "<tr><td align='center' class='row2'><input type='submit' name='submit' value='Install' class='mainoption' /></td></tr>";
echo "</form>";
echo "</table>";
echo "<br />";

//
// Generate the page end
//


include("includes/page_tail.php");

?>


I think the value for mode is not getting passed to the file. When you try to use it, the page just refreshes and $mode is never equal to install. Please help.

Thanks in advance.


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,475
   
You only run this install to install games right? Meaning you dont leave it on your server unless your installing a game?

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}


Remove that and see what happens.



_________________
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   
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
Correct, it is only on the server when installing a game.

Telli, I removed it and it didn't work. Its like the when I try to pass $mode whose value should be install it doesn't do it anymore. When you click install the it still just refreshes the part where you select the category.

The install section is never reached anymore.



Back to top Reply with quote
#4   re: Common.php after upgrade to 2.0.9 problem with other fil
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 

   if (is_array(${$var_prefix . $var . $var_suffix}))
      {
         unset_vars(${$var_prefix . $var . $var_suffix});
         @reset(${$var_prefix . $var . $var_suffix});
      }


If that code is commented out of common.php then it works fine. Is there a problem commenting out that code? If so, what do I have to change in the install file to fix this?


Back to top Reply with quote
#5   
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
The install file was missing a
$mode = $HTTP_GET_VARS['mode'];
Once that was put in place everything worked fine. Mighty_Y at portedmods figured it out.


Back to top Reply with quote
#6   re: Common.php after upgrade to 2.0.9 problem with other fil
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,475
   
LMAO! I thought about it at work and found that was the way to fix it. The vars are unset by the new added code meaning the defines don't pass that point. Your simply reestabilishing the var.

$mode = $HTTP_GET_VARS['mode'];


Is what I added to some other mods that wernt working dunno why I didnt remember that when i posted. Nice to see you troubleshot that by yourself your learning alot. icon_smile.gif



_________________
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
#7   
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
I found out were the problem was coming from but Mighty_Y actually came up with the fix. As always thanks for your help. I wasn't aware of this, now I am. icon_biggrin.gif



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