Click to See Complete Forum and Search --> : SSI #echo woes


zaimor
10-15-2005, 02:10 AM
I'm going crazy trying to get the LAST_MODIFIED and DATE_LOCAL variables to work. I once had them working on a Windows XP Apache 2.0.55 server. I'm now running the same version of Apache (2.0.55) on Slackware 10.1. Everything works fine, SSI works, #include works, but for the life of me I cannot get #echo to work. There's no errors, it just doesn't output text. I've tried everything... This is my footer.txt file at the moment, without the begin/end comments:

<!--Begin footer.txt-->
<!--#echo var="num1" -->,<!--#set var="num2" value="num2" -->,<!--#echo var="num2" -->.
<!--#config timefmt="%Y-%m-%d %H:%S %Z" -->
Test: <!--#flastmod virtual="home.html" --><br>
This file last updated: <!--#echo var="LAST_MODIFIED" --> <br>
Current Server Time: <!--#echo var="DATE_LOCAL" -->
<!--End footer.txt-->

And this is the output I get with that:

,,. Test:
This file last updated:
Current Server Time:

My syntax is correct I know. Includes are enabled throughout my conf file, because <!--#include xxxx works in any directory.

Suggestions? Oh, and the results are the same using both Opera 8.5 and IE 6.0, so I doubt it being a browser issue.

lcole
10-18-2005, 12:01 AM
I'm going crazy trying to get the LAST_MODIFIED and DATE_LOCAL variables to work. I once had them working on a Windows XP Apache 2.0.55 server. I'm now running the same version of Apache (2.0.55) on Slackware 10.1. Everything works fine, SSI works, #include works, but for the life of me I cannot get #echo to work. There's no errors, it just doesn't output text. I've tried everything... This is my footer.txt file at the moment, without the begin/end comments:

<!--Begin footer.txt-->
<!--#echo var="num1" -->,<!--#set var="num2" value="num2" -->,<!--#echo var="num2" -->.
<!--#config timefmt="%Y-%m-%d %H:%S %Z" -->
Test: <!--#flastmod virtual="home.html" --><br>
This file last updated: <!--#echo var="LAST_MODIFIED" --> <br>
Current Server Time: <!--#echo var="DATE_LOCAL" -->
<!--End footer.txt-->

And this is the output I get with that:

,,. Test:
This file last updated:
Current Server Time:

My syntax is correct I know. Includes are enabled throughout my conf file, because <!--#include xxxx works in any directory.

Suggestions? Oh, and the results are the same using both Opera 8.5 and IE 6.0, so I doubt it being a browser issue.


Well, this could be totally off the wall, and I haven't tested it to see if it fixes the problem, but try putting <!--#config timefmt="%Y-%m-%d %H:%S %Z" --> above the first echo strings. I don't know if it will make a difference since your first echo includes are not time related, but I found a note that says:

"config timefmt must come before the echo directive for it to work. This is a string compatible with the strftime library call under most versions of UNIX. "

So I figured it might be worth a shot.

zaimor
10-18-2005, 07:37 AM
doesnt work... originally those first few echo strings weren't there, they don't serve any real purpose... they're just to see weather the problem was with the "echo" include, or something with the file system (i.e. i wanted to make sure it wasnt just that the "last_modified" and "date_local" variables were broke). I can remove those, leave the config timefmt and the last 2 echos, and it gives me the same output. Thank you very much for the idea though, lemme know if that info helps lead you to any other possiblities =)

-Z

PS - if for some reason any of that makes less than perfect sense, lemme know. just got off a 26 hour shift. sleep. sleeeeeep.

lcole
10-18-2005, 07:26 PM
It's got to be something in the config. I just tested it on my server and got this back in the browser:
(none),,num2. Test: 2005-10-18 17:03 MDT
This file last updated: 2005-10-18 17:03 MDT
Current Server Time: 2005-10-18 17:08 MDT

What's your .htaccess file look like?

zaimor
10-18-2005, 11:54 PM
Right, but the tricky part is, it's got to be something in the config for the *nix version, and not the windows version. The exact same code with a [relatively] unchanged configuration worked under windows... the only problem i ran into was not putting a [space] before the closing -->.

I don't use .htaccess files. Here's any -possible- relative information i can find in the httpd.conf file. All involved directories (/www and under) are at least RWXRWXR-X, which should be more than plenty for any SSI includes to run. Keeping in mind that SSI -WORKS-... I include a footer file on all my main pages... it's just the ECHO that's broken.

------------------
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .html .shtml
-----------------
Ok, so apache knows what ssi is and to pass all html files through it. (I've also tried rename index.html to index.SHTML. No change.)

-----------------
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

#
# [... more documentary text...]
#
<Directory "/usr/local/apache2/www">

#
# Possible values for the Options directive are "None", "All",
# [... more documentary text...]
# for more information.
#
Options Indexes FollowSymLinks +Includes

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>
---------------------
And, /www is more than happy to approve include requests. (I've also tried adding +Includes to / but that didn't work either. Attached httpd.conf doesn't include that, removed it when it wouldnt work. Icky security risk.)

Are there any other possible environment variables in #config that may have to be set in the *nix version that I wouldn't have needed to play with in the winblows one? Attached is my intact httpd.conf file if it will be of any more assistance. Again, thanks for all your help =)

-Z

lcole
10-19-2005, 12:46 AM
Try adding this to the config:

AddType text/x-server-parsed-html .html

zaimor
10-19-2005, 08:53 AM
Added... all it did was make my browser ask me what to do with the .html files. Commented out.

lcole
10-19-2005, 11:42 PM
I'm sorry. I'm completely stumped. Just for grins, put an .htaccess file in the same directory as the html file that contains the includes. Put this in the .htaccess file.

Options Indexes FollowSymLinks Includes
AddType application/x-httpd-cgi .cgi
AddType text/x-server-parsed-html .html

Permissions on the .htaccess can be -rw-r--r--

zaimor
10-20-2005, 09:04 AM
What overrides would I have to allow? Haven't played with the htaccess files much... would I just need to override Includes or would I allowoverride Options and AddType?

lcole
10-20-2005, 04:20 PM
I really don't know that much about conf files, just enough to trash my own machine. <g> The first thing I'd do, if you haven't already, is make a backup copy of httpd.conf. Don't know how many times that has come in handy.

That said, I would only change
AllowOverride None to AllowOverride All
at this point in the conf. file:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit

Then stick the .htaccess file in the directory with the .html file. Test it and if it doesn't work, put it all back the way it was.

zaimor
10-20-2005, 06:29 PM
SCORENESS!

Tried the .htaccess approach. No-go. The addtype again broke the browsers' ability to recognize the .html files, so I commented it out and it still didn't work.

However, I found the solution.

Did some testing and found that the Echo includes WORK in the .html file itself. Renamed my footer file, footer.txt, to footer.txt.html and loaded it in a browser. Everything worked. Got to thinking, punched myself in the face a few times, and thought, "Hey... wait... what if Apache is parsing the footer file for code -BEFORE- it puts the code into the html file?" If that was the case, then NO includes would work in the footer file... why? Because the footer file doesnt get parsed for SSI. It's extension is TXT!

AddOutputFilter INCLUDES .html .shtml .txt

Problem Solved.

This file last updated: Wednesday, 19-Oct-2005 23:50:15 UTC
Current Server Time: Friday, 21-Oct-2005 18:24:35 UTC

Wow my clock is wrong.

Thanks a billion for your help, I probably would have given up hope on it without someone working on it beside me =)

-Z

lcole
10-20-2005, 06:42 PM
Woo Hoo!! Glad you got it figured out. :) I was about out of ideas and I never would have thought to ask if the footer file was html or not. I just assumed it was. Guess I learned something. <g>