SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 %"


    [/CODE]

    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. #2
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    New Jersey, USA
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew,

    Why not just change your executable definition:

    Instead of php.exe -r %1, try using php.exe <some script that strips the url> %1.

    The script would de-url-ize the %1 variable, then chain to the actual command/function.

    =Austin

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Austin_Hastings
    Andrew,

    Why not just change your executable definition:

    Instead of php.exe -r %1, try using php.exe <some script that strips the url> %1.

    The script would de-url-ize the %1 variable, then chain to the actual command/function.

    =Austin
    Thus the use of Jscript and WSH, I origionally used.


Bookmarks

Posting Permissions

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