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

Secure PHP Development- P106 potx

5 137 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

Listing 14-1 (Continued) | + forms | + apps | + class | + templates | + images To configure the applications for your directory structure, you’ll have to change the settings shown in Table 14-1. TABLE 14-1 THE survey.conf SETTINGS THAT YOU NEED TO CHANGE Fields Explanation $PEAR_DIR This should be set to the directory where you have installed the PEAR packages. This is needed because the DB class needed for class.DBI.php is part of the PEAR packages. $PHPLIB_DIR This should be set to the directory where the PHPLIB packages are stored. This is needed because the Template class ( template.inc) is part of the PHPLIB packages. $APP_FRAMEWORK_DIR This directory should point to our application framework class directory. $AUTHENTICATION_URL This URL should point the central authentication application ( login.php), which is part of the application framework. $LOGOUT_URL This URL should point to the central logout application ( logout.php), which is part of the application framework. $ROOT_PATH This directory point to the document root directory of your Web site where you host this application. $REL_ROOT_PATH This should point to the relative path, which is the parent of the apps directory. 496 Part III: Developing E-mail Solutions 18 549669 ch14.qxd 4/4/03 9:26 AM Page 496 Fields Explanation $SURVEY_DB_URL This URL should be configured to allow you to connect to the survey database via the named host using the named user name and password. $MAX_DELIVERY_AT_A_TIME This should be set to the maximum number of e-mail deliveries per run by the Survey Execution Manager. You should not set this number to a very large number. $MAX_WAIT_PER_DELIVERY This number sets how many seconds are past before the Survey Execution Manager is recalled via the meta refresh tag. Setting Up the Interface Template Files The applications use a number of template files that are provided in the ch14/ apps/templates directory in the CD-ROM. These files are discussed in Table 14-2. TABLE 14-2 INTERFACE TEMPLATES File Name Purpose survey_menu.ihtml This is the Survey Menu template. survey_add.ihtml This template is used to add surveys. survey_add_form.ihtml This template is used to add survey forms. survey_add_label.ihtml This template is used to add survey form labels. survey_add_list.ihtml This template is used for adding survey lists. survey_execute.ihtml This template is used for executing a survey. It shows the execution status information. survey_report.ihtml This template is used for showing the survey report. survey_status.ihtml This template is used to show status messages. This template is used by the PHPApplication’s show_status() method. powered_by.html This HTML file contains the footer that is added to the survey sent to the end user. Chapter 14: E-mail Survey System 497 18 549669 ch14.qxd 4/4/03 9:26 AM Page 497 These templates also use images that are stored in an image directory called images within the template directory pointed by the $TEMPLATE_DIR variable in the survey.conf file. Setting Up the Central Survey Messages File All the applications in the survey suite use a central messages file called survey. messages , which is shown in Listing 14-2. Listing 14-2: survey.messages <?php $MESSAGES[‘US’][‘LIST_DELETE_SUCCESSFUL’] = “List deleted.”; $MESSAGES[‘US’][‘LIST_DELETE_FAILED’] = “List not deleted.”; $MESSAGES[‘US’][‘LIST_UPLOAD_SUCCESSFUL’] = “List upload successful.”; $MESSAGES[‘US’][‘LIST_UPLOAD_FAILED’] = “List upload failed.”; $MESSAGES[‘US’][‘FORM_UPLOAD_SUCCESSFUL’] = “Form upload successful.”; $MESSAGES[‘US’][‘FORM_UPLOAD_FAILED’] = “Form upload failed.”; $MESSAGES[‘US’][‘FORM_DELETED’] = “Form deleted.”; $MESSAGES[‘US’][‘FORM_NOT_DELETED’] = “Form not deleted.”; $MESSAGES[‘US’][‘SURVEY_ADD_FAILED’] = “Survey not added.”; $MESSAGES[‘US’][‘SURVEY_ADD_SUCCESSFUL’] = “Survey added.”; $MESSAGES[‘US’][‘SURVEY_DELETE_SUCCESSFUL’] = “Survey deleted.”; $MESSAGES[‘US’][‘SURVEY_DELETE_FAILED’] = “Survey not deleted.”; $MESSAGES[‘US’][‘SURVEY_SENT’] = “Survey sent.”; ?> The default language of the messages is set in the survey.conf file using the $DEFAULT_LANGUAGE parameter. If you want to port this application to a different language, copy the above messages at the end of this file and change US to your two-digit language name and replace the English error messages with the appropri- ate translation. Google has a translation tool that can be used to translate simple messages to other languages such as Spanish, Italian, German, and so on. See www. google.com for details. Setting Up the Central Survey Errors File Like the central messages file, all the applications in the survey system use the survey. errors file for error messages, as shown in Listing 14-3. 498 Part III: Developing E-mail Solutions 18 549669 ch14.qxd 4/4/03 9:26 AM Page 498 Listing 14-3: survey.errors <?php // Errors for survey apps $ERRORS[‘US’][‘APP_FAILURE’] = “Application failure”; $ERRORS[‘US’][‘ADD_SURVEY_LIST_REQ_MISSING’] = “Please enter list and file name”; $ERRORS[‘US’][‘ADD_SURVEY_FORM_REQ_MISSING’] = “Please enter form and file name”; $ERRORS[‘US’][‘IHTML_REQUIRED’] = “IHTML file expected”; $ERRORS[‘US’][‘FIELD_NUM_INVALID’] = “Number of fields has to be a number greater than zero”; $ERRORS[‘US’][‘LIST_NO_LIST_CHOSEN’] = “Please select a list.”; $ERRORS[‘US’][‘FORM_NOT_SELECTED’] = “Please select a form.”; $ERRORS[‘US’][‘ADD_SURVEY_NAME_MISSING’] = “Please enter a survey name.”; $ERRORS[‘US’][‘ADD_SURVEY_LIST_MISSING’] = “Please select a survey list.”; $ERRORS[‘US’][‘ADD_SURVEY_FORM_MISSING’] = “Please select a survey form.”; $ERRORS[‘US’][‘DEL_SURVEY_ID_MISSING’] = “Please select a survey.”; $ERRORS[‘US’][‘RUN_SURVEY_ID_MISSING’] = “Please select a survey.”; $ERRORS[‘US’][‘ADD_FORM_MISSING_SUBJECT’] = “Please enter a subject line.”; $ERRORS[‘US’][‘ADD_FORM_MISSING_FROM’] = “Please enter a from address.”; $ERRORS[‘US’][‘SURVEY_EXECUTION_FAILED’] = “Survey execution failed.”; $ERRORS[‘US’][‘SURVEY_ALREADY_SUBMITTED’] = “Survey already submitted.”; $ERRORS[‘US’][‘SURVEY_SUBMITTED’] = “Survey submitted. \\n\\nThank you.”; $ERRORS[‘US’][‘REPORT_NOT_SELECTED’] = “Please select a report.”; ?> Creating Survey Forms The survey forms that are used in the survey system are HTML files that have a few specific requirements. They are listed here: ◆ Form action value should be set to {SERVER_URL}{APP_PATH}/ {SURVEY_RESPONSE} as shown here: <form action=”{SERVER_URL}{APP_PATH}/{SURVEY_RESPONSE}”> ◆ The form must contain the mainBlock comments as shown here: <! BEGIN mainBlock > Your form data goes here <! ENDBEGIN mainBlock > ◆ You can only personalize the form using the {FIRST} and {LAST} tags. Chapter 14: E-mail Survey System 499 18 549669 ch14.qxd 4/4/03 9:26 AM Page 499 ◆ Each field in the HTML form must be named using numbers. ◆ Each question can be either a text box (the maximum size is limited by the database, currently set to 50 characters), a checkbox, a radio button, or a drop-down select list. ◆ A set of hidden fields are a must to allow proper handing of the form. These fields are shown here: <input type=hidden name=”SURVEY_ID” value=”{SURVEY_ID}”> <input type=hidden name=”SUID” value=”{SUID}”> <input type=hidden name=”EXEC_ID” value=”{EXEC_ID}”> <input type=hidden name=”EXEC_TS” value=”{EXEC_TS}”> A sample form is available in ch14/forms directory in the CDROM. The {POWERED_BY_LOGO} tag is optional. Testing the Survey System When you’ve configured the application using survey.conf and installed it per the configuration under your web server’s document root, you can test the system. To test the system you need to create a CSV file with the following format: EMAIL, FIRST, LAST A sample CSV file called mycustomers.csv is shown in Listing 14-4. Listing 14-4: mycustomers.csv KABIR@evoknow.com,MOHAMMED,KABIR joe@evoknow.COM,Joe,Gunchy jennifer@evoknow.com,JENNIFER,GUNCHY abe@EVOKNOW.COM,ABE,NONE rome@EvoKnow.Com,rome,ahead Notice that this list has badly formatted e-mails and names. Because the List Manager can filter name and e-mail for case issues, you can fix these during list creation. 500 Part III: Developing E-mail Solutions 18 549669 ch14.qxd 4/4/03 9:26 AM Page 500 . needed because the DB class needed for class.DBI .php is part of the PEAR packages. $PHPLIB_DIR This should be set to the directory where the PHPLIB packages are stored. This is needed because. authentication application ( login .php) , which is part of the application framework. $LOGOUT_URL This URL should point to the central logout application ( logout .php) , which is part of the application framework. $ROOT_PATH. PHPLIB packages are stored. This is needed because the Template class ( template.inc) is part of the PHPLIB packages. $APP_FRAMEWORK_DIR This directory should point to our application framework class

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

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

TÀI LIỆU LIÊN QUAN