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

Secure PHP Development- P83 pptx

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

Tiêu đề Secure PHP Development
Trường học University of Technology
Chuyên ngành Computer Science
Thể loại Bài luận
Năm xuất bản 2003
Thành phố Hanoi
Định dạng
Số trang 5
Dung lượng 81,83 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: ◆ This method is called with the template name $template, category ID $cat_id, and block name $blockName where the subcategory will be populated.. ◆ Finally, the sho

Trang 1

◆ This method is called with the template name ($template), HTML template block name ($blockName) and the default selected value ($selectValue)

◆ A new category object called $categoryObjis created and the getCategoryList()method of that object is called to generate the avail-able main categories name and stored in a array named $categoryList

◆ 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 $blockNameis set to jsblockthen it parses the jsCategoryBlockand sets the output into the $categoryvariable Otherwise, it parses the categoryBlockblock to see whether the category ID is equal to the

$selectValueor not and sets the output in the $categoryvariable

◆ Finally this method returns the value of $categoryvariable

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 category class is created named $subcatagoryObjand the getSubCategoryList()method is called of the class with the given category ID ($cat_id) as the parameter The subcategory list is 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 parses the block and sets the output in the $subCategory variable

◆ Finally, this method returns the subcategory list stored in the

$subCategory

showAddMenu( )

This method displays the Web form to add new resources It works as follows:

◆ A template object called $menuTemplateis created To load the template,

a file named $IRM_CAT_HOME_TEMPLATE(configurable via irm.conf) is passed to the method

Trang 2

◆ Next this method creates an object of userclass named $userObj Then

it calls the getUserList()method of that object to get all users’ e-mail addresses The user’s name is taken from each e-mail address field

◆ Then This method calls populateCategoryto generate the category list

◆ Finally, the showWithTheme()method is called with the output of parsing main block to embed the message in the user theme template

addResource( )

This method adds the new resource to the database It works as follows:

◆ First, this method checks whether it is called with valid and required input

or not It checks where the category is provided or not If it is not provided, then it gives an error message of “category name missing” and returns null

◆ Next, it checks if the resource name and URL are given or not If they are not given, then an error message is shown and returns immediately

◆ It checks the validity of the given URL If it is not valid, then it shows the appropriate error message to the user and returns from the method

◆ If a new category name is provided by the user of his own, then it checks whether the category is already existing or not If not, then it adds the new category in the CATEGORYtable

◆ Now it creates an object of resourceclass and call the addResource() method with the proper parameter in the RESOURCEtable If it can success-fully add the resource, then it returns the resource ID If it fails to add, then a message is shown that the resource could not be added

◆ If the resource is added successfully, then it generates intranet MOTD messages for the requested users

◆ Finally, it calls the displayWithTheme()method to show the message with the user’s theme

showModifyMenu( )

This method displays the modify resource Web form It works as follows:

◆ First, this method checks whether any resource name ($resource) is selected or not If not, it gives an error message and returns from the method

◆ A template object called $menuTemplateis created To load the template,

a file named $IRM_CAT_HOME_TEMPLATE(configurable via irm.conf) is passed to the method

Trang 3

◆ Then an object of Resourceclass is created named $resourceObj It calls getResourceInfo()with the resource ID to get the information about the selected resource and calls getKeywords()to get keywords for the resource

◆ Next it sets the resource information in the template

◆ It calls populateCategory()to generate the category list

◆ Finally, the showWithTheme()method is called with the output of parsing the main block to embed the message with the user theme template

modifyResource( )

This method updates modified resource information to the database It works as follows:

◆ First, this method checks whether the category is provided If the category

is not provided, then it gives an error message and returns null

◆ Next, the method checks whether the resource name and URL is given

If the resource name is not given, then an error message is shown and

it returns null

◆ Then It checks the validity of a given URL If the URL is not valid, then it shows the appropriate error message to the user (“incorrect URL given”) and returns from the method

◆ If a new category name is provided by the user of his own, then it checks whether the category already exists If it doesn’t exist, then it adds the new category in the CATEGORYtable

◆ Then It creates an object of Resourceclass and calls the modifyResource()method with the proper parameter to resource in the RESOURCEtable If it successfully modifies the resource, then it returns the resource ID If it fails to modify, then a message is shown that the resource

is not modified

◆ If the resource is modified successfully, then it deletes all the previous keywords and adds new keywords in the RESOURCE_KEYWORDtable

◆ Finally, it calls the displayWithTheme()method to show the message with the user’s theme

delete( )

This method deletes resource information It works as follows:

◆ This method first checks whether any resource is selected to delete or not

If it is not given, then an error message is shown and returns null

Trang 4

◆ Then it creates an object of Resourceclass and calls deleteKeywords() with the selected resource ID as a parameter

◆ If it successfully deletes the keywords, then it calls the deleteResource() method to delete the resource information from the RESOURCEtable

◆ Finally, it calls the displayWithTheme()method to show the status message of deletion with the user’s theme

displayDescription( )

This method is used to display the description of the given resource It works as follows:

◆ A template object is created named $menuTemplate This method then loads the $IRM_RESOURCE_DES_TEMPLATE template

◆ Then It creates an object of Resourceclass and calls getResourceInfo() with the selected resource ID as a parameter, which returns the resource information

◆ Next it sets the title and description in the template

◆ Finally, it parses the main block and calls the displayWithTheme() method to show output with the user’s theme

selectResource( )

This method is used to give the user an option to choose a resource for modification The method works as follows:

◆ First, the method creates an object of Categoryclass named $catObj

◆ Next it populates the main category by calling the populateCategory() method

◆ If the $categoryis assigned any value, then it finds the subcategory list

by calling the getSubCategoryList()

◆ Then It checks whether the variable $changeis assigned any value or not

If $changehas any value, then it generates the resource list according to the main category or the subcategory changes

◆ Finally the showWithTheme()method is called with the output of parsing the main block to embed the message with the user theme template

displayWithTheme( )

This method is used to show the user’s theme template It works as follows:

Trang 5

◆ It creates a theme template object called $themeTemplate.

◆ The user’s theme template is loaded into the $themeTemplateobject

◆ This method is called with a parameter called $output, which will

be shown with the theme template This $outputis set into in the

‘CONTENT_BLOCK’block

◆ Then it parses all the blocks and shows the final output

authorize( )

This method authorizes everyone on the intranet to view the resource manager and, therefore, always returns TRUE

Creating a Resource Tracking Application

This application, irm_resource_track_mngr.php, is responsible for resources tracking This application is included on the CD-ROM in the ch11/appsdirectory

The application has the following methods

run( )

This method is responsible for running the application First it sets the user ID into

a variable named $uid Then it calls the keepTrack()method

keepTrack( )

This method keeps track of resource visits and updates the database It works as follows:

◆ First it defines an array named $paramscontaining the resource ID, visitor

ID (user ID), and current time

◆ Then it creates an object of Resourceclass and calls the trackResourceVisit()method with the $paramsarray to insert records

in the RESOURCE_VISITORtable

◆ If it successfully inserts the data, then it calls the getResourceUrl() method to get the URL of the resource

◆ Finally, it redirects the page to the resource URL

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