AW: [PHP-WIN] Double Click file to have it open in Windows Explorer
| From: | (Sven Schnitzke) | Date: | Wed, 14 May 2003 09:13:32 +0000 |
| Subject: | AW: [PHP-WIN] Double Click file to have it open in Windows Explorer | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-19929@lists.php.net to get a copy of this message | ||
Hi Malte,
this is kind of a fine idea you have. Let me suggest the following as execute.php:
<?php
if (!isset($_GET['path'])) {
exit("No path specified.");
} else {
$path = $_GET['path'];
}
$yourroot = "PHP/";
$path = str_replace("\\", "/", $path);
$path = str_replace("//", "/", $path);
$pos = strpos($path, $yourroot);
$pos += (strlen($yourroot));
header('Location: http://localhost/'.substr($path, $pos));
?>
There is one little caveat with your approach: it won't work with
pathnames containing spaces. This is not cured by double
quotes around the parameter because when starting it will
become $_GET['path'] and as such is not allowed to contain
spaces.
btw. you don't even have to fire up regedit for that: Explorer has
a menu entry (in german it's Ansicht - Ordneroptionen - Dateitypen,
should be "View - Folder options - File types" or so in english version)
that is good for adding any click action to any file type you want:
just sort out the file type (.PHP will usually not be listed if you don't
use an IDE that makes use of this feature).
So use button "New type" or "Edit" as appropriate. In the "New type"
case
fill in description (will go into the selection list of the "file types" dialog)
and MIME type (e.g. text/html).
In any case press the "New" button to add an action.
Put "Thru the web" into the action field and the launch command
>"C:\Programme\Internet Explorer\iexplore.exe" -nohome
>"http://localhost/execute.php?path=%1"
into the second. Here you can navigate to the appropriate folder. The
content of the first field will show up in the
pop up menu when right clicking a file with this extension. Don't select
"use DDE". Click Ok to get back to "Edit type" dialog.
You may add your favorite editor here too (and bulks of Browsers for
preview purposes and ...).
To specify the response to double clicking select the desired option in the
list and click the "Standard" button. The action will show up in bold.
If you have PHP-GTK.EXE at hand you can even associate the php logo to
php files: click "Other" next to the shown symbol and navigate to PHP-GTK.EXE
It contains a pure PHP logo. Select it and from that point on all .PHP files
will be associated with the logo. (Does anybody know of another source for
a PHP.ICO ?)
--
Sven
> -----Ursprüngliche Nachricht-----
> Von: malte [SMTP:der_diggen@gmx.net]
> Gesendet am: Mittwoch, 14. Mai 2003 01:17
> An: php-windows@lists.php.net
> Betreff: Re: [PHP-WIN] Double Click file to have it open in Windows Explorer
>
> I figured out a way to do what this guy (sorry, forgot the name) intended to do.
>
> Its a Registry, PHP, JavaScript Combination..
>
> first open regedit.exe and open the HKEY_CLASSES_ROOT tree
> search for .php and note the value of that key. (in my case Maguma_Studio.PHPFile)
>
> now search for search for that value in the HKEY_CLASSES_ROOT tree.
> When you found it, open it and the shell key underneath, create a new key
> and name it execute, assign a value to it like "open from webserver" this is what
you'll see in
> the context menu if you right click a php file
> in the execute key you just created, create a new key and name it command (this is important)
> assign something like this to it
>
> "C:\Programme\Internet Explorer\iexplore.exe" -nohome "http://localhost/execute.php?path=%1"
>
> the first parameter is your browser executable, i don't know what the second one does, but
it works though.
> The third is the file itself.
>
> What you gotta do now is create a file in you document root and name it execute.php
>
> then paste this code in it
>
> <html>
> <head>
> <title>Execute</title>
> <script language="JavaScript">
> <?
> $yourroot = "htdocs/";
> $path = $HTTP_GET_VARS['path'];
> $path = str_replace("\\", "/", $path);
> $path = str_replace("//", "/", $path);
> $pos = strpos($path, $yourroot);
> $pos += (strlen($yourroot));
> ?>document.location.href='<? echo