A free mailing list source program (ii)

Source: Internet
Author: User
Tags header include
Showsource.asp
<%@ Language=javascript%>

<!--#include file = "include/setglobals.asp"-->

<%
Get the page to display from the URL
var spage = "" + Request.QueryString ("page");

Make sure it's a page we allow them to view!
Switch (spage)
{
Case "wider":
Case "COM":
Case "Handle404":
Case "Categories":
Case "Categorypage":
Case "Columns":
Case "Resultspage":
Case "Date":
Case "Contacts":
Case "Subscribe":
Case "Mailtolist":
Break

Default
Response.Redirect ("naughtynaughty!");
}

Output relevant META tags
Init ("ASP Source Example");

Output common top of page
Header (' <a href= "work.asp" >Work</a>--> <a href= "' + Spage + '. asp" > "' + spage + '. asp" </a>- > Source ', 3);

Output page Content
Content ();

Output common bottom of page
Footer ();
%>

<%/* Standard page elements * *%>
<!--#include file = "utils/init.asp"-->
<!--#include file = "utils/header.asp"-->
<!--#include file = "utils/footer.asp"-->
<!--#include file = "utils/showfile.asp"-->

<%
// ============================================
The content of this page
// ============================================
function Content ()
{
Out (' <td width= ' 20% ' > </td> ');
Out (' <td width= "60%" > ");

Create Handle to FileSystemObject
var ofso = Server.CreateObject (' Scripting.FileSystemObject ');

Each source file, we show source, for could have a related
Documentation file for us to display before and after the
Source. For now, I use a generic header and footer file. The
' True ' tells Showfile to pass through any HTML to the browser.

Showfile (oFSO, ' Generic.pre ', true, false);

Switch (spage)
{
Case "Categories":
Case "Categorypage":
Case "Columns":
Out (' <p> <a href= "Categories.zip" > Download</a> all of the source for the category demonstration!<p> ');
Break
}

Showsource (OFSO, Spage + '. asp ', true);

Show any extra utility file (s) too
Switch (spage)
{
Case "wider":
Showsource (oFSO, ' include/setglobals.asp ', true);
Showsource (oFSO, ' utils/header.asp ', true);
Break

Case "Categories":
Case "Categorypage":
Case "Columns":
Case "Subscribe":
Case "Mailtolist":
Showsource (oFSO, ' utils/database.asp ', true);
Break

Case "Categories":
Case "Categorypage":
Case "Columns":
Showsource (oFSO, ' utils/showcategory.asp ', true);
Break
}

Show the generic footer
Showfile (oFSO, ' generic.pst ', true, false);

We ' ve finished with the "object so Free" resource
OFSO = null;

Out (' <p><center><a href= "fso.asp" ></a></center> ');

Out (' </td> ');
Out (' <td width= ' 20% ' > </td> ');
}
%>

Utils/showfile.asp
<%
Have we advertized our mailing list yet?
var bdonelink = false;

// ============================================
Display the contents of the given file
// ============================================
function Showfile (OFSO, Sfile, bpasshtml, Bshowname)
{
var ForReading = 1;
var forwriting = 2;
var forappending = 8;

Open ASP file for reading
var ffile = Ofso.opentextfile (Server.MapPath (sfile), ForReading);

Read entire file contents into variable
var s = ffile.readall ();

if (!bpasshtml)
{
Replace & with & so HTML displayed, not interpreted
s = s.replace (/&/g, ' & ');

Replace < with < so HTML displayed, not interpreted
s = s.replace (/</g, ' < ');

Replace newline with HTML equivalent
s = s.replace (/\n/g, ' <br> ');

Replace tabs with 3 spaces
s = S.replace (/\t/g, "");

Show filename and change font color for source code
s = ' <font color= ' black ' > ' + S + ' </font> ';

if (bshowname)
s = ' }

Out (s);

Ffile.close ();
}

// ============================================
Show a source file outside the table
// ============================================
function Showsource (OFSO, Sfile, Bshowname)
{
Advertize our mailing list before
if (!bdonelink)
{
Bdonelink = true;
Out (' <p><b>get informed when the source code below changes!</b> <a href= ' subscribe.asp ' &GT;SUBSCRI be to our mailing list.</a> ');
}

Out (' </td> ');
Out (' <td width= "20%" > </td></tr><tr><td colspan=3 width= "100%" bgcolor= "" #ff9900 ">");

Show News File
Showfile (oFSO, Sfile, False, Bshowname);

Out (' </td></tr><tr><td width= ' 20% ' > </td> ');
Out (' <td width= "60%" > ");
}
%>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.