一個免費的郵件清單來源程式(二)

來源:互聯網
上載者:User
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 "Contact":
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 that 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><img src="http://edu.cnzz.cn/NewsInfo/images/new.gif"> <a href="Categories.zip">Download</a> all 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 the resource
      oFSO = null;

      Out ( '<p><center><a href="FSO.asp"><img src="http://edu.cnzz.cn/NewsInfo/images/source.gif" border=0></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 = '<h4>' + sFile + '</h4>' + s;
   }

   Out ( s );

   fFile.Close ( );
}

// ============================================
// show a source file outside the table
// ============================================
function ShowSource ( oFSO, sFile, bShowName )
{
   // advertize our mailing list before the first source file
   if ( !bDoneLink )
   {
      bDoneLink = true;
      Out ( '<p><b>Get informed when the source code below changes!</b> <a href="subscribe.asp">Subscribe 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%">' );
}
%>


相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。