I have been assigned the task of redesigning an intranet sight. I have some major obstacles and I am not sure how to proceed.

What I have is a main page designed with menus and CSS formatting.

The major problem is that I am not allowed to change the code on the existing pages. These legacy pages need to be loaded dynamically into my template. The legacy pages are multiple links deep.

I need to know how to insert these pages into my template and keep theme there no matter how deep the user navigates.

I am not permitted to use PHP or frames of any kind including iFrames. CGI & PERL were suggested but I am not very familiar with what they offer. Any suggestions on how to tackle this problem will be appreciated.

Dani AI

Generated

described an intranet redesign where legacy pages cannot be edited but must appear inside a new template no matter how deep users navigate. A reliable, maintainable approach is a server-side wrapper (CGI/Perl is allowed) that loads the requested legacy page, parses and rewrites resource and navigation links so they point back through the wrapper, and then emits the template header, the rewritten content, and the template footer. This preserves the new look while leaving legacy files unchanged.

A minimal Perl proof‑of‑concept (skeleton) shows the idea: fetch the file (disk or local HTTP), parse it with an HTML parser, rewrite href/src/action attributes to route through the wrapper, and print the template + content.

#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use HTML::TreeBuilder;
use URI;
use URI::Escape qw(uri_escape);

my $q   = CGI->new;
my $page = $q->param('page') || 'index.html';
$page =~ s/\.\.//g;             # basic sanitise
my $path = "/var/www/legacy/$page";

open my $fh, '<', $path or die "Can't open $path: $!";
local $/; my $html = <$fh>;
close $fh;

my $tree = HTML::TreeBuilder->new_from_content($html);
for my $n ($tree->look_down(sub { $_[0]->attr('href') || $_[0]->attr('src') })) {
  if (my $href = $n->attr('href')) {
    my $abs = URI->new_abs($href, "http://intranet/$page");
    $n->attr('href', "/wrapper.cgi?page=" . uri_escape($abs->path_query));
  }
  if (my $src = $n->attr('src')) {
    my $abs = URI->new_abs($src, "http://intranet/$page");
    $n->attr('src', $abs->path_query);
  }
}

print $q->header('text/html; charset=UTF-8');
print $template_header;
print $tree->as_HTML;
print $template_footer;

Important notes and gotchas: use a real HTML parser (not fragile regex) to rewrite links; properly resolve relative URLs against the page base; sanitize paths to prevent directory traversal; rewrite form actions and proxy POST bodies if forms must continue to work; handle <base> tags and meta refresh redirects; preserve cookies/sessions if legacy pages expect them; and add caching for performance because on‑the‑fly parsing is CPU intensive. If legacy pages rely on server‑side includes or server execution, proxying the server (rather than reading raw files) will be necessary.

This expands on the options raised earlier by (copying the site) and the server‑level routing comments from and . A recommended rollout: build a small wrapper for one page, validate asset and form rewrites, add caching, then expand site‑wide.

Recommended Answers

All 4 Replies

Maybe I'm not understanding this corectly, but couldn't you duplicate the intranet (I asume it's static content) and re-design in a separate server (folder?) meanwhile the old intranet is up.

Also why is that CGI and Perl are OK, but PHP not? Seems a bit wierd :-|

Since you cant change the existing html pages, every time a user clicks on a link in your template, it links to the html page directly, and not through your template.
Avoiding this cannot be one with a server side scripting language anyways.
It depends on the server you are using. You will have to force the server to run your template each time a link, above your template directly is clicked. Then read the url, and include the html page in your template.
Forcing the server to run your template first is server dependant.
If on apache you can use mod rewrite, or forcetype directives. theres alot on the topics on the net.
Your problem is similar to creating search engine friendly urls on dynamic pages.
So one of the existing solutions may work.
:)

Digital-ether,

Your post is very interesting, and is exactly what im looking for.. but im not sure, i've got the code right.

what i have is:

FILE * db;
        char str[680];

        db = fopen("Applications\\ffdbs\\client001.ffdb", "rt+");
        //if(db == NULL) exit(1);
        int pos = 0;
        while(!feof(db))
        {
                fgets(str, 690, db);
                strcpy(data[pos].c_str(),str);
                pos = pos +1;
        }
        fclose(db);

that should theoretical copy the line into the line array (data[]). In another function i have:

FrmClient->ClientCode->Text = data[0].SubString(3,6);

which should return the client code, out of my line array at line position 0. But, it's returning a null value...

do you have any ideas why this may be happeneing, not just digital-ether, but anyone.... please let me know, my grade depends on it.

Thanks,

Lance Wassing

Since you cant change the existing html pages, every time a user clicks on a link in your template, it links to the html page directly, and not through your template.
Avoiding this cannot be one with a server side scripting language anyways.
It depends on the server you are using. You will have to force the server to run your template each time a link, above your template directly is clicked. Then read the url, and include the html page in your template.
Forcing the server to run your template first is server dependant.
If on apache you can use mod rewrite, or forcetype directives. theres alot on the topics on the net.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.