Welcome to Geeklog, Anonymous Tuesday, December 24 2024 @ 11:20 am EST

Geeklog Forums

SSI (Server Side Includes) Commands


Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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!
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by LWC: Can I use SSI commands in Geeklog?

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...

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
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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&quotWink;
?>
?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by LWC: Do you mean I can just use something like: (... snipped ...) and include it in where ever I want inside header.thtml?

Exactly.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Thanks!

If you have a better way to insert random text other than using CGI, don't hesitate to share...
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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...
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
If only I could delete this comment...
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by LWC: It works, but Geeklog also prints the line
"Content-type: text/html"

Then filter it out before displaying the text. 'system' returns a string that you can then manipulate with PHP's string functions.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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&quotWink;
$output = ereg_replace("Content-type: text/html\\n\\n", "", $output);
?>
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by LWC: "System" is not a string, it's a command.

I said it returns a string.

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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.

Actually, according to the PHP manual, 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
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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).
 Quote

All times are EST. The time is now 11:20 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content