| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 编程开发 > ASP教程 > ASP实例教程 > 文章正文 用户登录
一个站点要运营成
迅雷联盟:个人站
迅雷联盟,个人站
155提供免费播客空
Sogua免费提供音乐
Skype为推广员提供
免费的移动数码扫
Dotworlds免费提供
Poco免费提供个人
申请免费空间用在

一个免费的邮件列表源程序(二)           

一个免费的邮件列表源程序(二)

作者:佚名 来源:不详 更新:2006-8-25 21:05:35 错误报告 我要投稿
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%">&nbsp;</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="images/new.gif">&nbsp;<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="images/source.gif" border=0></a></center>' );

   Out ( '</td>' );
   Out ( '<td width="20%">&nbsp;</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 &amp; so HTML displayed, not interpreted
      s = s.replace ( /&/g, '&amp;' );

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

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

      // replace tabs with 3 spaces
      s = s.replace ( /\t/g, '&nbsp;&nbsp;&nbsp;' );

      // 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%">&nbsp;</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%">&nbsp;</td>' );
   Out ( '<td width="60%">' );
}
%>
文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。