Home arrow Web Standards arrow Page 4 - Completing a Configuration for Chrome and a Server

Completing a Configuration for Chrome and a Server

In this fourth article in a four-part series on configuring Firefox for Chrome and a server, you will learn how to create a XUL file, how to make login changes, and more. This article is excerpted from chapter four of Programming Firefox, written by Kenneth C. Feldt (O'Reilly, 2007; ISBN: 0596102437). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
June 26, 2008
  1. · Completing a Configuration for Chrome and a Server
  2. · PHP Serving XUL
  3. · Using PHP require()
  4. · Logic changes
  5. · Summary

print this article

Completing a Configuration for Chrome and a Server - Logic changes
(Page 4 of 5 )

Next, we change our doCommandXUL.php frontend script to execute the logic that decides what interface to serve. The only change from the last iteration of the code is to alter the path that actually checks the result if the user entered data into the name and password fields.

The code takes advantage of the PHPexplodefunction to break up the returned string into an array of name-value pairs.

We use the PHPsubst(inString,startingChar,lastChar)functions to break the result array’s strings into values, given the fact that we know the length of the names being used as tags. If the first returned value istrue, we save a string that holds session information into a variable, and include the PHP file that holds the XUL interface content. If the first returned value isfalse, we build a message that flags an unregistered user:

  else {
$retString = check_user($uName,$uPass);
   $resArray = explode(',',$retString);
   if ($resArray[0] == 'retcode=true') {
      $lastLoginTime = 'Last login was '.substr($resArray[1],
11,strlen($resArray[1]));  // extract last session
else { // invalid user, send rejection page
     echo '<h1>Sorry!</h1>';
     echo '<h2>You are not registered to use this service.</h2>';
     } // invalid user 


We need to insert another subtle change into the newssearch.js file. Because the login button is no longer on our startup screen (the doCommandXUL.php file is generating it), we can no longer try to attach a login script upon initialization. We could edit the code to remove all initialization references, or (if we wanted to use the same file for both local and served versions) we could add a test to make certain the button exists before attaching an event listener:

  function initialize(){
  try {
  // Add a login script 
    if (document.getElementById("loginButton")) { 

catch (e) {
     alert ("Exception: " + e);

Finally, we change the segment of the XUL source in our startupScreen.php file that manages the status label to include the PHP directives to substitute the$lastLoginTimevariable into thelabelattribute of the status display:

  <hbox >
     <!-- stack info and resize horizontally -->
     <!-- right align our status bar -->

       <statusbar id="status-bar" class="chromeclass-status">
       <statusbarpanel id="status-text"
    <spacer flex="1"/>

Now referencing the doCommandXUL.php file from the Firefox URL will present the same interaction with the user, except with the interface delivered from the web server. Figure 4-11 shows our XUL-served page for a successful login and a failed login.

blog comments powered by Disqus

- Mozilla Popcorn Maker 1.0 Makes Videos More...
- Completing a Configuration for Chrome and a ...
- Getting Connected with Firefox and Chrome
- Configuring Servers and Databases with Chrome
- Configuring Firefox for Chrome and a Server
- Designing the Elements of a Web Page
- Matching div heights with CSS and JavaScript
- Forms
- Get Down With Markup
- If I Said You Had a Beautiful Body...
- Web Standards in Dreamweaver Part 3
- Web Standards in Dreamweaver, Part 2
- Web Forms
- Making Lists Using XHTML
- Web Standards in Dreamweaver, Part 1

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials