Posted on: 09/11/04 07:57am
By: LWC
Hi!
Can I use SSI commands in Geeklog?
For example, I'd like to include a random quote in the header.thtml (just some lines, so I don't want a whole block), but I read that SSI only works in SHTML and those sort of pages.
However, Geeklog also uses PHP and there's a way to use SSI in PHP so there's still a chance...
Thanks!
SSI (Server Side Includes) Commands
Posted on: 09/11/04 08:28am
By: Dirk
[QUOTE BY= LWC] Can I use SSI commands in Geeklog?[/QUOTE]
Well, since PHP will let you do the same as SSI (and more), why not use PHP instead? You can use PHP code in header.thtml
[QUOTE BY= LWC] However, Geeklog also uses PHP and there's a way to use SSI in PHP so there's still a chance...[/QUOTE]
I'm not too familiar with SSI, but if there is such a way, then it would probably workin Geeklog, too. But then again, why not use PHP in the first place (see above)?
bye, Dirk
SSI (Server Side Includes) Commands
Posted on: 09/11/04 09:48am
By: LWC
Do you mean I can just use something like:
[quote (because the code box bigger than the text)]
<?php
code goes here...
?>
[/quote]and include it where ever I want inside header.thtml?
What I want is to use something like:
<!--#exec cgi="/cgi-bin/randomtext.cgi"-->
That CGI file takes a random text from a text file and displays it.
If you answered "yes" to the first question, does it mean I can use something like:
<?php
system("../cgi-bin/randomtext.cgi"
;
?>
?
SSI (Server Side Includes) Commands
Posted on: 09/11/04 09:55am
By: Dirk
[QUOTE BY= LWC] Do you mean I can just use something like: (... snipped ...) and include it in where ever I want inside header.thtml?[/QUOTE]
Exactly.
bye, Dirk
SSI (Server Side Includes) Commands
Posted on: 09/11/04 10:00am
By: LWC
Thanks!
If you have a better way to insert random text other than using CGI, don't hesitate to share...
SSI (Server Side Includes) Commands
Posted on: 09/11/04 01:20pm
By: LWC
It works, but Geeklog also prints the line
"Content-type: text/html"
and if I delete from the CGI the command
print "Content-type: text/html\n\n";
then I can't use the CGI anywhere but via PHP without causing an internal error...
SSI (Server Side Includes) Commands
Posted on: 09/11/04 07:08pm
By: LWC
If only I could delete this comment...
SSI (Server Side Includes) Commands
Posted on: 09/14/04 04:06pm
By: Dirk
[QUOTE BY= LWC] It works, but Geeklog also prints the line
"Content-type: text/html"[/QUOTE]
Then filter it out before displaying the text. 'system' returns a string that you can then manipulate with PHP's string functions.
bye, Dirk
SSI (Server Side Includes) Commands
Posted on: 09/14/04 09:08pm
By: LWC
Well, you confused me...:-)
"System" is not a string, it's a command.
For strings, one should use "shell_exec".
Then it's as easy as:
<?php
$output = shell_exec("../cgi-bin/randomtext.cgi"
;
$output = ereg_replace("Content-type: text/html\\n\\n", "", $output);
?>
SSI (Server Side Includes) Commands
Posted on: 09/15/04 01:58am
By: Dirk
[QUOTE BY= LWC] "System" is not a string, it's a command.[/QUOTE]
I said it returns a string.
bye, Dirk
SSI (Server Side Includes) Commands
Posted on: 09/15/04 11:31am
By: LWC
Well, that's where you are wrong. "System" is like the command "cmd" in Windows. You just can't "catch" its output.
For example, $whatever = system('foo.cgi')
will mean that the value of $whatever will be "" (i.e. nothing)!
It would still run the CGI, but you won't be able to control where it would output it as it won't be part of any string.
Neither will you able to do any string operations on it (like clear it of unneeded headers, etc.).
"shell_exec", on the other hand, does catch the output into a string.
If you know something about VBScript, it's like the difference between CreateObject("Wscript.Shell").run and CreateObject("Wscript.Shell").exec
SSI (Server Side Includes) Commands
Posted on: 09/15/04 02:02pm
By: Dirk
[QUOTE BY= LWC] Well, that's where you are wrong. "System" is like the command "cmd" in Windows. You just can't "catch" its output.[/QUOTE]
Actually, according to the
PHP manual[*1] , it returns
the last line of the command output. Which is pretty much useless if the command produces more than one line of output.
I was under impression that it returned the entire output, so sorry for the confusion.
bye, Dirk
SSI (Server Side Includes) Commands
Posted on: 09/15/04 03:45pm
By: LWC
Oops, I didn't mention this, but I did get the last line...
Now I finally understand why.
Actually, I got two outputs:
1) All the lines - but always on top of the page.
2) Only the last line - exactly where I needed it.
Now I understand 2)...as for 1), I assumed it was because the command "system" was loaded immediately before the rest of the page (instead of being kept in the memory till its time comes).