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

Secure PHP Development- P53 pot

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

■ Uses the logUserIn() method of the $analyzer object to log in the user. ■ Calls the reportDriver() method to render the updated access report. ◆ authorize(): This method authorizes access to this application. It works as follows: ■ It checks the current user ID using the getUID() method. Because all valid user IDs are positive numbers, it creates the DBI object called $user_dbi that points to the central user-authentication database (USER_DB_URL). ■ A user object called $userObj is created using the $user_dbi and the current user ID. ■ The getType() method is called to determine the user type of the cur- rent user. If the current user is of type administrator (ADMIN_TYPE), the $isAdmin variable is set to TRUE. ■ This method always returns TRUE, because everyone on the intranet can view this application. ◆ reportDriver(): This method generates and displays the user-access report. It works as follows: ■ Generates the appropriate report. For example, if the report type ($rpt) is a weekly report, the generateWeeklyReport() method is called to generate the weekly report. ■ Displays the report using the displayReport(). ◆ generateDailyReport(): This method generates the access report of a user for a specific day. This method works as follows: ■ If the user viewing the page has administrator privileges, this method shows her the admin block that includes a list of users from which she can select any user’s daily report. This block also includes a link to the overall summary report and the buttons for force login and force logout. ■ It finds out the timestamp of the day to be shown. Because the user has the option to scroll through the days by using the >> and << buttons, this timestamp is not always the current day. ■ It finds out the starting and ending timestamps of the given day and uses the ActivityAnalyzer object to retrieve the office hours and the extra hours for the day for that user. ■ It returns the formatted information that includes the date, the day, the start time, the end time, the total office hours, and the total extra hours. It also includes a brief summary with totals and averages. Chapter 7: Intranet System 231 10 549669 ch07.qxd 4/4/03 9:25 AM Page 231 ◆ generateWeeklyReport(): This method generates an access report of a user for a specific week. This method works as follows: ■ If the user viewing the page has administrator privileges, this method shows her the admin block that includes a list of users from which she can select any user’s daily report. The block includes a link to the over- all summary report and the buttons for force login and force logout. ■ It finds out the timestamp of the week to be shown. Because the user has the option to scroll through the weeks by using the >> and << but- tons, this timestamp is not always the current week. ■ It finds out the starting and ending timestamps of the given week and uses the ActivityAnalyzer object to retrieve the office hours and the extra hours for each day of the given week for that user. ■ It returns the formatted information that includes the date, the day, the start time, the end time, the total office hours, and the total extra hours, as well as a brief summary with totals and averages. ◆ generateMonthlyReport(): This method generates an access report of a user for a specific month. This method works as follows: ■ If the user viewing the page has administrator privileges, this method shows him the admin block that includes a list of users from which he can select any user’s monthly report. This includes a link to the overall summary report and the buttons for force login and force logout. ■ It finds out the timestamp of the month to be shown. As the user has the option to scroll through the months by using the >> and << but- tons, this timestamp is not always the current month. ■ It finds out the starting and ending timestamps of the given month and uses the ActivityAnalyzer object to retrieve the office hours and the extra hours for each day of the given month for that user. ■ It returns the formatted information that includes the date, the day, the start time, the end time, the total office hours, and the total extra hours and includes a brief summary with totals and averages. ◆ displayReport(): This method displays user-access reports. It works as follows: ■ It uses the Theme class to find out the preferred theme for this user. ■ It creates a new ThemeTemplate object called $themetemplate and loads the preferred theme template. ■ The content block of the $themeTemplate is loaded with $report, which is passed to this method as a parameter. ■ It renders the contents of $themeTemplate to the user. 232 Part II: Developing Intranet Solutions 10 549669 ch07.qxd 4/4/03 9:25 AM Page 232 Other methods for this application include those in the following table: Method Description convert() Converts time stamp values as taken from the seconds as input into hours, minutes, and remaining seconds and returns the resultant string. getWeeklyTSRange() Returns the weekly time stamp range for a given day, in an array containing the starting and ending time stamps of the week with any time stamp as input. getMonthlyTSRange() Returns the monthly time stamp range for a given day, in an array containing the starting and ending time stamps of the month with any time stamp as input. now() Returns the time stamp corresponding to the current date and time. Admin access reporter application The admin access reporter application, admin_access_reporter.php, shows the overall access report of all the employees/users that can be viewed only by the administrators. It is included on the CD-ROM in the ch07/apps directory. This application has the following methods. ◆ run(): When the application is run, this method is called. It checks whether the user has administrative privileges. If the user does not have administrative privileges, it exits from the application. If the user has administrative privileges, it calls the reportDriver() method. ◆ authorize(): This method authorizes only administrators to view the application. If the user has administrative privileges, it returns TRUE. Otherwise, it returns FALSE. It uses the $userObj object of User class to get the current user type; sets the isAdmin property of the application, depending on the type it finds; and returns the isAdmin property, which identifies whether the user is an administrator. ◆ generateDailyReport(): This method generates an access report of all users for a specific day. This method works as follows: ■ It finds out the timestamp of the day to be shown. Because the user has the option to scroll through the days by using the >> and << buttons, this timestamp is not always the current day. Chapter 7: Intranet System 233 10 549669 ch07.qxd 4/4/03 9:25 AM Page 233 ■ It finds out the starting and ending timestamps of the given day and then uses the ActivityAnalyzer object to retrieve the office hours and the extra hours for the day for all users. ■ It returns the formatted information that includes the user name, total office hours, and total extra hours of all users for that day, as well as a brief summary with totals and averages. ◆ generateWeeklyReport(): This method generates an access report of a user for a specific week. This method works as follows: ■ It finds out the timestamp of the week to be shown. Because the user has the option to scroll through the weeks by using the >> and << but- tons, this timestamp is not always the current week. ■ It finds out the starting and ending timestamps of the given week and uses the ActivityAnalyzer object to retrieve the office hours and the extra hours for each day of the given week for all users. ■ It returns the formatted information that includes the username, total office hours, and total extra hours of all users for that week, as well as a brief summary with totals and averages. ◆ generateMonthlyReport(): This method generates an access report of a user for a specific month. This method works as follows: ■ It finds out the timestamp of the month to be shown. Because the user has the option to scroll through the months by using the >> and << buttons, this timestamp is not always the current month. ■ It finds out the starting and ending timestamps of the given month and uses the ActivityAnalyzer object to retrieve the office hours and the extra hours for each day of the given month for all users. ■ It returns the formatted information that includes the username, total office hours, and total extra hours of all users for that month and a brief summary with totals and averages. ◆ displayReport(): This method is used to display user-access reports. It works as follows: ■ It uses the Theme class to find out the preferred theme for this user. ■ It creates a new ThemeTemplate object called $themeTemplate and loads the preferred theme template. ■ The content block of the $themeTemplate is loaded with $report, which is passed to this method as a parameter. ■ The contents of the $themeTemplate are rendered to the user. 234 Part II: Developing Intranet Solutions 10 549669 ch07.qxd 4/4/03 9:25 AM Page 234 The following tables describes the other methods for this application: Method Description reportDriver() Generates the appropriate report based on the type of report requested. (For example, if report type ( $rpt) is weekly report ( WEEKLY = 2), generateWeeklyReport() is called to generate the report.) It then calls displayReport() to display the report. convert() Converts timestamp values as taken from the seconds as input into hour, minute, and remaining seconds and returns the resultant string. getWeeklyTSRange() Returns the weekly timestamp range for a given day. This method returns an array containing the starting and ending timestamps of the week with any timestamp as input. getMonthlyTSRange() Returns the monthly timestamp range for a given day. This method returns an array containing the starting and ending timestamps of the month with any timestamp as input. now() Returns the timestamp corresponding to the current date and time. toggleSortCriteria() Toggles the sort criteria from ascending to descending and vice-versa. It takes the string ‘reverse’ or null as input and returns the other one of the two as output in an exclusive manner. sortByExtra() Sorts the report by extra hours of the users in descending order. It takes two arrays as parameters and returns 1 if the first one’s extra hour value is less than the other one’s; otherwise, it returns –1. sortByOffice() Sorts the report by office hours of the users in descending order. It takes two arrays as parameters and returns 1 if the first one’s office hour value is less than the other one’s; otherwise, it returns –1. reversesortByExtra() Sorts the extra hours of the users in ascending order. It takes two arrays as parameters and returns –1 if the first one’s extra hour value is less than the other one’s; otherwise, it returns 1. reversesortByOffice() Sorts the office hours of the users in ascending order. It takes two arrays as parameters and returns –1 if the first one’s office hour value is less than the other one’s; otherwise, it returns 1. Chapter 7: Intranet System 235 10 549669 ch07.qxd 4/4/03 9:25 AM Page 235 . time. Admin access reporter application The admin access reporter application, admin_access_reporter .php, shows the overall access report of all the employees/users that can be viewed only by the administrators.

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