Archive for January, 2008

Chapter 13: Tell-a-Friend System 459 (Web site translator) . The encrypted

Sunday, January 27th, 2008

Chapter 13: Tell-a-Friend System 459 . The encrypted check flag is decrypted and matched with the other parameters from the link. If the matching fails, the method returns false. . Even after the matching succeeds, a second checking is done using the friend ID that was hidden in the check flag. This friend ID is matched with all the friend IDs of the database and checked to see whether the corresponding e-mail is same as the e-mail hidden in the check flag. The method returns TRUE or FALSE depending on this matching result. processRequest() This method is used to process the subscription data and update the database thereby. It works as follows: . First it creates an array named $param with the form ID, friend e-mail, subscription status (sub or unsub), originator e-mail, and subscription time stamp. . Then the array is passed into the addSubscriptionData() method of the Form class to add the subscription data. . If the addition is successful and the subscription type is sub (which means the friend agreed to subscribe to the system), an e-mail is sent to the friend. . The e-mail to be sent to the friend is decided from the subscription message ID specified while setting up the form. This ID is retrieved using the Form class and then fed into the Message class to get its details. . At the end, the friend is shown a status message depending on the subscription data addition status. Creating a Tell-a-Friend Reporter Application This application, taf_reporter.php, is responsible for generating reports for the system. This application included on the CD-ROM in the ch13/apps directory. It implements the following functionalities: . Produces a report for form creator with subscription ratio and other details. . Produces a scorecard report for friend originator. These are the methods used by the application.

458 Part III: Developing E-mail Solutions . Then (Web site designers)

Saturday, January 26th, 2008

458 Part III: Developing E-mail Solutions . Then the campaign message ID is retrieved (the one to be sent to the new friends for this form) and $msgObj, an object of Message class, is used to get and store the information on that message. . For each friend supplied by the user request, the method first checks whether the friend e-mail is already unsubscribed. If not, the friend s submission data is added in to the submission table and the friend is sent the campaign message along with links for subscription and unsubscription. . Then the message ID to be sent to the originator is retrieved using $frmObj and given to $msgObj for information on that message. That message along with information on the successfully submitted friends is sent to the originator. This also contains a link to the scorecard for the originator. . At the end, a status message is shown to the user saying that her submission has been granted and a mail has been sent to her with details. Creating a Tell-a-Friend Subscriber Application This application, taf_subscribe.php, is responsible for handling the subscription requests from friends. This application is included on the CD-ROM in the ch13/apps directory. It implements the following functionalities: . Checks whether the request is valid via the authorize() method. . Updates database according to the subscription request. To achieve those functionalities it uses the following methods. run() When the application is run, this method is called. It simply calls the processRequest() method to process the subscription request from the friend. authorize() This method is used to verify the authenticity of the request. This is how it works: . Ideally, friends access this application through the link provided by the Form Handler application. And that link contains a check flag that is used here to verify.

Chapter 13: Tell-a-Friend System 457 Creating a Tell-a-Friend (Starting a web site)

Saturday, January 26th, 2008

Chapter 13: Tell-a-Friend System 457 Creating a Tell-a-Friend Form Processor Application This application, taf.php, is the core part of the system that is responsible for handling the form submission requests from users. This application is included on the CD-ROM in the ch13/apps directory. It implements the following functionalities: . Processes the form submitted by the users and updates the database accordingly. . Sends appropriate mails to newly added friends and the originator of those friends. To achieve those functionalities, it uses the following methods. run() When the application is run, this method is called. It simply calls the processRequest() method to process the submit request from the user. processRequest() This method is responsible for handling the request and takes the action thereby. This is how it works: . First, it checks whether the form ID is supplied or not. If not, it shows an alert message and returns null. . Then it verifies if the originator e-mail has been provided from the form or not. If not, it returns null after showing an alert. . Then it uses the AccessControl class to check whether the request IP address is banned from submitting friends for this form. If it is banned, then it shows the appropriate alert and returns null. . Then an object of the Form class, named $frmObj, is created. . $frmObj retrieves the activation date and termination date for the form and checks whether the current time falls into a valid time range. If not, it shows an alert message and returns null.

456 Part III: Developing E-mail Solutions addModifyMessage() This

Friday, January 25th, 2008

456 Part III: Developing E-mail Solutions addModifyMessage() This method is used to add or modify messages. It works as follows: . First, it prepares the $params array with all the message field values from the user request. . Then it creates an object of AccessControl to add or modify the access to the message. . When the mode for the method is add, the $params array is fed into the addMessage() method of the Message class to add the new message. If the addition fails, the method shows a failure message and returns. . If the addition operation is successful, the authorized IPs are added to the database using the addAccessIPs() method of the AccessControl class. And then a successful addition message is shown to the user. . When the mode for the method is modify, the $params array is fed into the modifyMessage() method of Message class to update the given message. If the update fails, the method shows a failure message and returns. . If the update operation is successful, the authorized IP addresses are added to the database using addAccessIPs() method of the AccessControl class after deleting the previous IPs. And then a successful update message is shown to the user. deleteMessage() This method is used for deleting messages. This works as follows: . First, it checks whether the message ID has been supplied or not. If not, it shows an alert message and returns null. . Then a new Message object $msgObj is created and the deleteMessage() method of $msgObj is used to delete the message. . If deletion succeeds, the AccessControl class is used to delete the related IPs from the authorized table for the message. . At the end, a status message is shown depending on the outcome of the deletion operation.

Chapter 13: Tell-a-Friend System 455 . When the (Mac os x web server)

Friday, January 25th, 2008

Chapter 13: Tell-a-Friend System 455 . When the $cmd is add or modify, it calls the addModifyDriver() method with the appropriate mode (add or modify). . And when the $cmd is delete, it calls the deleteForm() method to delete the form. authorize() This method checks whether the IP address (where the user is accessing the application from) is an authorized one. This is how it works: . This application allows everyone to add messages. So when the request $cmd is add, it directly returns true. . In case of modify and delete, the AccessControl object is used to verify whether the request IP is allowed to access the given message. It returns TRUE or FALSE depending on the verification result. addModifyDriver() This method is responsible for driving the add/modify procedure. Depending on the hidden form value $step, it decides whether to call the add/modify menu rendering method, displayAddModifyMenu(), or the add/modify method, addModifyMessage(). Both the methods are called with proper mode (add or modify). displayAddModifyMenu() This method is used to show the Web form for adding or modifying forms. It works as follows: . If the method is called with mode modify, it first checks whether the message ID has been supplied or not. In case of no message ID, the method shows an alert message and returns null. . Otherwise, all the previous information of the given message is retrieved and loaded in variables for later usage, to preload the modification Web form while showing to the user. In this case, the AccessControl object is used to retrieve the authorized IPs for the message. . Then a message setup template (TAF_MSG_SETUP_TEMPLATE) is loaded in a template object called $template. . The different form fields required for adding or modifying a message are prepared. . At the end, the template is parsed and printed to the user to give her a Web form to add or modify messages.

Web site - 454 Part III: Developing E-mail Solutions . If

Thursday, January 24th, 2008

454 Part III: Developing E-mail Solutions . If the update operation is successful, the authorized and denied IPs are added to the database using the addAccessIPs() and addDeniedIPs() methods of the AccessControl class after deleting the previous IPs. And then a successful update message is shown to the user. deleteForm() This method is used for deleting forms. This works as follows: . First, it checks whether the form ID has been supplied or not. If not, it shows an alert message and returns null. . Then a new Form object, $frmObj, is created and the deleteForm() method of $frmObj is used to delete the form. . If the deletion succeeds, the AccessControl class is used to delete the related IPs from the authorized and banned tables for the form. . At the end, a status message is shown depending on the outcome of the deletion operation. Creating a Tell-a-Friend Message Manager Application This application, taf_msg_mngr.php, is responsible for managing all messages for the system. This application is included on the CD-ROM in the ch13/apps directory. It implements the following functionality: . Allows any user to add a new message. . Allows users from authenticated IP addresses to delete or modify the selected message. This application has the following methods. run() When the application is run, this method is called. It does the following: . First, it retrieves the $cmd value from the user request. . Depending on the $cmd value, different methods are called.

Chapter 13: Tell-a-Friend System 453 displayAddModifyMenu() This method (Web hosting faq)

Thursday, January 24th, 2008

Chapter 13: Tell-a-Friend System 453 displayAddModifyMenu() This method is used to show the menu for adding or modifying forms. It works as follows: . If the method is called with mode modify, it first checks whether the form ID has been supplied or not. In case of no form ID, the method shows an alert message and returns null. . Otherwise, all the previous information of the given form is retrieved and loaded in variables for later usage, to preload the modification Web form while showing to the user. In this case, the AccessControl object is used to retrieve the authorized and banned IPs for the form. . Then a form setup template (TAF_FRM_SETUP_TEMPLATE) is loaded in a template object called $template. . For loading different message lists in the Web form, the Message object s getAllMessages() is used and then filtered using the AccessControl object s isAccessAllowed() method. . At the end, the template is parsed and printed to the user to give her a Web form to add or modify forms. addModifyForm() This method is used to add or modify forms. It works as follows: . First, it checks whether the date range given for the form (the activation and termination date) is a valid one or not. If not, the method shows an alert message and returns null. . Then it prepares the $params array with all the form field values from the user request. . Then it creates an object of AccessControl to add or modify the access to the form. . When the mode for the method is add the params array is fed into the addForm() method of the Form class to add the new form. If the addition fails, the method shows a failure message and returns. . If the addition operation is successful, the authorized and denied IPs are added to the database using the addAccessIPs() and addDeniedIPs() methods of the AccessControl class. Then a successful addition message is shown to the user. . When the mode for the method is modify, the $params array is fed into the modifyForm() method of the Form class to update the given form. If the update fails, the method shows a failure message.

452 Part III: Developing E-mail Solutions Creating a (Web hosting isp)

Wednesday, January 23rd, 2008

452 Part III: Developing E-mail Solutions Creating a Tell-a-Friend Form Manager Application This application, taf_form_mngr.php, is responsible for managing forms. This application is included on the CD-ROM in the ch13/apps directory. It implements the following functionality: . Allows any user to add a new form. . Allows users from authenticated IP addresses to delete or modify selected forms. This application has the following methods. run() When the application is run, this method is called. It does the following: . First it retrieves the $cmd value from the user request. . Depending on the $cmd value, different methods are called. . When the $cmd is add or modify, it calls the addModifyDriver() method with the appropriate mode (add or modify). . And when the $cmd is delete, it calls the deleteForm() method to delete the form. authorize() This method checks whether the IP address from where the user is accessing the application is an authorized one. This is how it works: . This application allows everyone to add forms. So when the request $cmd is add, it directly returns true. . In case of modify and delete, the AccessControl object is used to verify whether the request IP is allowed to access the given form. It returns TRUE or FALSE depending on the verification result. addModifyDriver() This method is responsible for driving the add/modify procedure. Depending on the hidden form value $step, it decides whether to call the add/modify menu rendering method, displayAddModifyMenu(), or the add/modify method, addModifyForm(). Both the methods are called with the proper mode (add or modify).

Chapter 13: Tell-a-Friend System 451 Creating the Tell-a-Friend (Yahoo web space)

Wednesday, January 23rd, 2008

Chapter 13: Tell-a-Friend System 451 Creating the Tell-a-Friend Main Menu Manager Application This application, taf_mngr.php, is responsible for managing the main menu of the system. This application is included on the CD-ROM in the ch13/apps directory. It implements the following functionality: . Allows every user to create messages and forms. . Allows users from authenticated IP addresses to delete or modify forms or messages. . Allows users from authenticated IP addresses to view the form report. This application has the following methods. run() When the application is run, this method is called. It simply calls the displyTAFMenu() method to render the main menu for the system. displayTAFMenu() This method is responsible for showing the main menu according to the privileges based on the IP address of the client. It works in the following manner: . A menu template (TAF_MENU_TEMPLATE) is loaded in a template object called $template. . All the form names and form IDs of the database are loaded in the array $frms. . For each of those forms the AccessControl object is used to check whether the request IP is allowed to access the form. If the check result is yes, then the form name is showed in the list to the user for him to modify, delete, or view a report. . Similarly, all the messages are loaded in an array and the AccessControl object is again used to verify the request IP s eligibility to access the message and the message list is prepared thereby. . After preparing the message list and the form list and setting all the links for deletion, modification, and report for the messages or forms, the template is parsed and printed to the user.

450 Part III: Developing E-mail Solutions Creating Application (Ecommerce web host)

Tuesday, January 22nd, 2008

450 Part III: Developing E-mail Solutions Creating 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 information dynamically. The templates are named in the taf.conf file. These templates are discussed in Table 13-2. TABLE 13-2 HTML TEMPLATES Configuration Variable Template File Purpose $STATUS_TEMPLATE taf_status.html This template is used to show the status message. TAF_MENU_TEMPLATE taf_menu.html This template is used to show the index page of the application. TAF_CREATOR_REPORT_ taf_report_creator This template is used for TEMPLATE .html the report to be shown to the form creator. TAF_FRM_SETUP_TEMPLATE taf_setup.html This template is used to show the form setup menu. TAF_MSG_SETUP_TEMPLATE taf_add_modify_ This template is used for msg.html the message add/modify menu. TAF_FRIEND_MSG_TEMPLATE taf_frnd_msg.html This template is used while sending mail to the friend. TAF_ORIGIN_MSG_TEMPLATE taf_orig_msg.html This template is used while sending mail to the originator. TAF_ORIGIN_REPORT_ taf_report_origin This template is used for TEMPLATE .html the report to be shown to the originator.