Update setup file
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 28 Nov 2016 20:41:16 +0000 (15:41 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 28 Nov 2016 20:41:16 +0000 (15:41 -0500)
Updating the setup file with path settings for newer version of PHP.
Using $ENV['GLM_HOST_ID']

setup.phtml

index b1eff56..35fd39e 100755 (executable)
@@ -12,1838 +12,1839 @@ ini_set('include_path', '/usr/share/pear' . ':' .ini_get('include_path'));
 if( !isset($SITEINFO) )
 {
 
-       if(!isset($DEBUG))
-       {
-               $DEBUG = (isset($mysecretcode) && $mysecretcode == 1234);
-       }
-       // setup for pages
-       define("HOME_ID",1); // change this if home page is other than id = 1
-       $PAGES['default'] = 'index';
-       define( "MEMBERS_CATEGORY", 57 ); // set this to the members only category.
-       define( "MEMBERS_LIST_RAND", false ); // set this to the members only category.
-       $PAGES[1] = 'index';
-       //$DEBUG = TRUE;
-
-       /*
-        *      Customer Setup
-        */
-       define("SITENAME","Mackinac Island Packages");  // used for outputing name of site in admin area
-       define("SITE_NAME",SITENAME);   // same as SITENAME
-       define("DB_TYPE", "postgres");  // DB library only knows postgres (FUTURE EXPANSION)
-       define("DB_ERROR_MSG", "an error has occured with the database!");      // default error message
-       define("MULTIPLE_CAT",0);               // weather or not to use many to many relations
-       define("CAT_LOCK",0);                   // If set to 1 or true will lock the categories
-       define("ENTRIES_PER_PAGE",10);  // default per page number
-       define("HTML_HELP_CODE",1);     // this is being depreciated for general help guides
-       define("PRODUCTION_MODE","ON"); // used in the email out for contact DB
-       define("HTML_EMAIL","ON");      // turn ON for html emails
-       define("ACTIVE_FLAG",1);                // turn on if bus_category table has active bool field
-       define("DELUXE_TOOLBOX",1);             // used for the toolbox deluxe vrs.
-       define("SEO_URL",1);                    // weather to use Search Engine Optimisezd url's requires .htaccess enabled
-       /* integration of different apps */
-       define("SITEMAP_GENERATOR",false);
-       define("PHOTO_GALLERY",0);
-       define("GOOGLE_SEARCH",0);
-       define("MEMBERS_DB",0);
-       /** htmlarea plugins */
-       define("HTMLAREA_TABLES",true); // weather to load the table plugin or not
-       define("HTMLAREA_CONTEXT_MENU",true);   // weather to load the context menu plugin or not
-       define("HTMLAREA_IMAGE_MANAGER",true);
-       define("HTMLAREA_CHARACTER_MAP",false);
-       define("HOME_PAGE_EVENTS",0);
-       /*
-        *
-        *      DO NOT EDIT THIS SECTION
-        *
-        */
-
-       // Find where this file is located
-
-       $BASE_PATH              = dirname( __FILE__ );
-       extract($_SERVER);
-
-       $CALLED_FROM_DIR        = substr( dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"]), strlen($BASE_PATH) );
-
-       if( ($x = strlen($CALLED_FROM_DIR)) > 0 )
-               $base_url       = $HTTP_HOST.substr( dirname($SCRIPT_NAME), 0, -strlen($CALLED_FROM_DIR) );
-       else
-       {
-               $script_name_dir = dirname($SCRIPT_NAME);
-               if( $script_name_dir == "/" )
-                       $script_name_dir = "";
-               $base_url       = $HTTP_HOST.$script_name_dir;
-       }
-       $BASE_URL = "http://".$base_url;
-       // Indicate that this file has been referenced
-       $SITEINFO               = TRUE;
-       /*
-        *
-        *      Dynamic Configuration - Parameters that DO change based on location
-        *
-        */
-       switch( $GLM_SERVER_ID )
-       {
-
-               case "devsys.gaslightmedia.com":
-                       ini_set("display_errors","1");
-                       // Use the $BASE_URL for secure URL on Devsys
-                       $BASE_SECURE_URL = $BASE_URL;
-                       define("AUTH_TEST_MODE","TRUE");
-                       define("BASE_SECURE_URL", $BASE_SECURE_URL."/");
-                       define("BASE_INSECURE_URL", $BASE_URL."/");
-                       define("CONN_STR", "host=devsys dbname=mackinacislandpackages");                // DB connection string
-                       define("OWNER_EMAIL", "jamie.kahgee@gmail.com");                // site owner's email address
-                       define("FROM_NEWS_EMAIL", "info@gaslightmedia.com");            // site owner's email address
-                       define("REPLY_TO", "info@gaslightmedia.com");                   // the reply-to field for email's
-               break;
-
-               case "ws1.gaslightmedia.com":
-                       error_reporting(0);
-                       ini_set("display_errors","0");
-                       $BASE_SECURE_URL = "https://".$base_url;
-                       define("BASE_SECURE_URL", $BASE_SECURE_URL."/");
-                       $BASE_URL = "http://".$base_url;
-                       define("BASE_INSECURE_URL", $BASE_URL."/");
-                       //define("BASE_INSECURE_URL", "http://www.mackinacislandpackage.com/");
-                       define("AUTH_TEST_MODE","FALSE");
-                       define("CONN_STR", "host=ds4 dbname=mackinacislandpackages");                    // DB connection string
-                       define("OWNER_EMAIL", "mackinacpackage@mict.com");               // site owner's email address
-                       define("FROM_NEWS_EMAIL", "mackinacpackage@mict.com");          // site owner's email address
-                       define("REPLY_TO", "mackinacpackage@mict.com");                  // the reply-to field for email's
-               break;
-               default:
-            error_reporting( E_ALL ^ E_NOTICE );
-                       ini_set("display_errors","1");
-                       $BASE_SECURE_URL = "https://".$base_url;
-                       // for some sites it is necesary to change base_url when in secure mode
-                       if( $_SERVER['HTTPS'] == "on" )
-                       {
-                               define("BASE_SECURE_URL", $BASE_SECURE_URL."/");         // url used for the secur site
-                               $BASE_URL = "http://".$base_url;                                         // This needs to be set to the real url ie. http://www.upnorth.net
-                       }
-                       define("BASE_INSECURE_URL", $BASE_URL."/");
-                       define("CONN_STR", "user=nobody dbname=mackinacislandpackages");                         // DB connection string
-                       define("OWNER_EMAIL", "mackinacpackage@mict.com");               // site owner's email address
-                       define("FROM_NEWS_EMAIL", "mackinacpackage@mict.com");          // site owner's email address
-                       define("REPLY_TO", "mackinacpackage@mict.com");                  // the reply-to field for email's
-               break;
-       }
-       define("BASE_URL", $BASE_URL."/");                                      // url used for the root of site
-       define("URL_BASE", $BASE_URL."/");                                      // same as BASE_URL
-       define("BASE_PATH", $BASE_PATH."/");                            // root directory path of site
-       define("BASE", $BASE_PATH."/");                                         // same as BASE_PATH
-       define("GOOGLE",BASE.'google/');
-       define("CLASSES",BASE.'classes/');
-       define("HELP_BASE", "help/");                                           // help guide base (depreciated)
-       define("UP_BASE", BASE."uploads/");                                     // uploads directory path
-       define("IMG_BASE", URL_BASE."images/");                         // the images url path
-       define("POSTCARD_URL",URL."postcard.phtml");            // postcard url (used for postcard app)
-       define("LOGO_IMG",URL_BASE."images/logoicon.gif");      // used in admin area as the path to image logo
-       define("HELP_IMG",URL_BASE."images/help.gif");          // help image url (depriated)
-       define("ORIGINAL_PATH", BASE."images/original/");       // path of original images
-       define("RESIZED_PATH", BASE."images/resized/");         // path of first resized image
-       define("MIDSIZED_PATH", BASE."images/midsized/");       // path of half sized of resized
-       define("THUMB_PATH", BASE."images/thumb/");                     // path of thumbnail directory
-       if( $_SERVER['HTTPS'] == "on" )
-       {
-               define("ORIGINAL", $BASE_SECURE_URL."/images/original/");       // url of original images
-               define("RESIZED", $BASE_SECURE_URL."/images/resized/");         // url of resized
-               define("MIDSIZED", $BASE_SECURE_URL."/images/midsized/");       // url of midsized
-               define("THUMB", $BASE_SECURE_URL."/images/thumb/");                     // url of thumbnail
-       }
-       else
-       {
-               define("ORIGINAL", URL_BASE."images/original/");        // url of original images
-               define("RESIZED", URL_BASE."images/resized/");          // url of resized
-               define("MIDSIZED", URL_BASE."images/midsized/");        // url of midsized
-               define("THUMB", URL_BASE."images/thumb/");                      // url of thumbnail
-       }
-
-       /** these are the image sizing defines USE THESE ONLY
-         only allowed string of 'WxH[<>]' [-quality Percentage]
-        */
-       define("ITEM_RESIZED", "'287>'");               // used in convert call to resize images
-       define("ITEM_MIDSIZED", "'210>'");
-       define("ITEM_THUMB","'120>'");
-
-       define("FOOTER_IMG", URL_BASE."images/logosmall.gif");
-       define("FOOTER_URL", URL_BASE);
-       define("STYLE","main.css");
-
-       /**
-         These are defines for the photo gallery images
-        */
-       define('PHOTO_LARGE_SIZE',"'700x450>'");
-       define('PHOTO_LARGE_DIR',BASE.'images/photo-large/');
-       define('PHOTO_LARGE_URL',BASE_URL.'images/photo-large/');
-
-       define('PHOTO_SMALL_SIZE',"'133x100>'");
-       define('PHOTO_SMALL_DIR',BASE.'images/photo-small/');
-       define('PHOTO_SMALL_URL',BASE_URL.'images/photo-small/');
-       // [status_US] array of states and their abbr.
-       $states_US[""] = "- Choose State -";
-       $states_US["AL"]= "Alabama";
-       $states_US["AK"]= "Alaska";
-       $states_US["AZ"]= "Arizona";
-       $states_US["AR"]= "Arkansas";
-       $states_US["CA"]= "California";
-       $states_US["CO"]= "Colorado";
-       $states_US["CT"]= "Connecticut";
-       $states_US["DE"]= "Delaware";
-       $states_US["DC"]= "District of Columbia";
-       $states_US["FL"]= "Florida";
-       $states_US["GA"]= "Georgia";
-       $states_US["HI"]= "Hawaii";
-       $states_US["ID"]= "Idaho";
-       $states_US["IL"]= "Illinois";
-       $states_US["IN"]= "Indiana";
-       $states_US["IA"]= "Iowa";
-       $states_US["KS"]= "Kansas";
-       $states_US["KY"]= "Kentucky";
-       $states_US["LA"]= "Louisiana";
-       $states_US["ME"]= "Maine";
-       $states_US["MD"]= "Maryland";
-       $states_US["MA"]= "Massachusetts";
-       $states_US["MI"]= "Michigan";
-       $states_US["MN"]= "Minnesota";
-       $states_US["MS"]= "Mississppi";
-       $states_US["MO"]= "Missouri";
-       $states_US["MT"]= "Montana";
-       $states_US["NE"]= "Nebraska";
-       $states_US["NV"]= "Nevada";
-       $states_US["NH"]= "New Hampshire";
-       $states_US["NJ"]= "New Jersey";
-       $states_US["NM"]= "New Mexico";
-       $states_US["NY"]= "New York";
-       $states_US["NC"]= "North Carolina";
-       $states_US["ND"]= "North Dakota";
-       $states_US["OH"]= "Ohio";
-       $states_US["OK"]= "Oklahoma";
-       $states_US["OR"]= "Oregon";
-       $states_US["PA"]= "Pennsylvania";
-       $states_US["RI"]= "Rhode Island";
-       $states_US["SC"]= "South Carolina";
-       $states_US["SD"]= "South Dakota";
-       $states_US["TN"]= "Tennessee";
-       $states_US["TX"]= "Texas";
-       $states_US["UT"]= "Utah";
-       $states_US["VT"]= "Vermont";
-       $states_US["VA"]= "Virginia";
-       $states_US["WA"]= "Washington";
-       $states_US["WV"]= "West Virginia";
-       $states_US["WI"]= "Wisconsin";
-       $states_US["WY"]= "Wyoming";
-
-       // [states] extended states array
-       $states[""] = "- Choose State -";
-       $states["AL"]  = "Alabama";
-       $states["AK"] =  "Alaska";
-       $states["AB"] =  "Alberta";
-//     $states["AS"] =  "American Samoa";
-       $states["AZ"] =  "Arizona";
-       $states["AR"] =  "Arkansas";
-       $states["BC"] =  "British Columbia";
-       $states["CA"] =  "California";
-       $states["CO"] =  "Colorado";
-       $states["CT"] =  "Connecticut";
-       $states["DE"] =  "Delaware";
-       $states["DC"] =  "District of Columbia";
-//     $states["FM"] =  "Federated States of Micronesia";
-       $states["FL"] =  "Florida";
-       $states["GA"] =  "Georgia";
-//     $states["GU"] =  "Guam";
-       $states["HI"] =  "Hawaii";
-       $states["ID"] =  "Idaho";
-       $states["IL"] =  "Illinois";
-       $states["IN"] =  "Indiana";
-       $states["IA"] =  "Iowa";
-       $states["KS"] =  "Kansas";
-       $states["KY"] =  "Kentucky";
-       $states["LA"] =  "Louisiana";
-       $states["ME"] =  "Maine";
-       $states["MB"] =  "Manitoba";
-//     $states["MH"] =  "Marshall Islands";
-       $states["MD"] =  "Maryland";
-       $states["MA"] =  "Massachusetts";
-       $states["MI"] =  "Michigan";
-       $states["MN"] =  "Minnesota";
-       $states["MS"] =  "Mississppi";
-       $states["MO"] =  "Missouri";
-       $states["MT"] =  "Montana";
-       $states["NE"] =  "Nebraska";
-       $states["NV"] =  "Nevada";
-       $states["NB"] =  "New Brunswick";
-       $states["NF"] =  "Newfoundland";
-       $states["NH"] =  "New Hampshire";
-       $states["NJ"] =  "New Jersey";
-       $states["NM"] =  "New Mexico";
-       $states["NY"] =  "New York";
-       $states["NC"] =  "North Carolina";
-       $states["ND"] =  "North Dakota";
-//     $states["MP"] =  "Northern Mariana Islands";
-       $states["NT"] =  "Northwest Territories";
-       $states["NS"] =  "Nova Scotia";
-       $states["OH"] =  "Ohio";
-       $states["OK"] =  "Oklahoma";
-       $states["ON"] =  "Ontario";
-       $states["OR"] =  "Oregon";
-//     $states["PW"] =  "Palau";
-       $states["PA"] =  "Pennsylvania";
-       $states["PE"] =  "Prince Edward Island";
-       $states["PR"] =  "Puerto Rico";
-       $states["QC"] =  "Quebec";
-       $states["RI"] =  "Rhode Island";
-       $states["SK"] =  "Saskatchewan";
-       $states["SC"] =  "South Carolina";
-       $states["SD"] =  "South Dakota";
-       $states["TN"] =  "Tennessee";
-       $states["TX"] =  "Texas";
-       $states["UT"] =  "Utah";
-       $states["VT"] =  "Vermont";
-       $states["VI"] =  "Virgin Islands";
-       $states["VA"] =  "Virginia";
-       $states["WA"] =  "Washington";
-       $states["WV"] =  "West Virginia";
-       $states["WI"] =  "Wisconsin";
-       $states["WY"] =  "Wyoming";
-       $states["YT"] =  "Yukon";
-//     $states["Asia"] =  "Asia";
-//     $states["Australia"] =  "Australia";
-//     $states["Bahamas"] =  "Bahamas";
-//     $states["Caribbean"] =  "Caribbean";
-//     $states["Costa Rica"] =  "Costa Rica";
-//     $states["South America"] =  "South America";
-//     $states["South Africa"] =  "South Africa";
-//     $states["Europe"] =  "Europe";
-//     $states["Mexico"] = "Mexico";
-       /* Libraries */
-       /* Replaced with the actual functions instead of includes (2001-12-14) */
-
-       $cp1252_map = array(
-                       "\xc2\x80" => "\xe2\x82\xac", /* EURO SIGN */
-                       "\xc2\x82" => "\xe2\x80\x9a", /* SINGLE LOW-9 QUOTATION MARK */
-                       "\xc2\x83" => "\xc6\x92",    /* LATIN SMALL LETTER F WITH HOOK */
-                       "\xc2\x84" => "\xe2\x80\x9e", /* DOUBLE LOW-9 QUOTATION MARK */
-                       "\xc2\x85" => "\xe2\x80\xa6", /* HORIZONTAL ELLIPSIS */
-                       "\xc2\x86" => "\xe2\x80\xa0", /* DAGGER */
-                       "\xc2\x87" => "\xe2\x80\xa1", /* DOUBLE DAGGER */
-                       "\xc2\x88" => "\xcb\x86",    /* MODIFIER LETTER CIRCUMFLEX ACCENT */
-                       "\xc2\x89" => "\xe2\x80\xb0", /* PER MILLE SIGN */
-                       "\xc2\x8a" => "\xc5\xa0",    /* LATIN CAPITAL LETTER S WITH CARON */
-                       "\xc2\x8b" => "\xe2\x80\xb9", /* SINGLE LEFT-POINTING ANGLE QUOTATION */
-                       "\xc2\x8c" => "\xc5\x92",    /* LATIN CAPITAL LIGATURE OE */
-                       "\xc2\x8e" => "\xc5\xbd",    /* LATIN CAPITAL LETTER Z WITH CARON */
-                       "\xc2\x91" => "\xe2\x80\x98", /* LEFT SINGLE QUOTATION MARK */
-                       "\xc2\x92" => "\xe2\x80\x99", /* RIGHT SINGLE QUOTATION MARK */
-                       "\xc2\x93" => "\xe2\x80\x9c", /* LEFT DOUBLE QUOTATION MARK */
-                       "\xc2\x94" => "\xe2\x80\x9d", /* RIGHT DOUBLE QUOTATION MARK */
-                       "\xc2\x95" => "\xe2\x80\xa2", /* BULLET */
-                       "\xc2\x96" => "\xe2\x80\x93", /* EN DASH */
-                       "\xc2\x97" => "\xe2\x80\x94", /* EM DASH */
-
-                       "\xc2\x98" => "\xcb\x9c",    /* SMALL TILDE */
-                       "\xc2\x99" => "\xe2\x84\xa2", /* TRADE MARK SIGN */
-                       "\xc2\x9a" => "\xc5\xa1",    /* LATIN SMALL LETTER S WITH CARON */
-                       "\xc2\x9b" => "\xe2\x80\xba", /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
-                       "\xc2\x9c" => "\xc5\x93",    /* LATIN SMALL LIGATURE OE */
-                       "\xc2\x9e" => "\xc5\xbe",    /* LATIN SMALL LETTER Z WITH CARON */
-                       "\xc2\x9f" => "\xc5\xb8"      /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
-                               );
-       /**
-        * is_utf8
-        *
-        * @param mixed $string
-        * @access public
-        * @return void
-        */
-       function is_utf8($string) {
-               return (preg_match('/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]|[\xee-\xef][\x80-\xbf]{2}|f0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})*$/', $string) === 1);
-       }
-       /**
-        * cp1252_to_utf8
-        *
-        * @param mixed $str
-        * @access public
-        * @return void
-        */
-       function cp1252_to_utf8($str) {
-               global $cp1252_map;
-               return  strtr(utf8_encode($str), $cp1252_map);
-       }
-       /**
-        * myEncode
-        *
-        * @param mixed $string
-        * @access public
-        * @return void
-        */
-       function myEncode( $string )
-       {
-               if( is_utf8( $string ) )
-               {
-                       return( $string );
-               }
-               else
-               {
-                       return( cp1252_to_utf8( $string ) );
-               }
-       }
-
-       /**
-        * CreditVal : CreditVal Checks for a valid credit card number doing Luhn check, if no
-        card type is given, attempts to guess. Then, if a list of
-        accepted types is given, determines whether or not we'll
-        accept it
-        * @param $Num: Credit Card Number
-        * @param $Name = '': Type of Card
-        * @param $Accepted='' : Accepted array
-        *
-        * @return bool
-        * @access
-        **/
-       function CreditVal($Num, $Name = '', $Accepted='')
-       {
-               $Name = strtolower( $Name );
-               $Accepted = strtolower( $Accepted );
-               $GoodCard = 1;
-               $Num = preg_replace("%[^[:digit:]]%", "", $Num);
-               switch ($Name)
-               {
-
-                       case "mastercard" :
-                               $GoodCard = preg_match("%^5[1-5].{14}$%", $Num);
-                       break;
-
-                       case "visa" :
-                               $GoodCard = preg_match("%^4.{15}$|^4.{12}$%", $Num);
-                       break;
-
-                       case "americanexpress" :
-                               $GoodCard = preg_match("%^3[47].{13}$%", $Num);
-                       break;
-
-                       case "discover" :
-                               $GoodCard = preg_match("%^6011.{12}$%", $Num);
-                       break;
-
-                       case "dinerscard" :
-                               $GoodCard = preg_match("%^30[0-5].{11}$|^3[68].{12}$%", $Num);
-                       break;
-
-                       default:
-                       if( preg_match("%^5[1-5].{14}$%", $Num) ) $Name = "mastercard";
-                       if( preg_match("%^4.{15}$|^4.{12}$%", $Num) ) $Name = "visa";
-                       if( preg_match("%^3[47].{13}$%", $Num) ) $Name = "americanexpress";
-                       if( preg_match("%^6011.{12}$%", $Num) ) $Name = "discover";
-                       if( preg_match("%^30[0-5].{11}$|^3[68].{12}$%", $Num) ) $Name="dinerscard";
-                       break;
-               }
-
-               // If there's a limit on card types we accept, check for it here.
-               if( $Accepted )
-               {
-                       $type_verified = FALSE;
-                       $brands = explode_trim( ",", $Accepted );
-                       foreach( $brands as $brand )
-                               if( $Name == $brand )
-                                       $type_verified = TRUE;
-
-                       if( !$type_verified ) return(FALSE);
-               }
-
-               $Num = strrev($Num);
-
-               $Total = 0;
-
-               for ($x=0; $x<strlen($Num); $x++)
-               {
-                       $digit = substr($Num,$x,1);
-                       if ($x/2 != floor($x/2))
-                       {
-                               $digit *= 2;
-                               if (strlen($digit) == 2)
-                                       $digit = substr($digit,0,1) + substr($digit,1,1);
-                       }
-                       $Total += $digit;
-               }
-               if ($GoodCard && $Total % 10 == 0)
-               {
-                       return(true);
-               }
-               else
-               {
-                       return(false);
-               }
-       }
-       /* DataBase Library */
-
-       /**
-        * db_connect :Creates a connection to database specified $conn_str
-        * @param $conn="" : connection string
-        *
-        * @return index or bool
-        * @access
-        **/
-       function db_connect($conn="")
-       {
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               if($conn == "")
-                                       $conn = CONN_STR;
-                       $ret = pg_connect($conn);
-                       break;
-                       default:
-                       return(0);
-               }
-
-               return($ret);
-       }
-
-       /**
-        * db_close :Closes the connection to database specified by the handle dbd
-        * @param $$dbd : database handle
-        *
-        * @return bool
-        * @access
-        **/
-       function db_close($dbd)
-       {
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               $ret = pg_close($dbd);
-                       break;
-                       default:
-                       return(0);
-               }
-
-               return($ret);
-       }
-
-       /**
-         NOTICE DON'T USE THIS
-        * db_pconnect :Creates a persistant connection to database specified in $conn_str
-        * @param $$conn="" : connection string
-        *
-        * @return
-        * @access
-        **/
-       function db_pconnect($conn="")
-       {
-               return( false );
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               if($conn == "")
-                                       $conn == CONN_STR;
-                       $ret = pg_pconnect($conn);
-                       break;
-                       default:
-                       return(0);
-               }
-
-               return($ret);
-       }
-
-       /**
-        * db_exec : Execute an SQL query
-        * @param $dbd: database handle
-        * @param $$qs : Query
-        *
-        * @return int Returns a valid result index on success 0 on failure
-        * @access
-        **/
-       function db_exec($dbd, $qs)
-       {
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               $ret = pg_exec($dbd, $qs);
-                       break;
-
-                       default:
-                       return(0);
-               }
-
-               return($ret);
-       }
-
-       /**
-        * db_fetch_array :Stores the data in associative indices, using the field names as
-        * keys.
-        * @param $res: valid database result index
-        * @param $i: row number
-        * @param $$type : database type
-        *
-        * @return array Returns an associative array of key-value pairs
-        * @access
-        **/
-       function db_fetch_array($res, $i, $type)
-       {
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               $row = pg_fetch_array($res, $i, $type);
-                       break;
-
-                       default:
-                       return(0);
-               }
-
-               return($row);
-       }
-
-       /**
-        * db_freeresult :Free result memory.
-        * @param $$res : valid database result index
-        *
-        * @return bool - Returns 1 for success 0 for failure
-        * @access
-        **/
-       function db_freeresult($res)
-       {
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               $ret = pg_freeresult($res);
-                       break;
-
-                       default:
-                       return(0);
-               }
-
-               return($ret);
-       }
-
-       /**
-        * db_numrows :Determine number of rows in a result index
-        * @param $$res : valid database result index
-        *
-        * @return int - Returns number of rows
-        * @access
-        **/
-       function db_numrows($res)
-       {
-
-               switch (DB_TYPE)
-               {
-                       case "postgres":
-                               $ret = pg_numrows($res);
-                       break;
-
-                       default:
-                       return(-1);
-               }
-
-               return($ret);
-       }
-
-       /************************************************************************
-        *                                                                                                                                              *
-        * BEGIN Auto functions                                                                                                 *
-        *                                                                                                                                              *
-        ***********************************************************************/
-
-       /**
-        * db_auto_array :The auto function for retrieving an array based soley on a query
-        * string. This function makes the connection, does the exec, fetches
-        * the array, closes the connection, frees memory used by the result,
-        * and then returns the array
-        * @param $qs: SQL query string
-        * @param $i: row number
-        * @param $$type : PGSQL_ASSOC or PGSQL_BOTH or PSQL_NUM
-        *
-        * @return array - Returns an associative array of key-value pairs
-        * @access
-        **/
-       function db_auto_array($qs, $i, $type)
-       {
-
-               $dbd = db_connect();
-               if(!$dbd)
-               {
-                       return(0);
-               }
-               $res = db_exec($dbd, $qs);
-               if(!$res)
-               {
-                       return(0);
-               }
-
-               $row = db_fetch_array($res, $i, $type);
-
-               if(!db_freeresult($res))
-               {
-                       return(0);
-               }
-
-               db_close($dbd);
-               return($row);
-       }
-
-       /**
-        * db_auto_exec :The auto function for executing a query.
-        * This function makes the connection, does the exec, fetches
-        * the array, closes the connection, frees memory used by the result,
-        * and then returns success (not a valid result index)
-        * @param $qs: SQL query string
-        * @param $$conn="" : Connect String
-        *
-        * @return int - Returns 1 (or oid, if available) for success 0 for failure
-        * @access
-        **/
-       function db_auto_exec($qs, $conn="")
-       {
-
-               if($conn == "")
-                       $conn = CONN_STR;
-               $dbd = db_connect($conn);
-               if(!$dbd)
-                       return(0);
-               if(!db_exec($dbd, $qs))
-               {
-                       db_close($dbd);
-                       return(0);
-               }
-               else
-               {
-                       db_close($dbd);
-                       return(1);
-               }
-       }
-
-       /**
-        * db_auto_get_data :The auto function for retrieving an array based soley on a query
-        string. This function makes the connection, does the exec, fetches
-        the array, closes the connection, frees memory used by the result,
-        and then returns the array
-        * @param $qs:  SQL query string
-        * @param $CONN_STR: Connect String
-        * @param $$fail_mode=0 : Failure Mode
-        *
-        * @return array Returns an associative array of key-value pairs
-        * @access
-        **/
-       function db_auto_get_data($qs,$conn = CONN_STR,$fail_mode=0)
-       {
-
-               if( !($dbd = db_connect($conn)) )
-               {
-                       return( FALSE );
-               }
-
-               if( !($res = db_exec($dbd, $qs)) )
-               {
-                       return( FALSE );
-               }
-
-               $totalrows = pg_NumRows($res);
-
-               for( $i = 0 ; $i < $totalrows ; $i++ )
-               {
-                       $data[$i] = db_fetch_array($res, $i, PGSQL_ASSOC );
-               }
-
-               db_close( $dbd );
-               if(isset($data) && $data!="")
-               {
-                       return( $data );
-               }
-               else
-               {
-                       return(0);
-               }
-       }
-
-       /* HTML Libraries */
-
-       /**
-        * html_footer :Generates a footer table on the bottom of the page it's called on.
-        and closes out the body and html tags.
-        *
-        * @return void
-        * @access
-        **/
-       function html_footer()
-       {
-               $footer_table_width = "400";
-               $footer_table_align = "center";
-
-               ?>
-                       <hr>
-                       <table width="<?echo $footer_table_width?>" align="<?echo $footer_table_align?>" summary="Footer Information" class="footertable" cellspacing="0">
-                       <tr>
-                       <td align="left" class="footertd">
-                       <a href="mailto:<?echo MASTER_EMAIL?>"><?echo MASTER?></a>
-                       </td>
-                       <td align="right" class="footertd">
-                       <a href="<?echo FOOTER_URL?>" target="new">
-                       <img src="<?echo FOOTER_IMG?>" border=0 alt="FOOTER_IMG"></a>
-                       </td>
-                       </tr>
-                       </table>
-                       </body>
-                       </html>
-                       <?
-                       exit(); /* we've got to terminate any more output */
-       }
-
-       /**
-        * html_error :Generates a footer table on the bottom of the page it's called on.
-        and closes out the body and html tags.
-        * @param $msg: string error message to be displayed
-        * @param $$bail : bool whether or not to exit() after $msg
-        *
-        * @return void
-        * @access
-        **/
-       function html_error($msg, $bail)
-       {
-               ?>
-                       <table summary="Error Information" class="errortable" cellspacing="0">
-                       <tr class="errortr">
-                       <td class="errortd">
-                       <div class="errormsg"><?echo "<pre>$msg</pre>"?></div>
-                       </td>
-                       </tr>
-                       </table>
-
-                       <?
-                       if($bail)
-                       {
-                               html_footer();
-                       }
-       }
-
-       /**
-        * html_nav_table :Generates a navigation table on the page it's called on.
-        * @param $nav: associative array with entries like:$nav[text][url]
-        * @param $$w : max width of table
-        *
-        * @return void
-        * @access
-        **/
-       function html_nav_table($nav, $w)
-       {
-               if( is_array( $nav ) )
-               {
-                       $out = '<ul class="admin_nav">';
-                       foreach( $nav as $link => $url )
-                       {
-                               $out .= '<li><a href="'.$url.'">'.$link.'</a></li>';
-                       }
-                       $out .= '</ul>';
-               }
-               echo $out;
-       }
-
-       /**
-        * html_header :Opens up the html tags, and includes the style sheet link
-        generates a header table on the top of the page it's called on.
-        * @param $title: Page Title
-        * @param $msg: message to display
-        * @param $$img : image to display
-        *
-        * @return void
-        * @access
-        **/
-       function html_header($title, $msg, $img)
-       {
-               $header_table_width = "400";
-               $header_table_align = "center";
-
-               ?>
-                       <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-                       "http://www.w3.org/TR/html4/loose.dtd">
-                       <html>
-                       <head>
-                       <title><?echo $title?></title>
-                       <link type="text/css" rel=stylesheet href="<?echo STYLE?>">
-                       </head>
-                       <body>
-                       <table width="<?echo $header_table_width?>" align="<?echo $header_table_align?>" summary="Header Information" class="headertable" cellspacing="0" cellpadding="3">
-                       <tr class="headertr">
-                       <td class="headertd">
-                       <?
-                       if($img)
-                       {
-                               ?>
-                                       <img src="<?echo IMG_BASE.$img?>" alt="<?echo HEAD?>" border="0">
-                                       <?
-                       }
-               ?>
-                       </td>
-                       </tr>
-                       <tr>
-                       <td class="headertd2" align="center">
-                       <div class="headerh2" align="center"><?echo "$msg"?></div>
-                       </td>
-                       </tr>
-                       </table>
-                       <?
-       }
-
-       /**
-        * form_header :Opens up the form tag, and includes the hidden assoc array as hidden
-        fields.
-        * @param $action: string form action string
-        * @param $method: string Method of form
-        * @param $$hidden = "" : assoc array with $hidden($name => $value)
-        *
-        * @return void
-        * @access
-        **/
-       function form_header($action, $method, $hidden = "")
-       {
-               echo "<form action=\"$action\" method=\"$method\"
-                       enctype=\"multipart/form-data\">";
-               if($hidden != "" && is_array($hidden))
-               {
-                       foreach($hidden as $key=>$value)
-                       {
-                               echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";
-                       }
-               }
-       }
-
-       /**
-        * text_area :Creates textarea with good default values for rows cols and wrap.
-        * @param $name: string form action string
-        * @param $value: string Method of form
-        * @param $$rows = 15: int4 number of rows in textarea box
-        * @param $$cols = 50: int4 number of cols in textarea box
-        * @param $$wrap = "virtual"  : string the wrap value for the textarea box
-        *
-        * @return void
-        * @access
-        **/
-       function text_area($name, $value, $rows = 15, $cols = 50, $wrap = "virtual" )
-       {
-               echo "<td class=\"navtd2\"><textarea id=\"$name\" name=\"$name\" cols=\"$cols\"
-                       rows=\"$rows\" wrap=\"$wrap\" maxlength=\"8104\">$value</textarea></td>";
-       }
-
-       /**
-        * text_box :Creates a input box for text with 35 as default size
-        * @param $name: string name of text box
-        * @param $value: string value of text box
-        * @param $$size = 35 : string size of text box
-        *
-        * @return void
-        * @access
-        **/
-       function text_box($name, $value, $size = 35)
-       {
-               echo "<td class=\"navtd2\"><input type=\"text\" name=\"$name\"
-                       value=\"".htmlspecialchars($value)."\" size=\"$size\"></td>";
-       }
-
-       /**
-        * form_footer :Closes up the form tag, and includes the submit button
-        * @param $name: string form action string
-        * @param $$suppress = 0: string Method of form
-        * @param $$cs : int colspan for td
-        *
-        * @return void
-        * @access
-        **/
-       function form_footer($name, $suppress = 0, $cs)
-       {
-               echo "<tr><td colspan=\"$cs\" align=center>
-                       <input type=\"SUBMIT\" name=\"Command\" value=\"$name\">";
-               if($suppress == 1)
-               {
-                       echo "<input type=\"SUBMIT\" name=\"Command\" value=\"Delete\">";
-               }
-               /*              echo "<input type=\"SUBMIT\" name=\"Command\" value=\"Cancel\">";*/
-               echo "</td>";
-       }
-
-       /* Graphics Libraries */
-       /**
-        * process_image
-        * NOTES:
-        * This function does the following:
-        *
-        * 1) places image into original folder
-        *
-        * 2) makes three images from original size and places them
-        * into the RESIZED, MIDSIZED, and THUMB folders
-        *
-        * @param mixed $image
-        * @param mixed $image_name
-        * @access public
-        * @return string
-        */
-       function process_image( $image, $image_name )
-       {
-               if(!defined("ORIGINAL_PATH"))
-               {
-                       html_error("this not defined original_path",1);
-               }
-               if(!defined("RESIZED_PATH"))
-               {
-                       html_error("this not defined resized_path",1);
-               }
-               if(!defined("MIDSIZED_PATH"))
-               {
-                       html_error("this not defined midsized_path",1);
-               }
-               if(!defined("THUMB_PATH"))
-               {
-                       html_error("this not defined thumb_path",1);
-               }
-               $image_upload_array = img_upload($image,$image_name,ORIGINAL_PATH);
-               //img_resize($image_upload_array[1],ORIGINAL_PATH.$image_upload_array[0],ITEM_ORIGINAL);
-               img_resize(ORIGINAL_PATH.$image_upload_array[0],RESIZED_PATH.$image_upload_array[0],ITEM_RESIZED);
-               img_resize(RESIZED_PATH.$image_upload_array[0],MIDSIZED_PATH.$image_upload_array[0],ITEM_MIDSIZED);
-               img_resize(MIDSIZED_PATH.$image_upload_array[0],THUMB_PATH.$image_upload_array[0],ITEM_THUMB);
-               $image_name = $image_upload_array[0];
-               return($image_name);
-       }
-
-       /**
-        * img_resize
-        * resized based on imagick widthxheight given
-        * to scale by maxwidth of 280 use '280>'
-        * which will keep it from making image larger
-        *
-        * @param mixed $path2image
-        * @param mixed $path2thumb
-        * @param mixed $size
-        * @access public
-        * @return string
-        */
-       function img_resize( $path2image, $path2thumb, $size )
-       {
-               exec( "which convert", $output, $return );
-               if( $return == 0 )
-               {
-                       $CONVERT = $output[0];
-               }
-               else
-               {
-                       return( $error = array('convert path uknown') );
-               }
-               $imageName = basename($path2image);
-               $thumbName = basename($path2thumb);
-
-               exec("$CONVERT -quality 100 -scale $size $path2image $path2thumb");
-
-               $img_resize_array = array("$imageName","$path2image","$thumbName","$path2thumb");
-               return($img_resize_array);
-       }
-
-       /**
-        * img_upload
-        * simplified to use the file_upload function with restricted set to true
-        * which will return an array instead of string (as in files)
-        * and only allow png,gif,jpg images to be uploaded
-        *
-        * @param mixed $form_field
-        * @param mixed $img_name
-        * @param mixed $destination_path
-        * @access public
-        * @return string
-        */
-       function img_upload( $form_field, $img_name, $destination_path )
-       {
-               return( file_upload( $form_field, $img_name, $destination_path, true ) );
-       }
-
-       /**
-        * file_upload
-        * this will replace the older version and that of img_upload which calls this with extra
-        * restricted of true
-        *
-        * @param mixed $form_field
-        * @param mixed $file_name
-        * @param mixed $destination_path
-        * @access public
-        * @return string
-        */
-       function file_upload( $form_field, $file_name, $destination_path, $restricted = false )
-       {
-               $file_name_in_use = false;
-               $file_name = preg_replace( "%[!@#$\%^&()+={};:\'\"\/ ]%", "-", $file_name );
-               if( $restricted )
-               {
-                       $size = getImageSize( $form_field );
-                       if( !in_array( $size[2], array( 1, 2, 3 ) ) )
-                       {
-                               echo '<p style="background-color:red;color:white;">'
-                               .'The file you uploaded was of an incorect type, please only upload .gif,.png or .jpg files'
-                               .'<BR CLEAR=ALL>'
-                               .'</p>'
-                               ."Hit your browser's back button to continue"
-                               .'<P>';
-                               $error[0] = "ERROR";
-                               return($error);
-                       }
-               }
-               if( file_exists( $destination_path.$file_name ) )
-               {
-                       $file_name_in_use = true;
-               }
-               if( $file_name_in_use == true )
-               {
-                       $new_file_name = mktime().$file_name;
-                       $new_file_location = $destination_path.$new_file_name;
-                       copy( $form_field, $new_file_location );
-                       $file_upload = $new_file_name;
-                       $file_upload_array = array( $new_file_name, $new_file_location );
-               }
-               else
-               {
-                       $new_file_name = $file_name;
-                       $new_file_location = $destination_path.$new_file_name;
-                       copy( $form_field, $new_file_location );
-                       $file_upload = $new_file_name;
-                       $file_upload_array = array( $new_file_name, $new_file_location );
-               }
-               if( is_file( $new_file_location ) )
-               {
-                       chmod( $new_file_location, 0666 );
-               }
-               if( $restricted )
-               {
-                       return( $file_upload_array );
-               }
-               else
-               {
-                       return( $file_upload );
-               }
-       }
-
-       /* Misc. Functions */
-
-       /**
-        * http_strip :Strips the http:// part from start of string
-        * @param $&$string : $string
-        *
-        * @return string $stirng minus http:// in front
-        * @access
-        **/
-       function http_strip(&$string)
-       {
-               $test_string = strtolower($string);
-               if(substr($test_string,0,7) == "http://")
-               {
-                       $string = substr($string,7);
-               }
-       }
-
-       /**
-        * footer : used for admin page footer to close out the top function
-        *
-        * @return void
-        * @access
-        **/
-       function footer()
-       {
-               $out = '
-                       </body>
-                       </html>
-                       ';
-               echo $out;
-       }
-
-       /**
-        * top :Output the starting html and admin table tags
-        * @param $message: The title
-        * @param $hp: The help file to use
-        * @param $$hp2 = NULL : The help file to use (links to gaslightmedia.com)
-        *
-        * @return void
-        * @access
-        **/
-       function top($message, $hp,$hp2 = NULL)
-       {
-               if($hp2 != "")
-               {
-                       $help_guide = '<div id="glm-manual">';
-                       /*
-                          $help_guide = '<div id="glm-manual"><a id="manual-html"
-                          href="http://www.gaslightmedia.com/manuals/html/'.$hp2.'.html"
-                          target="_blank">Online Help Guide</a>&nbsp;';
-                        */
-                       $help_guide .= '<a id="manual-pdf"
-                               href="http://www.gaslightmedia.com/manuals/pdf/'.$hp2.'.pdf"
-                               target="_blank">Printable Help Guide</a></div>';
-               }
-               $out = '
-                       <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-                       "http://www.w3.org/TR/html4/strict.dtd">
-                       <html>
-                       <head>
-                       <title>Untitled</title>
-                       <meta http-equiv="content-type" content="text/html;charset=utf-8">
-                       <link rel="stylesheet" type="text/css" href="../main.css">
-                       </head>
-                       <body>
-                       <h1>'.$message.'</h1>
-                       '.$help_guide.'
-                       ';
-               echo $out;
-       }
-
-       /**
-        * top2 : alias to top()
-        * @param $message: message title
-        * @param $hp: help file
-        * @param $$hp2 = NULL : gaslight help file
-        *
-        * @return
-        * @access
-        **/
-       function top2($message, $hp,$hp2 = NULL)
-       {
-               // make this an alias to top()
-               // by calling top instead of adding extra code
-               top($message,$hp,$hp2);
-
-       }
-
-       /********************************************************************************
-        *
-        *      DO NOT EDIT THIS SECTION
-        *
-        ********************************************************************************/
-
-       if( $DEBUG )
-       {
-               echo '<CENTER>
-                       <TABLE BORDER=0 CELLPADDING=3 CELLSPACING=1 WIDTH=600 BGCOLOR="#000000" ALIGN="CENTER">
-                       <TR VALIGN="middle" BGCOLOR="#9999CC">
-                       <TD COLSPAN="2" ALIGN="center"><H1>Portable Site Data - setup.phtml </H1></TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>CVS Version Id:</B></TD>
-                       <TD ALIGN="left">$Id: setup.phtml,v 1.10 2011/06/13 12:42:22 matrix Exp $</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>SITENAME</B></TD>
-                       <TD ALIGN="left">'.SITENAME.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>BASE</B></TD>
-                       <TD ALIGN="left">'.BASE.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>UP_BASE</B></TD>
-                       <TD ALIGN="left">'.UP_BASE.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>HELP_BASE</B></TD>
-                       <TD ALIGN="left">'.HELP_BASE.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>IMG_BASE</B></TD>
-                       <TD ALIGN="left">'.IMG_BASE.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>URL_BASE</B></TD>
-                       <TD ALIGN="left">'.URL_BASE.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>CONN_STR</B></TD>
-                       <TD ALIGN="left">'.CONN_STR.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>STYLE</B></TD>
-                       <TD ALIGN="left">'.STYLE.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>ORIGINAL_PATH</B></TD>
-                       <TD ALIGN="left">'.ORIGINAL_PATH.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>RESIZED_PATH</B></TD>
-                       <TD ALIGN="left">'.RESIZED_PATH.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>MIDSIZED_PATH</B></TD>
-                       <TD ALIGN="left">'.MIDSIZED_PATH.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>THUMB_PATH</B></TD>
-                       <TD ALIGN="left">'.THUMB_PATH.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>ORIGINAL</B></TD>
-                       <TD ALIGN="left">'.ORIGINAL.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>RESIZED</B></TD>
-                       <TD ALIGN="left">'.RESIZED.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>MIDSIZED</B></TD>
-                       <TD ALIGN="left">'.MIDSIZED.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>THUMB</B></TD>
-                       <TD ALIGN="left">'.THUMB.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>$CALLED_FROM_DIR</B></TD>
-                       <TD ALIGN="left">'.$CALLED_FROM_DIR.'&nbsp;</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>$BASE_PATH</B></TD>
-                       <TD ALIGN="left">'.$BASE_PATH.'</TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>$BASE_URL</B></TD>
-                       <TD ALIGN="left"><A HREF="'.$BASE_URL.'">'.$BASE_URL.'</A></TD>
-                       </TR>
-                       <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
-                       <TD BGCOLOR="#CCCCFF" ><B>$BASE_SECURE_URL</B></TD>
-                       <TD ALIGN="left">'.$BASE_SECURE_URL.'</TD>
-                       </TR>
-                       </TABLE>
-                       &nbsp;
-               <P>
-                       <HR WIDTH="600">
-                       <P>
-                       </CENTER>
-                       ';
-
-       }
-       /**
-        * htmlcode: Output code to enable htmlarea for the page
-        * MUST BE CALLED AFTER TEXTAREAS ON PAGE
-        * @param $$w = 570: width of htmlarea in px
-        * @param $$h = 400: height of htmlarea in px
-        *
-        * @return void
-        * @access
-        **/
-       function htmlcode( $w = 570, $h = 400, $textarea = array('description') )
-       {
-               echo '
-                       <style type="text/css">
-                       /*<![CDATA[*/
-                       <!--
-                       .textarea { height: '.$h.'px; width: '.$w.'px; }
-               -->
-                       /*]]>*/
-                       </style>
-                       <script type="text/javascript">
-                       //<![CDATA[
-                       _editor_url = "../htmlarea";
-               _editor_lang = "en";
-               //]]>
-               </script><!-- load the main HTMLArea file -->
-                       <script type="text/javascript" src="../htmlarea/htmlarea.js">
-                       </script>
-                       ';
-               echo '
-                       <script type="text/javascript">
-                       //<![CDATA[
-
-                       ';
-               if( HTMLAREA_CONTEXT_MENU == true )
-               {
-                       echo '
-                               HTMLArea.loadPlugin("ContextMenu");
-                       ';
-               }
-               if( HTMLAREA_TABLES == true )
-               {
-                       echo '
-                               HTMLArea.loadPlugin("TableOperations");
-                       ';
-               }
-               if( HTMLAREA_IMAGE_MANAGER == true )
-               {
-                       echo '
-                               HTMLArea.loadPlugin("ImageManager");
-                       ';
-               }
-               if( HTMLAREA_CHARACTER_MAP == true )
-               {
-                       echo '
-                               HTMLArea.loadPlugin("CharacterMap");
-                       ';
-               }
-               echo '
-                       initdocument = function () {
-                               var editor = new HTMLArea("description");
-
-                               ';
-                               foreach( $textarea as $htmlarea )
-                               {
-                                       echo '
-                                               var editor_'.$htmlarea.' = new HTMLArea("'.$htmlarea.'");
-
-                                       editor_'.$htmlarea.'.config.registerButton({
-                                          id        : \'backtotop\',
-                                          tooltip   : \'Back To Top\',
-                                          image     : \'images/backtotop.gif\',
-                                          textMode  : false,
-                                          action    : function(editor, id) {
-                                        editor.insertHTML(\'<p style="text-align: center;"><a href="#TOP">BACK TO TOP</a></p>\');
+    if(!isset($DEBUG))
+    {
+        $DEBUG = (isset($mysecretcode) && $mysecretcode == 1234);
+    }
+    // setup for pages
+    define("HOME_ID",1); // change this if home page is other than id = 1
+    $PAGES['default'] = 'index';
+    define( "MEMBERS_CATEGORY", 57 ); // set this to the members only category.
+    define( "MEMBERS_LIST_RAND", false ); // set this to the members only category.
+    $PAGES[1] = 'index';
+    //$DEBUG = TRUE;
+
+    /*
+     *  Customer Setup
+     */
+    define("SITENAME","Mackinac Island Packages");  // used for outputing name of site in admin area
+    define("SITE_NAME",SITENAME);   // same as SITENAME
+    define("DB_TYPE", "postgres");  // DB library only knows postgres (FUTURE EXPANSION)
+    define("DB_ERROR_MSG", "an error has occured with the database!");  // default error message
+    define("MULTIPLE_CAT",0);       // weather or not to use many to many relations
+    define("CAT_LOCK",0);           // If set to 1 or true will lock the categories
+    define("ENTRIES_PER_PAGE",10);  // default per page number
+    define("HTML_HELP_CODE",1);     // this is being depreciated for general help guides
+    define("PRODUCTION_MODE","ON"); // used in the email out for contact DB
+    define("HTML_EMAIL","ON");  // turn ON for html emails
+    define("ACTIVE_FLAG",1);        // turn on if bus_category table has active bool field
+    define("DELUXE_TOOLBOX",1);     // used for the toolbox deluxe vrs.
+    define("SEO_URL",1);            // weather to use Search Engine Optimisezd url's requires .htaccess enabled
+    /* integration of different apps */
+    define("SITEMAP_GENERATOR",false);
+    define("PHOTO_GALLERY",0);
+    define("GOOGLE_SEARCH",0);
+    define("MEMBERS_DB",0);
+    /** htmlarea plugins */
+    define("HTMLAREA_TABLES",true); // weather to load the table plugin or not
+    define("HTMLAREA_CONTEXT_MENU",true);   // weather to load the context menu plugin or not
+    define("HTMLAREA_IMAGE_MANAGER",true);
+    define("HTMLAREA_CHARACTER_MAP",false);
+    define("HOME_PAGE_EVENTS",0);
+    /*
+     *
+     *  DO NOT EDIT THIS SECTION
+     *
+     */
+
+    // Find where this file is located
+
+    $BASE_PATH   = dirname(__FILE__);
+    $php_version = phpversion();
+    // If php5 or above
+    if (version_compare($php_version, '5.0.0', '>')) {
+        $CALLED_FROM_DIR = substr(dirname($_SERVER['SCRIPT_FILENAME']), strlen($BASE_PATH));
+        define('GLM_HOST_ID', $_ENV['GLM_HOST_ID']);
+        define('PHP5', true);
+    } else {
+        $CALLED_FROM_DIR = substr(dirname($HTTP_SERVER_VARS['PATH_TRANSLATED']), strlen($BASE_PATH));
+        define('GLM_HOST_ID', $_SERVER['GLM_HOST_ID']);
+        define('PHP5', false);
+    }
+
+    if (($x = strlen($CALLED_FROM_DIR)) > 0) {
+        $base_url = $_SERVER['HTTP_HOST'] . substr(dirname($_SERVER['SCRIPT_NAME']), 0, -strlen($CALLED_FROM_DIR));
+    } else {
+        $script_name_dir = dirname($_SERVER['SCRIPT_NAME']);
+        if ($script_name_dir == '/') {
+            $script_name_dir = '';
+        }
+        $base_url = $_SERVER['HTTP_HOST'] . $script_name_dir;
+    }
+    // Added to strip any trailing /'s to make sure we don't end up with many
+    $base_url = preg_replace('|/*$|', '', $base_url);
+    $BASE_URL = "http://$base_url";
+    // Indicate that this file has been referenced
+    $SITEINFO       = TRUE;
+    /*
+     *
+     *  Dynamic Configuration - Parameters that DO change based on location
+     *
+     */
+    switch ($_ENV['GLM_HOST_ID']) {
+
+    case "DEVELOPMENT":
+    case "devsys.gaslightmedia.com":
+        error_reporting( E_ALL ^ E_NOTICE );
+        ini_set("display_errors","1");
+        $BASE_SECURE_URL = "https://".$base_url;
+        // Use the $BASE_URL for secure URL on Devsys
+        $BASE_SECURE_URL = $BASE_URL;
+        define("AUTH_TEST_MODE","TRUE");
+        define("BASE_SECURE_URL", $BASE_SECURE_URL."/");
+        define("BASE_INSECURE_URL", $BASE_URL."/");
+        define("CONN_STR", "host=devdb dbname=mackinacislandpackages");        // DB connection string
+        define("OWNER_EMAIL", "dev@gaslightmedia.com");        // site owner's email address
+        define("FROM_NEWS_EMAIL", "info@gaslightmedia.com");        // site owner's email address
+        define("REPLY_TO", "info@gaslightmedia.com");           // the reply-to field for email's
+    break;
+
+    case "PRODUCTION":
+    case "ws1.gaslightmedia.com":
+        error_reporting(0);
+        ini_set("display_errors","0");
+        $BASE_SECURE_URL = "https://".$base_url;
+        define("BASE_SECURE_URL", $BASE_SECURE_URL."/");
+        $BASE_URL = "http://".$base_url;
+        define("BASE_INSECURE_URL", $BASE_URL."/");
+        //define("BASE_INSECURE_URL", "http://www.mackinacislandpackage.com/");
+        define("AUTH_TEST_MODE","FALSE");
+        define("CONN_STR", "host=ds4 dbname=mackinacislandpackages");            // DB connection string
+        define("OWNER_EMAIL", "mackinacpackage@mict.com");       // site owner's email address
+        define("FROM_NEWS_EMAIL", "mackinacpackage@mict.com");      // site owner's email address
+        define("REPLY_TO", "mackinacpackage@mict.com");          // the reply-to field for email's
+    break;
+
+    default:
+        die( 'FATAL ERROR: No GLM_HOST_ID' );
+        break;
+    }
+    define("BASE_URL", $BASE_URL."/");                  // url used for the root of site
+    define("URL_BASE", $BASE_URL."/");                  // same as BASE_URL
+    define("BASE_PATH", $BASE_PATH."/");                // root directory path of site
+    define("BASE", $BASE_PATH."/");                     // same as BASE_PATH
+    define("GOOGLE",BASE.'google/');
+    define("CLASSES",BASE.'classes/');
+    define("HELP_BASE", "help/");                       // help guide base (depreciated)
+    define("UP_BASE", BASE."uploads/");                 // uploads directory path
+    define("IMG_BASE", URL_BASE."images/");             // the images url path
+    define("POSTCARD_URL",URL."postcard.phtml");        // postcard url (used for postcard app)
+    define("LOGO_IMG",URL_BASE."images/logoicon.gif");  // used in admin area as the path to image logo
+    define("HELP_IMG",URL_BASE."images/help.gif");      // help image url (depriated)
+    define("ORIGINAL_PATH", BASE."images/original/");   // path of original images
+    define("RESIZED_PATH", BASE."images/resized/");     // path of first resized image
+    define("MIDSIZED_PATH", BASE."images/midsized/");   // path of half sized of resized
+    define("THUMB_PATH", BASE."images/thumb/");         // path of thumbnail directory
+    if( $_SERVER['HTTPS'] == "on" )
+    {
+        define("ORIGINAL", $BASE_SECURE_URL."/images/original/");   // url of original images
+        define("RESIZED", $BASE_SECURE_URL."/images/resized/");     // url of resized
+        define("MIDSIZED", $BASE_SECURE_URL."/images/midsized/");   // url of midsized
+        define("THUMB", $BASE_SECURE_URL."/images/thumb/");         // url of thumbnail
+    }
+    else
+    {
+        define("ORIGINAL", URL_BASE."images/original/");    // url of original images
+        define("RESIZED", URL_BASE."images/resized/");      // url of resized
+        define("MIDSIZED", URL_BASE."images/midsized/");    // url of midsized
+        define("THUMB", URL_BASE."images/thumb/");          // url of thumbnail
+    }
+
+    /** these are the image sizing defines USE THESE ONLY
+      only allowed string of 'WxH[<>]' [-quality Percentage]
+     */
+    define("ITEM_RESIZED", "'287>'");       // used in convert call to resize images
+    define("ITEM_MIDSIZED", "'210>'");
+    define("ITEM_THUMB","'120>'");
+
+    define("FOOTER_IMG", URL_BASE."images/logosmall.gif");
+    define("FOOTER_URL", URL_BASE);
+    define("STYLE","main.css");
+
+    /**
+      These are defines for the photo gallery images
+     */
+    define('PHOTO_LARGE_SIZE',"'700x450>'");
+    define('PHOTO_LARGE_DIR',BASE.'images/photo-large/');
+    define('PHOTO_LARGE_URL',BASE_URL.'images/photo-large/');
+
+    define('PHOTO_SMALL_SIZE',"'133x100>'");
+    define('PHOTO_SMALL_DIR',BASE.'images/photo-small/');
+    define('PHOTO_SMALL_URL',BASE_URL.'images/photo-small/');
+    // [status_US] array of states and their abbr.
+    $states_US[""] = "- Choose State -";
+    $states_US["AL"]= "Alabama";
+    $states_US["AK"]= "Alaska";
+    $states_US["AZ"]= "Arizona";
+    $states_US["AR"]= "Arkansas";
+    $states_US["CA"]= "California";
+    $states_US["CO"]= "Colorado";
+    $states_US["CT"]= "Connecticut";
+    $states_US["DE"]= "Delaware";
+    $states_US["DC"]= "District of Columbia";
+    $states_US["FL"]= "Florida";
+    $states_US["GA"]= "Georgia";
+    $states_US["HI"]= "Hawaii";
+    $states_US["ID"]= "Idaho";
+    $states_US["IL"]= "Illinois";
+    $states_US["IN"]= "Indiana";
+    $states_US["IA"]= "Iowa";
+    $states_US["KS"]= "Kansas";
+    $states_US["KY"]= "Kentucky";
+    $states_US["LA"]= "Louisiana";
+    $states_US["ME"]= "Maine";
+    $states_US["MD"]= "Maryland";
+    $states_US["MA"]= "Massachusetts";
+    $states_US["MI"]= "Michigan";
+    $states_US["MN"]= "Minnesota";
+    $states_US["MS"]= "Mississppi";
+    $states_US["MO"]= "Missouri";
+    $states_US["MT"]= "Montana";
+    $states_US["NE"]= "Nebraska";
+    $states_US["NV"]= "Nevada";
+    $states_US["NH"]= "New Hampshire";
+    $states_US["NJ"]= "New Jersey";
+    $states_US["NM"]= "New Mexico";
+    $states_US["NY"]= "New York";
+    $states_US["NC"]= "North Carolina";
+    $states_US["ND"]= "North Dakota";
+    $states_US["OH"]= "Ohio";
+    $states_US["OK"]= "Oklahoma";
+    $states_US["OR"]= "Oregon";
+    $states_US["PA"]= "Pennsylvania";
+    $states_US["RI"]= "Rhode Island";
+    $states_US["SC"]= "South Carolina";
+    $states_US["SD"]= "South Dakota";
+    $states_US["TN"]= "Tennessee";
+    $states_US["TX"]= "Texas";
+    $states_US["UT"]= "Utah";
+    $states_US["VT"]= "Vermont";
+    $states_US["VA"]= "Virginia";
+    $states_US["WA"]= "Washington";
+    $states_US["WV"]= "West Virginia";
+    $states_US["WI"]= "Wisconsin";
+    $states_US["WY"]= "Wyoming";
+
+    // [states] extended states array
+    $states[""] = "- Choose State -";
+    $states["AL"]  = "Alabama";
+    $states["AK"] =  "Alaska";
+    $states["AB"] =  "Alberta";
+//  $states["AS"] =  "American Samoa";
+    $states["AZ"] =  "Arizona";
+    $states["AR"] =  "Arkansas";
+    $states["BC"] =  "British Columbia";
+    $states["CA"] =  "California";
+    $states["CO"] =  "Colorado";
+    $states["CT"] =  "Connecticut";
+    $states["DE"] =  "Delaware";
+    $states["DC"] =  "District of Columbia";
+//  $states["FM"] =  "Federated States of Micronesia";
+    $states["FL"] =  "Florida";
+    $states["GA"] =  "Georgia";
+//  $states["GU"] =  "Guam";
+    $states["HI"] =  "Hawaii";
+    $states["ID"] =  "Idaho";
+    $states["IL"] =  "Illinois";
+    $states["IN"] =  "Indiana";
+    $states["IA"] =  "Iowa";
+    $states["KS"] =  "Kansas";
+    $states["KY"] =  "Kentucky";
+    $states["LA"] =  "Louisiana";
+    $states["ME"] =  "Maine";
+    $states["MB"] =  "Manitoba";
+//  $states["MH"] =  "Marshall Islands";
+    $states["MD"] =  "Maryland";
+    $states["MA"] =  "Massachusetts";
+    $states["MI"] =  "Michigan";
+    $states["MN"] =  "Minnesota";
+    $states["MS"] =  "Mississppi";
+    $states["MO"] =  "Missouri";
+    $states["MT"] =  "Montana";
+    $states["NE"] =  "Nebraska";
+    $states["NV"] =  "Nevada";
+    $states["NB"] =  "New Brunswick";
+    $states["NF"] =  "Newfoundland";
+    $states["NH"] =  "New Hampshire";
+    $states["NJ"] =  "New Jersey";
+    $states["NM"] =  "New Mexico";
+    $states["NY"] =  "New York";
+    $states["NC"] =  "North Carolina";
+    $states["ND"] =  "North Dakota";
+//  $states["MP"] =  "Northern Mariana Islands";
+    $states["NT"] =  "Northwest Territories";
+    $states["NS"] =  "Nova Scotia";
+    $states["OH"] =  "Ohio";
+    $states["OK"] =  "Oklahoma";
+    $states["ON"] =  "Ontario";
+    $states["OR"] =  "Oregon";
+//  $states["PW"] =  "Palau";
+    $states["PA"] =  "Pennsylvania";
+    $states["PE"] =  "Prince Edward Island";
+    $states["PR"] =  "Puerto Rico";
+    $states["QC"] =  "Quebec";
+    $states["RI"] =  "Rhode Island";
+    $states["SK"] =  "Saskatchewan";
+    $states["SC"] =  "South Carolina";
+    $states["SD"] =  "South Dakota";
+    $states["TN"] =  "Tennessee";
+    $states["TX"] =  "Texas";
+    $states["UT"] =  "Utah";
+    $states["VT"] =  "Vermont";
+    $states["VI"] =  "Virgin Islands";
+    $states["VA"] =  "Virginia";
+    $states["WA"] =  "Washington";
+    $states["WV"] =  "West Virginia";
+    $states["WI"] =  "Wisconsin";
+    $states["WY"] =  "Wyoming";
+    $states["YT"] =  "Yukon";
+//  $states["Asia"] =  "Asia";
+//  $states["Australia"] =  "Australia";
+//  $states["Bahamas"] =  "Bahamas";
+//  $states["Caribbean"] =  "Caribbean";
+//  $states["Costa Rica"] =  "Costa Rica";
+//  $states["South America"] =  "South America";
+//  $states["South Africa"] =  "South Africa";
+//  $states["Europe"] =  "Europe";
+//  $states["Mexico"] = "Mexico";
+    /* Libraries */
+    /* Replaced with the actual functions instead of includes (2001-12-14) */
+
+    $cp1252_map = array(
+            "\xc2\x80" => "\xe2\x82\xac", /* EURO SIGN */
+            "\xc2\x82" => "\xe2\x80\x9a", /* SINGLE LOW-9 QUOTATION MARK */
+            "\xc2\x83" => "\xc6\x92",    /* LATIN SMALL LETTER F WITH HOOK */
+            "\xc2\x84" => "\xe2\x80\x9e", /* DOUBLE LOW-9 QUOTATION MARK */
+            "\xc2\x85" => "\xe2\x80\xa6", /* HORIZONTAL ELLIPSIS */
+            "\xc2\x86" => "\xe2\x80\xa0", /* DAGGER */
+            "\xc2\x87" => "\xe2\x80\xa1", /* DOUBLE DAGGER */
+            "\xc2\x88" => "\xcb\x86",    /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+            "\xc2\x89" => "\xe2\x80\xb0", /* PER MILLE SIGN */
+            "\xc2\x8a" => "\xc5\xa0",    /* LATIN CAPITAL LETTER S WITH CARON */
+            "\xc2\x8b" => "\xe2\x80\xb9", /* SINGLE LEFT-POINTING ANGLE QUOTATION */
+            "\xc2\x8c" => "\xc5\x92",    /* LATIN CAPITAL LIGATURE OE */
+            "\xc2\x8e" => "\xc5\xbd",    /* LATIN CAPITAL LETTER Z WITH CARON */
+            "\xc2\x91" => "\xe2\x80\x98", /* LEFT SINGLE QUOTATION MARK */
+            "\xc2\x92" => "\xe2\x80\x99", /* RIGHT SINGLE QUOTATION MARK */
+            "\xc2\x93" => "\xe2\x80\x9c", /* LEFT DOUBLE QUOTATION MARK */
+            "\xc2\x94" => "\xe2\x80\x9d", /* RIGHT DOUBLE QUOTATION MARK */
+            "\xc2\x95" => "\xe2\x80\xa2", /* BULLET */
+            "\xc2\x96" => "\xe2\x80\x93", /* EN DASH */
+            "\xc2\x97" => "\xe2\x80\x94", /* EM DASH */
+
+            "\xc2\x98" => "\xcb\x9c",    /* SMALL TILDE */
+            "\xc2\x99" => "\xe2\x84\xa2", /* TRADE MARK SIGN */
+            "\xc2\x9a" => "\xc5\xa1",    /* LATIN SMALL LETTER S WITH CARON */
+            "\xc2\x9b" => "\xe2\x80\xba", /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
+            "\xc2\x9c" => "\xc5\x93",    /* LATIN SMALL LIGATURE OE */
+            "\xc2\x9e" => "\xc5\xbe",    /* LATIN SMALL LETTER Z WITH CARON */
+            "\xc2\x9f" => "\xc5\xb8"      /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
+                );
+    /**
+     * is_utf8
+     *
+     * @param mixed $string
+     * @access public
+     * @return void
+     */
+    function is_utf8($string) {
+        return (preg_match('/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]|[\xee-\xef][\x80-\xbf]{2}|f0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})*$/', $string) === 1);
+    }
+    /**
+     * cp1252_to_utf8
+     *
+     * @param mixed $str
+     * @access public
+     * @return void
+     */
+    function cp1252_to_utf8($str) {
+        global $cp1252_map;
+        return  strtr(utf8_encode($str), $cp1252_map);
+    }
+    /**
+     * myEncode
+     *
+     * @param mixed $string
+     * @access public
+     * @return void
+     */
+    function myEncode( $string )
+    {
+        if( is_utf8( $string ) )
+        {
+            return( $string );
+        }
+        else
+        {
+            return( cp1252_to_utf8( $string ) );
+        }
+    }
+
+    /**
+     * CreditVal : CreditVal Checks for a valid credit card number doing Luhn check, if no
+     card type is given, attempts to guess. Then, if a list of
+     accepted types is given, determines whether or not we'll
+     accept it
+     * @param $Num: Credit Card Number
+     * @param $Name = '': Type of Card
+     * @param $Accepted='' : Accepted array
+     *
+     * @return bool
+     * @access
+     **/
+    function CreditVal($Num, $Name = '', $Accepted='')
+    {
+        $Name = strtolower( $Name );
+        $Accepted = strtolower( $Accepted );
+        $GoodCard = 1;
+        $Num = preg_replace("%[^[:digit:]]%", "", $Num);
+        switch ($Name)
+        {
+
+            case "mastercard" :
+                $GoodCard = preg_match("%^5[1-5].{14}$%", $Num);
+            break;
+
+            case "visa" :
+                $GoodCard = preg_match("%^4.{15}$|^4.{12}$%", $Num);
+            break;
+
+            case "americanexpress" :
+                $GoodCard = preg_match("%^3[47].{13}$%", $Num);
+            break;
+
+            case "discover" :
+                $GoodCard = preg_match("%^6011.{12}$%", $Num);
+            break;
+
+            case "dinerscard" :
+                $GoodCard = preg_match("%^30[0-5].{11}$|^3[68].{12}$%", $Num);
+            break;
+
+            default:
+            if( preg_match("%^5[1-5].{14}$%", $Num) ) $Name = "mastercard";
+            if( preg_match("%^4.{15}$|^4.{12}$%", $Num) ) $Name = "visa";
+            if( preg_match("%^3[47].{13}$%", $Num) ) $Name = "americanexpress";
+            if( preg_match("%^6011.{12}$%", $Num) ) $Name = "discover";
+            if( preg_match("%^30[0-5].{11}$|^3[68].{12}$%", $Num) ) $Name="dinerscard";
+            break;
+        }
+
+        // If there's a limit on card types we accept, check for it here.
+        if( $Accepted )
+        {
+            $type_verified = FALSE;
+            $brands = explode_trim( ",", $Accepted );
+            foreach( $brands as $brand )
+                if( $Name == $brand )
+                    $type_verified = TRUE;
+
+            if( !$type_verified ) return(FALSE);
+        }
+
+        $Num = strrev($Num);
+
+        $Total = 0;
+
+        for ($x=0; $x<strlen($Num); $x++)
+        {
+            $digit = substr($Num,$x,1);
+            if ($x/2 != floor($x/2))
+            {
+                $digit *= 2;
+                if (strlen($digit) == 2)
+                    $digit = substr($digit,0,1) + substr($digit,1,1);
+            }
+            $Total += $digit;
+        }
+        if ($GoodCard && $Total % 10 == 0)
+        {
+            return(true);
+        }
+        else
+        {
+            return(false);
+        }
+    }
+    /* DataBase Library */
+
+    /**
+     * db_connect :Creates a connection to database specified $conn_str
+     * @param $conn="" : connection string
+     *
+     * @return index or bool
+     * @access
+     **/
+    function db_connect($conn="")
+    {
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                if($conn == "")
+                    $conn = CONN_STR;
+            $ret = pg_connect($conn);
+            break;
+            default:
+            return(0);
+        }
+
+        return($ret);
+    }
+
+    /**
+     * db_close :Closes the connection to database specified by the handle dbd
+     * @param $$dbd : database handle
+     *
+     * @return bool
+     * @access
+     **/
+    function db_close($dbd)
+    {
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                $ret = pg_close($dbd);
+            break;
+            default:
+            return(0);
+        }
+
+        return($ret);
+    }
+
+    /**
+      NOTICE DON'T USE THIS
+     * db_pconnect :Creates a persistant connection to database specified in $conn_str
+     * @param $$conn="" : connection string
+     *
+     * @return
+     * @access
+     **/
+    function db_pconnect($conn="")
+    {
+        return( false );
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                if($conn == "")
+                    $conn == CONN_STR;
+            $ret = pg_pconnect($conn);
+            break;
+            default:
+            return(0);
+        }
+
+        return($ret);
+    }
+
+    /**
+     * db_exec : Execute an SQL query
+     * @param $dbd: database handle
+     * @param $$qs : Query
+     *
+     * @return int Returns a valid result index on success 0 on failure
+     * @access
+     **/
+    function db_exec($dbd, $qs)
+    {
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                $ret = pg_exec($dbd, $qs);
+            break;
+
+            default:
+            return(0);
+        }
+
+        return($ret);
+    }
+
+    /**
+     * db_fetch_array :Stores the data in associative indices, using the field names as
+     * keys.
+     * @param $res: valid database result index
+     * @param $i: row number
+     * @param $$type : database type
+     *
+     * @return array Returns an associative array of key-value pairs
+     * @access
+     **/
+    function db_fetch_array($res, $i, $type)
+    {
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                $row = pg_fetch_array($res, $i, $type);
+            break;
+
+            default:
+            return(0);
+        }
+
+        return($row);
+    }
+
+    /**
+     * db_freeresult :Free result memory.
+     * @param $$res : valid database result index
+     *
+     * @return bool - Returns 1 for success 0 for failure
+     * @access
+     **/
+    function db_freeresult($res)
+    {
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                $ret = pg_freeresult($res);
+            break;
+
+            default:
+            return(0);
+        }
+
+        return($ret);
+    }
+
+    /**
+     * db_numrows :Determine number of rows in a result index
+     * @param $$res : valid database result index
+     *
+     * @return int - Returns number of rows
+     * @access
+     **/
+    function db_numrows($res)
+    {
+
+        switch (DB_TYPE)
+        {
+            case "postgres":
+                $ret = pg_numrows($res);
+            break;
+
+            default:
+            return(-1);
+        }
+
+        return($ret);
+    }
+
+    /************************************************************************
+     *                                                                      *
+     * BEGIN Auto functions                                                 *
+     *                                                                      *
+     ***********************************************************************/
+
+    /**
+     * db_auto_array :The auto function for retrieving an array based soley on a query
+     * string. This function makes the connection, does the exec, fetches
+     * the array, closes the connection, frees memory used by the result,
+     * and then returns the array
+     * @param $qs: SQL query string
+     * @param $i: row number
+     * @param $$type : PGSQL_ASSOC or PGSQL_BOTH or PSQL_NUM
+     *
+     * @return array - Returns an associative array of key-value pairs
+     * @access
+     **/
+    function db_auto_array($qs, $i, $type)
+    {
+
+        $dbd = db_connect();
+        if(!$dbd)
+        {
+            return(0);
+        }
+        $res = db_exec($dbd, $qs);
+        if(!$res)
+        {
+            return(0);
+        }
+
+        $row = db_fetch_array($res, $i, $type);
+
+        if(!db_freeresult($res))
+        {
+            return(0);
+        }
+
+        db_close($dbd);
+        return($row);
+    }
+
+    /**
+     * db_auto_exec :The auto function for executing a query.
+     * This function makes the connection, does the exec, fetches
+     * the array, closes the connection, frees memory used by the result,
+     * and then returns success (not a valid result index)
+     * @param $qs: SQL query string
+     * @param $$conn="" : Connect String
+     *
+     * @return int - Returns 1 (or oid, if available) for success 0 for failure
+     * @access
+     **/
+    function db_auto_exec($qs, $conn="")
+    {
+
+        if($conn == "")
+            $conn = CONN_STR;
+        $dbd = db_connect($conn);
+        if(!$dbd)
+            return(0);
+        if(!db_exec($dbd, $qs))
+        {
+            db_close($dbd);
+            return(0);
+        }
+        else
+        {
+            db_close($dbd);
+            return(1);
+        }
+    }
+
+    /**
+     * db_auto_get_data :The auto function for retrieving an array based soley on a query
+     string. This function makes the connection, does the exec, fetches
+     the array, closes the connection, frees memory used by the result,
+     and then returns the array
+     * @param $qs:  SQL query string
+     * @param $CONN_STR: Connect String
+     * @param $$fail_mode=0 : Failure Mode
+     *
+     * @return array Returns an associative array of key-value pairs
+     * @access
+     **/
+    function db_auto_get_data($qs,$conn = CONN_STR,$fail_mode=0)
+    {
+
+        if( !($dbd = db_connect($conn)) )
+        {
+            return( FALSE );
+        }
+
+        if( !($res = db_exec($dbd, $qs)) )
+        {
+            return( FALSE );
+        }
+
+        $totalrows = pg_NumRows($res);
+
+        for( $i = 0 ; $i < $totalrows ; $i++ )
+        {
+            $data[$i] = db_fetch_array($res, $i, PGSQL_ASSOC );
+        }
+
+        db_close( $dbd );
+        if(isset($data) && $data!="")
+        {
+            return( $data );
+        }
+        else
+        {
+            return(0);
+        }
+    }
+
+    /* HTML Libraries */
+
+    /**
+     * html_footer :Generates a footer table on the bottom of the page it's called on.
+     and closes out the body and html tags.
+     *
+     * @return void
+     * @access
+     **/
+    function html_footer()
+    {
+        $footer_table_width = "400";
+        $footer_table_align = "center";
+
+        ?>
+            <hr>
+            <table width="<?echo $footer_table_width?>" align="<?echo $footer_table_align?>" summary="Footer Information" class="footertable" cellspacing="0">
+            <tr>
+            <td align="left" class="footertd">
+            <a href="mailto:<?echo MASTER_EMAIL?>"><?echo MASTER?></a>
+            </td>
+            <td align="right" class="footertd">
+            <a href="<?echo FOOTER_URL?>" target="new">
+            <img src="<?echo FOOTER_IMG?>" border=0 alt="FOOTER_IMG"></a>
+            </td>
+            </tr>
+            </table>
+            </body>
+            </html>
+            <?
+            exit(); /* we've got to terminate any more output */
+    }
+
+    /**
+     * html_error :Generates a footer table on the bottom of the page it's called on.
+     and closes out the body and html tags.
+     * @param $msg: string error message to be displayed
+     * @param $$bail : bool whether or not to exit() after $msg
+     *
+     * @return void
+     * @access
+     **/
+    function html_error($msg, $bail)
+    {
+        ?>
+            <table summary="Error Information" class="errortable" cellspacing="0">
+            <tr class="errortr">
+            <td class="errortd">
+            <div class="errormsg"><?echo "<pre>$msg</pre>"?></div>
+            </td>
+            </tr>
+            </table>
+
+            <?
+            if($bail)
+            {
+                html_footer();
+            }
+    }
+
+    /**
+     * html_nav_table :Generates a navigation table on the page it's called on.
+     * @param $nav: associative array with entries like:$nav[text][url]
+     * @param $$w : max width of table
+     *
+     * @return void
+     * @access
+     **/
+    function html_nav_table($nav, $w)
+    {
+        if( is_array( $nav ) )
+        {
+            $out = '<ul class="admin_nav">';
+            foreach( $nav as $link => $url )
+            {
+                $out .= '<li><a href="'.$url.'">'.$link.'</a></li>';
+            }
+            $out .= '</ul>';
+        }
+        echo $out;
+    }
+
+    /**
+     * html_header :Opens up the html tags, and includes the style sheet link
+     generates a header table on the top of the page it's called on.
+     * @param $title: Page Title
+     * @param $msg: message to display
+     * @param $$img : image to display
+     *
+     * @return void
+     * @access
+     **/
+    function html_header($title, $msg, $img)
+    {
+        $header_table_width = "400";
+        $header_table_align = "center";
+
+        ?>
+            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+            "http://www.w3.org/TR/html4/loose.dtd">
+            <html>
+            <head>
+            <title><?echo $title?></title>
+            <link type="text/css" rel=stylesheet href="<?echo STYLE?>">
+            </head>
+            <body>
+            <table width="<?echo $header_table_width?>" align="<?echo $header_table_align?>" summary="Header Information" class="headertable" cellspacing="0" cellpadding="3">
+            <tr class="headertr">
+            <td class="headertd">
+            <?
+            if($img)
+            {
+                ?>
+                    <img src="<?echo IMG_BASE.$img?>" alt="<?echo HEAD?>" border="0">
+                    <?
+            }
+        ?>
+            </td>
+            </tr>
+            <tr>
+            <td class="headertd2" align="center">
+            <div class="headerh2" align="center"><?echo "$msg"?></div>
+            </td>
+            </tr>
+            </table>
+            <?
+    }
+
+    /**
+     * form_header :Opens up the form tag, and includes the hidden assoc array as hidden
+     fields.
+     * @param $action: string form action string
+     * @param $method: string Method of form
+     * @param $$hidden = "" : assoc array with $hidden($name => $value)
+     *
+     * @return void
+     * @access
+     **/
+    function form_header($action, $method, $hidden = "")
+    {
+        echo "<form action=\"$action\" method=\"$method\"
+            enctype=\"multipart/form-data\">";
+        if($hidden != "" && is_array($hidden))
+        {
+            foreach($hidden as $key=>$value)
+            {
+                echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";
+            }
+        }
+    }
+
+    /**
+     * text_area :Creates textarea with good default values for rows cols and wrap.
+     * @param $name: string form action string
+     * @param $value: string Method of form
+     * @param $$rows = 15: int4 number of rows in textarea box
+     * @param $$cols = 50: int4 number of cols in textarea box
+     * @param $$wrap = "virtual"  : string the wrap value for the textarea box
+     *
+     * @return void
+     * @access
+     **/
+    function text_area($name, $value, $rows = 15, $cols = 50, $wrap = "virtual" )
+    {
+        echo "<td class=\"navtd2\"><textarea id=\"$name\" name=\"$name\" cols=\"$cols\"
+            rows=\"$rows\" wrap=\"$wrap\" maxlength=\"8104\">$value</textarea></td>";
+    }
+
+    /**
+     * text_box :Creates a input box for text with 35 as default size
+     * @param $name: string name of text box
+     * @param $value: string value of text box
+     * @param $$size = 35 : string size of text box
+     *
+     * @return void
+     * @access
+     **/
+    function text_box($name, $value, $size = 35)
+    {
+        echo "<td class=\"navtd2\"><input type=\"text\" name=\"$name\"
+            value=\"".htmlspecialchars($value)."\" size=\"$size\"></td>";
+    }
+
+    /**
+     * form_footer :Closes up the form tag, and includes the submit button
+     * @param $name: string form action string
+     * @param $$suppress = 0: string Method of form
+     * @param $$cs : int colspan for td
+     *
+     * @return void
+     * @access
+     **/
+    function form_footer($name, $suppress = 0, $cs)
+    {
+        echo "<tr><td colspan=\"$cs\" align=center>
+            <input type=\"SUBMIT\" name=\"Command\" value=\"$name\">";
+        if($suppress == 1)
+        {
+            echo "<input type=\"SUBMIT\" name=\"Command\" value=\"Delete\">";
+        }
+        /*      echo "<input type=\"SUBMIT\" name=\"Command\" value=\"Cancel\">";*/
+        echo "</td>";
+    }
+
+    /* Graphics Libraries */
+    /**
+     * process_image
+     * NOTES:
+     * This function does the following:
+     *
+     * 1) places image into original folder
+     *
+     * 2) makes three images from original size and places them
+     * into the RESIZED, MIDSIZED, and THUMB folders
+     *
+     * @param mixed $image
+     * @param mixed $image_name
+     * @access public
+     * @return string
+     */
+    function process_image( $image, $image_name )
+    {
+        if(!defined("ORIGINAL_PATH"))
+        {
+            html_error("this not defined original_path",1);
+        }
+        if(!defined("RESIZED_PATH"))
+        {
+            html_error("this not defined resized_path",1);
+        }
+        if(!defined("MIDSIZED_PATH"))
+        {
+            html_error("this not defined midsized_path",1);
+        }
+        if(!defined("THUMB_PATH"))
+        {
+            html_error("this not defined thumb_path",1);
+        }
+        $image_upload_array = img_upload($image,$image_name,ORIGINAL_PATH);
+        //img_resize($image_upload_array[1],ORIGINAL_PATH.$image_upload_array[0],ITEM_ORIGINAL);
+        img_resize(ORIGINAL_PATH.$image_upload_array[0],RESIZED_PATH.$image_upload_array[0],ITEM_RESIZED);
+        img_resize(RESIZED_PATH.$image_upload_array[0],MIDSIZED_PATH.$image_upload_array[0],ITEM_MIDSIZED);
+        img_resize(MIDSIZED_PATH.$image_upload_array[0],THUMB_PATH.$image_upload_array[0],ITEM_THUMB);
+        $image_name = $image_upload_array[0];
+        return($image_name);
+    }
+
+    /**
+     * img_resize
+     * resized based on imagick widthxheight given
+     * to scale by maxwidth of 280 use '280>'
+     * which will keep it from making image larger
+     *
+     * @param mixed $path2image
+     * @param mixed $path2thumb
+     * @param mixed $size
+     * @access public
+     * @return string
+     */
+    function img_resize( $path2image, $path2thumb, $size )
+    {
+        exec( "which convert", $output, $return );
+        if( $return == 0 )
+        {
+            $CONVERT = $output[0];
+        }
+        else
+        {
+            return( $error = array('convert path uknown') );
+        }
+        $imageName = basename($path2image);
+        $thumbName = basename($path2thumb);
+
+        exec("$CONVERT -quality 100 -scale $size $path2image $path2thumb");
+
+        $img_resize_array = array("$imageName","$path2image","$thumbName","$path2thumb");
+        return($img_resize_array);
+    }
+
+    /**
+     * img_upload
+     * simplified to use the file_upload function with restricted set to true
+     * which will return an array instead of string (as in files)
+     * and only allow png,gif,jpg images to be uploaded
+     *
+     * @param mixed $form_field
+     * @param mixed $img_name
+     * @param mixed $destination_path
+     * @access public
+     * @return string
+     */
+    function img_upload( $form_field, $img_name, $destination_path )
+    {
+        return( file_upload( $form_field, $img_name, $destination_path, true ) );
+    }
+
+    /**
+     * file_upload
+     * this will replace the older version and that of img_upload which calls this with extra
+     * restricted of true
+     *
+     * @param mixed $form_field
+     * @param mixed $file_name
+     * @param mixed $destination_path
+     * @access public
+     * @return string
+     */
+    function file_upload( $form_field, $file_name, $destination_path, $restricted = false )
+    {
+        $file_name_in_use = false;
+        $file_name = preg_replace( "%[!@#$\%^&()+={};:\'\"\/ ]%", "-", $file_name );
+        if( $restricted )
+        {
+            $size = getImageSize( $form_field );
+            if( !in_array( $size[2], array( 1, 2, 3 ) ) )
+            {
+                echo '<p style="background-color:red;color:white;">'
+                .'The file you uploaded was of an incorect type, please only upload .gif,.png or .jpg files'
+                .'<BR CLEAR=ALL>'
+                .'</p>'
+                ."Hit your browser's back button to continue"
+                .'<P>';
+                $error[0] = "ERROR";
+                return($error);
+            }
+        }
+        if( file_exists( $destination_path.$file_name ) )
+        {
+            $file_name_in_use = true;
+        }
+        if( $file_name_in_use == true )
+        {
+            $new_file_name = mktime().$file_name;
+            $new_file_location = $destination_path.$new_file_name;
+            copy( $form_field, $new_file_location );
+            $file_upload = $new_file_name;
+            $file_upload_array = array( $new_file_name, $new_file_location );
+        }
+        else
+        {
+            $new_file_name = $file_name;
+            $new_file_location = $destination_path.$new_file_name;
+            copy( $form_field, $new_file_location );
+            $file_upload = $new_file_name;
+            $file_upload_array = array( $new_file_name, $new_file_location );
+        }
+        if( is_file( $new_file_location ) )
+        {
+            chmod( $new_file_location, 0666 );
+        }
+        if( $restricted )
+        {
+            return( $file_upload_array );
+        }
+        else
+        {
+            return( $file_upload );
+        }
+    }
+
+    /* Misc. Functions */
+
+    /**
+     * http_strip :Strips the http:// part from start of string
+     * @param $&$string : $string
+     *
+     * @return string $stirng minus http:// in front
+     * @access
+     **/
+    function http_strip(&$string)
+    {
+        $test_string = strtolower($string);
+        if(substr($test_string,0,7) == "http://")
+        {
+            $string = substr($string,7);
+        }
+    }
+
+    /**
+     * footer : used for admin page footer to close out the top function
+     *
+     * @return void
+     * @access
+     **/
+    function footer()
+    {
+        $out = '
+            </body>
+            </html>
+            ';
+        echo $out;
+    }
+
+    /**
+     * top :Output the starting html and admin table tags
+     * @param $message: The title
+     * @param $hp: The help file to use
+     * @param $$hp2 = NULL : The help file to use (links to gaslightmedia.com)
+     *
+     * @return void
+     * @access
+     **/
+    function top($message, $hp,$hp2 = NULL)
+    {
+        if($hp2 != "")
+        {
+            $help_guide = '<div id="glm-manual">';
+            /*
+               $help_guide = '<div id="glm-manual"><a id="manual-html"
+               href="http://www.gaslightmedia.com/manuals/html/'.$hp2.'.html"
+               target="_blank">Online Help Guide</a>&nbsp;';
+             */
+            $help_guide .= '<a id="manual-pdf"
+                href="http://www.gaslightmedia.com/manuals/pdf/'.$hp2.'.pdf"
+                target="_blank">Printable Help Guide</a></div>';
+        }
+        $out = '
+            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+            "http://www.w3.org/TR/html4/strict.dtd">
+            <html>
+            <head>
+            <title>Untitled</title>
+            <meta http-equiv="content-type" content="text/html;charset=utf-8">
+            <link rel="stylesheet" type="text/css" href="../main.css">
+            </head>
+            <body>
+            <h1>'.$message.'</h1>
+            '.$help_guide.'
+            ';
+        echo $out;
+    }
+
+    /**
+     * top2 : alias to top()
+     * @param $message: message title
+     * @param $hp: help file
+     * @param $$hp2 = NULL : gaslight help file
+     *
+     * @return
+     * @access
+     **/
+    function top2($message, $hp,$hp2 = NULL)
+    {
+        // make this an alias to top()
+        // by calling top instead of adding extra code
+        top($message,$hp,$hp2);
+
+    }
+
+    /********************************************************************************
+     *
+     *  DO NOT EDIT THIS SECTION
+     *
+     ********************************************************************************/
+
+    if( $DEBUG )
+    {
+        echo '<CENTER>
+            <TABLE BORDER=0 CELLPADDING=3 CELLSPACING=1 WIDTH=600 BGCOLOR="#000000" ALIGN="CENTER">
+            <TR VALIGN="middle" BGCOLOR="#9999CC">
+            <TD COLSPAN="2" ALIGN="center"><H1>Portable Site Data - setup.phtml </H1></TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>CVS Version Id:</B></TD>
+            <TD ALIGN="left">$Id: setup.phtml,v 1.10 2011/06/13 12:42:22 matrix Exp $</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>SITENAME</B></TD>
+            <TD ALIGN="left">'.SITENAME.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>BASE</B></TD>
+            <TD ALIGN="left">'.BASE.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>UP_BASE</B></TD>
+            <TD ALIGN="left">'.UP_BASE.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>HELP_BASE</B></TD>
+            <TD ALIGN="left">'.HELP_BASE.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>IMG_BASE</B></TD>
+            <TD ALIGN="left">'.IMG_BASE.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>URL_BASE</B></TD>
+            <TD ALIGN="left">'.URL_BASE.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>CONN_STR</B></TD>
+            <TD ALIGN="left">'.CONN_STR.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>STYLE</B></TD>
+            <TD ALIGN="left">'.STYLE.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>ORIGINAL_PATH</B></TD>
+            <TD ALIGN="left">'.ORIGINAL_PATH.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>RESIZED_PATH</B></TD>
+            <TD ALIGN="left">'.RESIZED_PATH.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>MIDSIZED_PATH</B></TD>
+            <TD ALIGN="left">'.MIDSIZED_PATH.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>THUMB_PATH</B></TD>
+            <TD ALIGN="left">'.THUMB_PATH.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>ORIGINAL</B></TD>
+            <TD ALIGN="left">'.ORIGINAL.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>RESIZED</B></TD>
+            <TD ALIGN="left">'.RESIZED.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>MIDSIZED</B></TD>
+            <TD ALIGN="left">'.MIDSIZED.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>THUMB</B></TD>
+            <TD ALIGN="left">'.THUMB.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>$CALLED_FROM_DIR</B></TD>
+            <TD ALIGN="left">'.$CALLED_FROM_DIR.'&nbsp;</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>$BASE_PATH</B></TD>
+            <TD ALIGN="left">'.$BASE_PATH.'</TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>$BASE_URL</B></TD>
+            <TD ALIGN="left"><A HREF="'.$BASE_URL.'">'.$BASE_URL.'</A></TD>
+            </TR>
+            <TR VALIGN="baseline" BGCOLOR="#CCCCCC">
+            <TD BGCOLOR="#CCCCFF" ><B>$BASE_SECURE_URL</B></TD>
+            <TD ALIGN="left">'.$BASE_SECURE_URL.'</TD>
+            </TR>
+            </TABLE>
+            &nbsp;
+        <P>
+            <HR WIDTH="600">
+            <P>
+            </CENTER>
+            ';
+
+    }
+    /**
+     * htmlcode: Output code to enable htmlarea for the page
+     * MUST BE CALLED AFTER TEXTAREAS ON PAGE
+     * @param $$w = 570: width of htmlarea in px
+     * @param $$h = 400: height of htmlarea in px
+     *
+     * @return void
+     * @access
+     **/
+    function htmlcode( $w = 570, $h = 400, $textarea = array('description') )
+    {
+        echo '
+            <style type="text/css">
+            /*<![CDATA[*/
+            <!--
+            .textarea { height: '.$h.'px; width: '.$w.'px; }
+        -->
+            /*]]>*/
+            </style>
+            <script type="text/javascript">
+            //<![CDATA[
+            _editor_url = "../htmlarea";
+        _editor_lang = "en";
+        //]]>
+        </script><!-- load the main HTMLArea file -->
+            <script type="text/javascript" src="../htmlarea/htmlarea.js">
+            </script>
+            ';
+        echo '
+            <script type="text/javascript">
+            //<![CDATA[
+
+            ';
+        if( HTMLAREA_CONTEXT_MENU == true )
+        {
+            echo '
+                HTMLArea.loadPlugin("ContextMenu");
+            ';
+        }
+        if( HTMLAREA_TABLES == true )
+        {
+            echo '
+                HTMLArea.loadPlugin("TableOperations");
+            ';
+        }
+        if( HTMLAREA_IMAGE_MANAGER == true )
+        {
+            echo '
+                HTMLArea.loadPlugin("ImageManager");
+            ';
+        }
+        if( HTMLAREA_CHARACTER_MAP == true )
+        {
+            echo '
+                HTMLArea.loadPlugin("CharacterMap");
+            ';
+        }
+        echo '
+            initdocument = function () {
+                var editor = new HTMLArea("description");
+
+                ';
+                foreach( $textarea as $htmlarea )
+                {
+                    echo '
+                        var editor_'.$htmlarea.' = new HTMLArea("'.$htmlarea.'");
+
+                    editor_'.$htmlarea.'.config.registerButton({
+                       id        : \'backtotop\',
+                       tooltip   : \'Back To Top\',
+                       image     : \'images/backtotop.gif\',
+                       textMode  : false,
+                       action    : function(editor, id) {
+                     editor.insertHTML(\'<p style="text-align: center;"><a href="#TOP">BACK TO TOP</a></p>\');
                                                   }
                         });
-                                       ';
-                                       echo '
-                                               editor_'.$htmlarea.'.config.toolbar = [
-                                               [ "fontname", "space",
-                                               "fontsize", "space",
-                                               "formatblock", "space",
-                                               "bold", "italic", "underline", "separator","backtotop" ],
-
-                                               [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
-
-                                               "orderedlist", "unorderedlist", "outdent", "indent", "separator",
-                                               "forecolor", "separator",
-                                               "inserthorizontalrule", "createlink"';
-                                       if( HTMLAREA_TABLES == true )
-                                       {
-                                               echo ', "inserttable"';
-                                       }
-                                       if( HTMLAREA_IMAGE_MANAGER == true )
-                                       {
-                                               echo ', "insertimage"';
-                                       }
-                                       echo ', "htmlmode", "separator",
-                                                "copy", "cut", "paste", "space", "undo", "redo" ]
-                                                        ];
-                                       ';
-                                       if( HTMLAREA_CONTEXT_MENU == true )
-                                       {
-                                               echo '
-                                                       // add a contextual menu
-                                                       editor_'.$htmlarea.'.registerPlugin("ContextMenu");
-                                               ';
-                                       }
-                                       if( HTMLAREA_TABLES == true )
-                                       {
-                                               echo '
-
-                                                       // register the TableOperations plugin
-                                                       editor_'.$htmlarea.'.registerPlugin(TableOperations);
-                                               ';
-                                       }
-                                       if( HTMLAREA_CHARACTER_MAP == true )
-                                       {
-                                               echo '
-
-                                                       // register the CharacterMap plugin
-                                                       editor_'.$htmlarea.'.registerPlugin(CharacterMap);
-                                               ';
-                                       }
-                                       echo '
-                                               editor_'.$htmlarea.'.generate();
-                                       ';
-                               }
-
-                               echo '
-                       }
-               function addEvent(obj, evType, fn)
-               {
-                       if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
-                       else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  }
-                       else {  return false; }
-               }
-               addEvent(window, \'load\', initdocument);
-               //]]>
-               </script>
-                       ';
-       }
-
-       /**
-        * date_entry : Generate the select boxes for date entry
-        * month-day-year as drop down select
-        * @param $month:
-        * @param $day:
-        * @param $year:
-        * @param $month_name: name of select month
-        * @param $day_name: name of select day
-        * @param $$year_name : name of select year
-        *
-        * @return
-        * @access
-        **/
-       function date_entry($month,$day,$year,$month_name,$day_name,$year_name,$onChange = NULL)
-       {
-               $cur_date = getdate();
-
-               if($month == "")
-               {
-                       $month = $cur_date['mon'];
-               }
-               if($day == "")
-               {
-                       $day = $cur_date['mday'];
-               }
-               if($year == "")
-               {
-                       $year = $cur_date['year'];
-               }
-               $date = '<SELECT id="'.$month_name.'" NAME="'.$month_name.'" '.$onChange.'>';
-               for($i=1;$i<13;$i++)
-               {
-                       $date .= '<OPTION VALUE="';
-                       if($i < 10)
-                       {
-                               $date .= "0";
-                       }
-                       $date .= $i.'"';
-                       if($i == $month)
-                       {
-                               $date .= ' SELECTED';
-                       }
-                       $date .= '>'.$i;
-               }
-               $date .= '</SELECT>';
-               $date .= '<SELECT id="'.$day_name.'" NAME="'.$day_name.'" '.$onChange.'>';
-               for($i=1;$i<32;$i++)
-               {
-                       $date .= '<OPTION VALUE="';
-                       if($i < 10)
-                       {
-                               $date .= "0";
-                       }
-                       $date .= $i.'"';
-                       if($i == $day)
-                       {
-                               $date .= ' SELECTED';
-                       }
-                       $date .= '>'.$i;
-               }
-               $date .= '</SELECT>';
-               $date .= '<SELECT id="'.$year_name.'" NAME="'.$year_name.'" '.$onChange.'>';
-               for($i=2000;$i<2023;$i++)
-               {
-                       $date .= '<OPTION VALUE="'.$i.'"';
-                       if($i == $year)
-                       {
-                               $date .= ' SELECTED';
-                       }
-                       $date .= '>'.$i;
-               }
-               $date .= '</SELECT>';
-               return $date;
-       }
-
-       /**
-        * contact_date_entry : build select boxes for date entry going backwords in years
-        * @param $month:
-        * @param $day:
-        * @param $year:
-        * @param $month_name: name of select month
-        * @param $day_name: name of select day
-        * @param $$year_name : name of select year
-        *
-        * @return void
-        * @access
-        **/
-       function contact_date_entry($month,$day,$year,$month_name,$day_name,$year_name)
-       {
-               $cur_date = getdate();
-
-               if($month == "")
-               {
-                       $month = $cur_date['mon'];
-               }
-               if($day == "")
-               {
-                       $day = $cur_date['mday'];
-               }
-               if($year == "")
-               {
-                       $year = $cur_date['year'];
-               }
-               $date = '<SELECT NAME="'.$month_name.'">';
-               for($i=1;$i<13;$i++)
-               {
-                       $date .= '<OPTION VALUE="';
-                       if($i < 10)
-                       {
-                               $date .= "0";
-                       }
-                       $date .= $i.'"';
-                       if($i == $month)
-                       {
-                               $date .= ' SELECTED';
-                       }
-                       $date .= '>'.$i;
-               }
-               $date .= '</SELECT>';
-               $date .= '<SELECT NAME="'.$day_name.'">';
-               for($i=1;$i<32;$i++)
-               {
-                       $date .= '<OPTION VALUE="';
-                       if($i < 10)
-                       {
-                               $date .= "0";
-                       }
-                       $date .= $i.'"';
-                       if($i == $day)
-                       {
-                               $date .= ' SELECTED';
-                       }
-                       $date .= '>'.$i;
-               }
-               $date .= '</SELECT>';
-               $date .= '<SELECT NAME="'.$year_name.'">';
-               $ystart = $cur_date['year'] - 10;
-               for($i=$ystart;$i<=$year;$i++)
-               {
-                       $date .= '<OPTION VALUE="'.$i.'"';
-                       if($i == $year)
-                       {
-                               $date .= ' SELECTED';
-                       }
-                       $date .= '>'.$i;
-               }
-               $date .= '</SELECT>';
-               return $date;
-       }
-
-       /**
-        * time_entry : build select boxes for time entry
-        * @param $H:
-        * @param $m:
-        * @param $F:
-        * @param $H_name: name of select hour
-        * @param $m_name: name of select min
-        * @param $$F_name : name of select sec
-        *
-        * @return
-        * @access
-        **/
-       function time_entry($H,$m,$F,$H_name,$m_name,$F_name)
-       {
-               $cur_date = getdate();
-               if($H == "")
-               {
-                       $H = $cur_date['hours'];
-               }
-               if($m == "")
-               {
-                       $m = $cur_date['minutes'];
-               }
-               if($H>12)
-               {
-                       $F = "PM";
-                       $H = $H - 12;
-               }
-               $time = "Hr:<select name=\"$H_name\" size=\"1\">";
-               for($i=1;$i<=12;$i++)
-               {
-                       $time .= "<option value=\"";
-                       if($i < 10)
-                       {
-                               $time .= "0";
-                       }
-                       $time .= "$i\"";
-                       if($i == $H)
-                       {
-                               $time .= " selected";
-                       }
-                       $time .= ">$i\n";
-               }
-               $time .= "</select>\n";
-               $time .= "Min:<select name=\"$m_name\" size=\"1\">";
-               for($i=0;$i<60;$i=$i+15)
-               {
-                       $time .= "<Option value=\"";
-                       if($i < 10)
-                       {
-                               $time .= "0";
-                       }
-                       $time .= "$i\"";
-                       if($i == $m)
-                       {
-                               $time .= " selected";
-                       }
-                       $time .= ">";
-                       if($i < 10)
-                       {
-                               $time .= "0";
-                       }
-                       $time .= "$i\n";
-               }
-               $time .= "</select>";
-               $time .= "<select name=\"$F_name\" size=\"1\">";
-               $time .= "<option value=\"AM\"";
-               if($F == "AM")
-               {
-                       $time .= " selected";
-               }
-               $time .= ">AM\n";
-               $time .= "<option value=\"PM\"";
-               if($F == "PM")
-               {
-                       $time .= " selected";
-               }
-               $time .= ">PM\n";
-               $time .= "</select>\n";
-               return $time;
-       }
-
-       /**
-        * get_parentid: get the (highest level) parent category for this id
-        * @param $id: id from bus_category table
-        *
-        * @return int parent
-        * @access
-        **/
-       function get_parentid( $id )
-       {
-               static $parentshow;
-               if( $id == 0 )
-               {
-                       return( 0 );
-               }
-               if(!is_array($parentshow))
-               {
-                       $qs = "select parent from bus_category where id = $id";
-                       $parentrow = db_auto_get_data( $qs );
-               }
-               if($parentrow[0]['parent'] == 0)
-               {
-                       return($id);
-               }
-               else
-               {
-                       return( get_parentid($parentrow[0]['parent']) );
-               }
-       }
-
-       /**
-        * build_picklist:Builds a pick list from an array
-        * @param $fieldname: fieldname field name for select
-        * @param $data: data array of data
-        * @param $selected: selected witch element is selected
-        * @param $$type = "standard": type Standard,multi
-        * @param $$auto = 0: auto
-        * @param $$width = NULL : width width controlled by css
-        *
-        * @return void
-        * @access
-        **/
-       function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL )
-       {
-               if(!is_array($selected))
-               {
-                       $sel[0] = $selected;
-               }
-               else
-               {
-                       $sel = $selected;
-               }
-               if($auto == 1)
-                       $autosubmit = "onChange=\"form.submit()\"";
-               if($width)
-                       $autosubmit .= "style=\"width:".$width."px;\"";
-               switch( $type )
-               {
-                       case "multiple":
-                               $str = "<SELECT NAME=\"".$fieldname."\" multiple size=\"10\" ".$autosubmit.">\n";
-                       while( list($key, $val) = each($data) )
-                       {
-                               if( in_array($key,$sel) )
-                               {
-                                       $select = " SELECTED ";
-                               }
-                               else
-                                       $select = "";
-                               $str .= "       <OPTION VALUE=\"$key\"".$select.">$val\n";
-                       }
-                       break;
-                       case "simple":
-                               $str = "<SELECT NAME=\"$fieldname\" ".$autosubmit.">\n";
-                       for( $i=0 ; $i<count($data) ; $i++ )
-                       {
-                               $select = (in_array($data[$i],$sel)) ? " SELECTED ":"";
-                               $str .= "       <OPTION VALUE=\"".$data[$i]."\"".$select.">".$data[$i]."\n";
-                       }
-                       break;
-
-                       case "standard":
-                       default:
-                               $str = "<SELECT NAME=\"$fieldname\" ".$autosubmit.">\n";
-                               while( list($key, $val) = each($data) )
-                               {
-                                       $select = (in_array($key,$sel)) ? " SELECTED ":"";
-                                       $str .= "       <OPTION VALUE=\"$key\"".$select.">$val\n";
-                               }
-                               break;
-               }
-               $str .= "</SELECT>\n";
-
-               return( $str );
-
-       }
-
-       /**
-        * create_page_links:Create prev and next links
-        * to page through the results.
-        * @param $totalnum: The total result of the query
-        * @param $num: The total result for the page
-        * @param $$start=0: The starting num defaults to 0
-        * @param $params: variables to add to the url
-        * @param $ENTRIES_PER_PAGE: number of items on page defaults to the ENTRIES_PER_PAGE
-        *
-        * @return string of links
-        * @access
-        **/
-       function create_page_links($totalnum,$num,$start=0,$params,$page_length=ENTRIES_PER_PAGE)
-       {
-               // find out which page we're on.
-               if($totalnum!=0)
-               {
-                       $total_pages = floor($totalnum / $page_length);         // total pages = the total result divided by page length rounded down
-                       $total_pages++;                                                                         // then add one
-                       if($start == 0)                                                                         // if start is 0 then page is one
-                       {
-                               $page = 1;
-                       }
-                       else
-                       {
-                               $page = ($start / $page_length) + 1;
-                       }
-               }
-
-               if($totalnum > $page_length && ( $page != $totalpages ) )
-               {
-                       $end = $page_length + $start;
-               }
-               else
-               {
-                       $end = $totalnum;
-               }
-               $last = $start - $page_length;
-               if(($start - $page_length) < 0)
-                       $prev = "";
-               else
-                       $prev = "<span class=\"accenttext\">[</span><a class=\"small\"
-                               href=\"$GLOBALS[PHP_SELF]?start=".$last."&$params\">PREVIOUS PAGE</a><span
-                               class=\"accenttext\"> ]</span>";
-               if($end < $totalnum)
-                       $next = "<span class=\"accenttext\">[</span><a class=\"small\"
-                               href=\"$GLOBALS[PHP_SELF]?start=".$end."&$params\">NEXT PAGE</a><span
-                               class=\"accenttext\"> ]</span>";
-               else
-                       $next = "";
-               $starting = $start + 1;
-               $last_c = $start + $num;
-               $links = '<center><span class="pagetitle">Listings Displayed: </span><span
-                       class="accenttext">'.$starting.' to '.$last_c.'</span>
-                       <span class="pagetitle"> of '.$totalnum.'<br></span> '.$prev. ' &nbsp; <span
-                       class="pagetitle"></span> '.$next.'<BR></span></center>';
-               return($links);
-       }
+                    ';
+                    echo '
+                        editor_'.$htmlarea.'.config.toolbar = [
+                        [ "fontname", "space",
+                        "fontsize", "space",
+                        "formatblock", "space",
+                        "bold", "italic", "underline", "separator","backtotop" ],
+
+                        [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
+
+                        "orderedlist", "unorderedlist", "outdent", "indent", "separator",
+                        "forecolor", "separator",
+                        "inserthorizontalrule", "createlink"';
+                    if( HTMLAREA_TABLES == true )
+                    {
+                        echo ', "inserttable"';
+                    }
+                    if( HTMLAREA_IMAGE_MANAGER == true )
+                    {
+                        echo ', "insertimage"';
+                    }
+                    echo ', "htmlmode", "separator",
+                         "copy", "cut", "paste", "space", "undo", "redo" ]
+                             ];
+                    ';
+                    if( HTMLAREA_CONTEXT_MENU == true )
+                    {
+                        echo '
+                            // add a contextual menu
+                            editor_'.$htmlarea.'.registerPlugin("ContextMenu");
+                        ';
+                    }
+                    if( HTMLAREA_TABLES == true )
+                    {
+                        echo '
+
+                            // register the TableOperations plugin
+                            editor_'.$htmlarea.'.registerPlugin(TableOperations);
+                        ';
+                    }
+                    if( HTMLAREA_CHARACTER_MAP == true )
+                    {
+                        echo '
+
+                            // register the CharacterMap plugin
+                            editor_'.$htmlarea.'.registerPlugin(CharacterMap);
+                        ';
+                    }
+                    echo '
+                        editor_'.$htmlarea.'.generate();
+                    ';
+                }
+
+                echo '
+            }
+        function addEvent(obj, evType, fn)
+        {
+            if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
+            else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  }
+            else {  return false; }
+        }
+        addEvent(window, \'load\', initdocument);
+        //]]>
+        </script>
+            ';
+    }
+
+    /**
+     * date_entry : Generate the select boxes for date entry
+     * month-day-year as drop down select
+     * @param $month:
+     * @param $day:
+     * @param $year:
+     * @param $month_name: name of select month
+     * @param $day_name: name of select day
+     * @param $$year_name : name of select year
+     *
+     * @return
+     * @access
+     **/
+    function date_entry($month,$day,$year,$month_name,$day_name,$year_name,$onChange = NULL)
+    {
+        $cur_date = getdate();
+
+        if($month == "")
+        {
+            $month = $cur_date['mon'];
+        }
+        if($day == "")
+        {
+            $day = $cur_date['mday'];
+        }
+        if($year == "")
+        {
+            $year = $cur_date['year'];
+        }
+        $date = '<SELECT id="'.$month_name.'" NAME="'.$month_name.'" '.$onChange.'>';
+        for($i=1;$i<13;$i++)
+        {
+            $date .= '<OPTION VALUE="';
+            if($i < 10)
+            {
+                $date .= "0";
+            }
+            $date .= $i.'"';
+            if($i == $month)
+            {
+                $date .= ' SELECTED';
+            }
+            $date .= '>'.$i;
+        }
+        $date .= '</SELECT>';
+        $date .= '<SELECT id="'.$day_name.'" NAME="'.$day_name.'" '.$onChange.'>';
+        for($i=1;$i<32;$i++)
+        {
+            $date .= '<OPTION VALUE="';
+            if($i < 10)
+            {
+                $date .= "0";
+            }
+            $date .= $i.'"';
+            if($i == $day)
+            {
+                $date .= ' SELECTED';
+            }
+            $date .= '>'.$i;
+        }
+        $date .= '</SELECT>';
+        $date .= '<SELECT id="'.$year_name.'" NAME="'.$year_name.'" '.$onChange.'>';
+        for($i=2000;$i<2023;$i++)
+        {
+            $date .= '<OPTION VALUE="'.$i.'"';
+            if($i == $year)
+            {
+                $date .= ' SELECTED';
+            }
+            $date .= '>'.$i;
+        }
+        $date .= '</SELECT>';
+        return $date;
+    }
+
+    /**
+     * contact_date_entry : build select boxes for date entry going backwords in years
+     * @param $month:
+     * @param $day:
+     * @param $year:
+     * @param $month_name: name of select month
+     * @param $day_name: name of select day
+     * @param $$year_name : name of select year
+     *
+     * @return void
+     * @access
+     **/
+    function contact_date_entry($month,$day,$year,$month_name,$day_name,$year_name)
+    {
+        $cur_date = getdate();
+
+        if($month == "")
+        {
+            $month = $cur_date['mon'];
+        }
+        if($day == "")
+        {
+            $day = $cur_date['mday'];
+        }
+        if($year == "")
+        {
+            $year = $cur_date['year'];
+        }
+        $date = '<SELECT NAME="'.$month_name.'">';
+        for($i=1;$i<13;$i++)
+        {
+            $date .= '<OPTION VALUE="';
+            if($i < 10)
+            {
+                $date .= "0";
+            }
+            $date .= $i.'"';
+            if($i == $month)
+            {
+                $date .= ' SELECTED';
+            }
+            $date .= '>'.$i;
+        }
+        $date .= '</SELECT>';
+        $date .= '<SELECT NAME="'.$day_name.'">';
+        for($i=1;$i<32;$i++)
+        {
+            $date .= '<OPTION VALUE="';
+            if($i < 10)
+            {
+                $date .= "0";
+            }
+            $date .= $i.'"';
+            if($i == $day)
+            {
+                $date .= ' SELECTED';
+            }
+            $date .= '>'.$i;
+        }
+        $date .= '</SELECT>';
+        $date .= '<SELECT NAME="'.$year_name.'">';
+        $ystart = $cur_date['year'] - 10;
+        for($i=$ystart;$i<=$year;$i++)
+        {
+            $date .= '<OPTION VALUE="'.$i.'"';
+            if($i == $year)
+            {
+                $date .= ' SELECTED';
+            }
+            $date .= '>'.$i;
+        }
+        $date .= '</SELECT>';
+        return $date;
+    }
+
+    /**
+     * time_entry : build select boxes for time entry
+     * @param $H:
+     * @param $m:
+     * @param $F:
+     * @param $H_name: name of select hour
+     * @param $m_name: name of select min
+     * @param $$F_name : name of select sec
+     *
+     * @return
+     * @access
+     **/
+    function time_entry($H,$m,$F,$H_name,$m_name,$F_name)
+    {
+        $cur_date = getdate();
+        if($H == "")
+        {
+            $H = $cur_date['hours'];
+        }
+        if($m == "")
+        {
+            $m = $cur_date['minutes'];
+        }
+        if($H>12)
+        {
+            $F = "PM";
+            $H = $H - 12;
+        }
+        $time = "Hr:<select name=\"$H_name\" size=\"1\">";
+        for($i=1;$i<=12;$i++)
+        {
+            $time .= "<option value=\"";
+            if($i < 10)
+            {
+                $time .= "0";
+            }
+            $time .= "$i\"";
+            if($i == $H)
+            {
+                $time .= " selected";
+            }
+            $time .= ">$i\n";
+        }
+        $time .= "</select>\n";
+        $time .= "Min:<select name=\"$m_name\" size=\"1\">";
+        for($i=0;$i<60;$i=$i+15)
+        {
+            $time .= "<Option value=\"";
+            if($i < 10)
+            {
+                $time .= "0";
+            }
+            $time .= "$i\"";
+            if($i == $m)
+            {
+                $time .= " selected";
+            }
+            $time .= ">";
+            if($i < 10)
+            {
+                $time .= "0";
+            }
+            $time .= "$i\n";
+        }
+        $time .= "</select>";
+        $time .= "<select name=\"$F_name\" size=\"1\">";
+        $time .= "<option value=\"AM\"";
+        if($F == "AM")
+        {
+            $time .= " selected";
+        }
+        $time .= ">AM\n";
+        $time .= "<option value=\"PM\"";
+        if($F == "PM")
+        {
+            $time .= " selected";
+        }
+        $time .= ">PM\n";
+        $time .= "</select>\n";
+        return $time;
+    }
+
+    /**
+     * get_parentid: get the (highest level) parent category for this id
+     * @param $id: id from bus_category table
+     *
+     * @return int parent
+     * @access
+     **/
+    function get_parentid( $id )
+    {
+        static $parentshow;
+        if( $id == 0 )
+        {
+            return( 0 );
+        }
+        if(!is_array($parentshow))
+        {
+            $qs = "select parent from bus_category where id = $id";
+            $parentrow = db_auto_get_data( $qs );
+        }
+        if($parentrow[0]['parent'] == 0)
+        {
+            return($id);
+        }
+        else
+        {
+            return( get_parentid($parentrow[0]['parent']) );
+        }
+    }
+
+    /**
+     * build_picklist:Builds a pick list from an array
+     * @param $fieldname: fieldname field name for select
+     * @param $data: data array of data
+     * @param $selected: selected witch element is selected
+     * @param $$type = "standard": type Standard,multi
+     * @param $$auto = 0: auto
+     * @param $$width = NULL : width width controlled by css
+     *
+     * @return void
+     * @access
+     **/
+    function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL )
+    {
+        if(!is_array($selected))
+        {
+            $sel[0] = $selected;
+        }
+        else
+        {
+            $sel = $selected;
+        }
+        if($auto == 1)
+            $autosubmit = "onChange=\"form.submit()\"";
+        if($width)
+            $autosubmit .= "style=\"width:".$width."px;\"";
+        switch( $type )
+        {
+            case "multiple":
+                $str = "<SELECT NAME=\"".$fieldname."\" multiple size=\"10\" ".$autosubmit.">\n";
+            while( list($key, $val) = each($data) )
+            {
+                if( in_array($key,$sel) )
+                {
+                    $select = " SELECTED ";
+                }
+                else
+                    $select = "";
+                $str .= "   <OPTION VALUE=\"$key\"".$select.">$val\n";
+            }
+            break;
+            case "simple":
+                $str = "<SELECT NAME=\"$fieldname\" ".$autosubmit.">\n";
+            for( $i=0 ; $i<count($data) ; $i++ )
+            {
+                $select = (in_array($data[$i],$sel)) ? " SELECTED ":"";
+                $str .= "   <OPTION VALUE=\"".$data[$i]."\"".$select.">".$data[$i]."\n";
+            }
+            break;
+
+            case "standard":
+            default:
+                $str = "<SELECT NAME=\"$fieldname\" ".$autosubmit.">\n";
+                while( list($key, $val) = each($data) )
+                {
+                    $select = (in_array($key,$sel)) ? " SELECTED ":"";
+                    $str .= "   <OPTION VALUE=\"$key\"".$select.">$val\n";
+                }
+                break;
+        }
+        $str .= "</SELECT>\n";
+
+        return( $str );
+
+    }
+
+    /**
+     * create_page_links:Create prev and next links
+     * to page through the results.
+     * @param $totalnum: The total result of the query
+     * @param $num: The total result for the page
+     * @param $$start=0: The starting num defaults to 0
+     * @param $params: variables to add to the url
+     * @param $ENTRIES_PER_PAGE: number of items on page defaults to the ENTRIES_PER_PAGE
+     *
+     * @return string of links
+     * @access
+     **/
+    function create_page_links($totalnum,$num,$start=0,$params,$page_length=ENTRIES_PER_PAGE)
+    {
+        // find out which page we're on.
+        if($totalnum!=0)
+        {
+            $total_pages = floor($totalnum / $page_length);     // total pages = the total result divided by page length rounded down
+            $total_pages++;                                     // then add one
+            if($start == 0)                                     // if start is 0 then page is one
+            {
+                $page = 1;
+            }
+            else
+            {
+                $page = ($start / $page_length) + 1;
+            }
+        }
+
+        if($totalnum > $page_length && ( $page != $totalpages ) )
+        {
+            $end = $page_length + $start;
+        }
+        else
+        {
+            $end = $totalnum;
+        }
+        $last = $start - $page_length;
+        if(($start - $page_length) < 0)
+            $prev = "";
+        else
+            $prev = "<span class=\"accenttext\">[</span><a class=\"small\"
+                href=\"$GLOBALS[PHP_SELF]?start=".$last."&$params\">PREVIOUS PAGE</a><span
+                class=\"accenttext\"> ]</span>";
+        if($end < $totalnum)
+            $next = "<span class=\"accenttext\">[</span><a class=\"small\"
+                href=\"$GLOBALS[PHP_SELF]?start=".$end."&$params\">NEXT PAGE</a><span
+                class=\"accenttext\"> ]</span>";
+        else
+            $next = "";
+        $starting = $start + 1;
+        $last_c = $start + $num;
+        $links = '<center><span class="pagetitle">Listings Displayed: </span><span
+            class="accenttext">'.$starting.' to '.$last_c.'</span>
+            <span class="pagetitle"> of '.$totalnum.'<br></span> '.$prev. ' &nbsp; <span
+            class="pagetitle"></span> '.$next.'<BR></span></center>';
+        return($links);
+    }
 }
 ?>