$PHP_SELF;
$gen_state_array = array("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
$gen_sex_array = array("M", "F");
$gen_state_array_keys = array("AL" => "Alabama", "AK" => "Alaska", "AZ" => "Arizona", "AR" => "Arkansas", "CA" => "California", "CO" => "Colorado", "CT" => "Connecticut", "DE" => "Delaware", "DC" => "District of Columbia", "FL" => "Florida", "GA" => "Georgia", "HI" => "Hawaii", "ID" => "Idaho", "IL" => "Illinois", "IN" => "Indiana", "IA" => "Iowa", "KS" => "Kansas", "KY" => "Kentucky", "LA" => "Louisiana", "ME" => "Maine", "MD" => "Maryland", "MA" => "Massachusetts", "MI" => "Michigan", "MN" => "Minnesota", "MS" => "Mississippi", "MO" => "Missouri", "MT" => "Montana", "NE" => "Nebraska", "NV" => "Nevada", "NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NY" => "New York", "NC" => "North Carolina", "ND" => "North Dakota", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota", "TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VT" => "Vermont", "VA" => "Virginia", "WA" => "Washington", "WV" => "West Virginia", "WI" => "Wisconsin", "WY" => "Wyoming");
$gen_month_zero_short_array = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr", "05" => "May", "06" => "Jun", "07" => "Jul", "08" => "Aug", "09" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");
$gen_month_zero_long_array = 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");
$gen_month_short_array = array("1" => "Jan", "2" => "Feb", "3" => "Mar", "4" => "Apr", "5" => "May", "6" => "Jun", "7" => "Jul", "8" => "Aug", "9" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");
$gen_month_long_array = array("1" => "January", "2" => "February", "3" => "March", "4" => "April", "5" => "May", "6" => "June", "7" => "July", "8" => "August", "9" => "September", "10" => "October", "11" => "November", "12" => "December");
function doquery ($sql, $fetch = 0) {
$result = db_query($sql);
switch ($fetch) {
case '1': $data = @fetch_array($result);
return $data;
break;
case '2' :$data = @mysql_fetch_assoc($result);
return $data;
break;
default:
return $result;
break;
}
}
function db_query($sql) {
global $database;
global $db_type;
if ($db_type == "P") {
return pg_exec($GLOBALS["dbh"],$sql);
} else {
return mysql_db_query($database,$sql);
}
}
function fetch_array($result) {
global $db_type;
if ($db_type == "P") {
return pg_fetch_array($result);
} else {
return mysql_fetch_array($result);
}
}
/********************************************************************************
* numrows - (genfunc 1)
* - 2002/09/10 - Added function.
*
* Returns the number of rows in a database result set. Uses $db_type to
* determine which function to run. Default is MySQL;
********************************************************************************/
function numrows($result) {
global $db_type;
switch($db_type) {
case "P":
return @pg_numrows($result);
break;
default:
return @mysql_numrows($result);
}
}
function special($key, $data) {
list($sw,$key) = explode("|",$key);
if(is_array($data)) {
switch($sw) {
case "mcb":
return array($key, array_sum($data));
break;
case "imp":
return array($key, implode(":",$data));
default:
}
} else {
switch($sw) {
case "ph":
return array($key, preg_replace("/\D/","",$data));
break;
default:
}
}
return array($key, $data);
}
$reserved_words = array("action"=>"1","remLen"=>"1","uid"=>1,"submit"=>1,"func"=>1,"MAX_FILE_SIZE"=>1,"startday"=>1,"startmonth"=>"1","startyear"=>"1","endday"=>"1","endmonth"=>"1","endyear"=>"1", "PHPSESSID"=>"1", "ZDEDebuggerPresent"=>"1");
function Geninsert ($table, $varset) {
global $reserved_words;
$sql = "insert into $table (";
$values = " values(";
$first_col = 1;
reset ($varset);
while (list ($key, $data) = each ($varset)) {
if (preg_match("/^_$table\_/",$key)) {
$key = substr($key, (2+strlen($table)));
}
if (!isset($reserved_words[$key]) && !preg_match("/\b_/",$key)) {
if ($first_col) {
$first_col=0;
} else {
$sql = $sql . ",";
$values = $values . ",";
}
if (strpos("$key","|")) {
list($key, $data) = special($key, $data);
}
$sql = $sql . $key;
ereg_replace(10,"",$data);
ereg_replace(13,"
",$data);
$data = str_replace(array('"', "'"), array('\"', "\'"), $data);
$data = addslashes($data);
$data = mysql_real_escape_string($data);
$values = $values . "'" . $data . "'";
}
}
$sql = $sql . ")";
$values = $values . ")";
// if ($table = 'Agents')
// echo $sql.$values;
return $sql.$values;
}
function Genupdate ($table, $varset, $id) {
global $reserved_words;
$sql = "update $table set ";
$first_col = 1;
reset ($varset);
while (list ($key, $data) = each ($varset)) {
if (preg_match("/^_$table\_/",$key)) {
$key = substr($key, (2+strlen($table)));
}
if (!isset($reserved_words[$key]) && !preg_match("/\b_/",$key)) {
if ($first_col) {
$first_col=0;
} else {
$sql = $sql . ",";
}
if (strpos("$key","|")) {
list($key, $data) = special($key, $data);
}
$sql = $sql . $key . "=";
ereg_replace(10,"",$data);
ereg_replace(13,"
",$data);
$data = str_replace(array('"', "'"), array('\"', "\'"), $data);
$data = mysql_real_escape_string($data);
$sql = $sql . "'" . $data . "'";
}
}
$sql = $sql . " where ". $id;
return $sql;
}
function GenInsertArray ($table, $varset, $array) {
global $reserved_words;
$sql = "insert into $table (";
$values = " values(";
$first_col = 1;
reset ($varset);
while (list ($key, $data) = each ($varset)) {
if (preg_match("/^_$table\_/",$key)) {
$key = substr($key, (2+strlen($table)));
}
if (!isset($reserved_words[$key]) && !preg_match("/\b_/",$key)) {
if ($first_col) {
$first_col=0;
} else {
$sql = $sql . ",";
$values = $values . ",";
}
if (is_array($data)) {
if (strpos("$key","|")) {
list($key, $data[$array]) = special($key, $data[$array]);
}
$sql = $sql . $key;
ereg_replace(10,"",$data[$array]);
ereg_replace(13,"
",$data[$array]);
$values = $values . "'" . $data[$array] . "'";
} else {
if (strpos("$key","|")) {
list($key, $data) = special($key, $data);
}
$sql = $sql . $key;
ereg_replace(10,"",$data);
ereg_replace(13,"
",$data);
$values = $values . "'" . $data . "'";
}
}
}
$sql = $sql . ")";
$values = $values . ")";
return $sql.$values;
}
function GenUpdateArray ($table, $varset, $id, $array) {
global $reserved_words;
$sql = "update $table set ";
$first_col = 1;
reset ($varset);
while (list ($key, $data) = each ($varset)) {
if (preg_match("/^_$table\_/",$key)) {
$key = substr($key, (2+strlen($table)));
}
if (!isset($reserved_words[$key]) && !preg_match("/\b_/",$key)) {
if ($first_col) {
$first_col=0;
} else {
$sql = $sql . ",";
}
if (is_array($data)) {
if (strpos("$key","|")) {
list($key, $data[$array]) = special($key, $data[$array]);
}
$sql = $sql . $key . "=";
ereg_replace(10,"",$data[$array]);
ereg_replace(13,"
",$data[$array]);
$sql = $sql . "'" . $data[$array] . "'";
} else {
if (strpos("$key","|")) {
list($key, $data) = special($key, $data);
}
$sql = $sql . $key . "=";
ereg_replace(10,"",$data);
ereg_replace(13,"
",$data);
$sql = $sql . "'" . $data . "'";
}
}
}
$sql = $sql . " where ". $id;
return $sql;
}
function Genselect_record($uid, $table) {
return doquery("SELECT * FROM $table WHERE uid=$uid",1);
}
function Gendelete($uid, $table) {
return doquery("DELETE FROM $table WHERE uid=$uid",0);
}
function Genselect_all($table, $order_by) {
return doquery("SELECT * FROM $table ORDER BY $order_by",0);
}
function addSQLInsert($sql, $columns, $data) {
$index1 = strpos($sql, '(') + 1;
$index2 = strpos($sql, '(', $index1)+1;
$sql = substr($sql, 0, $index1) . $columns .substr($sql,$index1, $index2-$index1). $data .substr($sql, $index2);
return $sql;
}
function addSQLUpdate($sql, $update) {
$index1 = strpos($sql, 'set ') + 4;
$sql = substr($sql, 0, $index1) . $update . substr($sql, $index1);
return $sql;
}
function GenHTMLSelect($name,$key,$label,$label2,$result,$selected,$param) {
/* Legal values for param:
size - allows you to set the size of the select. pulldown if zero, scrolling list if > 0
multiple - allows multiple selections. size must be set. looks for selected values in $selected
null - add a null option to the beginning of the list
nulllabel - when "null" is set use this as the label
javascript - any javascript for the select, such as onChange()
*/
echo "\n";
}
function GenHTMLRadio($name,$value,$checked,$label) {
echo "";
if ($label != "") { echo $label; }
echo "\n";
}
function GenHTMLCheckbox($name,$value,$checked,$label) {
echo "";
if ($label != "") { echo $label; }
}
function moduloCheckbox($name,$value,$checked,$label) {
echo "= $value) { echo " CHECKED"; }
echo ">";
if ($label != "") { echo $label; }
}
function implodeCheckbox($name,$value,$checked,$label) {
echo "";
if ($label != "") { echo $label; }
}
function forHTMLselect($name,$start,$end,$selected,$param) {
/* Legal values for param are:
step - increase by a value other than one. defaults to one.
zeropadded - put zeros in front of the numbers generated by the loop
null - add a null option to the beginning of the list
nulllabel - when "null" is set use this as the label
javascript - any javascript for the select, such as onChange()
*/
if (isset($param["step"])) { $step = $param["step"]; } else { $step = 1; }
echo "\n";
}
function stateSelect($name, $selected, $param)
{
global $gen_state_array_keys;
arrayHTMLselect($name,$gen_state_array_keys, $selected, $param);
}
function arrayHTMLselect($name,$array,$selected,$param) {
/* Legal values for param are:
size - allows you to set the size of the select. pulldown if zero, scrolling list if > 0
multiple - allows multiple selections. size must be set. looks for selected values in $selected
null - add a null option to the beginning of the list
nulllabel - when "null" is set use this as the label
javascript - any javascript for the select, such as onChange()
*/
echo "\n";
}
function verticaltext($text) {
return eregi_replace("(.)","\\1
",$text);
}
function notnull($text) {
if ($text != "") { echo $text; } else { echo " "; }
}
function notn($text) {
if ($text != "N") { echo $text; } else { echo " "; }
}
function fakein_array($haystack, $needle) {
while (list ($key, $data) = each ($haystack)) {
if ($data == $needle) { return true; }
}
return false;
}
/***************************************************************************
* Added on 8/26/03
***************************************************************************/
function fetchEither($str) {
$temp = false;
if(isset($_GET[$str])) {
$temp = $_GET[$str];
} elseif(isset($_POST[$str])) {
$temp = $_POST[$str];
}
return $temp;
}
function fetchGet($str) {
$temp = '';
if(isset($_GET[$str])) {
$temp = $_GET[$str];
}
return $temp;
}
function fetchPost($str) {
$temp = '';
if(isset($_POST[$str])) {
$temp = $_POST[$str];
}
return $temp;
}
/***************************************************************************/
function print_phone($phone){
if (strlen($phone) > 0) {
$start=0;
if (strlen($phone) > 7) {
echo "(", substr($phone,0,3), ") ";
$start=3;
}
echo substr($phone,$start,3), "-", substr($phone,$start+3,4);
if (strlen($phone) > 10) {
echo " ", substr($phone,$start+7);
}
}
}
function print_param($varset) {
while (list($key,$value) = each($varset)) {
if (is_array($value)) {
while(list($nkey,$nvalue) = each($value)){
echo $key."[$nkey] = $nvalue\n
";
}
} else {
echo "$key = $value\n
";
}
}
}
function makedate($name, $varset) {
return sprintf("%d-%02d-%02d",$varset[$name."year"],$varset[$name."month"],$varset[$name."day"]);
}
function makedatearray($name, $varset, $array) {
return sprintf("%d-%02d-%02d",$varset[$name."year"][$array],$varset[$name."month"][$array],$varset[$name."day"][$array]);
}
if(!function_exists("makeSQLarray")) {
function makeSQLarray($value, $result, $param = 0) {
/* Legal values for param are:
key - what to use as the key of the array
secondary_value - what to use as the secondary value (instead of 1) when multikey is enabled
multikey - set means to make 3D arrays instead of 2D - used when you have multiple values for a given key
Note - for multikey to work, key must be set.
*/
global $db_type;
$temp = array();
if ($db_type == "P") {
for($i = 0; $i < pg_numrows($result); $i++) {
$data = pg_fetch_array($result, $i);
if (isset($param["key"])) {
if (isset($param["multikey"])) {
if (isset($param["secondary_value"])) {
$temp[$data[$param["key"]]][$data[$value]] = $data[$param["secondary_value"]];
} else {
$temp[$data[$param["key"]]][$data[$value]] = 1;
}
} else {
$temp[$data[$param["key"]]] = $data[$value];
}
} else {
$temp[] = $data[$value];
}
}
} else {
mysql_data_seek($result,0);
while($data = fetch_array($result)) {
if (isset($param["key"])) {
if (isset($param["multikey"])) {
if (isset($param["secondary_value"])) {
$temp[$data[$param["key"]]][$data[$value]] = $data[$param["secondary_value"]];
} else {
$temp[$data[$param["key"]]][$data[$value]] = 1;
}
} else {
$temp[$data[$param["key"]]] = $data[$value];
}
} else {
$temp[] = $data[$value];
}
# $temp[$data[$key]] = $data[$value];
}
}
return $temp;
}
}
function implodecheck($value, $checked) {
if (preg_match("/(\b|:)$value(:|\b)/",$checked)) { return true; }
return false;
}
/* function makevariable($name, $i) {
$str = '$'.$name.$i;
echo $str, "\t";
eval("\$str = \"$str\";");
echo $str, "\n
";
return $str;
}*/
function formmail($to, $subject, $result, $param) {
/* Legal values for param are:
header - any text that should preface the data
footer - any text that should follow the data
bcc - a list of any Bcc addresses
from - specify the sending e-mail address
reply-to - specify a Reply-To address
shownull - show field names when their value is null
*/
while(list($key, $value) = each($result)) {
$key = ucwords(str_replace("_"," ",$key));
if (isset($param["shownull"]) || !isset($param["shownull"]) && $value != "") {
$message .= "\n\n$key: $value";
}
}
if (count($param) != 0) {
while(list($key, $value) = each($param)) {
switch($key) {
case "header":
$message = $value . $message;
break;
case "footer":
$message .= "\n\n" . $value;
break;
case "bcc":
# if (strlen($addtl) > 0) {
# $addtl .="\n";
# }
$addtl .= "Bcc: ".$value."\n";
break;
case "from":
# if (strlen($addtl) > 0) {
# $addtl .="\n";
# }
$addtl .= "From: ".$value."\n";
# ini_set(sendmail_from,$value);
$cmdparam = "-tnf$value";
break;
case "reply-to":
# if (strlen($addtl) > 0) {
# $addtl .="\n";
# }
$addtl .= "Reply-to: ".$value."\n";
break;
}
}
}
if (isset($param["debug"])) {
echo "$to,\n".trim($subject).",\n$message,\n$addtl,\n$cmdparam\n
";
}
if (strlen($addtl) > 0) {
if (strlen($cmdparam) > 0) {
mail($to,trim($subject),$message,$addtl,$cmdparam);
} else {
mail($to,trim($subject),$message,$addtl);
}
# echo "$addtl\n
";
} else {
mail($to,$subject,$message);
}
# ini_restore(sendmail_from);
}
function form_require($require,$array,$return_failed) {
while(list($key, $value) = each($require)) {
if (!isset($array[$key]) || $array[$key]=="") {
$failed[] = $key;
}
}
if (count($failed) > 0) {
if ($return_failed) {
return $failed;
} else {
return false;
}
} else {
return true;
}
}
function monthtostring($month) {
switch($month) {
case "1":
case "01":
return "January";
break;
case "2":
case "02":
return "February";
break;
case "3":
case "03":
return "March";
break;
case "4":
case "04":
return "April";
break;
case "5":
case "05":
return "May";
break;
case "6":
case "06":
return "June";
break;
case "7":
case "07":
return "July";
break;
case "8":
case "08":
return "August";
break;
case "9":
case "09":
return "September";
break;
case "10":
return "October";
break;
case "11":
return "November";
break;
case "12":
return "December";
break;
}
}
function _pre($arr, $str, $color) {
if($_SERVER['REMOTE_ADDR'] == '65.107.72.130') {
if(empty($color)) {
$color = '#000000';
} else {
$color = '#FFFFFF';
}
if(!empty($arr)) {
echo '
'; print_r($arr); echo ''; } if(!empty($str)) { echo '