Jump to content

Include/file open/write? No idea


Illasera

Recommended Posts

I have a problem that started random, for no reason.I am trying to make a page generator, And everything went well, And all of a sudden, The pages that got generated and the new one stopped working, (The pages loaded takes 5 minutes to load, and in the end, Get rendered without the Header/Footer files).Now i isolated the problem by commenting most of my code that i was writing to the files i generated,And i found out the problem was, The header and footer of the files i include(),The only difference in the header/footer files i included is the way there are included,In all my none generated files they are used as "include();" (That works perfectly), While in my file generator i use fwrite($file, "include() .... ) which does the same, So i dont get it, Whats the difference?Whats URL_ALLOW_INCLUDE/use_include_path? Does it have to do anything with it?How do i solve it? And what does it all mean? Any why my generated files stopped working all of a sudden without any change?

Link to comment
Share on other sites

I have a problem that started random, for no reason.
This is your perception, but it is unlikely accurate.I might be able to help in one important way. Always keep in mind that anything that you include is treated as if it were part of the file that is including it. This could easily lead to looping, if you are not careful.Now, to go any deeper than this, I am relatively certain that the others will need to see some code.Roddy
Link to comment
Share on other sites

This is your perception, but it is unlikely accurate.I might be able to help in one important way. Always keep in mind that anything that you include is treated as if it were part of the file that is including it. This could easily lead to looping, if you are not careful.Now, to go any deeper than this, I am relatively certain that the others will need to see some code.Roddy
No endless loop as far as i can tell, Anything else mate?
Link to comment
Share on other sites

No endless loop as far as i can tell, Anything else mate?
Short segments of well selected code will usually get you a long way in this forum.Roddy
Link to comment
Share on other sites

Short segments of well selected code will usually get you a long way in this forum.Roddy
$File_Handle = fopen($hostname.".php", "w", 1);			$File_Syntax = "<?php			include('http://www.address.extension/Header1.php'); ?>"				fwrite($File_Handle, $File_Syntax);				fclose($File_Handle);

in case that wasn`t clear from the text.

Link to comment
Share on other sites

Please note that descriptions like "stopped working all of a sudden" are not helpful. If you mean your file does not get written, please say so.Have you tried any debugging? Do you have error reporting turned on? Do you know for a fact that the script parses, or do you know that it is a runtime error? Are you examining the return values of your functions?FWIW, if the code you posted is copied your actual script, then there is a missing quotation mark at the end of your string. That will cause a parsing error, the page will not execute at all, not even any HTML sections, and your browser will display an empty window. If that is what you meant by "stopped working all of a sudden," it would have been useful information.

Link to comment
Share on other sites

Please note that descriptions like "stopped working all of a sudden" are not helpful. If you mean your file does not get written, please say so.Have you tried any debugging? Do you have error reporting turned on? Do you know for a fact that the script parses, or do you know that it is a runtime error? Are you examining the return values of your functions?FWIW, if the code you posted is copied your actual script, then there is a missing quotation mark at the end of your string. That will cause a parsing error, the page will not execute at all, not even any HTML sections, and your browser will display an empty window. If that is what you meant by "stopped working all of a sudden," it would have been useful information.
First of all , The end qutation mark typo is in my post, not my sourcecode, I didnt post the entire sourcecode i guess.The code i posted, Generates(Writing the php files, and link them to the website working correctly) However, when i try to access these pages in the website, the connection seems to dieout (After few minutes, it displays the entire page without the header and footer), When i disable the includes, Everything seems to be working fine, The problem lays on the include() function, Not writing file, Not a parsing issue,The window isn`t empty, It displays all the context i wrote beside the header/footers that i included.In localhost i do all the debugging and error reports,And i getWarning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\test.php on line 2Warning: include(http://Domain_Path/Header1.php) [function.include]: failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\test.php on line 2Warning: include() [function.include]: Failed opening 'http://domain_Path/Header1.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\test.php on line 2.;C:\xampp\php\PEARhttp://Domain_Path,on the actual remote server, The .;C:\xampp\php\PEARhttp://Domain_Path, is replaced with http://Domain_Path"]http://Domain_Path/header or FooterPlease note the first error, Am quite sure i mentioned it in my original post.Nice day everyone.
Link to comment
Share on other sites

your url include option is off i think. thats why it cant open your header by url. you can change it from php.inioryou can add include by its server path like inlucde("C:\xampp\htdocs\headre1.php");

Link to comment
Share on other sites

your url include option is off i think. thats why it cant open your header by url. you can change it from php.inioryou can add include by its server path like inlucde("C:\xampp\htdocs\headre1.php");
I am afried i don`t have access to php.ini file in my hosting server, Makes since, Probably security reasons or they just want people to mess around.I do include the full file path in my include function, Or maybe i misunderstand you :) ...
Link to comment
Share on other sites

you can set it off at runtime like

ini_set('allow_url_include',1);

oryes you can add full path (c://xampp....) instead of using http://Domain_Path/Header1.phpsecond choice is better as from security view. if you realy dont need to include it from url. you can leave it disabled.

Link to comment
Share on other sites

you can set it off at runtime like
ini_set('allow_url_include',1);

oryes you can add full path (c://xampp....) instead of using http://Domain_Path/Header1.phpsecond choice is better as from security view. if you realy dont need to include it from url. you can leave it disabled.

Way #1 - Didnt change anything, Note that i also cant get the value of 'allow_url_include' with : echo ini_get('allow_url_include');Way #2 - I am hosting a remote server, So i don`t think accessing local files will help me.Unless again, I misunderstand you?I have set the "allow_url_include" to "on" in my php.ini file at my localhost, Seems to working fine, But again it`s in my localhost, Note that i don`t have access to php.ini in remote host.Birbal mathod of "ini_set('allow_url_include',1);"Didn`t seems to work well, Or maybe i don`t know where to put it how to set it take effect.But it`s seems clear that : in order for the pages to work, i need to set allow_url_include to "on".Also some background info about , why is this option "allow_url_include" exists and why is it disabled by default?
Link to comment
Share on other sites

"ini_set('allow_url_include',1);"you have to add it in every page.but why do you need url include. where as you can use absolute path of server (remote server or your localhost that does not matter) which is more safer.allow_url_include have some security vulnabarlity. so it is avoided if you have other way to do the same work.putting header file in web root(url_include) means it is accesible from browser (user can call it). you can add those outside of webroot (for your remote host it should be like this "/home/user/....") and can make it safer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...