Teach Yourself Cgi Programming With Perl 5 in a Week (Teach Yourself Series)
Eric Herrmann, Sams Publishing ISBN:1575211963, Edition: 2nd, 1996-12 Price: $39.99
C O N T E N T S
Introduction
Chapter 1 An Introduction to CGI and Its Environment
- The Common Gateway Interface (CGI)
- HTML, HTTP, and Your CGI Program
- The Role of HTML
- The HTTP Headers
- Your CGI Program
- The Directories on Your Server
- The Server Root
- The Document Root
- File Privileges, Permissions, and Protection
- WWW Servers
- MS-Based Servers
- The CERN Server
- The ncSA Server
- The Netscape Server
- The CGI Programming Paradigm
- CGI Programs and Security
- The Basic Data-Passing Methods of CGI
- CGI's Stateless Environment
- Preventing the Most Common CGI Bugs
- Tell the Server Your File Is Executable
- Finding Things on Your System
- Make Your Program Executable
- Learning Perl
- Hello World
- Exercise 1.1. Working with Perl variables
- Exercise 1.2. Using the scalar variable
- Summary
- Q&A
Chapter 2 Understanding How the Server and Browser Communicate
- Using the Uniform Resource Identifier
- The Protocol
- The Domain Name
- The Directory, File, or CGI Program
- Requesting Your Web Page with the Browser
- Using the Internet Connection
- TCP/IP, the Public Socket, and the Port
- One More Time, Using the Switchboard Analogy
- Using the HTTP Headers
- Status Codes in Response Headers
- The Method Request Header
- The Full Method Request Header
- The Accept Request Header
- The HTTP Response Header
- Changing the Returned Web Page Based on the User-Agent Header
- Learning Perl
- Exercise 2.2. Using the Perl regular array
- Exercise 2.3. Using Perl's associative array
- Summary
- Q&A
Chapter 3 Using Server Side Include Commands
- Using SSI Negatives
- Understanding How SSIs Work
- Deciding Whether to Enable SSIs
- Using the Options Directive
- Using the AddType Command for SSIs
- Using the srm.conf File
- Automatically Adding the Last Modification Date to Your Page
- Examining the Full Syntax of SSI Commands
- Using the SSI config Command
- Using the include Command
- Analyzing the include Command
- Using the virtual Command Argument
- Using the file Command Argument
- Examining the flastmod Command
- The Syntax of the SSI echo Command
- The exec Command and CGI Scripts
- Looking At Security Issues with SSIs
- Learning Perl
- Exercise 3.2. The Perl conditional statement if(){} else{}
- Summary
- Q&A
Chapter 4 Using Forms to Gather and Send Data
- Understanding HTML Form Tags
- Using the HTML Form Method Attribute
- The Get and Post Methods
- The Get Method
- The Post Method
- Generating Your First Web Page On-the-Fly
- Comparing CGI Web Pages to HTML Files
- Analyzing first.cgi
- Sending Variables in Your CGI Program
- Using the HTML Input Tag
- Sending Data to Your CGI Program with the Text Field
- Using the Submit Button to Send Data to Your CGI Program
- Making Your Text-Entry Form Fast and Professional Looking
- NPH-CGI Scripts
- NPH-CGI Scripts Are Faster
- URI-Encoded Data Ends Up in the Location Window
- Seeing What Happens to the Data Entered on Your Form
- Name/Value Pairs
- Path Information
- Using URI Encoding
- Reserved Characters
- The Encoding Steps
- Learning Perl
- The Perl for Statement
- The Perl foreach Statement
- Summary
- Q&A
Chapter 5 Decoding Data Sent to Your CGI Program
- Using the Post Method
- Using Radio Buttons in Your Web Page Forms and Scripts
- The HTML Radio Button Format
- The Name Attribute
- The Value Attribute
- The Checked Attribute
- Radio Button Rules
- Reading and Decoding Data in Your CGI Program
- Using the ReadParse Function
- Creating Name/Value Pairs from the Query String
- Decoding the Name/Value Pairs
- Using the Post Method
- Using the Perl read Function
- Including Other Files and Functions in Your CGI Programs
- Using the Data Passed with Radio Buttons
- Using Perl's If Elsif Block
- Using the HTML Checkbox
- Using a Database with Your CGI Program
- Using Pull-Down Menus in Your Web Page Forms and Scripts
- Using the HTML Form Select Tag
- Using the Option Field
- Using File Data in Your CGI Program
- Opening a File
- Reading Formatted Data
- Using Formatted File Data
- Using Data to Make Your CGI Programming Easier
- Learning Perl
- Exercise 5.2. Using ARGV
- Printing with Perl
- Summary
- Q&A
Chapter 6 Using Environment Variables in Your Programs
- Understanding Environment Variables
- Program Scope
- The Path Environment Variable
- Printing Your Environment Variables
- Sending Environment Variables to Your E-Mail Address
- Perl Subroutines
- The Unescape Subroutine
- The cgi_encode Subroutine
- The Main Mail Program
- Using the Two Types of Environment Variables
- Environment Variables Based on the Server
- Environment Variables Based on the Request Headers
- Finding Out Who Is Calling at YourWeb Page
- Getting the Username of Your Web Site Visitor
- Using the Cookie
- Returning the Cookie
- Learning Perl
- Exercise 6.1. Using files with Perl
- Understanding the Filename and Pathname
- Understanding the Filehandle
- Opening and Closing the File
- Exercise 6.2. Using filehandles
- Using Perl's Special Variables
- Summary
- Q&A
Chapter 7 Building an Online Catalog
- Using Forms, Headers, and Status Codes
- Registering Your Customer
- Setting Up Password Protection
- Using the Password File
- Using the Authentication Scheme
- Dealing with Multiple Forms
- Learning Perl
- Perl's write Statement
- The format Statement
- Field Formatting
- Summary
- Q&A
Chapter 8 Using Existing CGI Libraries
- Using the cgi-lib.pl Library
- Determining the Requesting Method
- Decoding Incoming CGI Data
- Printing the Magic HTTP Content Header
- Printing the Variables Passed to Your CGI Program
- Printing the Variables Passed to Your CGI Program in a Compact Format
- Using CGI.pm for Creating and Reading Web Forms
- Installing CGI.pm
- Reading Input Data
- Saving Your Incoming Data
- Saving the Current State of a Form
- Creating the HTTP Headers
- Creating an HTML Header
- Ending an HTML Document
- Creating Forms
- Creating a Submit Button
- Creating a Reset Button
- Creating a Defaults Button
- Creating a Hidden Field
- Creating a Clickable Image Button
- Controlling HTML Autoescaping
- Using the CGI Library for C Programmers: cgic
- Writing a cgic Application
- Using String Functions
- Using Numeric Functions
- Using Header Output Functions
- A cgic Variable Reference
- Summary
- Q&A
Chapter 9 Using Imagemaps on Your Web Page
- Defining an Imagemap
- Sending the x,y Coordinates of a Mouse Click to the Server
- Using the Ismap Attribute and the Img Tag
- Using the Ismap Attribute with <INPUT TYPE=IMAGE>
- Creating the Link to the Imagemap Program
- Using the imagemap.c Program
- Using the Mapfile
- Looking At the Syntax of the Imagemap File
- Deciding Where to Store the Imagemap File
- Increasing the Efficiency of Imagemap Processing
- Using the Default URI
- Ordering Your Mapfile Entries
- Using Client-Side Imagemaps
- The Usemap Attribute
- The HTML Map Tag
- The Area Tag and Its Attributes
- Summary
- Q&A
Chapter 10 Keeping Track of Your Web Page Visitors
- Defining an Access Counter
- Using the Existing Access Log File
- Using page-stats.pl to Build Log Statistics
- Getting Access Counts for Your Entire Server from wusage 3.2
- Configuring wusage
- Charting Access by Domain
- Running wusage
- Purging the access_log File (How and Why)
- Examining Access Counter Graphics and Textual Basics
- Working with DBM Files
- Locking a File
- Creating Your Own File Lock
- Using the flock() Command
- Excluding Unwanted Domains from Your Counts
- Printing the Counter
- Turning Your Counter into an Inline Image
- Generating Counters from a Bitmap
- Using the WWW Homepage Access Counter
- Using the gd 1.2 Library to Generate Counter Images On-the-Fly
- Using the gd 1.2 Library to Produce Images On-the-Fly
- Global Types
- Create, Destroy, and File Functions
- Drawing Functions
- Query Functions
- Font and Text-Handling Functions
- Color-Handling Functions
- Copying and Resizing Functions
- Summary
- Q&A
Chapter 11 Using Internet Mail with Your Web Page
- Looking At Existing Mail Programs
- The UNIX Mail Program
- The UNIX sendmail Program
- Using Existing CGI E-Mail Programs
- The WWW Mail Gateway Program
- Using a Multilingual E-Mail Tool
- Building Your Own E-Mail Tool
- Making Your Own E-Mail Form
- Sending the Blank Form
- Restricting Who Mail Can Be Sent To
- Implementing E-Mail Security
- Defining a Regular Expression
- Positioning Your Regular Expression Match
- Specifying the Number of Times a Pattern Must Occur
- Using Regular Expression Special Characters
- Summary
- Q&A
Chapter 12 Guarding Your Server Against Unwanted Guests
- Protecting Your CGI Program from User Input
- Protecting Your Directories with Access-Control Files
- The Directory Directive
- The AllowOverride Directive
- The Options Directive
- The Limit Directive
- The allow from Directive
- The deny from Directive
- The order Directive
- The require Directive
- Setting Up Password Protection
- The htpasswd Command
- The Groupname File
- Using the Authorization Directives
- The AuthType Directive
- The AuthName Directive
- The AuthUserFile Directive
- The AuthGroupFile Directive
- Examining Security Odds and Ends
- The emacs Files
- The Path Variable
- The Perl Taint Mode
- Cleaning Up Cookie Crumbs
- Summary
- Q&A
Chapter 13 Debugging CGI Programs
- Determining Which Program Has a Problem
- Determining Whether the Program Is Being Executed
- Checking the Program's Syntax
- Checking Syntax at the Command Line
- Interpreting Perl Error Messages
- Looking At the Causes of Common Syntax Errors
- Viewing HTML Sources of Output
- Using MIME Headers
- Examining Problems in the HTML Output
- Viewing the CGI Program's Environment
- Displaying the Raw Environment
- Displaying Name/Value Pairs
- Debugging at the Command Line
- Testing without the HTTP Server
- Simulating a Get Request
- Using Perl's Debug Mode
- Reading the Server Error Log
- Debugging with the Print Command
- Looking At Useful Code for Debugging
- Show Environment
- Show Get Values
- Show Post Values
- Display Debugging Data
- A Final Word about Debugging
- Summary
- Q&A
Chapter 14 Tips, Tricks, and Future Directions
- Making Browser-Sensitive Pages
- Simplifying Perl Code
- Looking At the Future of Perl
- Examining Python: A New Language for CGI
- Comparing Python and Perl
- Understanding the Python Language
- Implementing Python
- Examining Java and JavaScript: Bringing Life to HTML
- Understanding How Java Works
- Understanding How a Java Program Is Executed
- Looking At the Java Language
- Implementing Java in Your System
- Looking At JavaScript: Scripting for the Web
- Finding Useful Internet Sites for CGI Programmers
- CGI Information
- Perl Information
- Specific Product Information
- Summary
- Q&A
Appendix A MIME Types and File Extensions
Appendix B HTML Forms
- Form Attributes
- Action
- Enctype
- Method
- Script
- Input Fields
- Checkbox Fields
- File Attachments
- Hidden Fields
- Image Fields
- Password Fields
- Radio Buttons
- Range Fields
- Reset Buttons
- Scribble on Image Fields
- Single-Line Text Fields
- Submit Buttons
- Permitted Attributes for the Input Element
- Accept
- Align
- Checked
- Class
- Disabled
- Error
- ID
- Lang
- Max
- Maxlength
- MD
- Min
- Name
- Size
- SRC (Source)
- Type
- Value
- Textarea
- Select Elements
- Height
- Multiple
- SRC (Source)
- Units
- Width
- The Option Element
Appendix C Status Codes and Reason Phrases
Appendix D The ncSA imagemap.c Program
Appendix E The Perl Quick Reference Manual
- Perl Operators and Their Precedence
- Perl Operators and Their Meanings
- Special Variables
- Perl Commands
- Miscellaneous Perl Rules
- GNU License Information
Credits
|
|