$val) { $chk = ""; if($key == $default && $key) { $chk = 'selected'; } $buf .= "\n"; } return $buf; } function message($msg, $type = "good", $key = "default") { $_SESSION["messages"][$key][] = array("type" => $type, "message" => $msg); } function get_messages($key = "default") { if(!isset($_SESSION["messages"][$key])) return array(); $messages = $_SESSION["messages"][$key]; unset($_SESSION["messages"][$key]); return $messages; } function getDomain($url) { if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED) === FALSE) { return false; } /*** get the url parts ***/ $parts = parse_url($url); /*** return the host domain ***/ return $parts['scheme'].'://'.$parts['host']; } function valid_email($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function check_gift_info($data) { $ret = true; if(!valid_email($data["recipient"])) { message("The email address entered is not valid."); $ret = false; } /* if($data["recipient"] == $login["username"]) { message("You may not purchase a gift certificate for yourself."); $ret = false; } */ if(!is_numeric($data["gift_amount"]) || $data["gift_amount"] <= 0) { message("The gift amount entered is not valid."); $ret = false; } return $ret; } function zip_2_state($zip) { if(trim($zip) == "") return false; $allstates = array ( "AK" => array ("9950099929"), "AL" => array ("3500036999"), "AR" => array ("7160072999", "7550275505"), "AZ" => array ("8500086599"), "CA" => array ("9000096199"), "CO" => array ("8000081699"), "CT" => array ("0600006999"), "DC" => array ("2000020099", "2020020599"), "DE" => array ("1970019999"), "FL" => array ("3200033999", "3410034999"), "GA" => array ("3000031999"), "HI" => array ("9670096798", "9680096899"), "IA" => array ("5000052999"), "ID" => array ("8320083899"), "IL" => array ("6000062999"), "IN" => array ("4600047999"), "KS" => array ("6600067999"), "KY" => array ("4000042799", "4527545275"), "LA" => array ("7000071499", "7174971749"), "MA" => array ("0100002799"), "MD" => array ("2033120331", "2060021999"), "ME" => array ("0380103801", "0380403804", "0390004999"), "MI" => array ("4800049999"), "MN" => array ("5500056799"), "MO" => array ("6300065899"), "MS" => array ("3860039799"), "MT" => array ("5900059999"), "NC" => array ("2700028999"), "ND" => array ("5800058899"), "NE" => array ("6800069399"), "NH" => array ("0300003803", "0380903899"), "NJ" => array ("0700008999"), "NM" => array ("8700088499"), "NV" => array ("8900089899"), "NY" => array ("0040000599", "0639006390", "0900014999"), "OH" => array ("4300045999"), "OK" => array ("7300073199", "7340074999"), "OR" => array ("9700097999"), "PA" => array ("1500019699"), "RI" => array ("0280002999", "0637906379"), "SC" => array ("2900029999"), "SD" => array ("5700057799"), "TN" => array ("3700038599", "7239572395"), "TX" => array ("7330073399", "7394973949", "7500079999", "8850188599"), "UT" => array ("8400084799"), "VA" => array ("2010520199", "2030120301", "2037020370", "2200024699"), "VT" => array ("0500005999"), "WA" => array ("9800099499"), "WI" => array ("4993649936", "5300054999"), "WV" => array ("2470026899"), "WY" => array ("8200083199")); foreach($allstates as $state => $zipranges) { foreach($zipranges as $ziprange) { if(($zip >= substr($ziprange, 0, 5)) && ($zip <= substr($ziprange, 5))) return $state; } } return $false; } function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } ?> Could not connect to Data Base.