NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
PHP/SRV Server: $_SERVER['PHP_SELF'] should contain protocol


Joined: 31 Jul 2005
Posts: 16
Reply with quote
Actual behaviour:
When the script
Code:
http://localhost:8084/file:/c:/kildekode/site-editor/src/main.php
is run on the SRV Server in PHPEd 4.6, $_SERVER['PHP_SELF'] reports
Code:
/c:/kildekode/site-editor/src/main.php
which is useless as a self-reference URL.

Expected behaviour:
The $_SERVER['PHP_SELF'] variable should contain the protocol:
Code:
/file:/c:/kildekode/site-editor/src/main.php


Possible solution:
Encode the protocol in a way so that the URL is a valid RFC URL.

Url-encoding it works only partially, and breaks inside the script if the parseurl function is used; i.e.:
Code:
http://localhost:8084/file%3A/c%3A/kildekode/site-editor/src/main.php
causes $_SERVER['PHP_SELF'] to become
Code:
/file:/c:/kildekode/site-editor/src/main.php
but parseurl gives the following parts:
Code:
scheme = '/file'
path = '/c:/kildekode/site-editor/src/main.php'
query = ''
which, when reassembled according to the URL RFC (1738, i think) gives the following URL, unintelligible to SRV (it fails with the error message "HTTP/404 The requested URL alias for /c:/kildekode/site-editor/src/main.php is not defined."):
Code:
/file:///c:/kildekode/site-editor/src/main.php

_________________
jorgen*fabeljet,com
View user's profileFind all posts by j0rg3nSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
Expected behaviour:
The $_SERVER['PHP_SELF'] variable should contain the protocol:


Why are you expecting protocol there?
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Clumsily put.


Joined: 31 Jul 2005
Posts: 16
Reply with quote
It was perhaps not very clearly formulated; while writing the post, I discovered that the core of the problem was not the lacking '/file:' part in PHP_SELF, but the fact that the URLs used by SRV are not valid URLs (according to the RFC mentioned in the first post), and thus cannot be pulled apart and put toghether using the standard PHP functions (parseurl, for instance).

So: My feature request is actually to make the SRV URLs valid in some way, by encoding the first part of the path in a way that doesn't contain ':', and that doesn't get decoded when passed to the PHP script: if the ':' is hidden in the URL but present within the PHP script, nothing is gained.

I should of course have written that the first time. Cool

_________________
jorgen*fabeljet,com
View user's profileFind all posts by j0rg3nSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
It's clear that SRV works with filenames instead of regular URLs. It's provided for simplicity. You don't need to change any setting and it will work for you out of the box. On the other hand, such "simplicity" may cause problems Smile when working with filenames/URLs and trying to aquire data from the them. There are two approaches that may get good results: a) avoid parsing URLs. Just create a "config" file that will have a setting with absolute directory for the project. All the rest files should know their location relative to the project root. b) Switch to Apache server.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Tha same problem


Joined: 05 Jan 2007
Posts: 1
Reply with quote
dmitri wrote:
It's clear that SRV works with filenames instead of regular URLs. It's provided for simplicity. You don't need to change any setting and it will work for you out of the box. On the other hand, such "simplicity" may cause problems Smile when working with filenames/URLs and trying to aquire data from the them. There are two approaches that may get good results: a) avoid parsing URLs. Just create a "config" file that will have a setting with absolute directory for the project. All the rest files should know their location relative to the project root. b) Switch to Apache server.


Hello dmitri, I have the same problem. I prefer the solution (a) but I didn't understand it. Could you explain please how should be look like the config file.
Thank you.
View user's profileFind all posts by SICStusSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
I think we'll follow this suggestion:
Quote:
Possible solution:
Encode the protocol in a way so that the URL is a valid RFC URL


The idea with config file is quite strightforward:
you can define site root directory and root URL in this file and calculate relative path and URLs if you need them using __FILE__, config file info and funcitons like dirname().

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Change CRV to apache


Joined: 27 Mar 2010
Posts: 5
Location: Armenia
Reply with quote
hi
I want to know how can I run my phped project with apache located in my local mashin?
If yes,please tell me how?
Thanks
View user's profileFind all posts by DavitSend private messageSend e-mail
PHP/SRV Server: $_SERVER['PHP_SELF'] should contain protocol
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic