So I am getting errors on my site when running a simple script .php that takes another .php file and creates a .html file.
It has to be in the .htaccess probably for the ob_start function I am using. Since my sample.php is using NO attributes of RN itself. Any help would be greatly appreciated!
This is the script:
Code:
<?php
function buildhtml($strphpfile, $strhtmlfile) {
echo "Building ".$strhtmlfile."<br>";
// start buffering the output
ob_start();
include($strphpfile);
// write to a file
$data = ob_get_contents();
$fp = fopen ($strhtmlfile, "w");
fwrite($fp, $data);
fclose($fp);
ob_end_clean();
}
// make calls to the buildhtml function here, giving input and output filenames
buildhtml("sample.php","sample.html");
?>
Here is the sample.php file (for testing purposes)
Code:
<?php
Echo "Hello, World!";
?>
Now here is my current .htaccess file
Code:
#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
# THESE INSTRUCTIONS APPLY TO ALL Options DIRECTIVES
#
# The lines below this section that begin with Options may cause problems
# with some server configurations. They are required for certain functions
# of Apache and RavenNuke(tm), but may already be set by your server administrator in a way
# that dissallows changing them in your .htaccess file. If using any of them causes your server
# to error out, comment them out (add # to beginning of line), reload your site in your browser
# and test the functionality that is affected. If it works, then it has been set by your server
# administrator and you do not need it set here.
#####################################################
# 'Options +FollowSymLinks' is required for use of mod_rewrite.
# Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
# 'Options +Includes' is required for use of Server Side Includes (SSI), such as custom error pages (like 403.shtml).
# Can be commented out if causes errors, see notes above.
Options +Includes
# 'Options -Indexes' is used for controlling directory listings if there is not an index file in a directory (and said directory is readable by the web server).
# A directory index will be automatically generated and this can prove to be a dangerous security issue.
# To disable this feature, use: 'Options -Indexes'
# To enable this feature (not advised), use: 'Options +Indexes'
# Can be commented out if causes errors, see notes above.
Options -Indexes
# -------------------------------------------
# Set search order for index files
# -------------------------------------------
DirectoryIndex index.php index.htm index.html
# -------------------------------------------
# For better performance set FileETag to NONE base on recommendations from
# http://developer.yahoo.net/blog/archives/2007/07/high_performanc_11.html
# -------------------------------------------
FileETag none
# -------------------------------------------
# Only process if mod_expires is installed
# For faster load times cache certain types of files for specific amount of time
# You should adjust these settings based upon your caching requirements
# -------------------------------------------
<IfModule mod_expires.c>
ExpiresActive On
# ExpiresDefault A86400
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/css "access plus 5 minutes"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/plain "access plus 15 minutes"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType video/x-flv "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
# ExpiresByType text/html "access plus 5 minutes"
ExpiresByType text/javascript "access plus 5 minutes"
ExpiresByType application/x-javascript "access plus 5 minutes"
</IfModule>
# -------------------------------------------
# Start of NukeSentinel(tm) admin.php Auth
# -------------------------------------------
<Files .ftaccess>
deny from all
</Files>
<Files .staccess>
deny from all
</Files>
# -----------------------------------------------------------------------------------------------------
# Leave this block commented out unless HTTPAuth is NOT available in your NukeSentinel(tm) Admin Panel.
# This code is mainly for use with CGI Authentication when PHP is compiled as CGI and NOT an Apache module.
# -----------------------------------------------------------------------------------------------------
# <Files admin.php>
# <Limit GET POST PUT>
# require valid-user
# </Limit>
# AuthName "Restricted"
# AuthType Basic
# AuthUserFile /path/to/your/.staccess
# </Files>
# -----------------------------------------------------------------------------------------------------
# -------------------------------------------
# If you use TegoNuke(tm) ShortLinks with RavenNuke(tm) then copy your ShortLinks.htaccess file/rules below inbetween
# the <IfModule> and </IfModule> tags.
# Only process if mod_rewrite is installed
# -------------------------------------------
<IfModule mod_rewrite.c>
# TegoNuke(tm) ShortLinks - ShortLinks.htaccess file/rules should go after this line
#
# TegoNuke(tm) ShortLinks version 1.2.1
#
# This file contains the rewrite rules necessary to force Apache to recognize your
# shortened links and to rewrite them back to what PHP-Nuke is expecting.
# Copy and paste these rules into your .htaccess file in the root of your PHP-Nuke
# Installation. Whatever you do, make sure these are ABOVE NukeSentinel's area
# where it is to write its blocked IPs.
#
# For better performance, remove sections of rules for modules that you do not have
# active on your site.
#
# -------------------------------------------
# Error Document Redirects
# TegoNuke(tm) ShortLinks - ShortLinks.htaccess file MUST be before these directives (See above).
# If you add a new error redirect then you need to add the corresponding xxx.php file to modules/ErrorDocuments/
# Format:
# ErrorDocument xxx /PATH_TO_ERROR_DOCUMENT_RELATIVE_TO_WEB_SERVER_DOCUMENT_ROOT
# -------------------------------------------
# -------------------------------------------
# To prevent a looping redirect anomaly we use this 3 line routine for 404 Page Not Found errors
# -------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /modules.php?name=ErrorDocuments&file=404&rs=$1 [NC,L,R]
# -------------------------------------------
# Start of NukeSentinel(tm) DENY FROM area
# -------------------------------------------
And these are the errors I am getting when trying to run the script! (With ErrorReporting On)
Quote:
Warning: include(banners.php) [function.include]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 54
Warning: include(banners.php) [function.include]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 54
Warning: include() [function.include]: Failed opening 'banners.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 54
Warning: file(themes/Trott/blocks.html) [function.file]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: implode() [function.implode]: Invalid arguments passed in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: file(themes/Trott/blocks.html) [function.file]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: implode() [function.implode]: Invalid arguments passed in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: file(themes/Trott/blocks.html) [function.file]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: implode() [function.implode]: Invalid arguments passed in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: file(themes/Trott/blocks.html) [function.file]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: implode() [function.implode]: Invalid arguments passed in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: file(themes/Trott/blocks.html) [function.file]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: implode() [function.implode]: Invalid arguments passed in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 215
Warning: file(themes/Trott/left_center.html) [function.file]: failed to open stream: No such file or directory in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 89
Warning: implode() [function.implode]: Invalid arguments passed in /home/i7cgjo2s/public_html/themes/Trott/theme.php on line 89
ERROR: 500 - Internal Server Error
Internal Server Error
Hint: Check the .htaccess file for syntax/configuration errors
Your IP : 67.212.10.168
Page Requested : /sitemap/buildsitemap.php
Agent : Opera/9.80 (Windows NT 5.1; U; en) Presto/2.6.30 Version/10.61
Redirect Status : 500
Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
Posted:
Mon Nov 22, 2010 6:09 pm
I have never used ob_get_content but I believe it only returns the content of the output buffer so I'm suspecting you are trying to load an RN page into the buildhtml() function?
In any event, lets try and clarify things in case someone can help.
This is a stand alone script?
Have you tried to execute the script with the htaccess file temporarily renamed to determine if that is the problem?
Are you loading stand alone files into your buildhtml function?
Joined: Dec 02, 2006 Posts: 1364 Location: Texas, USA
Posted:
Mon Nov 22, 2010 6:10 pm
don't have time to look at your code, but looks like most of those errors are in your theme, calling template files and a banner script that are not there. the 500 error isn't necessarily related to your htaccess.. it could be due to a fatal problem with the script.. someone else will have to chime in for that
Actually on second thought I moved my entire nuke root folder and all .htaccess etc files (everything) into a subfolder except for the script which has CHMOD of 777 and I am still getting the above error! So it can't be RN involved....
Do you think it has something to do with my host blocking fwrite or something equiv from the below script?! (Much like ReWrite in shortlinks) Is there a way to turn it on in my .htaccess file?
Thoughts?
Code:
<?php
function buildhtml($strphpfile, $strhtmlfile) {
echo "Building ".$strhtmlfile."<br>";
// start buffering the output
ob_start();
include($strphpfile);
// write to a file
$data = ob_get_contents();
$fp = fopen ($strhtmlfile, "w");
fwrite($fp, $data);
fclose($fp);
ob_end_clean();
}
// make calls to the buildhtml function here, giving input and output filenames
buildhtml("sample.php","sample.html");
?>
EDIT:
And to answer your questions.
Yes this is a stand alone script.
No I am not trying to load a RN page in it. I am simply trying to use a basic page first to get this working. See above "Hello world!" code. I am now pretty sure my host is blocking one of those functions in the php script.
And yes I have tried removing .htaccess
And I am loading basic stand-alone files into the buildhtml.
don't have time to look at your code, but looks like most of those errors are in your theme, calling template files and a banner script that are not there. the 500 error isn't necessarily related to your htaccess.. it could be due to a fatal problem with the script.. someone else will have to chime in for that
This is the solution:
Go to your theme and open theme.php
Remove the line who calls banner.php
You can paste the code here so we can help you further.
It has nothing to do with RN, even as a stand alone script it isnt working. It must be my host blocking one of the ob_start commands. I am looking for an alternate script to generate static htmls!
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum