ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-windows
php-windows
Re: [PHP-WIN] Problem with removable media
by tg-php other posts by this author
Nov 15 2006 1:47PM messages near this date
[PHP-WIN] Problem with removable media | [PHP-WIN] SQL Server 2005
Styve,

Here's a block of code I borrowed (see comment block) and use to scan active drives on a Win
dows PC.  It uses the is_dir() which may still not work for you, but maybe it does it differ
ently than you did.

Also, I believe you can access Windows API functions that can return the status of a drive w
ithout throwing an error box.  http://www.php.net/manual/en/ref.w32api.php  (I think this is
 your best bet, just means diving into the Windows API and figuring out how to get the two t
o work together properly)

Another thing to look at is maybe head over to http://www.winbinder.com and see if any of th
ose guys have found a good way to do it, since not only is it PHP + Windows specific, but no
n-web browser based coding that deals directly with Windows API issues.

And lastly, may be able to get info via COM interface with some other Windows apps, but I th
ink this is a long shot and kind of sloppy:  http://us2.php.net/com

Let us know if you find a good solution.  Good luck!

-TG

#########################################################################
#
# The following code as found at: http://www.php.net/manual/en/ref.filesystem.php
# Simple enough code, but m2pc saved me some typing so I'm giving credit here. Thanks for sh
aring your code!
#
# The only things I changed were some formatting and....
#
#########################################################################

  # m2pc (at) hotmail.com
  # 07-Oct-2004 12:18
  # After searching all over the place to find a function to do what I wanted, I wrote the f
ollowing:

  /*
  **  Returns an array of valid drives on the system (a:, b:, etc.)
  */
  function getSystemDrives() {

   // Initialize
   $aResult = Array ();

   // Loop from A-Z and try opening the root dir
   for ($letter = 'A'; $letter <= 'Z'; $letter ++) {
     if (is_dir ($letter . ":"))
       $aResult [] = $letter . ":";
   }

   // Return results
   return ($aResult);
  }

  # It simply returns an array of valid drives as seen from the server (A:, B:, etc.).  This
 obviously is targeted to Win32 installations only.
#########################################################################


= = = Original message = = =

Hi folks,

I have a PHP apps who let people listen to audio files. Those files are
mainly store on the hard drive of the server. But the old ones are
backed up on DVD and purged from the hard drive. I need to offer the
possibility to listen to the files on the DVD. So, I have tried
different things:

I have added an alias in Apache configuration pointing to the DVD drive.
The problem is that as Apache validate is configuration on start, if
there is no disk in the drive, the service refuses to start. This
implied that we ALWAYS had to have a disk in the drive in case of a
server reboot. This solution was not retained after the test phase.

One of the other things that I have tried is to add an entry in the PHP
application configuration so we can configure the path to the DVD drive.
With that approach, Apache is always able to start correctly. I can also
listen to the files stores on the DVD. The problem comes when I try to
access to file on the DVD drive and there is no disk in the drive. All
the functions I have tried (file_exists(), is_dir(), etc.) make a
message box to appear on the server (There is no disk in the drive,
blabla... Abort, Retry, Ignore). This cause the session on the client to
hangs (waiting for the message box on the server). I have not been able
to suppress or prevent the message box to appear.

Writing a restoration application, is out of scope (not enough time left
on the project). Moving to PHP5 to have better error handling to.

Have any of you had to work on accessing removable media?

My server conf.:
Windows 2000 server SP4
Apache 2.0.50
PHP 4.3.3
The DVD drive is DVD-RAM

Best regards.

Styve



___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Styve Couture
tg-php

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved