Error: Can't connect to database"); } $result = mysql_select_db($DBdb, $DBlink); if (!$result) { exit("Error: Database doesn't exist."); } $GLOBALS[DBlink] = $DBlink; return $GLOBALS[DBlink]; } function SQLdisconnect() { global $DBlink; if (!@mysql_close($DBlink)) { exit("Error: Database link specified for closing doesn't exist."); } } function check($id) { if (ereg('^[0-9]{1,10}$', $id)) return "TRUE"; } function check_id($id) { global $DBlink, $DBTABLE; if (ereg('^[0-9]{1,10}$', $id)) { $sql = "SELECT lid FROM $DBTABLE WHERE lid=$id"; $result = mysqli_query($DBlink, $sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) return "TRUE"; } } SQLconnect(); global $DBlink; ############################################################ # Functions ############################################################ function display_Html($message, $type = "", $back = "") { if ($type) print '

Error

'; print '

$message

'; if ($back) print '

Click Back to fix error and resubmit.

'; exit(); } function formatPhone($phone) { if (empty($phone)) return "N/A"; if (strlen($phone) == 7) sscanf($phone, "%3s%4s", $prefix, $exchange); else if (strlen($phone) == 10) sscanf($phone, "%3s%3s%4s", $area, $prefix, $exchange); else if (strlen($phone) == 11) sscanf($phone, "%1s%3s%3s%4s", $country, $area, $prefix, $exchange); else if (strlen($phone) > 11) sscanf($phone, "%3s%3s%4s%s", $area, $prefix, $exchange, $extension); else return "unknown phone format: $phone"; $out = ""; $out .= isset($country) ? $country . ' ' : ""; $out .= isset($area) ? '(' . $area . ') ' : ""; $out .= $prefix . '-' . $exchange; $out .= isset($extension) ? ' ext.' . $extension : ""; return $out; } function link_urls($string) { //change single to double quotes (only necessary if you work with databases) $string = ereg_replace("\'", "\"", $string); //change full stops and question marks that don't need to be linked $string = ereg_replace("\? ", " question_mark ", $string); $string = ereg_replace("\?\r\n"," question_mark_new_line ", $string); $string = ereg_replace("\. ", " full_stop ", $string); $string = ereg_replace("\.\r\n"," full_stop_new_line ", $string); $string = eregi_replace("((ftp://)|(http://)|(www))(([a-z0-9.\-])*)(@)?(([a-z0-9\.])*)(([:/])?)((([a-z0-9]*)(@?)/*)+([.a-z]{2,4}){1})?((\??[a-z0-9\=]*)?)((\&[a-z0-9\=]*)?)(([\.a-z]){2,4})?", "\\0", $string); //change back dots and question marks $string = ereg_replace(" full_stop_new_line ", "\.\r\n", $string); $string = ereg_replace(" full_stop", "\.", $string); $string = ereg_replace(" question_mark_new_line ", "\?\r\n", $string); $string = ereg_replace(" question_mark", "\?", $string); return $string; } $month_name = array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December', ); $day_array = array('01' => '1st', '02' => '2nd', '03' => '3rd', '04' => '4th', '05' => '5th', '06' => '6th', '07' => '7th', '08' => '8th', '09' => '9th', '10' => '10th', '11' => '11th', '12' => '12th', '13' => '13th', '14' => '14th', '15' => '15th', '16' => '16th', '17' => '17th', '18' => '18th', '19' => '19th', '20' => '20th', '21' => '21st', '22' => '22nd', '23' => '23rd', '24' => '24th', '25' => '25th', '26' => '26th', '27' => '27th', '28' => '28th', '29' => '29th', '30' => '30th', '31' => '31st' ); function getMonthList() { print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; } function getDayList() { for ($i = 1, $max = 31; $i <= $max; $i++) { if ($i <= 9) { print " \n"; } else { print " \n"; } } } function getYearList() { for ($i = 1970; $i <= date('Y'); $i++) { print " \n"; } } function clean_userinput($value, $allowed = "") { $value = stripslashes($value); $value = strip_tags($value); $value = preg_replace("*[^0-9a-zA-Z $allowed]*", "", $value); $value = addslashes($value); return $value; } function numbers_only($value, $allowed = "") { $value = stripslashes($value); $value = strip_tags($value); $value = preg_replace("*[^0-9$allowed]*", "", $value); return addslashes($value); } function clean_value($val) { if ($val == "") { return ""; } $val = str_replace( " ", " ", $val ); $val = str_replace( "&" , "&" , $val ); $val = str_replace( "" , "-->" , $val ); $val = preg_replace( "/