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
◆ Record ID: A numeric record ID must be in the target list table to identify the customer record. ◆ E-mail field: An e-mail field must be there in the target list table. The field names can be anything. These two fields must be mapped during the list-creation process using the list management application. The e-campaign system allows you to map all the standard personalization fields shown in Table 15-1 during list creation so that you can use them in message personalization. Designing E-campaign Classes Based on the system diagram shown in Figure 15-1, you need to create a set of classes to provide the objects needed to implement the e-campaign system. In the following sections, I discuss the necessary classes in details. Creating a List class The purpose of this class is to provide the List object, which is needed to manipu- late the lists. An implementation of this class can be found in the ch15/apps/ class/class.EcampaignList.php file in the CDROM. This class implements the methods discussed in the following sections. EcampaignList() This is the constructor method. It does the following: ◆ Sets member variables list_tbl, list_field_map, assembly_tbl, unsub_tbl, and bounced_tbl to global configuration variables $ECAMPAIGN_LIST_TBL, $LIST_FIELD_MAP_TBL, $ECAMPAIGN_ASSEMBLY_ TBL , $ECAMPAIGN_UNSUB_TBL, and $ECAMPAIGN_BOUNCED_TBL, respectively. ◆ A member variable called dbi is set to $dbi, which is a DBI object passed from the application. ◆ A member variable called std_map_fields is set to an associative array that holds the field and field type for standard personalization fields sup- ported by the e-campaign system. ◆ Finally, this method calls the setEcampaignListID() method to set the list ID, which can also be passed from the application when creating an object. setEcampaignListID() This method sets the current object’s list ID to the given list ID, which is passed as a parameter. It always returns the current list ID. 516 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 516 getEcampaignListInfo() This method returns all the information about a given list. Information is returned as a standard row object. If no information is found about a list, null is returned. addNewEcampaignList() This method adds a new list to the database. modEcampaignList() This method updates an existing list. addMapping() This method stores standard personalization fields (FIRST, LAST, EMAIL, and so on) mapping information that is used to identify which customer database field matches with which standard personalization fields. getAvailableLists() This method returns a list of available lists. The method returns an associative array where LIST_ID is the key and NAME is the value. deleteList() This method deletes an existing list. prepareLocalList() This method creates a local copy of the list data necessary to execute a campaign. It does the following: ◆ Determines the list of mapped fields. ◆ Makes a SQL statement to get the mapped field data from the customer database table. ◆ Queries the customer database with the prepared statement. ◆ Inserts the data in the assembly table. ◆ Removes the customers who have previously unsubscribed from this list. ◆ Returns the total number of records inserted in the assembly table. pushMappedFields() This is a utility method that pushes a field name into an array if the field name is not null. map() This is a utility method that returns the field name for a given standard contact field name. Chapter 15: E-campaign System 517 19 549669 ch15.qxd 4/4/03 9:26 AM Page 517 getClientDBURL() This method returns the database URL for a given list. It retrieves the database information from the list record and constructs a database_type://user: password ↓tabase_hostname/database_name URL, which can be used to retrieve customer data. getTargetData() This method returns a list of row objects from the assembly table and then deletes the records from the assembly table. This method is used to fetch a specific number of rows from the assembly table for mail delivery. The returned array of rows uses REC_ID as the key and the row object as the value. addToBounced() This method inserts a record in the bounce e-mail table. This record is used in the report to determine how many e-mails bounced during delivery. When an e-mail is not bounced during delivery, it can still be bounced later after delivery by the recipient’s target mail server, which may try to delivery it to an internal mail server within an organization. Therefore, the bounce tracking done in the e-campaign is not 100-percent accurate.In fact,if e-mail addresses aren’t local to the mail server being used, the bounces usually aren’t right away. This problem can be avoided in a future version of the e-campaign system. modifyMapList() This method allows you to modify the standard personalization field map for a given list. Creating a URL class The purpose of this class is to provide the URL object, which is needed to manipu- late the URL. An implementation of this class can be found in ch15/apps/class/ class.EcampaignURL.php . This class implements the methods discussed in the following sections. EcampaignURL() This is the constructor method. It does the following: ◆ Sets the url_tbl variable to the configuration variable called $ECAMPAIGN_URL_TBL, which holds the name of the URL table in the campaign database. 518 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 518 ◆ Sets the home_url variable to configuration variable called $HOME_URL, which holds the home URL. ◆ Sets the dbi variable to the DBI object, which is passed to the URL object from the caller application. addURL() This method inserts a new URL in the URL table within the e-campaign database. getURL() This method gets the URL for a given URL ID. getURLInfo() This method returns the name and URL for a given URL ID from the URL table in the e-campaign database. modURL() This method updates an existing URL in the URL table in the e-campaign database. getURLList() This method returns a list of URLs in an associative array (key = URL_ID, value = name ) from the URL table in the e-campaign database. getURLLocationList() This method returns a list of URLs in an associative array (key = URL_ID, value = URL ) from the URL table in the e-campaign database. deleteURL() This method deletes an existing URL from the URL table in the e-campaign database. Creating a Message class The purpose of this class is to provide the Message object, which is needed to manipulate the message. An implementation of this class can be found in ch15/ apps/class/class.EcampaignMessage.php . This class implements the methods discussed in the following sections. EcampaignMessage() This is the constructor method for the Message class. It does the following: ◆ Sets message_tbl to $ECAMPAIGN_MESSAGE_TBL, which holds the name of the message table. The $ECAMPAIGN_MESSAGE_TBL is set in the ecampaign. conf configuration file. ◆ Sets header_tbl to $MESSAGE_HDRS_TBL, which holds the name of the header table. The $MESSAGE_HDRS_TBL is set in the ecampaign.conf configuration file. Chapter 15: E-campaign System 519 19 549669 ch15.qxd 4/4/03 9:26 AM Page 519 ◆ Sets msg_fields to an associative array, which contains the message table field names and their types (text or number). This associative array is used in other methods to determine which field value needs to be quoted and protected from embedded slashes using the addslashes() method. ◆ Sets hdr_fields to an associative array, which contains the message header table field names and their types (text or number). This associative array is used in other methods to determine which field value needs to be quoted and protected from embedded slashes using the addslashes() method. ◆ Calls setEcampaignMessageID() to set the campaign ID, which is passed to the constructor method from the application. setEcampaignMessageID() This method sets the message ID. getEcampaignMessageInfo() This method returns the message information for a given message ID or the current message ID. getEcampaignHeaderInfo() This method returns message header information for a given message ID or the cur- rent message ID. addNewEcampaignMessage() This method adds a new message in the message table and its headers in the header table. getAvailableMessages() This returns a list of messages in the current e-campaign database. The returned list is an associative array with the message ID (MSG_ID) being the key and the message name (NAME) as the value. deleteMessage() This method deletes a message and its header. UpdateEcampaignMessage() This method updates a message. UpdateEcampaignMessageHdr() This method updates headers of a message. 520 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 520 . lists. An implementation of this class can be found in the ch15/apps/ class/class.EcampaignList .php file in the CDROM. This class implements the methods discussed in the following sections. EcampaignList() This. manipu- late the URL. An implementation of this class can be found in ch15/apps/class/ class.EcampaignURL .php . This class implements the methods discussed in the following sections. EcampaignURL() This. message. An implementation of this class can be found in ch15/ apps/class/class.EcampaignMessage .php . This class implements the methods discussed in the following sections. EcampaignMessage() This