You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by ro...@apache.org on 2004/07/07 12:23:42 UTC

cvs commit: tcl-site/websh/examples emailform.ws3

ronnie      2004/07/07 03:23:42

  Modified:    websh/examples emailform.ws3
  Log:
  - better email check
  - minor beatifications
  
  Revision  Changes    Path
  1.5       +18 -13    tcl-site/websh/examples/emailform.ws3
  
  Index: emailform.ws3
  ===================================================================
  RCS file: /home/cvs/tcl-site/websh/examples/emailform.ws3,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- emailform.ws3	4 Jul 2004 13:23:30 -0000	1.4
  +++ emailform.ws3	7 Jul 2004 10:23:42 -0000	1.5
  @@ -90,7 +90,7 @@
       set email [web::formvar email]
   
       # make sure we have alpha-numeric stuff separated by "@"
  -    if {![regexp -nocase {^([a-z0-9]+)@([a-z0-9]+)\.+([a-z]+)$} \
  +    if {![regexp -nocase {^([a-z._0-9-]+)@([a-z._0-9-]+)\.+([a-z]+)$} \
   	      $email email name domain]} {
   	# return error code
   	return 2
  @@ -112,14 +112,16 @@
   # create the e-mail message and send it to the given e-mail address
   proc sendEmail {} {
   
  -    # disabled for security reasons, and because there is no sendmail on www.apache.org ;-)
  -    return
  +    # disabled for security reasons, and because there is no 
  +    # sendmail on www.apache.org ;-)
  +    return 1
   
       set emailtxt {
   
   Thank you for your submission.
   
   We have recieved the following information:}
  +
       append emailtxt "\nName:\n[web::formvar name]\n"
       append emailtxt "Address:\n"
       append emailtxt [web::formvar addr]
  @@ -141,9 +143,9 @@
   	puts $fh $emailtxt
   	close $fh
       } cmsg ] } {
  -
  -	showErrorPage
  +	return 0
       }
  +    return 1
   }
   
   
  @@ -152,12 +154,11 @@
       page "Error" {
   
   	web::putx {
  -	    <h3>Error</h3>
   	    An error occurred while processing your request.
   	    Please {web::put "<a href=\"[web::cmdurl default]\">try</a>"} again
   	    <br><br>
   	    If the problem persists, please contact the
  -	    {web::put "<a href=\"mailto:webmaster@tcl.apache.org\">webmaster</a>"}.
  +	    {web::put "<a href=\"mailto:webmaster@websh.com\">webmaster</a>"}.
   	}
       }
   }
  @@ -181,9 +182,10 @@
   	    <dt><b>E-Mail:</b>
   	    <dd>{web::put [web::htmlify [web::formvar email]]}<p>
   	    </dl>
  -	    You should recieve a confirmation by e-mail shortly.<br>
  -	  <b>Note: to prevent misue, sending the actual email is disabled, so please don't wait for the mail ;-)</b>
  -	    <br>
  +	    You should recieve a confirmation by e-mail shortly.
  +
  +	    <p><b>Note: to prevent misue, sending the actual email is disabled, so please don't wait for the mail ;-)</b></p>
  +
   	    {web::put "<a href=\"[web::cmdurl default]\">Order more</a>"}
   	    cool stuff.
   	}
  @@ -211,12 +213,15 @@
   web::command submit {
   
       if { [set res [checkFormData]] == 0 } {
  -	sendEmail
  -	showConfirmationPage
  +	if {[sendEmail]} {
  +	    showConfirmationPage
  +	} else {
  +	    showErrorPage
  +	}
       } else {
   	showForm $res
       }
   }
   
   
  -web::dispatch
  \ No newline at end of file
  +web::dispatch
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org