The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 12, 2012, 07:17:06 PM

Login with username, password and session length


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

Posts: 9792



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

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


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

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
jammaster82
Lifer
*****
Offline Offline

Posts: 666


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

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
Phaėton
Lifer
*****
Offline Offline

Posts: 503


⎝⏠⏝⏠⎠


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

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
krustee
Rookie
**
Offline Offline

Posts: 33


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
Lifer
*****
Offline Offline

Posts: 503


⎝⏠⏝⏠⎠


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

nice.
Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌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!