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
Figure 15-12: Mapping database fields. Figure 15-13: Creating a URL. Chapter 15: E-campaign System 551 19 549669 ch15.qxd 4/4/03 9:26 AM Page 551 Add a URL of your choice and give a name to the URL. Submit the URL and it should be stored in the database. Repeat this process as many times as you want, to create multiple URLs. These URLs will be trackable. Creating a message Next create a message by clicking on the Add Msg button. You’ll see a screen like the one in Figure 15-14. Create a message to your liking by filling out the form. You can enter the same information as shown in the screen if you want. Figure 15-14: Creating a message. You can personalize the message, as shown in Figure 15-14, by selecting the personalization menu and inserting the appropriate tags. Due to JavaScript limitations, the personalization tag is always appended to the message at the end. You can simply copy and paste it in the designed location.The same is also true for URLs. 552 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 552 If you want to track URLs, you can insert one or more trackable URLs from the URL list. If you enter the URL directly in the message, it will not be tracked by the redirection application. Only URLs that are inserted from the URL list are tracked. When inserting URLs in the message, consider using <a href=””> label</a> instead of inserting raw URL in the message.The automatically generated redirection URLs are not pretty to look at, so they’re best kept somewhat invisible from the average user by using the HTML anchor link tag. After you’ve created the message, you can preview it or save it. If you decided to preview it, you’ll be asked to fill out the standard personalization field values once, because during preview no real list data from the database is fetched. Save the message after you have previewed. Remember that this e-campaign system only sends an HTML message, so you must use proper HTML tags to format your message so it’s rendered properly in modern e-mail clients such as Outlook Express. Creating a campaign After you’ve created a list, one or more URLs (if you want to add URLs in the mes- sage), and a message, you’re ready to create a campaign. Click on the Add Campaign button in the main user interface shown by ecampaign_mngr.php to add a campaign from an interface similar to Figure 15-15. Figure 15-15: Creating a campaign. Chapter 15: E-campaign System 553 19 549669 ch15.qxd 4/4/03 9:26 AM Page 553 Give a name to your campaign, select a list and a message, and save the cam- paign. That’s all there is to creating a campaign! Now you’re ready to execute this test campaign. Executing a campaign Select the campaign from the bottom of the main user interface shown by ecmapaign_mngr.php, and click on the red Execute button. The campaign will be executed and a status message will be shown as shown in Figure 15-16. Figure 15-16: Executing a campaign. Now access the campaign e-mail in your e-mail client program. Viewing a campaign report After you’ve executed the campaign, the campaign report becomes available imme- diately. You can view the campaign report by selecting the campaign name from the main user interface shown by ecampaign_mngr.php and clicking on the Show Report button. If you view the report before any URL is clicked by any user, the report will show no URL track. If you click on a tracked URL in a message and then check the report, you’ll see your track being reported. You can click on the URL in your message as many times as you want, and you’ll notice that the report accurately reports the unique and total URL clicks. Figure 15-10 shows a sample report. Like URL clicks, the unsubscription tracks are also reported in the report. 554 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 554 Security Considerations The checksum algorithm used in making trackable URL links and unsubscription URL needs to be modified before you start using the redir.php and unsub.php applications in real-world email campaign scenarios. At the least, you should change the value of $SECRET in the configuration file. Because the current algorithms are published in the book, someone can easily guess how to defeat them. For example, the computeCheckSum() method in the redir.php application can be changed to: function computeCheckSum() { global $SECRET; $u = $this->getRequestField(‘u’); $uid = $this->getRequestField(‘uid’); $c = $this->getRequestField(‘c’); return ($u << 4) + ($uid << 3) + ($c << 7) + $SECRET; } Here this version uses different bit shifts for $u, $uid, and $c. Of course you should choose your own values to make sure they are not known to anyone. The best approach would be to come up with a completely new algorithm that does not use even the same bit shifting technique. I will leave that to you to develop. Summary In this chapter you learned to develop a simple email campaign system that allows you to send personalized, URL tracked HTML messages to email addresses found in MySQL databases. Note that since the email campaign system uses your default mail transport agent (i.e. mail server), the performance will very based on your mail server’s abilities. Chapter 15: E-campaign System 555 19 549669 ch15.qxd 4/4/03 9:26 AM Page 555 . trackable URL links and unsubscription URL needs to be modified before you start using the redir .php and unsub .php applications in real-world email campaign scenarios. At the least, you should change. campaign Select the campaign from the bottom of the main user interface shown by ecmapaign_mngr .php, and click on the red Execute button. The campaign will be executed and a status message will. campaign report by selecting the campaign name from the main user interface shown by ecampaign_mngr .php and clicking on the Show Report button. If you view the report before any URL is clicked by