Secure PHP Development- P60 ppsx

5 253 0
Secure PHP Development- P60 ppsx

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

Thông tin tài liệu

| | + ld_tools (Intranet Simple Document Publisher Application) | | | + apps (publisher apps and configuration files) | | | + class (publisher apps and configuration) | | | + templates (publisher HTML templates) | | | + themes symbolically linked + By changing the following configuration parameters in ld.conf, you can mod- ify the directory structure to fit your site requirements. $ROOT_PATH = $_SERVER[‘DOCUMENT_ROOT’]; $REL_PHOTO_DIR = ‘/photos’; $PHOTO_DIR = $ROOT_PATH . $REL_PHOTO_DIR; $REL_ROOT_PATH = ‘/ld_tool’; $REL_APP_PATH = $REL_ROOT_PATH . ‘/apps’; $TEMPLATE_DIR = $ROOT_PATH . $REL_APP_PATH . ‘/templates’; $CLASS_DIR = $ROOT_PATH . $REL_APP_PATH . ‘/class’; $REL_TEMPLATE_DIR = $REL_APP_PATH . ‘/templates/’; $THEME_TEMPLATE_DIR = $TEMPLATE_DIR . ‘/themes’; The themes directory within the ld_tools/apps/templates should be a symbolic link pointing to the themes directory of the Intranet home application themes. For the given directory structure the ld_tools/apps/templates/themes can be created using the following command: ln -s home/templates/themes ld_tools/apps/templates/themes The above command assumes that it is being run from the %DocumentRoot% (htdocs) directory of the intranet Web site. If you cannot make symbolic links between two directories, you can simply copy the home/templates/themes directory as ld_tools/apps/templates/themes. Also, you can set the $THEME_TEMPLATE_DIR to $ROOT_PATH . ‘/home/templates/themes’ . The messages file The messages displayed by the publisher applications are stored in the ch8/apps/ld.messages file in the CDROM. You can change the messages using a text editor. 266 Part II: Developing Intranet Solutions 11 549669 ch08.qxd 4/4/03 9:25 AM Page 266 The errors file The error messages displayed by the document publishing applications are stored in the ch8/apps/ld.errors file in the CDROM. You can modify the error messages using a text editor. Setting Up the Application Templates The HTML interface templates needed for the applications are included on the CD-ROM. These templates contain various template tags to display necessary infor- mation dynamically. The templates are named in the ld.conf file. These templates are discussed in Table 8-3. TABLE 8-3 HTML TEMPLATES Configuration Variable Template File Purpose $STATUS_TEMPLATE ld_status.html Shows status message. $LD_HOME_TEMPLATE ld_brief.html Document index template. $LD_DETAILS_TEMPLATE ld_details.html Shows the contents of the document. $LD_RESPONSE_TEMPLATE ld_response_ Web form template to input.html enter response information. $LD_VIEW_RESPONSE_TEMPLATE ld_response_ Response viewer view.html template. $ADD_MOD_DOC_TEMPLATE ld_add_mod_doc.html Web form template to add or modify documents. $ADD_MOD_CATEGORY_TEMPLATE ld_add_mod_cat.html Web form template to add or modify category. Continued Chapter 8: Intranet Simple Document Publisher 267 11 549669 ch08.qxd 4/4/03 9:25 AM Page 267 TABLE 8-3 HTML TEMPLATES (Continued) Configuration Variable Template File Purpose $ANNOUNCE_LD_ADDED_TEMPLATE ld_added_ Message template announcement.html is shown when a new document is added. $ANNOUNCE_LD_MOD_TEMPLATE ld_modified_ Message that is announcement.html shown when an existing document is modified. $LD_VISIT_LIST_TEMPLATE ld_visit_list.html Lists the complete document-tracking information. $LD_REORDER_CAT_TEMPLATE ld_order_cat.html Web form template that enables an administrator to modify the order of the categories. The Document Publisher Application The document publisher application, ld_admin_mngr.php, is responsible for man- aging documents and categories. This application is included on the CD-ROM in the ch8/apps directory. It implements the following functionality: ◆ Enables administrative users to create, modify, and delete categories and documents. ◆ Enables administrative users to assign viewers (users who can view docu- ments in a category) and publishers (users who can create, modify, or delete documents in a category) to each category. ◆ Enables users to create, modify, and delete documents. ◆ Does not allow non-administrative users to create, modify, or delete categories. The ch8/apps/ld_admin_mngr.php in the CDROM an implementation of this application. 268 Part II: Developing Intranet Solutions 11 549669 ch08.qxd 4/4/03 9:25 AM Page 268 Here are the methods in this application: ◆ run(): When the application is run, this method is called. It decides which functionality is requested by the user and calls the appropriate driver method to perform the desired operations. Here’s how it works: ■ 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. ■ If the application is called with the cmd=del query parameter, deleteDriver() is run. Similarly, cmd=add calls addDriver(), cmd=mod calls modifyDriver(), and cmd=reo calls reorderDriver(). ◆ reorderDriver(): This method is used to change the order of the cate- gories in the system. Categories can be displayed in navigation displayed by the home.php (discussed in Chapter 7) in the given order set by this method. In addition, when the categories are listed in the document index page, the order of each category is determined by order information stored in the database. This method allows you to change the order. It is called when cmd=reo is passed as a query parameter to the application. Here is how it works: ■ The method checks to see if the application is being run by an adminis- trator. If it isn’t, the method returns a null. ■ The reordering of categories requires that first the user is given a chance to set the order and then apply the requested order. So the method uses the $step query parameter to control the application state. ■ If step=1 is passed, the method displays the Web form that allows the user to reorder the categories. This Web form is created by calling displayReorderMenu(). If step=2 is passed, the method updates the order of the category because the step=2 is only passed from the Web form displayed by displayReorderMenu(), which is shown when step=1 is passed. ◆ deleteDriver(): This method controls how delete operations are per- formed on documents, responses, and categories. It works as follows: ■ If the obj=doc query parameter is passed to this method when called, it calls deleteDoc() to start the document delete process. ■ If the obj=response query parameter is passed, it runs deleteResponse() to start the delete process for response for a document. ■ If the obj=category query parameter is passed, it runs deleteCategory() to start the category delete process. Chapter 8: Intranet Simple Document Publisher 269 11 549669 ch08.qxd 4/4/03 9:25 AM Page 269 ◆ addDriver(): This method controls how add operations are performed on documents and categories. It works as follows: ■ If the obj=doc query parameter is passed to this method when called, it calls addDoc() to start the document creation process. ■ If the obj=category query parameter is passed, it runs addCategory() to start the category creation process. ◆ modifyDriver(): This method controls how modify operations are per- formed on documents and categories. It works as follows: ■ If the obj=doc query parameter is passed to this method when called, it calls modifyDoc() to start the document modification process. ■ If the obj=category query parameter is passed, it runs modifyCategory() to start the category modification process. ◆ addDoc(): This method controls how a new document is added. It works as follows: ■ If the step=NULL query parameter is passed, it calls the displayAddModDocMenu() method with ‘add’ parameter to display the new document Web form. ■ If the step=2 query parameter is passed, storeDoc() is called to store the new document. ◆ modifyDoc(): This method controls how documents are modified. It works as follows: ■ If the step=NULL and nid (document ID) query parameter is not empty, displayAddModDocMenu() is called with a ‘Modify’ parameter, which loads the document referred by $nid and allows the user to modify it. ■ If the method is called without an nid (document ID), an error alert is shown. ■ If step=2 parameter is passed, the document is updated using updateDoc(). ◆ addCategory(): This method controls how a new category is added. It works as follows: ■ If step=NULL query parameter is passed, it calls the displayAddMod CategoryMenu() method with the ‘add’ parameter to display the new category Web form. ■ If step=2 query parameter is passed, storeCategory() is called to store the new category. 270 Part II: Developing Intranet Solutions 11 549669 ch08.qxd 4/4/03 9:25 AM Page 270 . categories. The Document Publisher Application The document publisher application, ld_admin_mngr .php, is responsible for man- aging documents and categories. This application is included on the. allow non-administrative users to create, modify, or delete categories. The ch8/apps/ld_admin_mngr .php in the CDROM an implementation of this application. 268 Part II: Developing Intranet Solutions 11. the cate- gories in the system. Categories can be displayed in navigation displayed by the home .php (discussed in Chapter 7) in the given order set by this method. In addition, when the categories

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

Mục lụ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

Tài liệu cùng người dùng

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

Tài liệu liên quan