Chapter 2: Understanding and Avoiding Security Risks
Identifying the Sources of Risk
Minimizing User-Input Risks
Not Revealing Sensitive Information
Summary
Chapter 3: PHP Best Practices
Best Practices for Naming Variables and Functions
Best Practices for Function/Method
Best Practices for Database
Best Practices for User Interface
Best Practices for Documentation
Best Practices for Web Security
Best Practices for Source Configuration Management
Summary
Part II
Chapter 4: Architecture of an Intranet Application
Understanding Intranet Requirements
Building an Intranet Application Framework
Creating a Database Abstraction Class
Creating an Error Handler Class
Creating a Built-In Debugger Class
Creating an Abstract Application Class
Creating a Sample Application
Summary
Chapter 5: Central Authentication System
How the System Works
Creating an Authentication Class
Creating the Central Login Application
Creating the Central Logout Application
Creating the Central Authentication Database
Testing Central Login and Logout
Making Persistent Logins in Web Server Farms
Summary
Chapter 6: Central User Management System
Identifying the Functionality Requirements
Creating a User Class
User Interface Templates
Creating a User Administration Application
Creating a User Password Application
Creating a Forgotten-Password Recovery Application
Summary
Chapter 7: Intranet System
Identifying Functionality Requirements
Designing the Database
Designing and Implementing the Intranet Classes
Setting Up Application Configuration Files
Setting Up the Application Templates
Intranet Home Application
Installing Intranet Applications from the CD- ROM
Testing the Intranet Home Application
Summary
Chapter 8: Intranet Simple Document Publisher
Identifying the Functionality Requirements
The Prerequisites
Designing the Database
The Intranet Document Application Classes
Setting up Application Configuration Files
Setting Up the Application Templates
The Document Publisher Application
Installing Intranet Document Application
Testing Intranet Document Application
Summary
Chapter 9: Intranet Contact Manager
Functionality Requirements
Understanding Prerequisites
The Database
The Intranet Contact Manager Application Classes
The Application Configuration Files
The Application Templates
The Contact Category Manager Application
The Contact Manager Application
Installing Intranet Contract Manager
Testing Contract Manager
Summary
Chapter 10: Intranet Calendar Manager
Identifying Functionality Requirements
Understanding Prerequisites
Designing the Database
The Intranet Calendar Application Event Class
The Application Configuration Files
The Application Templates
The Calendar Manager Application
The Calendar Event Manager Application
Installing the Event Calendar on Your Intranet
Testing the Event Calendar
Summary
Chapter 11: Internet Resource Manager
Functionality Requirements
Understanding the Prerequisites
Designing the Database
Designing and Implementing the Internet Resource Manager Application Classes
Creating Application Configuration Files
Creating Application Templates
Creating a Category Manager Application
Creating a Resource Manager Application
Creating a Resource Tracking Application
Creating a Search Manager Application
Installing an IRM on Your Intranet
Testing IRM
Security Concerns
Summary
Chapter 12: Online Help System
Functionality Requirements
Understanding the Prerequisites
Designing and Implementing the Help Application Classes
Creating Application Configuration Files
Creating Application Templates
Creating the Help Indexing Application
Creating the Help Application
Installing Help Applications
Testing the Help System
Security Considerations
Summary
Part III
Chapter 13: Tell-a-Friend System
Functionality Requirements
Understanding Prerequisites
Designing the Database
Designing and Implementing the Tell- a- Friend Application Classes
Creating Application Configuration Files
Creating Application Templates
Creating the Tell-a-Friend Main Menu Manager Application
Creating a Tell-a-Friend Form Manager Application
Creating a Tell-a-Friend Message Manager Application
Creating a Tell-a-Friend Form Processor Application
Creating a Tell-a-Friend Subscriber Application
Creating a Tell-a-Friend Reporter Application
Installing a Tell-a-Friend System
Testing the Tell-a-Friend System
Security Considerations
Summary
Chapter 14: E-mail Survey System
Functionality Requirements
Architecture of the Survey System
Designing the Database
Designing and Implementing the Survey Classes
Designing and Implementing the Survey Applications
Developing Survey Execution Manager
Setting Up the Central Survey Configuration File
Setting Up the Interface Template Files
Testing the Survey System
Security Considerations
Summary
Chapter 15: E-campaign System
Features of an E-campaign System
Architecting an E-campaign System
Designing an E-campaign Database
Understanding Customer Database Requirements
Designing E-campaign Classes
Creating Common Configuration and Resource Files
Creating Interface Template Files
Creating an E-campaign User Interface Application
Creating a List Manager Application
Creating a URL Manager Application
Creating a Message Manager Application
Creating a Campaign Manager Application
Creating a Campaign Execution Application
Creating a URL Tracking and Redirection Application
Creating an Unsubscription Tracking Application
Creating a Campaign Reporting Application
Testing the E-Campaign System
Security Considerations
Summary
Part IV
Chapter 16: Command-Line PHP Utilities
Working with the Command-Line Interpreter
Building a Simple Reminder Tool
Building a Geo Location Finder Tool for IP
Building a Hard Disk Usage Monitoring Utility
Building a CPU Load Monitoring Utility
Summary
Chapter 17: Apache Virtual Host Maker
Understanding an Apache Virtual Host
Defining Configuration Tasks
Creating a Configuration Script
Developing makesite
Installing makesite on Your System
Testing makesite
Summary
Chapter 18: BIND Domain Manager
Features of makezone
Creating the Configuration File
Understanding makezone
Installing makezone
Testing makezone
Summary
Part V
Chapter 19: Web Forms Manager
Functionality Requirements
Understanding Prerequisites
Designing the Database
Designing and Implementing the Web Forms Manager Application Classes
Creating the Application Configuration Files
Creating Application Templates
Creating the Web Forms Submission Manager Application
Creating the Web Forms Reporter Application
Creating the CSV Data Exporter Application
Installing the Web Forms Manager
Testing the Web Forms Manager
Security Considerations
Summary
Chapter 20: Web Site Tools
Functionality Requirements
Understanding Prerequisites
Designing the Database
Designing and Implementing the Voting Tool Application Class
Creating the Application Configuration Files
Creating the Application Templates
Creating the Vote Application
Installing the Voting Tool
Testing the Voting Tool
Summary
Part VI
Chapter 21: Speeding Up PHP Applications
Benchmarking Your PHP Application
Buffering Your PHP Application Output
Compressing Your PHP Application Output
Caching Your PHP Applications
Summary
Chapter 22: Securing PHP Applications
Controlling Access to Your PHP Applications
Securely Uploading Files
Using Safe Database Access
Recommended php.ini Settings for a Production Environment
Limiting File System Access for PHP Scripts
Running PHP Applications in Safe Mode
Summary
Part VII
Appendix A: What's on the CD-ROM
System Requirements
What's on the CD
Troubleshooting
Appendix B: PHP Primer
Object-Oriented PHP
Appendix C: MySQL Primer
Using MySQL from the Command- Line
Using phpMyAdmin to Manage MySQL Database
Appendix D: Linux Primer
Installing and Configuring Apache 2.0
Installing and Configuring MySQL Server
Installing and Configuring PHP for Apache 2.0
Common File/Directory Commands
Index
Wiley Publishing, Inc. End-User License Agreement
Nội dung
Configuring Apache By default, Apache reads a single configuration file called httpd.conf. Every Apache source distribution comes with a set of sample configuration files. In the standard Apache source distribution, you will find a directory called conf, which contains sample configuration files with the -dist extension. The first step you need to take before you modify this file is to create a backup copy of the original. The httpd.conf file contains two types of information: com- ments and server directives. Lines starting with a leading # character are treated as comment lines; these comments have no purpose for the server software, but they serve as a form of documentation for the server administrator. You can add as many comments as you want; the server simply ignores all comments when it parses the file. Except for the comments and blank lines, the server treats all other lines as either complete or partial directives. A directive is like a command for the server. It tells the server to perform a certain task in a particular fashion. While editing the httpd.conf file, you need to make certain decisions regarding how you want the server to behave. The following sections describe what these directives mean and how you can use them to customize your server. Listing D-1 shows the default httpd.conf file created in the conf directory of your Apache installation. Most of the comments have been removed, and the code has been edited slightly for brevity. Listing D-1: Default httpd.conf Created from httpd.conf-dist ServerRoot “/usr/local/apache” <IfModule !mpm_netware.c> PidFile logs/httpd.pid </IfModule> Timeout 300 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 15 <IfModule prefork.c> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 ServerLimit 16 </IfModule> <IfModule worker.c> StartServers 2 786 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 786 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 ServerLimit 16 </IfModule> <IfModule perchild.c> NumServers 5 StartThreads 5 MinSpareThreads 5 MaxSpareThreads 10 MaxThreadsPerChild 20 MaxRequestsPerChild 0 ServerLimit 16 </IfModule> Listen 80 <IfModule !mpm_winnt.c> <IfModule !mpm_netware.c> User nobody Group #-1 </IfModule> </IfModule> ServerAdmin you@your.address UseCanonicalName Off DocumentRoot “/usr/local/apache/htdocs” <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory “/usr/local/apache/htdocs”> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all Continued Appendix D: Linux Primer 787 34 549669 AppD.qxd 4/4/03 9:28 AM Page 787 Listing D-1 (Continued) </Directory> UserDir public_html DirectoryIndex index.html index.html.var AccessFileName .htaccess <Files ~ “^\.ht”> Order allow,deny Deny from all </Files> TypesConfig conf/mime.types DefaultType text/plain <IfModule mod_mime_magic.c> MIMEMagicFile conf/magic </IfModule> HostnameLookups Off ErrorLog logs/error_log LogLevel warn LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined LogFormat “%h %l %u %t \”%r\” %>s %b” common LogFormat “%{Referer}i -> %U” referer LogFormat “%{User-agent}i” agent CustomLog logs/access_log combined ServerSignature On Alias /icons/ “/usr/local/apache/icons/” <Directory “/usr/local/apache/icons”> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> Alias /manual “/usr/local/apache/manual” <Directory “/usr/local/apache/manual”> Options Indexes FollowSymLinks MultiViews IncludesNoExec AddOutputFilter Includes html AllowOverride None 788 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 788 Order allow,deny Allow from all </Directory> ScriptAlias /cgi-bin/ “/usr/local/apache/cgi-bin/” <IfModule mod_cgid.c> </IfModule> <Directory “/usr/local/apache/cgi-bin”> AllowOverride None Options None Order allow,deny Allow from all </Directory> IndexOptions FancyIndexing VersionSort AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip AddIconByType (TXT,/icons/text.gif) text/* AddIconByType (IMG,/icons/image2.gif) image/* AddIcon /icons/binary.gif .bin .exe AddIcon /icons/binhex.gif .hqx # Many AddIcon directives are removed # to keep the listing short DefaultIcon /icons/unknown.gif ReadmeName README.html HeaderName HEADER.html IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t AddEncoding x-compress Z AddEncoding x-gzip gz tgz AddLanguage en .en AddLanguage fr .fr AddLanguage de .de # Other AddLanguage directives are removed # to keep the listing short LanguagePriority en da nl et fr de el it ja ko no pl pt pt-br ltz ca es sv tw ForceLanguagePriority Prefer Fallback Continued Appendix D: Linux Primer 789 34 549669 AppD.qxd 4/4/03 9:28 AM Page 789 Listing D-1 (Continued) AddDefaultCharset ISO-8859-1 AddCharset ISO-8859-1 .iso8859-1 .latin1 AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen # Other AddCharset removed to reduce the size # of this listing AddType application/x-tar .tgz AddHandler type-map var <IfModule mod_negotiation.c> <IfModule mod_include.c> Alias /error/ “/usr/local/apache/error/” <Directory “/usr/local/apache/error”> AllowOverride None Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Order allow,deny Allow from all LanguagePriority en es de fr ForceLanguagePriority Prefer Fallback </Directory> ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var # Other ErrorDocument directives have been removed # to keep the listing short. </IfModule> </IfModule> BrowserMatch “Mozilla/2” nokeepalive BrowserMatch “MSIE 4\.0b2;” nokeepalive downgrade-1.0 force-response-1.0 BrowserMatch “RealPlayer 4\.0” force-response-1.0 # Other BrowserMatch directives have been removed # to keep the listing short. <IfModule mod_ssl.c> Include conf/ssl.conf </IfModule> 790 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 790