AW: [PHP-WIN] Double Click file to have it open in Windows Explorer
| From: | (Sven Schnitzke) | Date: | Wed, 14 May 2003 12:19:58 +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-19931@lists.php.net to get a copy of this message | ||
Afterthought, adressing the spaces problem:
Why even bother with HTML/Browser in the first step anyway ?
Let's have IE_exec.php in the following manner:
<?php
$path_to_browser = "C:\WINDOWS\IEXPLORE.EXE";
// or anything else appropriate; eventually add options too
// here you might need a lookup if you have virtual hosts
$root_as_seen_from_web = 'htdocs/';
$server_name = 'localhost/'; // e.g.; maybe not the only one
if (!isset($argv[1])) {
exit("No path specified.");
} else {
$path = $argv[1];
}
$path = str_replace("\\", "/", $path);
$path = str_replace("//", "/", $path);
// here you might need to associate another anchor if webname and fs-name are related otherwise
// very comfortable would be scanning apaches conf file ... (howto get knowledge using IIS, PWS,
...?)
$pos = strpos($path, $root_as_seen_from_web);
$pos += (strlen($root_as_seen_from_web));
system("$path_to_browser http://$server_name$root_as_seen_from_web"
. substr($path, $pos));
?>
Then launch it using
PATH_TO_PHP-CLI.EXE\php-cli.exe "PATH_TO_IE_exec.php\IE_exec.php" "%1"
in the execute field of folder options - file extensions - new action. Set up as many flavors as you
are using browsers NS_exec.php, OP_exec.php. ...
Then you have all of them at the right click of any .PHP ( and .HTML also!) file that is within
reach of a (virtual) server on your machine.
To add even more style you can set up a .PIF file specifying execution in minimized console window.
Happy hacking!
--
Sven
> -----Ursprüngliche Nachricht-----
> Von: Sven Schnitzke [SMTP:Sven.Schnitzke@t-online.de]
> Gesendet am: Mittwoch, 14. Mai 2003 11:14
> An: '[PHP-WIN]'
> Betreff: AW: [PHP-WIN] Double Click file to have it open in Windows Explorer
>
> 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 "http://localhost/".substr($path,
$pos);?>';
> > </script>
> > </head>
> > <body>
> > You probably won't ever read this...
> > </body>
> > </html>
> >
> > The last thing you gotta do is define $yourroot. So if your docRoot is
"c:\apache\somecrap\" make it $yourroot='somecrap/'
> > it is a slash not a backslash mind you.
> >
> > let me know if this was any help or if it doesn't work
> > diggn
> >