1 CGI, SSI, ASP and PHP The Common Gateway Interface E-Commerce Prof. Sheizaf Rafaeli.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Lecture 11 Server Side Interaction
CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
Java Script Session1 INTRODUCTION.
DT228/3 Web Development WWW and Client server model.
CGI Programming.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Python and Web Programming
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Website Development with PHP and MySQL Introduction.
1 CGI The Common Gateway Interface E-Commerce Prof. Sheizaf Rafaeli.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Chapter 6: Hostile Code Guide to Computer Network Security.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
CGI Programming Languages Web Based Software Development July 21, 2005 Song, JaeHa.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Common Gateway Interface
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
INTRODUCTION TO WEB DATABASE PROGRAMMING
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Python CGI programming
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
HTML. Principle of Programming  Interface with PC 2 English Japanese Chinese Machine Code Compiler / Interpreter C++ Perl Assembler Machine Code.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
2-1 WEB DATABSE INTERFACING Colorado Technical University IT420.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
CSU - DEO Introduction to CGI - Fort Collins, CO Copyright © XTR Systems, LLC Introduction to the Common Gateway Interface (CGI) Instructor: Joseph DiVerdi,
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
 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.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CS 330 Class 8 Homework A pattern that contains a word with an optional period A pattern that contains Fred with a space (not Freddy) See regexp.txt guest4.htm.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
National College of Science & Information Technology.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
WWW and HTTP King Fahd University of Petroleum & Minerals
Chapter 27 WWW and HTTP.
Presentation transcript:

1 CGI, SSI, ASP and PHP The Common Gateway Interface E-Commerce Prof. Sheizaf Rafaeli

2 E-Busainess, Sheizaf Rafaeli

3

4

5

6 CGI

7 How CGI Works n n Recall discussion of clients vs. servers n n The Common Gateway Interface (CGI) – –is an agreement between HTTP server implementors about how to integrate such gateway scripts and programs n CGI programs are scripts written for the http server (httpd) n The specs for CGI (1.1 and 1.2) are at

8 E-Busainess, Sheizaf Rafaeli Normal HTML vs. CGI n With Normal HTML, your browser receives HTML, and decodes it for presentation. Your browser also sends regular URL (pointer requests). n With CGI, your browser sends –PUT or GET –something else, not regular URL, –call for a program

9 E-Busainess, Sheizaf Rafaeli How CGI scripts work (2) n n Your browser decodes the first part of the URL and contacts the server. n n Your browser supplies the remainder of the URL to the server. n n The server translates the URL into a path and file name. n n The server realizes that the URL points to a program instead of a static file.

10 E-Busainess, Sheizaf Rafaeli How CGI scripts work (3) n n The server prepares the environment and launches the script. n n The script executes and reads the environment variables and STDIN. n n The script sends the proper MIME headers to STDOUT for the forthcoming content. n n The script sends the rest of its output to STDOUT and terminates.

11 E-Busainess, Sheizaf Rafaeli How CGI scripts work (4) n n Non-parsed Header (nph) scripts can bypass the server, sending stuff directly back to the browser n n The server notices that the script has finished and closes the connection to your browser. NOTE: stateless, connectionless n n Your browser displays the output from the script.

12 E-Busainess, Sheizaf Rafaeli Where CGI scripts live n CGI programs can reside anywhere, provided the location is recognized by the http server n “Anywhere” means on same machine or other, same directories or other n Best if set apart from document structure n Usually should be better protected, for fame, security, property reasons

13 E-Busainess, Sheizaf Rafaeli Programming Languages in CGI n Perl and C, C++ are the most common n Visual Basic and Java rapidly catching up n Many others used too n ASP, PHP, SSI n Tension (choice) between compiled vs. interpreted n Dimensions: –Portability, –Ease of learning, debugging –Speed, efficiency

14 E-Busainess, Sheizaf Rafaeli CGI vs. API and server specific technologies n API is emerging as one alternative to CGI n Less portable (not “common”) n “Behind” the server (httpd) n API more efficient, less compliant n Examples: Netscape ONE, Microsoft WindowsDNA, Oracle and others

15 E-Busainess, Sheizaf Rafaeli Calling a CGI script n CGI scripts can be invoked in a variety of ways. They can be called from –The tag » » –The anchor tag » » Click Here –The image tag » » –As server side includes » »

16 E-Busainess, Sheizaf Rafaeli ASP, SSI and PHP alternatives SSI (Server Side Includes): SSI lets you embed a number of special 'commands' into the HTML itself. When the server reads an SSI document, it looks for these commands and performs the necessary action. PHP is a server-side scripting language. Like ASP, PHP script is processed by the Web server. After the server plays with the PHP code, it returns plain old HTML back to the browser.

17 E-Busainess, Sheizaf Rafaeli SSI and PHP alternatives PHP HTML Embedding  SGML style:  XML style:  ASP style:  Javascript style: code Search results for " "

18 E-Busainess, Sheizaf Rafaeli The simplest (and available) Server-Side include n n The basic format for the server-side include is as follows: – – n n Possible SSI commands :   config, echo, include, exec, fsize, flastmod Depends on server configuration BEWARE!!!

19 E-Busainess, Sheizaf Rafaeli SSI example hello This file is pretty big! it is bytes or, in short bytes ò hello ssi.html This file is pretty big! it is 326 bytes or, in short 1k bytes hello again!

20 E-Busainess, Sheizaf Rafaeli Some ASP examples n Hello world (see next slide) n Greeting, Session and Time n Environment Variables (see slide) n Database Example

21 E-Busainess, Sheizaf Rafaeli Hello, ASP World! My first script was created 7/24/00

22 E-Busainess, Sheizaf Rafaeli

23 E-Busainess, Sheizaf Rafaeli The Form n n The tag is used to define the HTML to be used for user input n n Most HTML calls CGI using forms n n The tag's attributes specify – –the program's name and location either locally or as a full URL – –the type of encoding being used, – – what method is being used to transfer the data n n

24 E-Busainess, Sheizaf Rafaeli Elements in a form see n n Each tag identifies TYPE of area, has a NAME, and could have a VALUE. n n Types include: – –text, checkbox, password – –reset and submit – –Textarea and Select are special cases n For example: –

25 E-Busainess, Sheizaf Rafaeli Elements in a form (2) n Text areas are invoked using : – – n Selection menus are invoked using Cinnamon Cocoa Nutmeg Cloves Allspice Shaved Dark Chocolate Paprika

26 E-Busainess, Sheizaf Rafaeli Environment Variables available to the CGI program n Remember that this is sessionless or “connectionless” n n But: various pieces of information about: – – the browser (type, what it can view, the remote host name etc) – –the server (name and version, the port its running on, and so on) – –and the CGI program itself (the program name and where it's located). n n The server provides all of this information to the CGI program through environment variables.

27 E-Busainess, Sheizaf Rafaeli A simple environment variables program ENVIRONMENT.PL: #!/usr/local/bin/perl print "Content-type: text/html\n\n"; print " \n"; print " CGI Environment \n"; print " \n"; print " \n"; print " CGI Environment \n"; foreach $env_var (keys %ENV) { print " $env_var = $ENV{$env_var} \n"; } print " \n";

28 E-Busainess, Sheizaf Rafaeli A simple environment variables program (2) n Try running directly – n And try submitting from a form: –

29 E-Busainess, Sheizaf Rafaeli The FORM HTML Here is a post button <FORM ACTION= " METHOD=POST> And here is a Get button

30 E-Busainess, Sheizaf Rafaeli CGI and Security n Secure the machine (telnet and other access) n Secure the Web-server (daemon) n Secure the location of the cgi scripts (write and read access) n Then:   Your program should do what you want and nothing more.   Don't give client more information than it needs to know.   Don't trust the client to give you the proper information.   Minimize potential damage if break-in does occur

31 E-Busainess, Sheizaf Rafaeli CGI and Security (2) n Generally, compiled preferable over interpreted n Beware of buffer flow (pointer after-effect) n Encrypting incoming and / or outgoing messages: –SSL –SHTTP

32 E-Busainess, Sheizaf Rafaeli CGI and Security hopefully…

33 E-Busainess, Sheizaf Rafaeli CGI and client side processing

34 E-Busainess, Sheizaf Rafaeli “Packaged” CGI scripts (1) n There are thousands of scripts available n Try, for instance: – – – n CGI programming libraries are important for : –parsing –output

35 E-Busainess, Sheizaf Rafaeli “Packaged” CGI scripts (2) “ready made” n Like other providers, the UofM denies most users access to CGI directories n However, like many providers, UofM allows use of “prepackaged” applications. These include: –Finger, HtMail (forms-to- ), Imagemap, Swishgate, Counter, Survey, Guestbook (and loggate) n See

36 E-Busainess, Sheizaf Rafaeli “Hosted”, remotely hosted CGI services n n Often as simple as cutting and pasting some html into your pages. Sometimes require registration. Ranging from quizzes, "quote of the day" programs, to advanced affiliate programs and advertising systems. n See, e.g., at: – –