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

Secure PHP Development- P63 potx

5 195 0

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

THÔNG TIN TÀI LIỆU

■ If the current user is an administrator, the administrative block in the template is set; otherwise, it is set to NULL. ■ The getTrackDetails() of the $docObj is called to retrieve the track count to display as number of visits. ■ The document is displayed with the number of visits and responses. The document response application The document response application, ld_response _mngr.php, manages responses for each document. It’s included on the CD-ROM in the ch08/apps directory. Users can create or view responses. It has the following methods: ◆ run(): This method is used to control how the application works. Here is how this method works: ■ A theme object called $this->themeObj is created. The theme used by the current user is set as the application’s theme using the $this- >theme variable. ■ The $cmd query parameter is used to determine if the user wants to cre- ate or view responses. If the $cmd is empty, displayResponseForm() is shown to allow the user to enter a new response. If the $cmd variable is set to ‘submit’, the user has submitted a new response, and using submitResponse() is used. Finally, if $cmd is set to ‘view , the user wants to view a response, which is done using showResponse(). ◆ showResponse(): This method is responsible for showing responses to documents. It works as follows: ■ It creates a theme template object called $themeTemplate, loads the cur- rent user’s theme template, and sets theme-related template key values. ■ It creates a Response object called $respObj and retrieves the docu- ment’s ID ($nid) using getResponseDocID() on the $resObj. ■ Using the $nid, it creates a document object called $docObj and retrieves the document’s header ($heading) and publish date ($docPublishDate) using getHeading() and getPublishDate(), respectively, on the $docObj. ■ It retrieves the responder user name ($responderName), response head- ing ($responseHeading), and response ($responseBody) by calling the getResponder(), getResponseSubject(), and getResponseBody() methods, respectively, on the $resObj. ■ The response information is displayed using a template object called $template. Chapter 8: Intranet Simple Document Publisher 281 11 549669 ch08.qxd 4/4/03 9:25 AM Page 281 ◆ submitResponse(): This method allows the application to write a new response of a chosen document. Here is how it works: ■ If the method is called without a document ID ($nid), empty response subject/header ($sub), or response body ($comment) as query parame- ters, it shows an alert message and returns NULL. ■ If all the required response data is supplied, an associative array called $params is created, which is passed to the addResponse() of a new Response object called $resObj to create the response in the database. ■ The status of the addition is displayed using the show_status() method. ◆ showStatusMessage(): This method displays a message in a template. The method is called with the message ($statusMessage) and it simply loads a template object and displays the message in the template. ◆ displayResponseForm(): This method is used to display the response entry Web form. It works as follows: ■ If a document ID ($nid) is not supplied as a query parameter, the method shows an alert message and returns null. ■ If a document ID is supplied, it creates a theme template object ($themeTemplate) and a template object ($template) and displays the response entry Web form. The document view list application The document view list application, ld_view_list_mngr.php, shows the list of users who have viewed this document. This application included on the CD-ROM in the ch08/apps directory. It has the following methods: ◆ run(): This method calls the displayDocVisitList() to display the list of users who have viewed the chosen document. ◆ authorize(): This method authorizes everyone on the intranet to view the document access list and, therefore, always returns TRUE. ◆ displayDocVisitList(): This method displays a list of users who have viewed the chosen document. It works as follows: ■ A template object called $template is created and various template variables are set. ■ If the document ID ($nid) is not supplied by the user as the query para- meter, an alert message is shown and the application aborts. 282 Part II: Developing Intranet Solutions 11 549669 ch08.qxd 4/4/03 9:25 AM Page 282 ■ If $nid is supplied, a new document object called $docObj is created. ■ The heading of the document is retrieved via the getHeading() method of the $docObject and inserted into the template after parsing for slashes by using stripslashes(). ■ A list of document tracking information is stored in $trackArr by call- ing the getTrackDetails() method of the current document object. ■ A DBI object called $user_dbi is created, which opens a connection to the user table specified by USER_DB_URL. ■ For each track record for the document, the template is populated with a viewer’s e-mail address by calling getEMAIL() of the $userObj object, which is created inside the loop for each track. Installing Intranet Document Application I assume that you’re using a Linux system with MySQL and Apache server installed. The following installation process presumes the following: ◆ Your intranet web server document root directory is /evoknow/intranet/ htdocs . Of course, if you have a different path, which is likely, you should change this path whenever you see it in a configuration file or instruction in this chapter. During the installation process, I will refer to this directory as %DocumentRoot%. ◆ You have installed the PHPLIB and PEAR library. Normally, these are installed during PHP installation. For your convenience, I have provided these in the lib/phplib.tar.gz and lib/pear.tar.gz directories on the CD-ROM. In these sample installation steps, I will assume that these are installed in the /evoknow/phplib and /evoknow/pear directories. Because your installation locations for these libraries are likely to differ, make sure you replace these paths in the configuration files. Here is how you can get your intranet document publishing applications up and running: 1. Install the base intranet applications. If you haven’t yet installed the base intranet user home application and the messaging system discussed in Chapter 7, you must do so before proceeding further. Chapter 8: Intranet Simple Document Publisher 283 11 549669 ch08.qxd 4/4/03 9:25 AM Page 283 2. Install the intranet document publisher database tables. You must already have installed the INTRANET database (see Chapter 7 for details). Once you have installed INTRANET database, you need to create the tables needed for the document publisher. The easiest way to do this is to use the ch08/sql/ld_tools.sql file found in the CDROM. To create the tables is to run the following commands: mysql –u root –p –D INTRANET < ld_tools.sql 3. Install the intranet document publisher applications. Now from the ch8 directory of the CD-ROM, extract ch8.tar.gz in %DocumentRoot%. This creates ld_tool in your document root. Configure %DocumentRoot%/ ld_tool/apps/ld.conf for path and database settings. The applications are installed in the %DocumentRoot%/ld_tool/apps directory and the templates are stored in %DocumentRoot%/ld_tool/apps/templates. Your MySQL server is hosted on the intranet web server and, therefore, it can be accessed via localhost. However, if this is not the case, you can easily modify the database URLs in each application’s configuration files. For example, the home.conf file has a MySQL database access URLs such as the following: $LD_DB_URL=’mysql://root:foobar@localhost/INTRANET’ define(‘USER_DB_URL’, ‘mysql://root:foobar@localhost/auth’); Say your database server is called db.domain.com and the user name and password to access the INTRANET and auth databases (which you will cre- ate during this installation process) are admin and db123. In this case, you will modify the database access URLs throughout each configuration file as follows: $LD_DB_URL=’mysql://admin:db123@db.domain.com/INTRANET’ define(‘USER_DB_URL’, ‘mysql://admin:db123@db.domain.com/auth’); 4. Set file/directory permissions. Make sure you have changed file and directory permissions such that your intranet web server can access all the files. The path pointed by $LD_CATEGORY_NAV_DIR variable in home.conf and ld.conf files must be writable by the web server, because this is the navigation file that gets generated whenever a new document is pub- lished. This directory should be outside your Web document tree and should be only writable by the Web server user running the PHP scripts. 284 Part II: Developing Intranet Solutions 11 549669 ch08.qxd 4/4/03 9:25 AM Page 284 The default theme template (std_blue) has links to the document publish- ing application. If you have installed the document publishing applications anywhere other than the %DocumentRoot%/ld_tool/apps directory (default), you will need to modify the %DocumentRoot%/themes/ std_blue/home_left_nav.html file. Similarly, you have to modify the other (std_aqua, std_wheat) themes. After you’ve performed these steps, you’re ready to test your publishing applications. Testing Intranet Document Application Log in to your intranet via http://yourserver/index.php or http://yours- erver/home/home.php using the user name and password you created in Chapter 6 and tested in Chapter 7. Click on the Document Publisher link on the left navigation bar of your Intranet home page — or point your web browser to http://yourserver/ld_tool/ apps/ld_mngr.php after you’re logged in to the intranet — to see the primary doc- ument index, as shown in Figure 8-3. Figure 8-3: The main document index. Chapter 8: Intranet Simple Document Publisher 285 11 549669 ch08.qxd 4/4/03 9:25 AM Page 285 . %DocumentRoot%. ◆ You have installed the PHPLIB and PEAR library. Normally, these are installed during PHP installation. For your convenience, I have provided these in the lib/phplib.tar.gz and lib/pear.tar.gz. Intranet Document Application Log in to your intranet via http://yourserver/index .php or http://yours- erver/home/home .php using the user name and password you created in Chapter 6 and tested in Chapter. responses. The document response application The document response application, ld_response _mngr .php, manages responses for each document. It’s included on the CD-ROM in the ch08/apps directory.

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

Xem thêm: Secure PHP Development- P63 potx

Mục lục

    Is This Book for You?

    How This Book Is Organized

    Tell Us What You Think

    Contents at a Glance

    Chapter 1: Features of Practical PHP Applications

    Features of a Practical PHP Application

    Employing the Features in Applications

    Chapter 2: Understanding and Avoiding Security Risks

    Identifying the Sources of Risk

    Not Revealing Sensitive Information

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

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

TÀI LIỆU LIÊN QUAN