PDA

View Full Version : Include for UBB?


teach1st
12-02-2000, 06:13 PM
I'm slowly but unsurely converting all my class pages to SSI. I'd like to have my UBB look like rest of the pages, with the top and bottom and side menus as includes. I would guess I make the page an SHTML extension and I'm pretty sure I know how to do the menus and all, but can I do an include for the main UBB cgi script?
------------------
fred

dank
12-02-2000, 11:30 PM
I haven't worked with UBB for a while, so there may be some allowance for "SSI" that I'm not aware of, but including includes in a cgi script generally requires a function along the lines of:

sub insert_header {
[nbsp][nbsp][nbsp][nbsp][nbsp]open (FILE, "/path/to/top.txt") or die "can't open: top.txt ($!)";
[nbsp][nbsp][nbsp][nbsp][nbsp]print <FILE>;
[nbsp][nbsp][nbsp][nbsp][nbsp]close FILE;
}

and then call &amp;insert_header; wherever you want it included in the script.

Die

Charles Capps
12-03-2000, 08:22 PM
Is there a reason you can't use the UBB's Header and Footer fields?

teach1st
12-03-2000, 08:27 PM
Is there a reason you can't use the UBB's Header and Footer fields?
I'm doing that now, but it's not an include, which means every time I update my site, I have to update the UBB. It's not a biggie. I'm perparing to try to understand dank's solution for including an include in a cgi. I just may be way above my head. :)
------------------
fred

[This message has been edited by teach1st (edited 12-03-00@8:27 pm)]

Charles Capps
12-05-2000, 04:13 AM
Actually, dank's not too far off.

We use this solution at UBBHackers (http://www.ubbhackers.com/) (another proudly-hosted-by-FQ site..)[nbsp][nbsp];)

Stick the following code at the top of your ubb_library.pl file:

$Header = $Footer = &quot;&quot;;
open(HEAD, &quot;<$NonCGIPath/header.txt&quot;) or die $!;
while(<HEAD>) { $Header .= $_; }
close HEAD;
open(FOOT, &quot;<$NonCGIPath/footer.txt&quot;) or die $!;
while(<FOOT>) { $Footer .= $_; }
close FOOT;

Stick header and footer.txt in the UBB's noncgi directory (or change the paths above) as required.[nbsp][nbsp]That should do the trick.

PaulKroll
12-06-2000, 02:03 AM
You could also do:

$EORHolder = $\;
undef $\;
open(HEAD, &quot;<$NonCGIPath/header.txt&quot;) or die $!;
$Header = <HEAD>;
close HEAD;
open(FOOT, &quot;<$NonCGIPath/footer.txt&quot;) or die $!;
$Footer = <FOOT>;
close FOOT;
$\ = $EORHolder;

Which is a bit faster. (No while-loop overhead.)

teach1st
12-06-2000, 06:06 AM
Thanks all!