Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Pub
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating Protocol for PHP

    This is probably an extremely stupid question to put here, but I am just toying about with Windows and PHP.

    I can manage to execute PHP from its own protocol, however I cannot return a stream back to the browser...

    PHP Code:
    <a href="php://phpinfo();" title="PHP">phpinfo();</a
    or in the browser as php://phpinfo();

    Now you must be thinking wtf, lol.

    Introduction...

    Registering an Application to a URL Protocol

    To enable an application to handle a particular URL protocol, you must add a new key, with the appropriate keys and values, to the registry in HKEY_CLASSES_ROOT.

    The new registry key must match the protocol scheme that is being added. For instance, to add the protocol note:, the key added to HKEY_CLASSES_ROOT should be note. Under this new key, the Default string value should be the name of the new protocol, and the URLProtocol string value should contain either protocol-specific information or an empty string. Also under the new key, a DefaultIcon key and a shell key should be added. The Default string value under the DefaultIcon key must be the file name to use as an icon for this new URL protocol. Under the shell key, a key using a verb (such as open) should be added. A command key and a DDEEXEC key can be added under the key using a verb. The values under the command and DDEEXEC keys are used to call the application.

    Code:
    [HKEY_CLASSES_ROOT\php]
    @="\"URL: php Protocol\""
    "URL Protocol"=""
    [HKEY_CLASSES_ROOT\php\shell]
    [HKEY_CLASSES_ROOT\php\shell\open]
    [HKEY_CLASSES_ROOT\php\shell\open\command]
    @="php.exe -r %"
    Problem: Using php.exe -r %1, passes everything including the protocol, for example php://phpinfo(); /
    Now whilst, I don’t think I can use PHP directly, I have tried an alternative method by using Jscript (WSH) as an intermediary and executing PHP. Now whilst I can manage to get a JScript echo (alert), I have been racking my brain for a way to actually, write/hook into the browser. It works exactly the same way as <a href=”java_script_:..”> works, so how can I actually, write to the browser from an external JScript via the PHP protocols call?

    I have tried a number of methods, to actually do this, however using the following doesn’t work…

    window.document.write
    WScript.StdOut.Write('test');

    There is one more method that I can think off, which is something along the lines of…. external …

    Any Ideas anyone? Not, that you probably all think i'm crazy now.

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,071
    Thanks
    11
    Thanked 96 Times in 94 Posts
    I don't think you can do what you are trying to do , e.g pipe the results of the PHP stream to your browser without rewriting IE etc

    the best you will get is to start an instance of PHP in which you can then parse $argv & do whatever (an interesting idea all on its own !) note that in later versions of PHP register_argv is disabled in the php.ini by default.

    all you can do (and its mostly pointless if you have a webserver running) is say create a deamon in PHP serving a given socket & then call that for output say <img src="http://localhost:6969" /> , its a nice way of running a background script when no server is available (PHP is the server here)

    I must say thanks BTW cos thats a great idea for another project I have , just gotta find out how to do the same in *NIX ...
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Pub
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by firepages
    I don't think you can do what you are trying to do , e.g pipe the results of the PHP stream to your browser without rewriting IE etc
    the best you will get is to start an instance of PHP in which you can then parse $argv & do whatever (an interesting idea all on its own !) note that in later versions of PHP register_argv is disabled in the php.ini by default.
    all you can do (and its mostly pointless if you have a webserver running) is say create a deamon in PHP serving a given socket & then call that for output say <img src="http://localhost:6969" /> , its a nice way of running a background script when no server is available (PHP is the server here)
    I must say thanks BTW cos thats a great idea for another project I have , just gotta find out how to do the same in *NIX ...
    I believe otherwise, the reason being is that I very much doubt JavaScript is built into iexplore directly here is why (%Systemroot%/system32/jscript.dll). JavaScript or JScript in Microsoft’s instance, works in exactly the same manner, for example using the address bar of a href attribute with ‘javascript:’ prefixed, works exactly the same.

    PHP would have to execute a predefined script, prior, to accepting the parameters from the PHP protocol, due to the fact that the entire string in the HTML attribute is parsed e.g. ‘php://phpinfo();’. So you essentially have to buffer and parse and eval the command, yuck!

    Hmmm, I think you are confusing what I am actually, referring too. I was actually, looking at embedding PHP on the client side browser, via registering the php protocol. Essentially, to see if it was possible, and the more I look into it the more I believe it is possible . Although an interface may be required, to hook php back into the current instance of the browser (HWND) and use com as an interface for the current window. As you know, we can execute applications via com, eg…
    PHP Code:
    <?php
      
    class IESink 
        var 
    $terminated false
        function 
    OnQuit() { $this->terminated true; } 
      } 
      
    $sink = new IESink
      
    $ie = new COM("InternetExplorer.Application"); 
      
    com_event_sink($ie$sink"DWebBrowserEvents2"); //IShellWindows
      
    $ie->Visible true;
      
    $ie->Navigate("http://www.php.net/"); 
      while( 
    $IE->Busy ) {
        
    sleep(1);
      }
      while (!
    $sink->terminated) { 
        
    com_message_pump(4000); 
      } 
    ?>

    Part of reasoning for this is due to a programming language called REBOL. Take a look at this... http://www.devx.com/webdev/Article/17120/1954?pf=true

    I had a quick search for you with regard to registering protocols on nix, however I don't think the docs I found were very relevent, more todo with network stacks. Anyway, fancy explaining a little about this project, as i'm not sure we had quite the same idea?

    Well, I couldn't see what you were refering to exactly, which confused me slightly.
    all you can do (and its mostly pointless if you have a webserver running) is say create a deamon in PHP serving a given socket & then call that for output say <img src="http://localhost:6969" /> , its a nice way of running a background script when no server is available (PHP is the server here)

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,071
    Thanks
    11
    Thanked 96 Times in 94 Posts
    I very much doubt JavaScript is built into iexplore directly
    nor do I , but don't confuse what is happening when you type javascript://blah into IE/moz with what happens when inside a webpage you use <sript src="" as there are 2 different things happening there altogether.

    I don't pretend to know how JavaScript is called within IE , but am pretty sure that it has nothing to do with the javascript protocol, actually Alex Vincent may have a better idea (from a Moz perspective) perhaps he will read this , I don't see that COM is relevant here either.

    for embedding PHP in any other compiled application you need to be looking at the php_embed.sapi , I know for instance you can compile PHP scripting into MySQL myphp , there are other talks on embedding in talks.php.net somewhere

    my project concerns an issue with launching php-gtk GUI's applications from within IE & Moz , currently links to executables require 3rd party tools to run onclick from within IE , nor can I find any workarounds for gecko, but the idea of <a href="php-gtk://app_to_run"> is a corker ! and appears to work , also from the command line as noted in the rebol link , so cheers for that !

    I do remember talk of <script src="php"></script> with the advent of the embed sapi though I have heard no more of it since.
    Last edited by firepages; 05-12-2004 at 07:50 AM.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Pub
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    We can only guess how it works, unless we actually find out , the reason I mentioned Com; although a v.nasty idea, was a way to dump the output into IE/Automate IE, from PHP.
    PHP Code:
      $ie->Navigate("http://www.php.net/");  
      while( 
    $IE->Busy ) { 
        
    sleep(1); 
      } 
      
    $ie->document->innerHTML=var_dump($this); 
    The reason for this is because my knowledge of C is zero (so embedding is out of the question, unless I did something in C#), whilst I was only toying with the notion, i'm glad it gave someone some inspiration.

    I beleive you will enjoy this too... [http://msdn.microsoft.com/library/de...sp?frame=true]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •