php-windows Digest 19 May 2009 02:55:27 -0000 Issue 3625
Topics (messages 29337 through 29340):
Excel OLE Automation using COM: file access problem
29337 by: Faubry, Samuel
29339 by: Richard Quadling
29340 by: Faubry, Samuel
Re: Debug PHP , Write Every Action (and not just errors debug related) into a
file
29338 by: Richard Quadling
Administrivia:
To subscribe to the digest, e-mail:
php-windows-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-windows-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-wind...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hi,
I am interfacing PHP and Excel to build a web-based reporting tool. I am
running IIS6.0 with PHP 5.2.5 on Windows Server 2003, with Office 2003
installed.
For testing purpose, I wrote a script that just connects to Excel, opens a
workbook, saves it under another name and closes Excel:
$if_path = 'C:\if_test.xls';
$of_path = 'C:\of_test.xls';
echo date('H:i:s') . " Launch Excel application \n";
$excelApp = new COM("Excel.Application") or die("Cannot create an Excel
object");
echo date('H:i:s') . " Loaded Excel, version {$excelApp->Version}\n";
echo date('H:i:s') . " Open workbook at path $if_path\n";
$excelApp->Workbooks->Open($if_path, 2);
echo date('H:i:s') . " Save changes to $of_path\n";
$excelApp->Workbooks[1]->SaveAs($of_path);
echo date('H:i:s') . " Close Excel\n";
$excelApp->Quit();
When I open the page in Internet Explorer, if I put
"http://localhost/test.php", everything works fine, but if I put
"http://my_server_name.domain.int/test.php", the script is blocked when trying
to open the file, which means I can't access the script elsewhere than on the
server.
By "blocked", I mean no error is shown, but it doesn't react, and the excel.exe
task keeps running and keeps the file locked.
My guess is that Excel is run with different permissions in the second case, so
it cannot access the file, but it might be completely something else...
Does someone have any experience in that matter ?
Thank you very much !
--- End Message ---
--- Begin Message ---
2009/5/18 Faubry, Samuel <samuel.fau...@parexel.com>:
> Hi,
>
> I am interfacing PHP and Excel to build a web-based reporting tool. I am
> running IIS6.0 with PHP 5.2.5 on Windows Server 2003, with Office 2003
> installed.
>
> For testing purpose, I wrote a script that just connects to Excel, opens a
> workbook, saves it under another name and closes Excel:
>
> $if_path = 'C:\if_test.xls';
> $of_path = 'C:\of_test.xls';
>
> echo date('H:i:s') . " Launch Excel application \n";
> $excelApp = new COM("Excel.Application") or die("Cannot create an Excel
> object");
> echo date('H:i:s') . " Loaded Excel, version {$excelApp->Version}\n";
>
> echo date('H:i:s') . " Open workbook at path $if_path\n";
> $excelApp->Workbooks->Open($if_path, 2);
>
> echo date('H:i:s') . " Save changes to $of_path\n";
> $excelApp->Workbooks[1]->SaveAs($of_path);
>
> echo date('H:i:s') . " Close Excel\n";
> $excelApp->Quit();
>
> When I open the page in Internet Explorer, if I put
> "http://localhost/test.php", everything works fine, but if I put
> "http://my_server_name.domain.int/test.php", the script is blocked when
> trying to open the file, which means I can't access the script elsewhere than
> on the server.
>
> By "blocked", I mean no error is shown, but it doesn't react, and the
> excel.exe task keeps running and keeps the file locked.
>
> My guess is that Excel is run with different permissions in the second case,
> so it cannot access the file, but it might be completely something else...
>
> Does someone have any experience in that matter ?
>
> Thank you very much !
>
>
If it is permissions, TEMPORARILY, allow IIS to interact with the
desktop. Hopefully you can RDP to the server as the console and see
what error message pops up (if any).
As PHP and excel run on the server, you will need to see the server
for any errors that can be displayed in this regard.
I don't think you'll be able to do this on server 2008 as the
"console" is no longer displayed (session 0 is purely for internal use
only - services and the like - and no display is allowed).
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--- End Message ---
--- Begin Message ---
> From: Richard Quadling
> 2009/5/18 Faubry, Samuel <samuel.fau...@parexel.com>:
> > Hi,
> >
> > I am interfacing PHP and Excel to build a web-based
> reporting tool. I am running IIS6.0 with PHP 5.2.5 on Windows
> Server 2003, with Office 2003 installed.
> >
> > For testing purpose, I wrote a script that just connects to
> Excel, opens a workbook, saves it under another name and closes Excel:
> >
> > $if_path = 'C:\if_test.xls';
> > $of_path = 'C:\of_test.xls';
> >
> > echo date('H:i:s') . " Launch Excel application \n";
> > $excelApp = new COM("Excel.Application") or die("Cannot
> create an Excel object");
> > echo date('H:i:s') . " Loaded Excel, version
> {$excelApp->Version}\n";
> >
> > echo date('H:i:s') . " Open workbook at path $if_path\n";
> > $excelApp->Workbooks->Open($if_path, 2);
> >
> > echo date('H:i:s') . " Save changes to $of_path\n";
> > $excelApp->Workbooks[1]->SaveAs($of_path);
> >
> > echo date('H:i:s') . " Close Excel\n";
> > $excelApp->Quit();
> >
> > When I open the page in Internet Explorer, if I put
> "http://localhost/test.php", everything works fine, but if I
> put "http://my_server_name.domain.int/test.php", the script
> is blocked when trying to open the file, which means I can't
> access the script elsewhere than on the server.
> >
> > By "blocked", I mean no error is shown, but it doesn't
> react, and the excel.exe task keeps running and keeps the file locked.
> >
> > My guess is that Excel is run with different permissions in
> the second case, so it cannot access the file, but it might
> be completely something else...
> >
> > Does someone have any experience in that matter ?
> >
> > Thank you very much !
> >
> >
>
> If it is permissions, TEMPORARILY, allow IIS to interact with the
> desktop. Hopefully you can RDP to the server as the console and see
> what error message pops up (if any).
>
> As PHP and excel run on the server, you will need to see the server
> for any errors that can be displayed in this regard.
>
> I don't think you'll be able to do this on server 2008 as the
> "console" is no longer displayed (session 0 is purely for internal use
> only - services and the like - and no display is allowed).
>
>
> --
> -----
> Richard Quadling
> Zend Certified Engineer :
> http://zend.com/zce.php?c=ZEND002498&r=213474731
> "Standing on the shoulders of some very clever giants!"
>
Hi, thanks for your reply, Richard.
I RDP'd to the server console, but no error pops up. I allowed IIS to
interact with the desktop, but I didn't change anything.
I might have found the problem: the file I am trying to open has
external links. With a "normal" file it works fine whatever way I run
the script.
That's why I used the second argument (UpdateLinks) in the Open call
documented here (2 means "Never update links for this workbook on
opening"):
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.w
orkbooks.open(office.11).aspx
Apparently, the argument I passed (2 of PHP type integer) is invalid.
Let me explain why I think so:
In the following, I am running everything from
http://localhost/test.php, which allows user interaction.
If I put $excelApp->Visible = 0 and use 2 as the UpdateLinks argument to
Open, everything runs fine without any interaction with the user.
If I put $excelApp->Visible = 1 and use 2 as the UpdateLinks argument to
Open, Excel shows up and tells me the links could not be updated, which
means it tried to update it, which is NOT the expected behaviour!
The values 1, 2 and 3 all give the same result, which is contradictory
with the documentation (1 is "ask", 2 is "do not update" and 3 is "do
update").
If I put 0, Excel shows up and closes without any interaction, but 0 is
not an authorised value according to the documentation.
Any other value crashes the script.
If I don't specify this argument, Excel shows up and asks me if I want
to update, which is the expected behaviour.
According to the documentation, this UpdateLinks argument is an Object,
maybe that's where the problem lies? If so, how can I create the object
to be passed as an argument to Open?
By the way, just out of curiosity, I tried to use the value 0 and run
the script from a client computer, but it is still blocked in the way
described above.
Thanks for your help !
--- End Message ---
--- Begin Message ---
2009/5/18 Louis Solomon <lo...@steelbytes.com>:
> you could use error_log() with __LINE__ __FILE__ right before each call to
> mail() to track the usage. Yes this does mean searching and editing a lot of
> files, but it will get you an answer (or more accurately it will show you
> what is not causing it. As it may not be php's mail func contracy to what
> the email headers show, as they could be faked).
>
> Ps if you want to write a wrapper func then use debug_backtrace() to identify
> the caller instead of __LINE__ __FILE__
>
> Louis Solomon
> www.SteelBytes.com
>
>
> -----Original Message-----
> From: onemancrew [mailto:i...@wserv.co.il]
> Sent: Saturday, 16 May 2009 8:20 PM
> To: php-wind...@lists.php.net
> Subject: Re: [PHP-WIN] Debug PHP , Write Every Action (and not just errors
> debug related) into a file
>
> Hi Again
>
> I am the server administrator.
>
> some details about the server:
>
> OS: Windows Server 2003
> PHP Version: PHP 4.4.6 (cgi-fcgi) (built: Feb 28 2007 21:35:46)
> MailServer Application: MailEnable (works under Windows OS)
>
> How do I know that the source of the problem is PHP ?
> Because I have investigated the email header and I have found that the
> emails have been created through PHP.
> It's 200% that the spam emails have been created through PHP code.
>
> The Mail() function is enable. Also I provide mail relay only to requests
> which comes from localhost (127.0.0.1)
> What does it means ?
> it means that if a php script try to create new email envelop and in the
> script the mail server which is defined is 127.0.0.1 or localhost then the
> php script will be able to create the email envelop. Also in such case no
> authentication is required.
>
> The relay option for 127.0.0.1 or localhost is defined in the Email Server
> Application (MailEnable).
> And I must use such setting because I have php applications which don't make
> any authentication through the email server.
>
> Under this server I have alots of web sites.
> So I can't start checking each IIS log file on daily basis.
>
> I have enabled the error php debug file. but it is only log unsuccessful php
> actions.
> So this log file doesn't provide me information regarding success mail()
> function operation.
> And because of that I can't track after the source of the PHP code which
> create those emails envelop.
>
> What I need is the following (because I don't find any better solution):
> I must have the capability to track any php action into a file.
> I need to have the capability to track down each action that php.exe is
> doing in relevant of mail() function.
>
> I did some investigation and couldn't find internal feature inside php.exe
> to log any action that it's doing (not only errors).
>
> Regarding the additional_parameters and the vhost-unique key.
> I think that I can't implement such feature while PHP is working under
> Windows OS and While the Email Server Application is MailEnable.
> I think that such feature is eligible and working only when the Email Server
> Application is SendMail.
> Because MailEnable doesn't support special Key processing.
>
> Any Suggestion ?
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
An option (you may or may not want to take) is to upgrade to a later
release of PHP (would have to be 5.3 which is still a dev release) and
then you could use the mail.log option to record any mail being sent
using the mail() function.
This does not log the use of using sockets (or any other technique) to
send email.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--- End Message ---