Archive for July, 2007

Part II: (Web hosting services) Developing Intranet Solutions Listing 4-4 (Continued)

Tuesday, July 31st, 2007

Part II: Developing Intranet Solutions Listing 4-4 (Continued) global $MESSAGES, $DEFAULT_LANGUAGE, $REL_APP_PATH, $REL_TEMPLATE_DIR; // initialize application $this->app_name = $this->setDefault($param[ app_name ], null); $this->app_version = $this->setDefault($param[ app_version ], null); $this->app_type = $this->setDefault($param[ app_type ], null); $this->app_db_url = $this->setDefault($param[ app_db_url ], null); $this->debug_mode= $this->setDefault($param[ app_debugger ], null); $this->auto_connect = $this->setDefault($param[ app_auto_connect ], TRUE); $this->auto_chk_session = $this>setDefault($param[ app_auto_chk_session ], TRUE); $this->auto_authorize = $this >setDefault($param[ app_auto_authorize ], TRUE); $this->session_ok = $this>setDefault($param[ app_auto_authorize ], FALSE); $this->error = array(); $this->authorized= FALSE; $this->language = $DEFAULT_LANGUAGE; $this->base_url = sprintf( %s%s , $this->get_server(), $REL_TEMPLATE_DIR); $this->app_path = $REL_APP_PATH; $this->template_dir = $TEMPLATE_DIR; $this->messages = $MESSAGES; // If debuggger is ON then create a debugger object if (defined( DEBUGGER_LOADED ) && $this->debug_mode == $ON) { if (empty($param[ debug_color ])) { $param[ debug_color ] = red ; } $this->debugger = new Debugger(array( color => $param[ debug_color ], prefix => $this->app_name, buffer => $OFF)); }

Chapter 4: Architecture of an Intranet Application (Jetty web server) In

Tuesday, July 31st, 2007

Chapter 4: Architecture of an Intranet Application In this example, the first two debug messages ( Name = $name and Email = $email ) will be printed after the This will print before debug messages. nn message. In the next section, we look at how we can incorporate all of these classes to create an abstract PHP application class. Creating an Abstract Application Class The code in Listing 4-4 uses class.DBI.php, class.ErrorHandler.php, and class.Debugger.php to create an abstract PHP application class. Listing 4-4: class.PHPApplication.php * @access public * * Version 1.0.1 */ if (defined( DEBUGGER_LOADED ) && ! empty($DEBUGGER_CLASS)) { include_once $DEBUGGER_CLASS; } //require_once lib.session_handler.php ; class PHPApplication { function PHPApplication($param = null) { global $ON, $OFF, $TEMPLATE_DIR; Continued

Windows 2003 server web - Part II: Developing Intranet Solutions // Write the

Tuesday, July 31st, 2007

Part II: Developing Intranet Solutions // Write the variable out using debugger write() method $myDebugger->write( Name = $name ); ?> This will print a message such as the following: 000   Name = M. J. Kabir
Buffering debug messages enables you to print all debug messages together, which is often very beneficial in identifying a flow sequence. For example, here an application called test_debugger3.php buffers debugging information and prints the information when the buffer is flushed using flush_buffer() method found in the Debugger class. blue , prefix => MAIN , buffer => TRUE) ); $myDebugger->write( Name = $name ); $myDebugger->write( Email = $email ); echo This will print before debug messages.nn ; $myDebugger->flush_buffer(); ?>

Chapter 4: Architecture (Web hosting service) of an Intranet Application .

Monday, July 30th, 2007

Chapter 4: Architecture of an Intranet Application . write(): This function displays a debug message using the chosen color and automatically prints the debug message line number. If debug buffering is on, then the message is written to the buffer (buffer_str). . debug_array(): This function allows you to debug an associative array. It prints the contents of the associative array parameter using the write() method. . set_buffer(): This function sets the buffering of debug messages. . reset_buffer(): This function resets the buffering of debug messages. . flush_buffer(): This function prints the buffer content along with the debug banner. Now let s look at how an application called test_debugger2.php can use this debugging facility: blue , prefix => MAIN , buffer => 0) );

Adult web hosting - Part II: Developing Intranet Solutions controls the banner

Monday, July 30th, 2007

Part II: Developing Intranet Solutions controls the banner printing, is set to FALSE. The debugger can be invoked in an application called test_debugger1.php as follows: red , => MAIN , => FALSE) $fruits = array( apple , orange , banana ); // Show the array contents $myDebugger->debug_array($fruits); ?> In this example, a new Debugger object called $myDebugger is created, which will print debug messages in red color and use MAIN as the prefix for each message. The buffering of debug messages is disabled as well. . print_banner(): This function prints a banner message as follows: Debugger started for PREFIX The PREFIX is set when the object is created.

Chapter 4: Architecture of an Intranet Application function (Web design careers)

Sunday, July 29th, 2007

Chapter 4: Architecture of an Intranet Application function debug_array($hash = null) { while(list($k, $v) = each($hash)) { $this->write( $k = $v ); } } function set_buffer() { $this->buffer = TRUE; } function reset_buffer() { $this->buffer = FALSE; $this->buffer_str = null; } function flush_buffer() { $this->buffer = FALSE; $this->print_banner(); echo $this->buffer_str; } } ?> The debugger class has the following methods: . Debugger(): This is the constructor function for the debugger class (class.Debugger.php). This function initializes the color, prefix, line, and buffer_str, banner_printed member variables. The color is used to display the debug information in a given color. The prefix variable is used to prefix each debug message displayed, which allows for easier identification of messages. The line variable is initialized to zero, which is automatically incremented to help locate debug information quickly. The buffer_str variable is used to store buffered debug information. The banner_printed variable, which

Part II: Developing Intranet Solutions Listing 4-3 (Continued)

Sunday, July 29th, 2007

Part II: Developing Intranet Solutions Listing 4-3 (Continued) } function print_banner() { if ($this->banner_printed == TRUE) { return 0; } $out =

myTextColor > . Debugger started for $this->prefix .


; if ($this->buffer == TRUE ){ $this->buffer_str .= $out; } else { echo $out; $this->banner_printed = TRUE; } return 1; } function write($msg) { $out = sprintf( %03d   . %s
n , $this->myTextColor, $this->line++, $this->color, $msg); if ($this->buffer == TRUE) { $this->buffer_str .= $out; } else { echo $out; } }

Web design seattle - Chapter 4: Architecture of an Intranet Application Creating

Saturday, July 28th, 2007

Chapter 4: Architecture of an Intranet Application Creating a Built-In Debugger Class When developing applications, each developer uses at least some form of debugging. Although PHP-supported Integrated Development Environments (IDEs) are becoming available, they re still not the primary development tools for most PHP developers, who are still using echo, print, and printf functions to display debugging information during development. The debugging class called class.Debugger.php is a bit more advanced than the standard echo, print, and printf messages. It provides a set of facilities that include . Color-coding debug messages . Automatically printing debug line numbers . Optionally buffering debug messages . Prefixing debug messages with a given tag to make it easy to identify messages in a large application Listing 4-3 shows the debugger class that is part of our application framework. It can be used to perform basis application debugging. Listing 4-3: class.Debugger.php color = $params[ color ]; $this->prefix = $params[ prefix ]; $this->line = 0; $this->buffer_str = null; $this->buffer = $params[ buffer ]; $this->banner_printed = FALSE; Continued

Part II: Developing Intranet Solutions You can set (Web site designers)

Saturday, July 28th, 2007

Part II: Developing Intranet Solutions You can set an application s default language using the $DEFAULT_LANGUAGE variable in a configuration file for your application. For example, If this configuration is loaded by an application using the ErrorHandler class, all error messages will be displayed in U.S. English. ErrorHandler() is the constructor function for the class.ErrorHandler.php. This function sets the default language of the error handler to what is set in the application configuration as global $DEFAULT_LANGUAGE variable. This method can be passed an associative array as a parameter. If the parameter array has a key=value pair called caller=class_name, then it sets the member variable called caller_class to the value. The constructor also initializes a member array called error_message and loads the error code for the default language by calling the load_error_code() method. The error handler class ErrorHandler is automatically invoked by the PHPApplication class so you don t need to create an error handler manually in your application code. Now let s look at the other functions available in ErrorHandler class. . alert(): This function displays an internationalized error message using a simple JavaScript pop-up alert dialog box. It is called with the error code. The get_error_message() method is used to retrieve the appropriate error message in default application language from the application s error configuration file. . get_error_message(): This function retrieves the error messages for given error code. If an array of error codes is supplied as parameter, the function returns an array of error messages. If no error code is supplied, the function returns a default error message using the MISSING error code. . load_error_code(): This function loads the application s error code in from the global $ERRORS array to its own member array variable error_message. This function is called from the constructor method and does not need to be called manually, unless you want to reload error messages from $ERRORS.

Web hosting asp - Chapter 4: Architecture of an Intranet Application }

Friday, July 27th, 2007

Chapter 4: Architecture of an Intranet Application } function load_error_code() { global $ERRORS; if (empty($ERRORS[$this->language])) { return FALSE; } while (list($key, $value) = each ($ERRORS[$this->language])) { $this->error_message[$key] = $value; } return TRUE; } } ?> The class.ErrorHandler.php class assumes that the application has all its error messages defined in an application-specific configuration file and all error messages are stored in a multidimensional array called $ERRORS. For example: If this code is stored in appname.errors file and loaded by an application using require_once( appname.errors ), then the ErrorHandler class can print the SAMPLE_ERR_CODE error message in any of the three languages, depending on the default language settings. You can translate your error messages in multiple languages using Language Translation Tools provided by Google at http://translate. google.com/translate_t. Be aware that not all automatic translations are perfect.