/include/utilINC.php

Description

utilINC.php stores site-wide utility functions

Stores functions like myerror(), which handles MySQL and other or die() errors, myRedirect() to direct users away from pages and dbOut() which cleans data coming from MySQL

Includes
require_once ("configINC.php") (line 31)

Provides sitewide configuration info and error handling function

require_once ("connINC.php") (line 36)

Provides database connection capability with conn() function

Functions
dbOut (line 110)

Wrapper function for processing data pulled from db

Forward slashes are added to MySQL data upon entry to prevent SQL errors. Using our dbOut() function allows us to encapsulate the most common functions for removing slashes with the PHP stripslashes() function, plus the trim() function to remove spaces.

Later, we can add to this function sitewide, as new requirements or vulnerabilities develop.

  • return: data cleaned of slashes, spaces around string, etc.
  • todo: none
$str dbOut (string $str)
  • string $str: data as pulled from MySQL
myerror (line 59)

Prints a customized MySQL (or other die() based) error message

When 'or die()' is used, we use this function to customize the error message sent. The global var $HidePageErrors, if true, shows only a public error message, including a code for users to pass identifying the page and line number involved for the error.

Example: TLNCx41

The above would be the example for this file, plus an error at line 41 This allows a user to report an error that identifies it, without compromising site security

void myerror ( $myFile,  $myLine, [string $errorMsg = "No error message sent."], string $myfile, string $myline)
  • string $myfile: file name provided by __FILE__ constant
  • string $myline: line number provided by __LINE__ constant
  • string $errorMsg: message provided by MySQL or programmer
  • $myFile
  • $myLine
myRedirect (line 88)

Forcibly passes user to a local URL. Requires ob_start(); at the top of including pages

PHP does not have a redirect to a local file. The PHP header() function requires an absolute URL, eliciting this workaround. Any page using myRedirect() needs ob_start() at the top of the page or header() errors will occur.

Error will say 'headers already sent', etc.

For completeness, ob_flush() should go at the bottom of the page using myRedirect().

  • todo: none
void myRedirect (string $myURL)
  • string $myURL: locally referenced file as destination for user

Documentation generated on Sat, 03 May 2008 19:47:45 -0700 by phpDocumentor 1.4.1