|
|
|
|
|
Dicas
|
|
ASP - Active Server Page (Miscelâneas)
|
|
|
Título da Dica: Adicionando BLOG em seu site
|
|
|
|
Postada em 3/10/2003 por ^HEAVY-METAL^
Para não ficar fora da onda
shouts.asp
<%@ Language=VBScript %>
<% ' ban ip addresses ' if Request.ServerVariables("REMOTE_ADDR") = "127.0.0.1" then ' response.redirect("banned.asp") ' end if %>
<HTML> <HEAD> <title>View shouts</title> <link rel="stylesheet" type="text/css" href="styles/sb.css"> </HEAD> <BODY>
<h1>Shouts</h1> <iframe src="sframe.asp" width="200" height="500" frameborder="0">Your browser doesnt support frames</iframe> <p align="left"><a href="shout.asp" target="_top">Shout again</a></p>
</BODY> </HTML>
sb.css BODY { PADDING-RIGHT: 2px; PADDING-LEFT: 2px; FONT-WEIGHT: lighter; FONT-SIZE: 11px; PADDING-BOTTOM: 3px; MARGIN: 3px 2px; COLOR: #000000; PADDING-TOP: 3px; FONT-FAMILY: Arial, 'Tempus Sans ITC', 'MS Sans Serif'; BACKGROUND-COLOR: #ffffff } P { FONT-WEIGHT: lighter; FONT-SIZE: 11px; TEXT-TRANSFORM: none; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: Arial, Tahoma, 'MS Sans Serif'; LIST-STYLE-TYPE: square; FONT-VARIANT: normal; TEXT-DECORATION: none } H1 { FONT-WEIGHT: bolder; FONT-SIZE: 15pt; TEXT-TRANSFORM: none; COLOR: #00008b; FONT-STYLE: normal; FONT-FAMILY: Arial, Tahoma, 'MS Sans Serif'; FONT-VARIANT: normal; TEXT-DECORATION: none } INPUT { BACKGROUND-COLOR: #f8f8ff } TEXTAREA { BACKGROUND-COLOR: #f8f8ff } TABLE { FONT-WEIGHT: lighter; FONT-SIZE: 12pt; TEXT-TRANSFORM: none; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: Arial, Tahoma, 'MS Sans Serif'; FONT-VARIANT: normal; TEXT-DECORATION: none }
banned.asp
<%@ Language=VBScript %> <HTML> <HEAD> <title>IP Address banned</title> <link rel="stylesheet" type="text/css" href="styles/sb.css"> </HEAD> <BODY>
<h1>Banned User</h1>
<p>Due to levels of abuse of this shoutbox, this IP address has been banned. To contact the administrator regarding this ban, email admin@some_email.com</p>
</BODY> </HTML>
connectionstring.asp
<% ' connection string for the web joblist database
dim dbasepath dim provider
dbasepath = "" & server.mappath("db/shoutdb.mdb") & "" provider = "Microsoft.Jet.OLEDB.4.0"
%>
sbprocess.asp
<%@ Language=VBScript %>
<!-- #include file="connectionstring.asp" -->
<% ' variables dim name dim email dim posterIP dim post dim CS dim RS dim iSQL dim frmName dim frmEmail dim frmPost dim pdate
' parameters posterIP = Request.ServerVariables("REMOTE_ADDR")
frmName = QuoteReplace(Request.Form("name")) frmEmail = QuoteReplace(Request.Form("email")) frmPost = QuoteReplace(Request.Form("post"))
if frmName = "" then Response.Redirect("shout.asp?incomplete=true") end if
if frmEmail = "" then Response.Redirect("shout.asp?incomplete=true") end if
if frmPost = "" then Response.Redirect("shout.asp?incomplete=true") end if
pdate = now()
' objects Set CS = Server.CreateObject("ADODB.Connection")
' connection string (info in connectionstring.asp) CS.ConnectionString = dbasepath CS.Provider = provider CS.Open
' sql queries iSQL = "INSERT INTO shoutbox(name,email,post,posterIP,pdate) VALUES ('" & frmName & "','" & frmEmail & "','" & frmPost & "','" & posterIP & "','" & pdate & "')"
CS.Execute(iSQL)
Function QuoteReplace(formVar) QuoteReplace = Replace (formVar, Chr(34),""") QuoteReplace = Replace (QuoteReplace,"'","'") End Function
' display shouts Response.Redirect("shout.asp") %>
sframe.asp
<!-- #include file="connectionstring.asp" --> <html> <head> <link rel="stylesheet" type="text/css" href="styles/sb.css"> </head> <body> <% dim sql dim CS dim RS dim x
' objects Set CS = Server.CreateObject("ADODB.Connection") Set RS = Server.CreateObject("ADODB.Recordset")
' connection string (info in connectionstring.asp) CS.ConnectionString = dbasepath CS.Provider = provider CS.Open
sql = "SELECT TOP 10 * FROM shoutbox ORDER BY postID DESC"
Set RS = CS.Execute(sql)
Response.Write "<p align=left>"
while RS.EOF = false Response.Write "<strong>" & RS("name") & "</strong>" Response.Write "<br>" Response.Write "<a href='mailto:" & RS("email") & "'>" & RS("email") & "</a>" Response.Write "<br>" Response.Write "" & RS("post") & "" Response.Write "<br>" Response.Write "<em>Posted at: " & RS("pdate") & "</em>" Response.Write "<br><hr size=1 noshade color=#c0c0c0>" RS.MoveNext wend Response.Write "</p>" %>
</body> </html>
shout.asp <%@ Language=VBScript %>
<% Option Explicit %>
<% ' ban ip addresses ' if Request.ServerVariables("REMOTE_ADDR") = "127.0.0.1" then ' response.redirect("banned.asp") ' end if %> <HTML> <HEAD> <title>ASP Shoutbox by designplace.org</title> <link rel="stylesheet" type="text/css" href="styles/sb.css">
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript"> <!-- function validate() { /*Validate textarea length before submitting the form*/
var maxChar = 200 if (document.forms[0].post.value.length > maxChar) { diff=document.forms[0].post.value.length - maxChar; if (diff>1) diff = diff + " characters"; else diff = diff + " character"; alert("This field is limited to " + maxChar + " characters\n" + "Please reduce the text by " + diff); document.forms[0].post.focus(); return (false); } }
//--> </SCRIPT>
</HEAD> <BODY>
<h1>Shoutbox</h1>
<table width="99%" cellspacing="2" cellpadding="2"> <tr> <td valign="top" width="79%"> <% if Request.QueryString("incomplete") > "" then Response.Write "you <strong>must</strong> enter information for all fields." end if %> <form name="shoutbox_post_form" action="sbProcess.asp" method="post"> Name:<br> <input type="text" name="name" size="30" maxlength="40" autocomplete="off" /><br> Email<br> <input type="text" name="email" size="30" maxlength="40" autocomplete="off" /><br> Shout<br> <textarea name="post" cols="23" rows="10" maxlength="200" /> </textarea> <br>
<input type="submit" value="submit" onclick="return validate();" /> <input type="reset" value="reset" /> </form></td>
<td width="20%" valign="top" style="border: #c0c0c0 1px dotted;"> <iframe src="sframe.asp" width="200" height="500" frameborder="0">Your browser doesnt support frames</iframe> </td> </tr> </table>
</BODY> </HTML>
T+,
|
|
|
|
|