1. Trang chủ
  2. » Công Nghệ Thông Tin

Secure PHP Development- P115 pps

5 91 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Secure PHP Development

    • Front Matter

      • Preface

        • Is This Book for You?

        • How This Book Is Organized

        • Tell Us What You Think

      • Acknowledgments

      • Contents at a Glance

      • Contents

    • Part I

      • Chapter 1: Features of Practical PHP Applications

        • Features of a Practical PHP Application

        • Employing the Features in Applications

        • Summary

      • 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

◆ First, it checks to see if all required fields — campaign name ($name), list ID ($lid), and message ID ($mid) — are provided. If not, error messages are displayed and the user is returned to the previous screen. ◆ A Campaign object is created and its addCampaign() is called to add the campaign in the database. ◆ Finally, an appropriate status message reflecting the success or failure of the add operation is displayed. updateCampaign() This method updates an existing campaign in the database as follows: ◆ First, it checks to see if all required fields — campaign name ($name), list ID ($lid), and message ID ($mid) — are provided. If not, error messages are displayed and the user is returned to the previous screen. ◆ A Campaign object is created and its modifyCampaign() is called to modify the campaign in the database. ◆ Finally, an appropriate status message reflecting the success or failure of the modification operation is displayed. Creating a Campaign Execution Application The campaign execution application delivers e-mails by fetching the appropriate list data and localizing them in the assembly table and then delivering e-mails to them. Because large e-mail campaigns require a great deal of time, performing them in one shot is not possible via the Web due to the potential for browser timeout. This is why this execution application performs a chunk-size number of delivery and then calls itself from the Web status screen using an HTTP meta refresh trick. The entire execution process is shown in Figure 15-7. The campaign execution application called ecampaign_execution.php, which can be found in ch15/apps directory in the CDROM, performs the e-mail delivery using the methods discussed in the following sections. run() This method calls the executeCampaign() method to perform the e-mail delivery task. Chapter 15: E-campaign System 541 19 549669 ch15.qxd 4/4/03 9:26 AM Page 541 Figure 15-7: How the campaign execution application works. executeCampaign() This method performs all the tasks necessary to execute the campaign. It works as follows: ◆ If the user has not selected a campaign ID ($campaign_id) from the main user interface to execute, an alert message is displayed and user is returned to the main interface. ◆ A Campaign object is created, and the selected campaign data is loaded. ◆ If the selected campaign is loaded, its status is checked using the getStatus() method. If the status is -1, then the campaign execution has already finished. The status value is stored in the $lastrow variable. ◆ The campaign’s message ID is retrieved via the Campaign object’s getMessageID(). Get List ID and Message ID for the campaign Fetch mapped fields from remote database and store in assembly table. Remove records that match rows in unsubscription table Get message template from database Get a chunk of records from the assembly table. Load the records in memory and delete the records from the assembly table Deliver emails to the current chunk of records Set up HTML meta refresh tag to call self and restart the entire process until campaign is completely executed Load list configuration data Outgoing emails 542 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 542 ◆ The campaign’s list ID is retrieved via the Campaign object’s getListID(). ◆ The server name and the application path are stored in $server and $appPath variables, respectively. ◆ If $lastrow is empty, then this is the first time the campaign is being run. In other words, the executeCampaign() method is running for the first time for this campaign. So it needs to assemble the campaign data in the e-campaign database by fetching the required data from the remote table in the database pointed by the list configuration. ◆ A List object is used to retrieve the client database URL using the getClientDBURL() method. A connection to the client database holding the list is made using a DBI object called $client_dbi. ◆ The prepareLocalList() of the List object is called to prepare the assembly table. ◆ If the prepareLocalList() method returns 0, then there are no data to pump out via e-mail and, therefore, an error message is shown. ◆ The getTargetData() method is used to retrieve chunk-size (set by $MAX_DELIVERY_AT_A_TIME in the ecampaign.conf configuration file) records to execute. ◆ A Message object is created and message data is retrieved using the getEcampaignMessageInfo() of the object. If message data is not found, the execution halts with an error message. ◆ The body of the message is retrieved from the Message object and it is inserted into a message template. ◆ The message headers are retrieved using the getEcampaignHeaderInfo(). E-mail is sent via the built-in mail() method. ◆ For each record in the current chunk or rows, the message is personalized using the data retrieved from the assembly table, the URL tags are replaced with redirection URL, and the UNSUB tag is replaced with a personalized unsubscription link. ◆ The campaign status field is set to indicate where the next chunk should start. ◆ A status template is shown after each chunk size of message is sent. This template has a meta refresh tag, which recalls the execution application after $MAX_WAIT_PER_DELIVERY (configuration variable) seconds to con- tinue with the next chunk of messages. authorize() See the authorize() method in the e-campaign user interface application called ecampaign_mngr.php for details. Chapter 15: E-campaign System 543 19 549669 ch15.qxd 4/4/03 9:26 AM Page 543 Creating a URL Tracking and Redirection Application When the campaign execution application sends e-mail, the URLs are transformed into the redirection URL. Figure 15-8 shows how such redirection URLs are tracked and redirected using the URL tracking application. Figure 15-8: How the URL tracking and redirection application works. The redir.php, which can be found in the ch15/apps directory in the CDROM, implements the tracking and URL redirection using the following methods. run() This method first determines if the redirection request mode is test or not. If the redirection mode is test, which is true during message preview, the redirectTest() method is called to redirect the tester to the target URL without recording the track in the database. If the mode is not test, the checksum value of the redirection request is com- pared with the calculated checksum. If both checksum values match, the redirection Yes Show error message Start URL Tracking ApplicationCampaign Message Is URL Request Valid? Locate URL target and redirect user to the target URL End No E-campaign Database Add track record in database Dear Joe, Thank you for visiting our Web site and filling out the inquiry form. Based on your interest we have identified the following resources for you. Please visit at your convenience. Click here to visit ROI Mail Thanks again! Kind Regards, PHP Team, EVOKNOW Click here to remove from future mailing 544 Part III: Developing E-mail Solutions 19 549669 ch15.qxd 4/4/03 9:26 AM Page 544 request is considered valid and the keepTrackAndRedirect() method is called to track and redirect the end-user to the target URL. computeCheckSum() This method implements a simple checksum algorithm using the URL ID ($u), USER ID ($uid), campaign ID ($c), and a random number stored in configuration file called $SECRET. This checksum value is compared with the campaign-execution-application- generated checksum stored in the redirection link to check the validity of the redi- rection request. Using this checksum technique, we can avoid invalid requests from unfriendly users who want to distort the tracking data. keepTrackAndRedirect() This method tracks the URL request in the database and redirects the user to the tar- get URL. It creates a URL Track object and calls the storeTrack() method to store the track data. It also creates a URL object and gets the URL for the given URL ID ($u) and redi- rects the user to the target URL via the HTTP location header. redirectTest() This method creates a URL object and redirects the user to the target URL by finding the target URL using the getURL() method and redirecting using the HTTP location header. Creating an Unsubscription Tracking Application When an end-user clicks on the unsubscription link sent by the campaign execution application, it is processed by the unsubscription process shown in Figure 15-9. The unsub.php, which can be found in ch15/apps directory in the CDROM, implements the unsubscription application using the following methods. run() This method first determines if the unsubscription redirection request mode is test or not. If the mode is test, which is true during message preview, the alert() method is used to display a message stating that the unsubscription request is a test and therefore it isn’t tracked and stored in the database. Chapter 15: E-campaign System 545 19 549669 ch15.qxd 4/4/03 9:26 AM Page 545 . shown in Figure 15-7. The campaign execution application called ecampaign_execution .php, which can be found in ch15/apps directory in the CDROM, performs the e-mail delivery using the methods discussed. application. Figure 15-8: How the URL tracking and redirection application works. The redir .php, which can be found in the ch15/apps directory in the CDROM, implements the tracking and URL redirection using. execution application, it is processed by the unsubscription process shown in Figure 15-9. The unsub .php, which can be found in ch15/apps directory in the CDROM, implements the unsubscription application using the

Ngày đăng: 07/07/2014, 07:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN