Move uploaded file before parse?

Requests, feedback, and general discussion about WoWRoster
DO NOT post topics about WoWRoster AddOns here!

Move uploaded file before parse?

Postby HalloranElder » Thu Aug 24, 2006 1:22 pm

Hi all,

I'm having serious issues with my hosting where I've got WowRoster located. The open_basedir restriction is in effect and the upload directory isn't located there so as a result it can't parse the uploaded file.

We've tried to get it working my adding the upload directory to the open_basedir, but it doesn't seem to be working and we have no idea why.

While I would love to get it working correctly as it should, it doesn't look like it's going to happen any time soon, and I want this working, so it looks like I'm going to have to edit the code.

I've done a bit of investigating, and it looks like all I have to do is use the move_uploaded_file function to move the file from the upload directory to a directory allowed by the open_basedir, and everything should work. The problem is that I don't know enough about php to be confident about doing it without some help.

From the looks of it, I would need to put the function call somewhere in the following section of update.php, probably immediatly before the foreach:

Code: Select all
// Loop through each posted file
foreach ($_FILES as $filefield => $file)
{
    
$filename $file['tmp_name'];
    
$filemode '';

    if( 
substr_count($file['name'],'.gz') > )    // If the file is gzipped
        
$filemode 'gz';

    foreach( 
$filefields as $acceptedfile )    // Itterate through all the possible filefields
    
{
        if( 
$acceptedfile == $file['name'] || $acceptedfile.'.gz' == $file['name'] )
        {
            
// Filefield is 1 of the kind we accept.
            
if( $roster_conf['authenticated_user'] )
            {
                
$uploadFound true;

                
// Parse the lua file into a php array that we can use
                
$data ParseLuaFile$filename $filemode );

                
// If pvp data is there, assign it to $uploadData['PvpLogData']
                
if( isset($data['PurgeLogData']) )
                {
                    
$uploadData['PvpLogData'] = $data;
                }

                
// If CP data is there, assign it to $uploadData['myProfile']
                
if( isset($data['myProfile']) )
                {
                    
$uploadData['myProfile'] = $data['myProfile'];
                }
                
// Clear the $data variable
                
unset($data);
            }
        }
    }
    @
unlink($filename);    // Done with the file, we don't need it anymore


Is this right? Anything else you can think of?

All help greatly appreciated. I'm getting really frustrated about not being able to get this working.
Image
User avatar
HalloranElder
WR.net Apprentice
WR.net Apprentice
 
Posts: 6
Joined: Tue Aug 08, 2006 9:32 am
Location: Brisbane, Australia

Re: Move uploaded file before parse?

Postby HalloranElder » Thu Aug 31, 2006 10:08 am

After getting no response, I eventually tried to myself, and sort of got it working.

I modified the code to the following:
Code: Select all
// Loop through each posted file
foreach ($_FILES as $filefield => $file)
{
    
$uploaddir 'uploadtmp/';
    
$uploadfile $uploaddir basename($file['name']);
    
    
move_uploaded_file($file['tmp_name'], $uploadfile);
    
    
$filename $uploadfile;
    
$filemode '';

    if( 
substr_count($file['name'],'.gz') > )    // If the file is gzipped
        
$filemode 'gz';

    foreach( 
$filefields as $acceptedfile )    // Itterate through all the possible filefields
    
{
 


While it does seem to upload the files and parse them correctly (meaning that I finally have information in the Roster database) I still get the following error:

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(C:\uploadtemp\php5C6E.tmp) is not within the allowed path(s): (D:\Hosting\randomevent\random\wowcoldblood.com) in D:\Hosting\randomevent\random\wowcoldblood.com\www\roster\admin\update.php on line 75


As I said, it seems to have parsed everything correctly, so I'm not sure what's going on. Any help?
Image
User avatar
HalloranElder
WR.net Apprentice
WR.net Apprentice
 
Posts: 6
Joined: Tue Aug 08, 2006 9:32 am
Location: Brisbane, Australia

Move uploaded file before parse?

Postby zanix » Thu Aug 31, 2006 11:39 am

You need to include php's upload temp folder for open_basedir in php.ini
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Move uploaded file before parse?

Postby HalloranElder » Thu Aug 31, 2006 4:19 pm

zanix wrote:You need to include php's upload temp folder for open_basedir in php.ini


I'm aware of that. However, I don't have control over the php configuration, and the person who does doesn't seem to be able to get it working properly, hence my modification to the code. According to the php documentation, the move_uploaded_file function will move the uploaded file from anywhere (including locations not in the open_basedir) into a location that is in the open_basedir.
Image
User avatar
HalloranElder
WR.net Apprentice
WR.net Apprentice
 
Posts: 6
Joined: Tue Aug 08, 2006 9:32 am
Location: Brisbane, Australia

Move uploaded file before parse?

Postby zanix » Fri Sep 01, 2006 4:20 am

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(C:\uploadtemp\php5C6E.tmp) is not within the allowed path(s): (D:\Hosting\randomevent\random\wowcoldblood.com) in D:\Hosting\randomevent\random\wowcoldblood.com\www\roster\admin\update.php on line 75

Well aparently, open_basedir isn't letting move_uploaded_file() work either
Last edited by zanix on Fri Sep 01, 2006 4:21 am, edited 1 time in total.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US


Return to General Support & Feedback

Who is online

Users browsing this forum: No registered users and 1 guest

cron