The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. March 12, 2010, 10:18:55 AM

Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: reading files from a different directory with php  (Read 707 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 7858



View Profile
« Reply #15 on: September 08, 2009, 05:46:25 PM »

Going to go PM for the rest of this... sorry for the hijack JM...
Logged

A wise man can learn more from a foolish question than a fool can learn from a wise answer. -Bruce Lee
jammaster82
Lifer
*****
Offline Offline

Posts: 619


Thats craigs list for ya


View Profile
« Reply #16 on: September 09, 2009, 08:26:54 PM »

thanks for putting my initials next to the word hijack.... now im on the fucking list! ROFLMAO


Cheers!
Logged

Dont be afraid of making progress slowly, only be afraid of standing still.
jammaster82
Lifer
*****
Offline Offline

Posts: 619


Thats craigs list for ya


View Profile
« Reply #17 on: October 10, 2009, 01:44:20 PM »

So, file_get_contents('myDir/script/txtfiles') would start at wherever Apache or the shell interpreter had fired off your script[/i/, then drill down into myDir, then script then txtFiles.

How can you tell where the shell interpreter has fired off your script *THIS TIME* ?



For future reference, the path to root can be
determined by $_SERVER['SCRIPT_URL'] it will
end up being something like:

/onedirectoryoffroot/adirectorybelowthat/

so you ../ one less times than there are /'s in
the script_url ... and then you are at the root
directory, ready to crawl down the

 *SERVERS TREE* and into wherever you need..

example:


if the script_url is:

/2009-10-07/posts/

and you wanted to get somewhere else
the route would be:
       
../../wp-content/plugins/myplugindir/myfile.php

just so its up here for when i forget it a week from now.  Smiley
« Last Edit: October 11, 2009, 04:34:19 AM by jammaster82 » Logged

Dont be afraid of making progress slowly, only be afraid of standing still.
Phaėton
Journeyman
***
Offline Offline

Posts: 73

son of helios


View Profile
« Reply #18 on: February 04, 2010, 03:24:18 AM »

If you are  Devilish unsure of where you might be running from
you can do this which is not only cool, but also looks like the
epson  mx 80 hold down form feed at power on demo mode:

Code:

if (file_exists("./wp-config.php")){include("./wp-config.php");}
elseif (file_exists("../wp-config.php")){include("../wp-config.php");}
elseif (file_exists("../../wp-config.php")){include("../../wp-config.php");}
elseif (file_exists("../../../wp-config.php")){include("../../../wp-config.php");}
elseif (file_exists("../../../../wp-config.php")){include("../../../../wp-config.php");}
elseif (file_exists("../../../../../wp-config.php")){include("../../../../../wp-config.php");}
elseif (file_exists("../../../../../../wp-config.php")){include("../../../../../../wp-config.php");}
elseif (file_exists("../../../../../../../wp-config.php")){include("../../../../../../../wp-config.php");}
elseif (file_exists("../../../../../../../../wp-config.php")){include("../../../../../../../../wp-config.php");}

Logged

__̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡._
krustee
Rookie
**
Offline Offline

Posts: 26


View Profile
« Reply #19 on: February 07, 2010, 12:05:31 PM »

Code:
while(!file_exist($i . "wp-config.php"))
{
$i = $i . "../";
if (file_exist($i . "wp-config.php"))
{
include($i . "wp-config.php");
}
}
This should work once there is only one file of that name.
« Last Edit: February 08, 2010, 06:38:27 AM by krustee » Logged
Phaėton
Journeyman
***
Offline Offline

Posts: 73

son of helios


View Profile
« Reply #20 on: February 08, 2010, 12:24:52 PM »

nice.
Logged

__̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡._
Pages: 1 [2]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!