[PHP] PHP Include Help
I have a series of text files that are set up with each line being a different field. Line "0" is song title, "1" is artist, "2" is album, and so forth. I know how to use PHP to include those files in an HTML template so that I don't have to make a separate page for each song, however, I do have two problems: On line "6", I have the list of musicians in the song. Example (ignore the quotes): "Doyle Lawson -- lead vocal; Dale Perry -- bass vocal" Is there a way to make it so that, when I include line 6 in my PHP template, the ";" will be replaced with a line break so I get one musician per line in the HTML output? Lines 7 and so on are the lyrics. The text file has one line per line (makes sense, right?) and a blank line between sections of the song. I have the script set up to read all the lines from 7 on, but it jumbles them all together, ignoring the line breaks. Is there a way to script PHP to add the line breaks, or should the line break HTML just be inserted everywhere needed in all my separate files? All help is appreciated! -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ --- Outgoing mail is certified Virus Free because I care. Jesus Saves! Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Including Text File in PHP/HTML Template
I have a series of text files that are set up with each line being a different field. Line "0" is song title, "1" is artist, "2" is album, and so forth. I know how to use PHP to include those files in an HTML template using 'echo' so that I don't have to make a separate page for each song, however, I do have two problems: On line "6", I have the list of musicians in the song. Example (ignore the quotes): "Doyle Lawson -- lead vocal; Dale Perry -- bass vocal" Is there a way to make it so that, when I include line 6 in my PHP template, the ";" will be replaced with a line break so I get one musician per line in the HTML output? Lines 7 and so on are the lyrics. The text file has one line per line (makes sense, right?) and a blank line between sections of the song. I have the script set up to read all the lines from 7 on, but it jumbles them all together, ignoring the line breaks. Is there a way to script PHP to add the line breaks, or should the line break HTML just be inserted everywhere needed in all my separate files? All help is appreciated! -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ --- Outgoing mail is certified Virus Free because I care. Jesus Saves! Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Thanks!
Thanks, Erwin! -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Erwin wrote: >> On line "6", I have the list of musicians in the song. >> Example (ignore the quotes): "Doyle Lawson -- lead vocal; Dale Perry >> - >> - bass vocal" >> Is there a way to make it so that, when I include line 6 in my PHP >> template, the ";" will be replaced with a line break so I get one >> musician per line in the HTML output? > > You could use str_replace on the line you've just read... > http://www.php.net/str_replace > >> Lines 7 and so on are the lyrics. The text file has one line per line >> (makes sense, right?) and a blank line between sections of the song. >> I have the script set up to read all the lines from 7 on, but it >> jumbles them all together, ignoring the line breaks. Is there a way >> to script PHP to add the line breaks, or should the line break HTML >> just be inserted everywhere needed in all my separate files? > > Use nl2br: http://www.php.net/nl2br > This function replaces all "\n" (newlines) with "\n" (HTML break > with newline) > > HTH > Erwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Recursive Replace
That line of code successfully will display lines 7 and on of an included text file into my HTML boilerplate. However, in my hundreds of source text files, "" is not included at the end of the lines, therefore lines 7 and on appear as one chunk of text, rather than neatly formatted lines. How can I combine that line of code with str_replace() or some other replace function in order to turn "\n" into "" for each line. I've experimented with several different possibilities, but none of them output anything. Please help ASAP. The lyrics site is the most popular part of my website, and unfortunately it's down until I get this code figured out. -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recursive Replace
Nevermind. Leave it to me to make a very stupid mistake. I fixed it though, and now it works great. For any who are interested, here is the working code... Dunno why you'd need it, but whatever: ",$info[$i]); echo $new7; } ?> My mistake was leaving that I left the second '$' out of '$info[$i]'. At least I found it before I frustrated myself. Thanks anyway! :-) -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Rick Beckman wrote: > > > That line of code successfully will display lines 7 and on of an > included text file into my HTML boilerplate. However, in my hundreds > of source text files, "" is not included at the end of the lines, > therefore lines 7 and on appear as one chunk of text, rather than > neatly formatted lines. How can I combine that line of code with > str_replace() or some other replace function in order to turn "\n" > into "" for each line. I've experimented with several different > possibilities, but none of them output anything. > > Please help ASAP. The lyrics site is the most popular part of my > website, and unfortunately it's down until I get this code figured > out. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Recursive Replace
Thanks everyone! Works great! :-) If only I would have noticed how obvious it was before trying making it more difficult than I had to. -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Mike Ford wrote: >> -Original Message- >> From: Rick Beckman [mailto:[EMAIL PROTECTED]] >> Sent: 02 October 2002 12:12 >> >> >> >> That line of code successfully will display lines 7 and on of >> an included >> text file into my HTML boilerplate. However, in my hundreds >> of source text >> files, "" is not included at the end of the lines, >> therefore lines 7 and >> on appear as one chunk of text, rather than neatly formatted >> lines. How can >> I combine that line of code with str_replace() or some other replace >> function in order to turn "\n" into "" for each line. > > If it's genuinely one line per $info[] element, just add the > dad-blamed to your echo: > > '; > } ?> > > Cheers! > > Mike > > - > Mike Ford, Electronic Information Services Adviser, > Learning Support Services, Learning & Information Services, > JG125, James Graham Building, Leeds Metropolitan University, > Beckett Park, LEEDS, LS6 3QS, United Kingdom > Email: [EMAIL PROTECTED] > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Calling Files from a different directory
I have a page set up that loads the contents of a text file into an HTML template using PHP. (i.e. something.com/page.php?include=1 where "1" is a simple no-extension text file in the same directoy as page.php). Is there a way to modify the PHP code in the template page to search for the included page in another directory? Right now, the only way to do it is to have the URL as "page.php?include=files/1". Currently, here is the code I use to takes the $include URL variable and makes the file accessible in the template: $info = file($include); -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ --- Outgoing mail is certified Virus Free because I care. Jesus Saves! Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling Files from a different directory
Sarcasm aside, I do have the script set up (although I didn't note so in the last response) to not accept files with '.' or '..' in the path. The URL can accept directories within the one the PHP script is in, but not in a different path or any directory above its own (i.e., the server files). -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ John W. Holmes wrote: >> I have a page set up that loads the contents of a text file into an >> HTML template using PHP. (i.e. something.com/page.php?include=1 >> where "1" is a simple no-extension text file in the same directoy as >> page.php). Is there a >> way to modify the PHP code in the template page to search for the >> included page in another directory? Right now, the only way to do it >> is to have the URL as "page.php?include=files/1". >> >> Currently, here is the code I use to takes the $include URL variable >> and makes the file accessible in the template: >> >> $info = file($include); > > Can I get the URL to your server, please, so I can pull up > page.php?include=/etc/passwd ?? Thanks, I would really appreciate > that. > > But seriously, I really hope you are validating what $include is. > > If you want the file to be included from a different directory, then > you have to pass some flag/variable to PHP to tell it where to look. > If you always want it to be in the same dir, then use > > $info = file('files/' . $include); > > ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Umm... Uh-oh
Okay, I was mistaken... There is a gaping security hole in my simple li'l script... How do I modify it to only accept files from a certain path? I want the url format to be script.php?call=1 where "1" is the called file in the /includes/ directory. Just when I get optimistic I leave the entire system exposed. Yeah, that fits with my luck. :-) -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Rick Beckman wrote: > Sarcasm aside, I do have the script set up (although I didn't note so > in the last response) to not accept files with '.' or '..' in the > path. The URL can accept directories within the one the PHP script is > in, but not in a different path or any directory above its own (i.e., > the server files). > > > John W. Holmes wrote: >>> I have a page set up that loads the contents of a text file into an >>> HTML template using PHP. (i.e. something.com/page.php?include=1 >>> where "1" is a simple no-extension text file in the same directoy as >>> page.php). Is there a >>> way to modify the PHP code in the template page to search for the >>> included page in another directory? Right now, the only way to do it >>> is to have the URL as "page.php?include=files/1". >>> >>> Currently, here is the code I use to takes the $include URL variable >>> and makes the file accessible in the template: >>> >>> $info = file($include); >> >> Can I get the URL to your server, please, so I can pull up >> page.php?include=/etc/passwd ?? Thanks, I would really appreciate >> that. >> >> But seriously, I really hope you are validating what $include is. >> >> If you want the file to be included from a different directory, then >> you have to pass some flag/variable to PHP to tell it where to look. >> If you always want it to be in the same dir, then use >> >> $info = file('files/' . $include); >> >> ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] the files I'm working with
song.php is the file that I'm using as my template file, and it calls information from the includes/ directory, which the file "1" would be in. If someone would please look at song.php (I stripped it down to the basics pretty much) and let me know the best and most secure way to do what I want it to do. When finished, the includes directory will have dozens of files (numbered 1 and up), as you can see from the dropdown list in song.php . Thanks for the help. -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Rick Beckman wrote: > Okay, I was mistaken... There is a gaping security hole in my simple > li'l script... How do I modify it to only accept files from a certain > path? I want the url format to be script.php?call=1 where "1" is the > called file in the /includes/ directory. Just when I get optimistic I > leave the entire system exposed. Yeah, that fits with my luck. :-) > > > Rick Beckman wrote: >> Sarcasm aside, I do have the script set up (although I didn't note so >> in the last response) to not accept files with '.' or '..' in the >> path. The URL can accept directories within the one the PHP script is >> in, but not in a different path or any directory above its own (i.e., >> the server files). >> >> >> John W. Holmes wrote: >>>> I have a page set up that loads the contents of a text file into an >>>> HTML template using PHP. (i.e. something.com/page.php?include=1 >>>> where "1" is a simple no-extension text file in the same directoy >>>> as page.php). Is there a >>>> way to modify the PHP code in the template page to search for the >>>> included page in another directory? Right now, the only way to do >>>> it is to have the URL as "page.php?include=files/1". >>>> >>>> Currently, here is the code I use to takes the $include URL >>>> variable and makes the file accessible in the template: >>>> >>>> $info = file($include); >>> >>> Can I get the URL to your server, please, so I can pull up >>> page.php?include=/etc/passwd ?? Thanks, I would really appreciate >>> that. >>> >>> But seriously, I really hope you are validating what $include is. >>> >>> If you want the file to be included from a different directory, then >>> you have to pass some flag/variable to PHP to tell it where to look. >>> If you always want it to be in the same dir, then use >>> >>> $info = file('files/' . $include); >>> >>> ---John Holmes... begin 666 song.php M/"%$3T-465!%($A434P@4%5"3$E#("(M+R]7,T,O+T141"!(5$U,(#0N,#$@ M5')A;G-I=&EO;F%L+R]%3B(@(FAT=' Z+R]W=W2 \/R!E8VAO("1N973X-"@D\:#$@8VQA6QE($QA=W-O;B F86UP.R!1=6EC:W-I;'9E2!";V%T/"]O<'1I;VX^#0H)"3QO<'1I;VX@=F%L=64](C$P(B!L86)E;#TB M5')A8VL@,3 B/DES(%1H870@=&AE($)E;&QS(&]F($AE879E;C\\+V]P=&EO M;CX-"@D)/&]P=&EO;B!V86QU93TB,3$B(&QA8F5L/2)4F5O9B@D:6YF;RD[("1I*STQ*0T* M>PT*"65C:&\@;FPR8G(H)&EN9F];)&E=*3L-"GT-"C\^#0H\+W ^#0H\+V)O ,9'D^#0H\+VAT;6P^ ` end begin 666 1.dat M22=L;"!+965P(&]N(%-A:6QI;F<-"D1O>6QE($QA=W-O;B F(%%U:6-K6QE($QA=W-O;@T*1&]Y;&4@3&%W2!38V]T=" M+2!G=6ET87(-"DDG;2!S86EL M:6YG(&]N(&QI9F4G6EN9R!A;&]N9R!T:&4@=V%Y#0I5;G1I;"!)(&QA;F0@;VX@ M:&5A=F5N)W,@2!,;W)D(&-O;65S(&)A8VL@86YD M($AE('=I;&P@=&%K92!M>2!T;R!M>2!H96%V96YL>2!H;VUE#0I))VQL(&ME M97 @;VX@6]U(&9O;&QO=R!M90T*06YD(&=I=F4@>6]U M6]U(&9R964_ M#0I(:7,@;&]V92=S('5N96YD:6YG+"!A2!,;W)D M(&-O;65S(&)A8VL@86YD($AE('=I;&P@=&%K92!M>2!T;R!M>2!H96%V96YL M>2!H;VUE#0I))VQL(&ME97 @;VX@2!,;W)D M(&-O;65S(&)A8VL@86YD($AE('=I;&P@=&%K92!M>2!T;R!M>2!H96%V96YL M>2!H;VUE#0I))VQL(&ME97 @;VX@http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: the files I'm working with
Outlook Express added a .dat extension to the "1" file... The actual files I'm working with do NOT have extensions. Just wanted to clear that up. -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Rick Beckman wrote: > song.php is the file that I'm using as my template file, and it calls > information from the includes/ directory, which the file "1" would be > in. If someone would please look at song.php (I stripped it down to > the basics pretty much) and let me know the best and most secure way > to do what I want it to do. When finished, the includes directory > will have dozens of files (numbered 1 and up), as you can see from > the dropdown list in song.php . Thanks for the help. > > > Rick Beckman wrote: >> Okay, I was mistaken... There is a gaping security hole in my simple >> li'l script... How do I modify it to only accept files from a certain >> path? I want the url format to be script.php?call=1 where "1" is the >> called file in the /includes/ directory. Just when I get optimistic I >> leave the entire system exposed. Yeah, that fits with my luck. :-) >> >> >> Rick Beckman wrote: >>> Sarcasm aside, I do have the script set up (although I didn't note >>> so in the last response) to not accept files with '.' or '..' in the >>> path. The URL can accept directories within the one the PHP script >>> is in, but not in a different path or any directory above its own >>> (i.e., the server files). >>> >>> >>> John W. Holmes wrote: >>>>> I have a page set up that loads the contents of a text file into >>>>> an HTML template using PHP. (i.e. something.com/page.php?include=1 >>>>> where "1" is a simple no-extension text file in the same directoy >>>>> as page.php). Is there a >>>>> way to modify the PHP code in the template page to search for the >>>>> included page in another directory? Right now, the only way to do >>>>> it is to have the URL as "page.php?include=files/1". >>>>> >>>>> Currently, here is the code I use to takes the $include URL >>>>> variable and makes the file accessible in the template: >>>>> >>>>> $info = file($include); >>>> >>>> Can I get the URL to your server, please, so I can pull up >>>> page.php?include=/etc/passwd ?? Thanks, I would really appreciate >>>> that. >>>> >>>> But seriously, I really hope you are validating what $include is. >>>> >>>> If you want the file to be included from a different directory, >>>> then you have to pass some flag/variable to PHP to tell it where >>>> to look. If you always want it to be in the same dir, then use >>>> >>>> $info = file('files/' . $include); >>>> >>>> ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $B$($($H(B
The best translation I could find comes from worldlingo.com ... $B$3(B $B$l(B $B$C(B $B$F(B $B$I(B $B$&(B $B$d(B $B$C(B $B$F(B solution? $B$9(B $B$k(B $B$s(B $B$G(B $B$7(B $B$g(B $B$&(B? Obviously, that's not enough to help.. Sorry. However, they do offer "clarification by human translators" for only 31 bucks... I suppose if the problem is great enough, someone will shell out the cash. Other than that, no dice. --? Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ $B>>K\AO(B wrote: > $B$3$l$C$F$I$&$d$C$F2rFI$9$k$s$G$7$g$&!&!&!&(B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $B$($($H(B
And I see my post got butchered... Well, that's what I get for trying to help. :-\ -- Kyrie Eleison, Rick www.spiritsword.com/phpBB2/ Rick Beckman wrote: > The best translation I could find comes from worldlingo.com ... > $B$3(B $B$l(B $B$C(B $B$F(B $B$I(B $B$&(B $B$d(B > $B$C(B $B$F(B solution? $B$9(B $B$k(B $B$s(B $B$G(B > $B$7(B $B$g(B $B$&(B? > > Obviously, that's not enough to help.. Sorry. However, they do offer > "clarification by human translators" for only 31 bucks... I suppose > if the problem is great enough, someone will shell out the cash. > Other than that, no dice. > > --? > Kyrie Eleison, > Rick > www.spiritsword.com/phpBB2/ > > > $B>>K\AO(B wrote: >> $B$3$l$C$F$I$&$d$C$F2rFI$9$k$s$G$7$g$&!&!&!&(B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Includes
I'm wanting to use PHP to make updating an entire site easier by using include() [I think that's the function] to include navigation bars, notices, etc. on multiple pages. What's the best way to do that, and is it possible to keep the included files from being indexed/viewed on their own (possibly by password protecting [htaccess] the directory they are in)? Thanks in advance for any help. -- Kyrie Eleison, Rick Beckman www.spiritsword.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php