php help
- Started
- Last post
- 16 Responses
- versa
this should be easier for me, but i am struggling
just want to open a .txt with fopen and have the pre-assigned variables in the .txt either get equated with new variables that then get echoed into the current page, or just be brought in directly and used as is
i have the .txt open no problem (simple i know), but can't seem to figure out how to see and use the pre-assigned variables that are in .txt as they reside in the main fopen variable
- cosmo0
never done it myself, but hope this helps.
- versa0
why shouldn't you be able to put pre-assigned vars in a .txt
and then just bring them in, ...so in the .txt just have:
$fooVar=someStr;
and then find $fooVar inside of the var equated with the fopen ?
maybe i am just ignent
- cosmo0
i know u can do that with includes ("watever.php"), but not sure if u can treat text files as includes too.
Includes r a bless.
- versa0
so if i have something like this:
[?php
$riderCurr = $_GET['rdr'];
$dataPath = "../data/riders/riders.txt";$ridersData = fopen("$dataPath", "r");
if($ridersData){
while(!feof($ridersData)) {
$allData = fread($ridersData, filesize("$dataPath"));
}
fclose($ridersData);
}?]
*********
why can i then have vars in my .txt that are then stored inside of $allData which i can find without having to use a foreach loop, or treating $allData as an array
?
am i making any sense
- versa0
specifically in that example, the query string would have 'rdr' assigned to a 3 letter value, eg. /?rdr=BUT ( for the persons name) which i would like to use in my parsing ...
as in the txt, the vars have that 3 letter value in their naming structure: like
$BUT_name=Butcher
- cosmo0
aaahh yes, u r storing the file contents as string thats why u can find all the data in "allData".
- versa0
i guess i just don't know a good way to move through the data, as ideally i would just want to use the 'rdr' value to find variables in the .txt, and not have to use a foreach and treat allData like an array, exploding it , and all, when i just need the values based on which person/var i want to access
- cosmo0
ok, why do u just explode all content being read from text files at "=" sign, store the variable name in one arrya and info in another. Does it make sense?
- unfittoprint0
use the folowing method.
create dynamic tags like ::name::', '::country::', etc... within your text files.
create an array of variables like
$name - > 'John', $country - > 'Portugal'after reading the contents of the txt file using fopen and storing it in a variable [$var] using fread u then proceed to use a foreach loop using that array and to str_replace every '::'.$key.'::' it finds with the content $var.
to, well, replace '::'.$key.'::'
use a str_treplace
- versa0
well, its for a team - bike company team - i have a shell page that all the riders content will load into as a rider is chosen - i currently want to have a unique name and paragraph description that i bring in from one .txt that has all rider content, and was thinking i would somehow use the same 'rdr' var/nomenclature that i am passing in the query string to load in the proper vars from that .txt
since in the shell page i am doing things like this to load the corresponding imgs:
[img src="../img/riders//_360x260_1.j... id="mainImg" width="360" height="260" border="0" alt=""]
i thought i could do something similar inside the h5 and p tags to load in the names and descriptive paragraphs
- versa0
correcting mistake from last post:
[img src="../img/riders/[?= $_GET['rdr'] ?]/[?= $_GET['rdr'] ?]_360x260_1.jpg" id="mainImg" width="360" height="260" border="0" alt=""]
- instantok0
hrm...if you wanted to do it using xml here you go:
- rabattski0
hmmmm, really not clear to me what you exactly want but i would just use include to load a php file with all the predefined variables.
- BZZZP0
i am looking forward to ripping that box a new one if you are passing values between the query string and fopen forr reading and displaying files.
what's the url?
- versa0
aaahh
i am guessing you are a big sweetheart in real life BZZZP as you do at least offer to help me alot with my dumb php ?s
is this your way of teaching me how vulnerable my code is ?
:)
- BZZZP0
no, i'm just looking for something to assrape, and you will do.
but yeah, that's extremely exploitable.