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

Secure PHP Development- P63 potx

5 198 0
Tài liệu đã được kiểm tra trùng lặp

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 116,41 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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.. ■ Using the $nid,

Trang 1

■ 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 $docObjis 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/appsdirectory 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->themeObjis created The theme used by the current user is set as the application’s theme using the

$this->themevariable

■ The $cmdquery parameter is used to determine if the user wants to cre-ate or view responses If the $cmdis empty, displayResponseForm()is shown to allow the user to enter a new response If the $cmdvariable is set to ‘submit’, the user has submitted a new response, and using

submitResponse()is used Finally, if $cmdis 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 Responseobject called $respObjand retrieves the docu-ment’s ID ($nid) using getResponseDocID()on the $resObj

■ Using the $nid, it creates a document object called $docObjand 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

Trang 2

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

$paramsis created, which is passed to the addResponse()of a new

Responseobject called $resObjto 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/appsdirectory 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 $templateis 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

Trang 3

■ If $nidis supplied, a new document object called $docObjis created.

■ The heading of the document is retrieved via the getHeading()

method of the $docObjectand 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.gzdirectories on the CD-ROM In these sample installation steps, I will assume that these are installed in the /evoknow/phpliband /evoknow/peardirectories

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

Trang 4

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.sqlfile 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.gzin %DocumentRoot% This creates ld_tool in your document root Configure %DocumentRoot%/ ld_tool/apps/ld.conffor path and database settings The applications are installed in the %DocumentRoot%/ld_tool/appsdirectory 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.conffile 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.comand 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_DIRvariable 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

Trang 5

The default theme template ( std_blue ) has links to the document publish-ing application If you have installed the document publishpublish-ing 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.phpusing 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.phpafter 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.

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