Re: [PHP] include statement giving me hives! - help
DougD wrote: I am new to all this, but here is the basic code: $link_titles = file('links/master.txt'); $links_include = $link_titles[$point]; // path to directory include $links_include; If I echo the value of $links_include just prior to the include() function it contains what I would expect it to contain Except it contains newline at the end. Get rid of the newline and it should work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include statement giving me hives! - SOLVED
rtrim () solved the issue. There was a newline sitting at the end of the variable and messing it up! Thanks for all your help! Marek Kilimajer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] DougD wrote: I am new to all this, but here is the basic code: $link_titles = file('links/master.txt'); $links_include = $link_titles[$point]; // path to directory include $links_include; If I echo the value of $links_include just prior to the include() function it contains what I would expect it to contain Except it contains newline at the end. Get rid of the newline and it should work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] include statement giving me hives! - help
I am new to all this, but here is the basic code: $link_titles = file('links/master.txt'); $links_include = $link_titles[$point]; // path to directory include $links_include; If I echo the value of $links_include just prior to the include() function it contains what I would expect it to contain and the file does exist. But I get an error: Warning: main(./main/links/topsites.php ) [function.main]: failed to create stream: No such file or directory in . on line 23 Warning: main() [function.main]: Failed opening './main/links/topsites.php ' for inclusion (include_path='.:/usr/local/lib/php') in on line 23 If I add the line: $links_include = path to intended include file; just prior to the include statement it works fine. Am I missing something? I've tried a variety of renditions of the include() statement and can't get it to react unless I 'hard code' the value of $links_include. Appreciate your help!! -Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include statement errors -- something missing
I've tried a hundred different things -- YOURS WORKED! Thank you very much! -Doug - Original Message - From: Niklas Lampén [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Monday, June 17, 2002 10:45 PM Subject: RE: [PHP] include statement errors -- something missing So far so good. $myfile is now a pointer to this file, so you can't print it like that. Use fgets() or something else to read your file. Niklas -Original Message- From: Doug DeVries [mailto:[EMAIL PROTECTED]] Sent: 18. kesäkuuta 2002 8:34 To: Chris Knipe; Doug DeVries; Php-General (E-mail) Subject: Re: [PHP] include statement errors -- something missing here is what I tried: ?php $myfile=fopen(http://www.gospelcom.net/mnn/includes/pubNewsTease.php?li =yes limit=4, r); ? ?php echo $myfile;? -- but basically it returns me Resource ID#1 which makes me feel like I am close. Thanks again for your time and input. I've been learning a lot as I've been researching for this issue. -Doug - Original Message - From: Chris Knipe [EMAIL PROTECTED] To: Doug DeVries [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Monday, June 17, 2002 3:49 PM Subject: Re: [PHP] include statement errors -- something missing Yes, you will. You've only opened the file, you need to read it, and process it and extract the data that you want. i.e.. $blah = fopen(http://a/a.html, r); while ($blah) { do something with it } and so forth Try php.net / google.com there's lost of examples of sites and pages using fopen to include data from other web sites... Kind Regards, Chris Knipe MegaLAN Corporate Networking Services Tel: +27 21 854 7064 Cell: +27 72 434 7582 - Original Message - From: Doug DeVries [EMAIL PROTECTED] To: Chris Knipe [EMAIL PROTECTED]; Doug DeVries [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Tuesday, June 18, 2002 12:32 AM Subject: Re: [PHP] include statement errors -- something missing Thank you, but it is not quite working yet. I get no errors, but rather blank. http://www.solomonsporch.org/test.php - Original Message - From: Chris Knipe [EMAIL PROTECTED] To: Doug DeVries [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Monday, June 17, 2002 12:55 PM Subject: Re: [PHP] include statement errors -- something missing RTFM http://www.php.net/manual/en/function.fopen.php fopen(http://www.gospelcom.net/mnn/includes/pubNewsTease.php?li=yeslim it=4 , r); Would give read-only access to the file, which is what you want. - Original Message - From: Doug DeVries [EMAIL PROTECTED] To: Chris Knipe [EMAIL PROTECTED]; Doug DeVries [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Monday, June 17, 2002 9:36 PM Subject: Re: [PHP] include statement errors -- something missing I tried fopen in the following way, but with no success. ?php fopen(http://www.gospelcom.net/mnn/includes/pubNewsTease.php?li=yeslim it=4 ); ? - Original Message - From: Chris Knipe [EMAIL PROTECTED] To: Doug DeVries [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Monday, June 17, 2002 12:33 PM Subject: Re: [PHP] include statement errors -- something missing I don't think you can use include like that Have a look at fopen though, I'm not 100% sure that is going to help, but I know fopen opens files on remote sites, include only does local. - Original Message - From: Doug DeVries [EMAIL PROTECTED] To: Php-General (E-mail) [EMAIL PROTECTED] Sent: Monday, June 17, 2002 9:27 PM Subject: [PHP] include statement errors -- something missing Help ... please. ... From the page www.solomonsporch.org/test.php I get the following error. Warning: Failed opening 'http://www.gospelcom.net/mnn/includes/pubNewsTease.php?li=yeslimit =4' for inclusion (include_path='c:\php4\pear') in e:\solomonsporch.org\test.php on line 10 The page HTML is as follows: html head /head body test area should show 4 lines of news ?php include(http://www.gospelcom.net/mnn/includes/pubNewsTease.php?li=yesl imit =4); ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http
Re: [PHP] include statement
This is because the PHP include statement is ment to include other blocks of PHP code, rather than bits of HTML. Hence, it includes things from anywhere on the system. To include things from under your current htdocs directory, use... include($DOCUMENT_ROOT . "/includes/metatags.include"); though the more 'correct' method would be readfile($DOCUMENT_ROOT . "/includes/metatags.include"); adamw - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:04 PM Subject: [PHP] include statement I'm a PHP newbie and am looking into using the include statement to put things like the header and footer in so they are always the same. I do this now with SSI. In SSI I'll use the following statement: !--#include virtual="/includes/metatags.include" -- I like this cause it lets me use the same statement all over the site and I don't have to worry about where the document is and how many directories i have to go up an into "../../../../../" I was guessing PHP's version would be: ?PHP include("/includes/metatags.include"); ? However I get an error. If I put the absolute it works: ?PHP include("/home/httpd/includes/metatags.include"); ? which is scary cause this worked too: ?PHP include("/usr/local/apache/conf/httpd.conf"); ? doesn't this seem like a huge security hole? Well what I want is to use something like /inc/footer.html so i can use the same PHP statements in any document and not worry about getting it "../../../" Any suggestions. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include statement
This all depends on your include_path set in the PHP config files; see the manual section on config for more info. About the security hole... yes it would be dangerous on a system where accounts are given to untrusted users (ie, customers), but there are ways to make PHP secure for multi-account environments as well; this is also is described in the manual. php.net/manual --Toby - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 12:04 PM Subject: [PHP] include statement I'm a PHP newbie and am looking into using the include statement to put things like the header and footer in so they are always the same. I do this now with SSI. In SSI I'll use the following statement: !--#include virtual="/includes/metatags.include" -- I like this cause it lets me use the same statement all over the site and I don't have to worry about where the document is and how many directories i have to go up an into "../../../../../" I was guessing PHP's version would be: ?PHP include("/includes/metatags.include"); ? However I get an error. If I put the absolute it works: ?PHP include("/home/httpd/includes/metatags.include"); ? which is scary cause this worked too: ?PHP include("/usr/local/apache/conf/httpd.conf"); ? doesn't this seem like a huge security hole? Well what I want is to use something like /inc/footer.html so i can use the same PHP statements in any document and not worry about getting it "../../../" Any suggestions. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include statement
Michael Zornek wrote: which is scary cause this worked too: ?PHP include("/usr/local/apache/conf/httpd.conf"); ? doesn't this seem like a huge security hole? No. If you know can trust your scripts, this is possible, but trusted scripts won't do any abuse, will they? If you can't trust your scripts, use safe-mode, and it isn't possible any more. Wagner -- One maniac alone can do what 20 together cannot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include statement
Adam(and everyone else who answers in 5 minutes, god i love this list), thanks for the help. Why is readfile more 'correct'? Just wondering? Mike At 5:07 PM + 1/17/01, Adam Wright wrote: This is because the PHP include statement is ment to include other blocks of PHP code, rather than bits of HTML. Hence, it includes things from anywhere on the system. To include things from under your current htdocs directory, use... include($DOCUMENT_ROOT . "/includes/metatags.include"); though the more 'correct' method would be readfile($DOCUMENT_ROOT . "/includes/metatags.include"); adamw - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:04 PM Subject: [PHP] include statement I'm a PHP newbie and am looking into using the include statement to put things like the header and footer in so they are always the same. I do this now with SSI. In SSI I'll use the following statement: !--#include virtual="/includes/metatags.include" -- I like this cause it lets me use the same statement all over the site and I don't have to worry about where the document is and how many directories i have to go up an into "../../../../../" I was guessing PHP's version would be: ?PHP include("/includes/metatags.include"); ? However I get an error. If I put the absolute it works: ?PHP include("/home/httpd/includes/metatags.include"); ? which is scary cause this worked too: ?PHP include("/usr/local/apache/conf/httpd.conf"); ? doesn't this seem like a huge security hole? Well what I want is to use something like /inc/footer.html so i can use the same PHP statements in any document and not worry about getting it "../../../" Any suggestions. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include statement
What about the security issue mentioned? Is it then possible (using the include and/or readfile) to grab anything found on the server? 1 More thing: what if I wanted to place the contents of a file into a variable. How do you achieve that? Karl *also a newbie, and this is a great group* - Original Message - From: "Adam Wright" [EMAIL PROTECTED] To: [EMAIL PROTECTED]; "Michael Zornek" [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 10:18 AM Subject: Re: [PHP] include statement For your things (where you are including HTML), readfile just reads a file and dumps it to the screen. This is fine, because you are just dealing with HTML, so no processing is required. include will actually try and parse the file as if it has PHP inside somewhere, which your HTML (probably) doesnt. So, readfile uses less resources, and is much more like the SSI include statement than PHP's include :) adamw - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: "Adam Wright" [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:14 PM Subject: Re: [PHP] include statement Adam(and everyone else who answers in 5 minutes, god i love this list), thanks for the help. Why is readfile more 'correct'? Just wondering? Mike At 5:07 PM + 1/17/01, Adam Wright wrote: This is because the PHP include statement is ment to include other blocks of PHP code, rather than bits of HTML. Hence, it includes things from anywhere on the system. To include things from under your current htdocs directory, use... include($DOCUMENT_ROOT . "/includes/metatags.include"); though the more 'correct' method would be readfile($DOCUMENT_ROOT . "/includes/metatags.include"); adamw - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:04 PM Subject: [PHP] include statement I'm a PHP newbie and am looking into using the include statement to put things like the header and footer in so they are always the same. I do this now with SSI. In SSI I'll use the following statement: !--#include virtual="/includes/metatags.include" -- I like this cause it lets me use the same statement all over the site and I don't have to worry about where the document is and how many directories i have to go up an into "../../../../../" I was guessing PHP's version would be: ?PHP include("/includes/metatags.include"); ? However I get an error. If I put the absolute it works: ?PHP include("/home/httpd/includes/metatags.include"); ? which is scary cause this worked too: ?PHP include("/usr/local/apache/conf/httpd.conf"); ? doesn't this seem like a huge security hole? Well what I want is to use something like /inc/footer.html so i can use the same PHP statements in any document and not worry about getting it "../../../" Any suggestions. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include statement
Pretty much, yes (within the bounds of the permissions of the files. Most webservers run as nobody on unix, and hence can only read those files which nobody can (confusing, huh :)). But, unless you have a mallicious user with upload access to your server, this isnt an issue. If you do, investigate "Safe mode" this instant :) adamw - Original Message - From: "Karl J. Stubsjoen" [EMAIL PROTECTED] To: "Adam Wright" [EMAIL PROTECTED]; [EMAIL PROTECTED]; "Michael Zornek" [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:21 PM Subject: Re: [PHP] include statement What about the security issue mentioned? Is it then possible (using the include and/or readfile) to grab anything found on the server? 1 More thing: what if I wanted to place the contents of a file into a variable. How do you achieve that? Karl *also a newbie, and this is a great group* - Original Message - From: "Adam Wright" [EMAIL PROTECTED] To: [EMAIL PROTECTED]; "Michael Zornek" [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 10:18 AM Subject: Re: [PHP] include statement For your things (where you are including HTML), readfile just reads a file and dumps it to the screen. This is fine, because you are just dealing with HTML, so no processing is required. include will actually try and parse the file as if it has PHP inside somewhere, which your HTML (probably) doesnt. So, readfile uses less resources, and is much more like the SSI include statement than PHP's include :) adamw - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: "Adam Wright" [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:14 PM Subject: Re: [PHP] include statement Adam(and everyone else who answers in 5 minutes, god i love this list), thanks for the help. Why is readfile more 'correct'? Just wondering? Mike At 5:07 PM + 1/17/01, Adam Wright wrote: This is because the PHP include statement is ment to include other blocks of PHP code, rather than bits of HTML. Hence, it includes things from anywhere on the system. To include things from under your current htdocs directory, use... include($DOCUMENT_ROOT . "/includes/metatags.include"); though the more 'correct' method would be readfile($DOCUMENT_ROOT . "/includes/metatags.include"); adamw - Original Message - From: "Michael Zornek" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 17, 2001 5:04 PM Subject: [PHP] include statement I'm a PHP newbie and am looking into using the include statement to put things like the header and footer in so they are always the same. I do this now with SSI. In SSI I'll use the following statement: !--#include virtual="/includes/metatags.include" -- I like this cause it lets me use the same statement all over the site and I don't have to worry about where the document is and how many directories i have to go up an into "../../../../../" I was guessing PHP's version would be: ?PHP include("/includes/metatags.include"); ? However I get an error. If I put the absolute it works: ?PHP include("/home/httpd/includes/metatags.include"); ? which is scary cause this worked too: ?PHP include("/usr/local/apache/conf/httpd.conf"); ? doesn't this seem like a huge security hole? Well what I want is to use something like /inc/footer.html so i can use the same PHP statements in any document and not worry about getting it "../../../" Any suggestions. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]