phpgroupware-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-users] VFS and M$ issues


From: Don Graver (dgraver)
Subject: [Phpgroupware-users] VFS and M$ issues
Date: Tue, 16 Dec 2003 14:52:46 -0000

I am hoping somone with VFS knowledge can help me out on this one...or
M$ knowledge.  First of all, I added the ability for users to attach
files to calendar events, so that other users can just click on the
attachment and the file displays/saves on their computer.  Everything
seems to work fine with updating the phpgw_vfs table, displaying the
links to the files themselves, even removing them.  However...
When a user on a Microsoft 2000 (haven't tested other versions) machine
clicks on the link and it tries to open an Excel file it fails with the
following error "Filename.xls cannot be accessed. The file may be
read-only or you may be trying to access a read-only location. Or, the
server document is stored on may not be responding.".  
If a user tries to open a .pdf file he just gets an image displayed on
the web browser.
If a user tries to open a Powerpoint file he gets "Powerpoint cannot
open the type of file represented by D:/...../Filename.ppt".  

.txt, .doc, .csv, and image files seem to work just fine with no
problems.

Now, I have tested to make sure that it is not just the way I stream the
file to the user by copying the files directly from there source
(RELATIVE_ROOT) to another web accessible spot on the server and tried
accessing them that way, but get the same errors.  I have even checked
to make sure that my attach_file function is not corrupting the data by
comparing the data string before and after to make sure they are equal.
To make things even more confusing, all my Linux boxes have absolutely
no problem opening up these files using OpenOffice...so I am at a
loss...and still hating M$.  Anyone else ever heard of this or seen
this??

The gory details:
All attached files have uog+rw permissions...with wwwrun as the owner
and nogroup as the group.
The machine is a Suse 8.2, and running mysql, with php4, and phpgw
0.9.14.512.

Here is what I do:
/calendar/inc/class.bocalendar.inc.php

     $this->attach_file('calendar',$tmp_event['id'],$tmp_file);

$tmp_file looks like this:
# Array: 
Name - BCS.xls
Type - application/excel
tmp_name - /tmp/phpaGAwre
Size  - 22528



And here is my vfs->attach_file function (copied and pasted so some
lines have an extra '\'):
                function attach_file($app,$id,$file,$comment='')
                {
                        if ($this->debug)
                        {
                                echo "<p>attach_file: app='$app',
id='$id', tmp_name='$file[tmp_name]', name='$file[name]',
size='$file[size]', type='$file[ty\
pe]', path='$file[path]', ip='$file[ip]', comment='$comment'</p>\n";
                        }
                        // create the root for attached files in
calendar, if it does not exists
                        if (!($this->vfs->file_exists(array(
                                                            'string'=>
$this->vfs_basedir,
 
'relatives'=>array(RELATIVE_ROOT)))))
                        {
                                $this->vfs->override_acl = 1;
                                $this->vfs->mkdir(array(
                                                        'string'=>
$this->vfs_basedir,
 
'relatives'=>array(RELATIVE_ROOT)));
                                $this->vfs->override_acl = 0;
                        }

                        $dir=$this->vfs_path($app);
                        if (!($this->vfs->file_exists(array(
                                                            'string'=>
$dir,
 
'relatives'=>array(RELATIVE_ROOT)))))
                        {
                                $this->vfs->override_acl = 1;
                                $this->vfs->mkdir(array(
                                                        'string'=> $dir,
 
'relatives'=>array(RELATIVE_ROOT)));
                                $this->vfs->override_acl = 0;
                        }
                        $dir=$this->vfs_path($app,$id);
                        if (!($this->vfs->file_exists(array(
                                                            'string'=>
$dir,
 
'relatives'=>array(RELATIVE_ROOT)))))
                        {
                                $this->vfs->override_acl = 1;
                                $this->vfs->mkdir(array(
                                                        'string'=> $dir,
 
'relatives'=>array(RELATIVE_ROOT)));
                                $this->vfs->override_acl = 0;
                        }
                        $fname =
$this->vfs_path($app,$id,$file['name']);
                        $tfname = '';
                        if (!empty($file['path']))
                        {
                                $file['path'] =
str_replace('\\\\','/',$file['path']);  // vfs uses only '/'
                                @reset($this->link_pathes);
                                while ((list($valid,$trans) =
@each($this->link_pathes)) && !$tfname)
                                {  // check case-insensitive for WIN
etc.
                                        $check = $valid[0] == '\\' ||
strstr(':',$valid) ? 'eregi' : 'ereg';
                                        $valid2 =
str_replace('\\','/',$valid);
                                        //echo "<p>attach_file:
ereg('".$this->send_file_ips[$valid]."',
'$file[ip]')=".ereg($this->send_file_ips[$valid],$fil\
e['ip'])."</p>\n";
                                        if
($check('^('.$valid2.')(.*)$',$file['path'],$parts) &&
 
ereg($this->send_file_ips[$valid],$file['ip']) &&     // right IP
 
$this->vfs->file_exists(array(
                                                          'string'=>
$trans.$parts[2],
 
'relatives'=>array(RELATIVE_NONE|VFS_REAL))))
                                        {
                                                $tfname =
$trans.$parts[2];
                                        }
                                        //echo "<p>attach_file:
full_fname='$file[path]', valid2='$valid2', trans='$trans',
check=$check, tfname='$tfname', pa\
rts=(x,'${parts[1]}','${parts[2]}')</p>\n";
                                }
                                if ($tfname &&
!$this->vfs->securitycheck(array( 'string'=> $tfname)))
                                {
                                        return False; //lang('Invalid
filename').': '.$tfname;
                                }
                        }
                        $this->vfs->override_acl = 1;
                        if ($tfname)    // file is local
                        {
 
$this->vfs->symlink($tfname,$fname,array(RELATIVE_NONE|VFS_REAL,RELATIVE
_ROOT));
                        }
                        else
                        {
                          $this->vfs->cp(array( 'from'=>
$file['tmp_name'],
                                                'to'=>$fname,
 
'relatives'=>array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT)));
                        }
                        $this->vfs->set_attributes (array(
                                                          'string'
=> $fname,
                                        'relatives'     => array
(RELATIVE_ROOT),
                                        'attributes'    => array
('mime_type' => $file['type'],
                                                 'comment' =>
stripslashes ($comment),
                                                                  'app'
=> $app)));
                        $this->vfs->override_acl = 0;

                        $link =
$this->info_attached($app,$id,$file['name']);
                        return is_array($link) ? $link['file_id'] :
False;
                }
-- Don Graver




reply via email to

[Prev in Thread] Current Thread [Next in Thread]