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

Secure PHP Development- P84 pptx

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

authorize() This method authorizes everyone on the intranet to view the resource manager and, therefore, always returns TRUE. Creating a Search Manager Application This application, irm_search_mngr.php, is responsible for managing search oper- ations. This application is included on the CD-ROM in the ch11/apps directory. This application has the following methods. run() When the application is run, this method is called. It does the following: ◆ It creates a theme object, $this->themeObj. ◆ The current user’s theme choice is stored in $this->theme by calling the getUserTheme() method of the theme object created. ◆ Next, if the query parameter $cmd is set to search, it calls the displaySearchResult() method; if $cmd is set to previous or next, then it calls displaySearResultNextandPrevious(); if it is set to mostvisited, then it calls showMostVisitedResource() to show the most visited resources; if it is set to topranking, then it calls showTopRankingResource() to show the top-ranking resources; if the $cmd is set to title, rating, or addedby, then it calls sortAndDisplay(); and if $cmd is set to nothing then it calls showMenu(). In other words, the run() method decides which functionality is requested by the user and calls the appropriate driver method to perform the desired operations. populateCategory() This method is used to populate the list of all available main categories. It works as follows: ◆ This method is called with the template name ($template), the block name ($blockName), and the default selected value ($selectValue). ◆ A new Category object called $categoryObj is created and the getCategoryList() method of that object is called to generate the avail- able main categories name and stored in an array named $categoryList. 386 Part II: Developing Intranet Solutions 14 549669 ch11.qxd 4/4/03 9:25 AM Page 386 ◆ If the category list is not empty, then it sets the category ID and name for each category in the list; otherwise, it returns null. ◆ If $blockName is set to jsblock, then it parses the jsCategoryBlock and sets the output into the $category variable. Otherwise, it parses the categoryBlock block if the category ID is not equal to the $selectValue and sets the output in the $category variable. ◆ Finally, this method returns the value of $category variable. populateSubCategory() This method is used to populate the subcategory list for the given category. It works as follows: ◆ This method is called with the template name ($template), category ID ($cat_id), and block name ($blockName), where the subcategory will be populated. ◆ A new object of the Category class is created named $subcatagoryObj, and the getSubCategoryList() method is called from the class with the given category ID ($cat_id) as a parameter. The subcategory list is then stored in the array named $subcategoryList. ◆ If the subcategory list is not there, then it checks the given block name. Then it sets the subcategory name and ID in respective variables in the given block and sets the output in the $subCategory variable parsing the block. ◆ Finally, this method returns the subcategory list stored in the $subCategory. populateResource() This method is used to display resources to show the search result. It works as follows: ◆ This method is called with a template name ($template), resource display starting point ($startingPoint), and block name ($blockName) where the resource information is displayed. ◆ Next it sets the resource information in the template. ◆ Then It sets the alternative different colors in rows to display, parses each row, and stores it in the $resource variable. ◆ Finally, it returns the value of $resource. showMenu() This method is used to display the menu shown in the search index page. It works as follows: Chapter 11: Internet Resource Manager 387 14 549669 ch11.qxd 4/4/03 9:25 AM Page 387 ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ It creates an object of the Category class named $catObj and shows the category and subcategory names with the number of resources belonging to respective categories. ◆ Then It calls the populateCategory() method to show the category list in the drop-down list in the template. ◆ It creates an object of the User class named $userObj and calls the getUserList() method to populate all the user lists. ◆ Next it checks whether the viewer is an administrator of the IRM applica- tion or not. If she is not an administrator, it gives only the add resource link. On the other hand, If she is an administrator, it gives the category and resource manager link along with the add resource. ◆ Finally, the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. displaySearchResult() This method is used to display the results after executing a search operation. It works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Then it creates a Resource class object named $resourceObj and calls the searchResource() method with the search criteria given by the user and stores it in the array named $resourceList. ◆ It creates a User class object named $userObj and calls the getUserInfo() method to get the name of the user who added the resource. ◆ Next, it assigns the search result in the SESSION_SEARCH_LIST session variable and assigns the value in the SESSION_PAGE_SIZE session variable if it is given by the user from the search interface. If it is not given by the user, then it assigns the default value (DEFAULT_PAGE_SIZE), which is con- figurable via irm.conf. ◆ Then It calls the populateResource() method to show the search result. ◆ Finally, the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. 388 Part II: Developing Intranet Solutions 14 549669 ch11.qxd 4/4/03 9:25 AM Page 388 sortAndDisplay() This method is used to sort the search result according to user’s criteria. This method works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ This method stores the value of the session variable in an array object named $data, which is used to sort the data. ◆ Next it checks the $cmd value, which contains sorting criteria. If $cmd is set to ‘title’, then it calls usort() with ‘sortByResourceTitle’ as the function parameter to sort the search result according to resource title and checks the $sorttype value. Depending on the value of $sorttype, array_reverse() is called to reverse the sorting result. ◆ If the $cmd is set to rating, then it calls usort() with sortByResourceRating as the function parameter to sort the result depending on the $sorttype value according to the resource rating. ◆ If the $cmd is set to addedby, then it calls usort() with ‘sortByResourceAddedBy’ as the function parameter. ◆ Then the method registers the SESSION_SEARCH_LIST session variable and assigns the sorted result in that variable. ◆ Next it calls the populateResource() method to show the sorted result. ◆ Finally, the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. displaySearResultNextandPrevious() This method is used to display the previous/next page results after executing a search operation. This method works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Now it checks the $cmd value. If it is set to ‘next’, then it generates the next page resource starting point. If $cmd is set to ‘previousBlock’, then it generates the previous page starting point. ◆ Next it calls the populateResource() method to show the sorted result. ◆ Finally, the showWithTheme() method is called with the output of parsing the main HTML template block to embed with the user’s theme template. Chapter 11: Internet Resource Manager 389 14 549669 ch11.qxd 4/4/03 9:25 AM Page 389 showTopRankingResource() This method is used to display the top-ranked resources. It works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Next it registers the session variables SESSION_SEARCH_LIST and SESSION_PAGE_SIZE to store the search output and number of resources that needs to be shown each page, respectively. ◆ Then it creates a Resource class object named $resourceObj and calls the getTopRankingList() method with the defined variable ‘TOPRANKING’ (which is configurable in the irm.conf) to get the top-ranking resource. ◆ It creates a User class object named $userObj and calls getUserInfo() method to get the name of the user who added the resource. ◆ It sets the result and parses the main block. Then it calls the showWithTheme() method to embed the output with the user’s theme template. showMostVisitedResource() This method is used to display the most visited resources. It works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Next it registers the session variables SESSION_SEARCH_LIST and SESSION_PAGE_SIZE to store the search output and number of resources to be shown in each page, respectively. ◆ Then It creates an object of Resource class named $resourceObj and calls the getMostVisitedResource() method with a arameter called MOSTVISITED, which specifies the number of the most visited resource to be shown (configurable in the irm.conf). ◆ It calls the getResourceInfo() method to get information for each resource and stores in the session variable SESSION_SEARCH_LIST and displays the search result. ◆ Finally the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. showWithTheme() This method is use to show the user’s theme template. It works as follows: 390 Part II: Developing Intranet Solutions 14 549669 ch11.qxd 4/4/03 9:25 AM Page 390 . and, therefore, always returns TRUE. Creating a Search Manager Application This application, irm_search_mngr .php, is responsible for managing search oper- ations. This application is included on the CD-ROM

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