Re: [PHP] Relative Url

2004-04-02 Thread Chris Thomas
What im trying to do is this.

I working on creating a poll script, and right now it consists of 3 main
files:
poll.php   - Which does the server-side processing
pollFunctions.php   - Which draws the poll and does some client side stuff
poll.css- stylesheet
These files reside in the /poll directory (for now)

pollFunctions.php is included in the file that wants the poll, which may
reside in any folder.
So what im trying to figure out is the relative url of where the
pollfunctions.php file resides.

--  Now that i think about it i could just include the stylesheet from the
calling file (ie index.php)

I probally should have thought of this a little more before i posted...oh
well

Chris

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Chris Thomas [EMAIL PROTECTED] wrote:
  Is there anyway that i can get a url relative to my server for a
  script that is being run??

 $relative_url = '/';

 That's a relative URL to your document root. What are you wanting,
 exactly?

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security - O'Reilly
  Coming Fall 2004
 HTTP Developer's Handbook - Sams
  http://httphandbook.org/
 PHP Community Site
  http://phpcommunity.org/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Relative Url

2004-04-02 Thread Red Wingate
Hi chris,

Haven't much time now but maybe you can find a way with those ideas:

in pollFunctions.php do :

$pollFunctions_path = str_replace( basename ( _FILE_ ) , '' , _FILE_ );

in foo.php do :

$foo_path = str_replace( basename ( _FILE_ ) , '' , _FILE_ );

Now you just have to compute the diff between $foo_path and 
$pollFunctions_path.

Hope this helps :-)

 -- red

Chris Thomas wrote:

What im trying to do is this.

I working on creating a poll script, and right now it consists of 3 main
files:
poll.php   - Which does the server-side processing
pollFunctions.php   - Which draws the poll and does some client side stuff
poll.css- stylesheet
These files reside in the /poll directory (for now)
pollFunctions.php is included in the file that wants the poll, which may
reside in any folder.
So what im trying to figure out is the relative url of where the
pollfunctions.php file resides.
--  Now that i think about it i could just include the stylesheet from the
calling file (ie index.php)
I probally should have thought of this a little more before i posted...oh
well
Chris

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
--- Chris Thomas [EMAIL PROTECTED] wrote:

Is there anyway that i can get a url relative to my server for a
script that is being run??
$relative_url = '/';

That's a relative URL to your document root. What are you wanting,
exactly?
Chris

=
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming Fall 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Relative Url

2004-04-02 Thread Red Wingate
Ok found his one on some old libs of mine, guess this should work but i 
am not sure :

?php

function find_relativ_path( $origin , $target ){
$append = '';
$string = '';
$origin = explode('/',$origin); 
$target = explode('/',$target);
unset($origin[(count($origin)-1)]);
unset($target[(count($target)-1)]);
for ( $i = 0 ; TRUE ; $i++ ){
if ( !isset($target[$i]) AND !isset($origin[$i]) )
break;
if ( strlen($string) == 0 AND $origin[$i] == $target[$i] ){;
continue;
}else if ( isset($target[$i]) AND $origin[$i] != $target[$i] ){
$append .= $target[$i].'/';
if ( isset($origin[$i]) ){
$string .= '../';
}
}else{
$string .= '../';
}
}
return $string.$append;
}
?

Use this with $pollFunctions_path and $foo_path

Red Wingate wrote:

Hi chris,

Haven't much time now but maybe you can find a way with those ideas:

in pollFunctions.php do :

$pollFunctions_path = str_replace( basename ( _FILE_ ) , '' , _FILE_ );

in foo.php do :

$foo_path = str_replace( basename ( _FILE_ ) , '' , _FILE_ );

Now you just have to compute the diff between $foo_path and 
$pollFunctions_path.

Hope this helps :-)

 -- red

Chris Thomas wrote:

What im trying to do is this.

I working on creating a poll script, and right now it consists of 3 main
files:
poll.php   - Which does the server-side processing
pollFunctions.php   - Which draws the poll and does some client side 
stuff
poll.css- stylesheet
These files reside in the /poll directory (for now)

pollFunctions.php is included in the file that wants the poll, which may
reside in any folder.
So what im trying to figure out is the relative url of where the
pollfunctions.php file resides.
--  Now that i think about it i could just include the stylesheet from 
the
calling file (ie index.php)

I probally should have thought of this a little more before i posted...oh
well
Chris

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
--- Chris Thomas [EMAIL PROTECTED] wrote:

Is there anyway that i can get a url relative to my server for a
script that is being run??


$relative_url = '/';

That's a relative URL to your document root. What are you wanting,
exactly?
Chris

=
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming Fall 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Relative Url

2004-04-02 Thread Chris Shiflett
--- Chris Thomas [EMAIL PROTECTED] wrote:
 I working on creating a poll script, and right now it consists of 3
 main files:
 poll.php
 pollFunctions.php
 poll.css
 These files reside in the /poll directory (for now)

[snip]

 So what im trying to figure out is the relative url of where the
 pollfunctions.php file resides.

$url = '/poll/pollfunctions.php';

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Relative Url

2004-04-01 Thread Chris Shiflett
--- Chris Thomas [EMAIL PROTECTED] wrote:
 Is there anyway that i can get a url relative to my server for a
 script that is being run??

$relative_url = '/';

That's a relative URL to your document root. What are you wanting,
exactly?

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Relative Url

2004-04-01 Thread Rick Fletcher
 Is there anyway that i can get a url relative to my server 
 for a script that is being run??
 
 The script is being included in mulitple files and 
 $_SERVER['SCRIPT_NAME'] just gives me the name of the file 
 that is including the other scripts.
 Also $_SERVER['SCRIPT_FILENAME'] is returning nothing.

I'm not completely sure I know what you're after.  If you're looking to get
the http path to an included file, this should work:

?php

$http_path = http://; . $_SERVER['SERVER_NAME'] .
 str_replace( $_SERVER['DOCUMENT_ROOT'], , __FILE__ );

?

If you're in windows I don't think the replace would work, because the
docroot's slashes go one way and the __FILE__ slashes go the other.  You'd
use something like strtr( __FILE__, \\, / ) before the replacement to
fix that.

Cheers,
Rick


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php