Web Programming Week 6 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 10/05/10.

Slides:



Advertisements
Similar presentations
Administrative  Philosophy  Class survey  Grading  Project  Presentation.
Advertisements

Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
ASP.NET Validating user input Validating user input on the client and/or server side 1ASP.NET Validating User Input.
Simple PHP application. A simple application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the.
CS 174: Web Programming February 26 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
. If the PHP server is an server or is aware of which server is the server, then one can write code that s information. –For example,
Web Programming Week 10 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 11/02/10.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
Web Server Design Week 5 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/10/10.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
HTML Forms and Scripts. Session overview What are forms? Static vs dynamic Client-side scripts –JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
Copyright (c) 2010, Dr. Kuanchin Chen1 The Client-Server Architecture of the WWW Dr. Kuanchin Chen.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Includes and Dates.
Web Server Design Week 14 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/14/10.
Examples – RFC 5322 MIME messages multipart/alternative Human Readable Text To: "External, User" From: "Test, User1" Subject: I-D ACTION:draft-ietf-mailext-pipeline-01.txt.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 8/31/10.
CS 174: Web Programming September 30 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
Internet Information Systems Writing to Databases and Amending Data.
PHP2. PHP Form Handling The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. Name: Age:
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Web Server Design Week 8 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/3/10.
Perl: Lecture 2 Advanced RE & CGI. Regular Expressions 2.
Web Server Design Week 4 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/03/10.
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
Web Server Design Assignment #1: Basic Operations Due: 02/03/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
Web Server Design Assignment #2: Conditionals & Persistence Due: 02/24/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Web Programming Week 9 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 10/26/10.
CS 174: Web Programming October 14 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Web Server Design Week 2 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 1/20/10.
Web Server Design Week 7 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/24/10.
Web Server Design Week 13 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/7/10.
Web Server Design Assignment #4: Authentication Due: 04/14/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
Web Server Design Week 6 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/17/10.
Web Server Design Assignment #3: Transfer Encoding & Content Negotiation Due: 03/24/2010 Old Dominion University Department of Computer Science CS 495/595.
1 CS428 Web Engineering Lecture 22 Building Dynamic Web pages (PHP - V)
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Web Server Design Week 10 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/17/10.
Web Server Design Week 5 Old Dominion University Department of Computer Science CS 495/595 Spring 2012 Michael L. Nelson 02/07/12.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2007 Michael L. Nelson 8/27/07.
1 Week 8 Final Project Planning & Chapter 6 JavaScript Advanced Web Development IT225 Spring Term 2016 Marymount University School of Business Administration.
Web Server Design Week 3 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 1/23/06.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Web Server Design Week 6 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 2/13/06.
HTTP Protocol.
Web Server Design Week 15 Old Dominion University
Web Server Design Week 5 Old Dominion University
Today’s Objectives Week 12 Announcements ASP.NET
Web Programming Week 8 Old Dominion University
Web Server Design Week 6 Old Dominion University
Web Programming Week 7 Old Dominion University
Requests and Server Response Codes
Web Server Design Week 5 Old Dominion University
Web Server Design Week 14 Old Dominion University
Web Programming Week 8 Old Dominion University
Web Server Design Week 6 Old Dominion University
Web Server Design Week 7 Old Dominion University
Web Programming Week 1 Old Dominion University
Web Server Design Week 7 Old Dominion University
Presentation transcript:

Web Programming Week 6 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 10/05/10

Server-Side Input Validation (Chapter 8 in book, 7 in sample code) Client-side input validation is nice but not a replacement for server-side validation –client-side security == no security malicious or broken clients –client-side (Javascript) examples: Server-side can be built using: –empty(), is_numeric(), is_string(), is_bool(), is_array(), is_object(), etc. –

Separate URI to Handle Errors … if (empty($var1)) { $errors.= "$var1 should not be empty"; } if (!is_numeric($var2)) { $errors.= "$var2 should be a number"; } // check all anticipated error conditions … if (empty($errors)) { // do interesting work } else { $errors = urlencode($errors); header("Location: }

Same URI to Handle Errors … if (empty($var1)) { $errors.= "$var1 should not be empty"; } if (!is_numeric($var2)) { $errors.= "$var2 should be a number"; } // check all anticipated error conditions … if (empty($errors)) { // do interesting work } else { internal_error_function($errors); } function internal_error_function ($errors) { // generate pretty HTML response // provide link to start over }

Same URI with Error Argument … if (empty($var1)) { $errors.= "$var1 should not be empty"; } if (!is_numeric($var2)) { $errors.= "$var2 should be a number"; } // check all anticipated error conditions … if (empty($errors)) { // do interesting work } else { $errors = urlencode($errors); header("Location:".$_SERVER["REQUEST_URI"]."?errors=$errrors"; }

Encoding/Decoding URLs RFC-1738 requires “unsafe” and “reserved” characters to be encoded in URIs: – –Reserved examples “/”, “:”, “?”… –Unsafe examples [space], “%”, “#”… PHP urlencode(), urldecode() – – More info: –

Escaping HTML <?php $orig = "I'll \"walk\" the dog now"; $a = htmlentities($orig); $b = html_entity_decode($a); echo $a; // I'll "walk" the <b>dog</b> now echo $b; // I'll "walk" the dog now ?> See: Also:

Regular Expressions More Info: if ( !preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{4})/", $_POST['movie_release'], $reldatepart) ) { $error.= "Please+enter+a+date+with+the+dd-mm-yyyy+format"; } Attention: "ereg" has been deprecated as of PHP 5.3 and hence will cause a warning! if $_POST['movie_release'] == then: $reldatepart[0] = $reldatepart[1] = 31 $reldatepart[2] = 05 $reldatepart[3] = 1969

Date/Time More info: $movie_release = mktime ( 0, 0, 0, $reldatepart['2'], $reldatepart['1'], $reldatepart['3']); // $seconds_since_Jan1st1970 = mktime(hour,min,sec,month,day,year)

Apache httpd.conf % less /etc/apache2/httpd.conf … # # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html ErrorDocument 404 /error.php?404 #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument # …

SMTP Mesg Return-Path: Received: from exchange.cs.odu.edu (darkisland.csnet.cs.odu.edu [ ]) by unixmail.cs.odu.edu (8.14.2/8.14.2) with ESMTP id o94LPccJ (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Mon, 4 Oct :25: (EDT) Resent-Date: Mon, 4 Oct :25: (EDT) Resent-Message-Id: Resent-From: Received: from unixmail.cs.odu.edu ( ) by darkisland.csnet.cs.odu.edu ( ) with Microsoft SMTP Server id ; Mon, 4 Oct :25: Received: from mln-web (mln-web.cs.odu.edu [ ]) by unixmail.cs.odu.edu (8.14.2/8.14.2) with SMTP id o94LPblD for ; Mon, 4 Oct :25: (EDT) Message-ID: Received: by mln-web (sSMTP sendmail emulation); Mon, 4 Oct :17: From: added by portage for apache Date: Mon, 4 Oct :17: To: Subject: Error Page MIME-Version: 1.0 Content-Type: text/html; charset="iso " Error occurred on Monday, October 4, 2010 at 17:17:12:2010 Error received was a 404 error. The page that generated the error was: /~mklein/code/code/ch08/error.php.02.php?404 The generated error message was: "Page Not Found" Error Page - (Error Code 404) The page you are looking for cannot be found <a the system administrator if you feel this to be in error PHP syntax: mail($to,$subject,$body,$headers)