View Single Post
  #1633  
Old 10-18-2003, 07:12 PM
futureal futureal is offline
 
Join Date: Feb 2002
Location: Del Mar, CA, USA
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Pseudomizer: Thanks again for figuring out the upload bug in the Admin CP. I worked with it a bit and discovered what the exact problem was.

In some versions of Apache/PHP, variable names are automatically created from forms. So for example, the input file "championicon" would turn into "$championicon_name" and "$championicon_data" automatically when it's passed through the headers into the next page.

So for some combinations of OS/Apache/PHP, this wouldn't happen, and the variables would not get inserted correctly into the database. The key then is to use the $HTTP_POST_FILES array for everything, rather than relying on PHP to do the dirty work.

The vpaupload() function already does this for the data portion, but the name was being mishandled. So the code now looks like this:

PHP Code:
    // only process the files if changes were made
    
if (is_array($HTTP_POST_FILES)) {

      
$thumbnail_name$HTTP_POST_FILES[thumbnail]['name'];
      
$championicon_name$HTTP_POST_FILES[championicon]['name'];

      if (
$thumbnail_name != "")
        
$thumbdata vpaupload("thumbnail");
      else
        
$thumbdata "";

      if (
$championicon_name != "")
        
$championdata vpaupload("championicon");
      else
        
$championdata "";

    } else {

      
$thumbdata "";
      
$championdata "";
    }

    
// make sure we have a valid hash offset
    
if ($hashoffset 31)
      
$hashoffset $hashoffset 31;
    else if (
$hashoffset 0)
      
$hashoffset 0;

    
$updatearcade "UPDATE arcadegames
                     SET name='
$name', title='$title', description='$desc', filename='$filename', hashoffset='$hashoffset',
                         "
.iif(($championdata != "") || ($deletechampicon == 1),"championpicname='$championicon_name', championpicdata='$championdata',","")."
                         "
.iif(($thumbdata != "") || ($deletethumb == 1),"thumbnailname='$thumbnail_name', thumbnaildata='$thumbdata',","")."
                         active='
$active', scorevar='$scorevar', gamecode='$gamecode',championactive='$championactive',championtext='$championtext',championcolor='$championcolor'
                     WHERE gameid='
$gameid'";

    
$DB_site->query($updatearcade); 
This fix (and appropriate credit) is given in Beta 2.1.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01039 seconds
  • Memory Usage 1,795KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete