0) $isnew = func_get_arg(0); if($numargs > 1) $target = func_get_arg(1); global $loggedin, $session_u, $HTTP_COOKIE_VARS; if(isset($session_u) && is_numeric($session_u) && ((!$isnew && $session_u > 0) || ($isnew))){ if($session_u==-1 && $isnew){ // get rid of cookies setcookie("g", "", time()-1000, "/"); } $loggedin = true; }else{ // first check for a guid cookie value (g) if(isset($HTTP_COOKIE_VARS["g"]) && strlen($HTTP_COOKIE_VARS["g"]) == 32){ $guid = $HTTP_COOKIE_VARS["g"]; open_db(); $rs_login = mysql_query("SELECT id FROM user_login WHERE guid='$guid'"); if($row_login = mysql_fetch_row($rs_login)){ // if($row_login[2]==1){ // check if active $session_u = $row_login[0]; // }else{ // you aren't active // response_redirect("/secure/signin.php?target=".$target); // } }else{ // we don't know you you! response_redirect("./secure/signin.php"); } unset($row_login); unset($rs_login); mysql_close(); session_register("session_u"); }else{ // we don't know you! response_redirect("./secure/signin.php?target=".$target); } } } function get_guid(){ return (md5($REMOTE_ADDR.microtime())); } // ======================================================================== // DATABASE CONSTANTS AND FUNCTIONS // ======================================================================== function open_db(){ global $Connection, $db, $db_user, $db_pass, $host; $Connection = mysql_connect($host,$db_user,$db_pass) or die(throwError("500")); //mysql_select_db($db, $Connection) or die(throwError("501")); mysql_select_db($db, $Connection) or die( "
" . mysql_errno() . ": " . mysql_error() . "
" ); } function sqlInsert($str, $table){ $a = explode(",", $str); $col = array(); for($counter=0; $counter < count($a); $counter++){ $col[$counter] = "" . $a[$counter] . ""; } $str = ("INSERT INTO ". $table ."(". implode(",", $col) .") VALUES("); for($counter=0; $counter < count($a); $counter++){ $delim = ""; $aval = $GLOBALS[$a[$counter]]; if(is_string($aval) && $aval != null) // for some reason the null check is necessary $delim = "'"; $str .= $delim . (($aval != null) ? $aval : "null") . $delim . ", "; } $str = substr($str, 0, strlen($str)-2) . ");"; return $str; } function sqlUpdate($str, $table, $str_id){ $a = explode(",", $str); $col = array(); for($counter=0; $counter < count($a); $counter++){ $col[$counter] = "" . $a[$counter] . ""; } $str = "UPDATE ". $table ." SET "; for($counter=0; $counter < count($a); $counter++){ $delim = ""; $aval = $GLOBALS[$a[$counter]]; if(is_string($aval) && $aval != null) // for some reason the null check is necessary $delim = "'"; $str .= ($col[$counter] . "=" . $delim . (($aval != null) ? $aval : "null") . $delim . ", "); } $str = substr($str, 0, strlen($str)-2) . " WHERE ". $str_id ."=". $GLOBALS[$str_id] .";" ; return $str; } // ======================================================================== // FORM VALIDATION FUNCTIONS // ======================================================================== function checkLength($var, $max, $min){ if(strlen($var)<$min || strlen($var)>$max){ return false; } else { return true; } } function checkExpired($month, $year){ if(intval($year.$month) < intval(date("Ym"))){ return false; } else { return true; } } function checkCardtype($var){ open_db(); $q = sprintf("SELECT * FROM cardtypes WHERE cardtype = '%s'", $var); if($res = mysql_query($q)){ if(mysql_num_rows($res) > 0){ $row = mysql_fetch_array($res, MYSQL_ASSOC); return $row['id']; } else { return false; } } else { return false; } } function lookupCardtype($var){ open_db(); $q = sprintf("SELECT * FROM cardtypes WHERE id = '%s'", $var); if($res = mysql_query($q)){ if(mysql_num_rows($res) > 0){ $row = mysql_fetch_array($res, MYSQL_ASSOC); return $row['cardtype']; } else { return false; } } else { return false; } } function get_option_types($pid){ $types = array(); $q = "SELECT DISTINCT option_type FROM options WHERE product_id = ".strval($pid); if($res = mysql_query($q)){ if(mysql_num_rows($res) >= 1){ while($row = mysql_fetch_array($res, MYSQL_ASSOC)){ $types[] = $row['option_type']; } return $types; } else { return false; } } else { return false; } } function lookupOption($var){ open_db(); $q = sprintf("SELECT * FROM options WHERE id = '%s'", $var); if($res = mysql_query($q)){ if(mysql_num_rows($res) > 0){ $row = mysql_fetch_array($res, MYSQL_ASSOC); return $row['name']; } else { return false; } } else { return false; } } function get_option($oid){ open_db(); $q = sprintf("SELECT * FROM options WHERE id = '%s'", $oid); if($res = mysql_query($q)){ if(mysql_num_rows($res) > 0){ $row = mysql_fetch_array($res, MYSQL_ASSOC); return $row; } else { return false; } } else { return false; } } function fromForm($var, $max, $min, $ifnull){ // type definition // 0 = boolean // 1 = number // 2 = string // ereg("[\"\\\$\|;%&><]", $var) if(($max > 0 && strlen($var) > $max) || ($min > 0 && strlen($var) < $min)){ return ($ifnull); }else{ return ($var); } } function requireInput($var, $max, $min, $errcode, $errpage){ if(fromForm($var, $max, $min, $errcode) == $errcode){ response_redirect($errpage."?err=".$errcode); }else{ return (addslashes($var)); } } function requireMatch($var1, $var2, $errcode, $errpage){ if($var1 != $var2){ response_redirect($errpage."?err=".$errcode); }else{ return ($var1); } } function requireValues($var, $okvalues, $errcode, $errpage){ $var = (string) $var; if(eregi_replace("[$okvalues]", "", $var) != ""){ response_redirect($errpage."?err=".$errcode); }else{ return ($var); } } function requireZipCode($var, $errcode, $errpage){ if(!isZipCode($var)){ response_redirect($errpage."?err=".$errcode); }else{ return ($var); } } function requireAreaCode($var, $errcode, $errpage){ if(!isAreaCode($var)){ response_redirect($errpage."?err=".$errcode); }else{ return ($var); } } function requireEmail($var, $errcode, $errpage){ if(!isEmail($var)){ response_redirect($errpage."?err=".$errcode); }else{ return ($var); } } function isZipCode($zip) { return(ereg("^[0-9]{5}((-[0-9]{4})|([0-9]{4}))?$",$zip)); } function isAreaCode($ac) { return(ereg("^[0-9]{3}$",$ac)); } function isPhone($phone) { return(ereg("^[0-9]{3}-?[0-9]{4}$",$phone)); } function isEmail($email){ return(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)); } // ======================================================================== // GENERAL FUNCTIONS // ======================================================================== // ------------------------------------------------------------------------ // DEFAULT ERROR HANDLER // PARAMS: $err = error string or number // ------------------------------------------------------------------------ function throwError($err){ // response_redirect("./error.php?err=". $err); writeln($err); } // ------------------------------------------------------------------------ // WRITE A STRING TO SCREEN WITH A BR AND RETURN FEED // PARAMS: $str = string to be printed // ------------------------------------------------------------------------ function writeln($str){ echo $str."
\n"; } // ------------------------------------------------------------------------ // GENERATE A STRING OF RANDOM CHARACTERS // PARAMS: length = length of the string // ------------------------------------------------------------------------ function randStr($length){ srand(date("s")); $possible_charactors = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $string = ""; while(strlen($string) < $length) $string .= substr($possible_charactors,(rand()%(strlen($possible_charactors))),1); return($string); } /* // ------------------------------------------------------------------------ // ENCRYPT A STRING INPUT // PARAMS: input = plain text string to be encrypted // ------------------------------------------------------------------------ function encryptStr($input){ $pt = $input; GLOBAL $privateKey; define("KEY",$privateKey); define("CIPHER",MCRYPT_TRIPLEDES); if (!isset($pt)) $pt = ""; $blob=WEB_encrypt($pt); return chunk_split($blob); } // ------------------------------------------------------------------------ // DECRYPT A STRING ENCRYPTED BY ENCRYPTSTR FUNCTION ABOVE // PARAMS: blob = encrypted string to be decrypted // ------------------------------------------------------------------------ function decryptStr($blob){ GLOBAL $privateKey; define("KEY",$privateKey); define("CIPHER",MCRYPT_TRIPLEDES); return WEB_decrypt($blob); } */ /* communitech doesn't support mcrypt lib so we're going to use this function instead */ $key1 = md5("asldkfjlasdfjlasdkfjlaskjflsakjdflksajfliwtoriurte,4nj"); $key2 = md5("1239823749827591284792837492183749128374921473912873492"); $key3 = md5("idididididididiorororororopwqpwpwpwpwpwp,c,c,c,c,chahaa"); function keygen($input,$crypted){ $crypted=md5($crypted); $ctr=0; $keyresult=""; for($i=0;$i PHP Fatal error: Call to undefined function open_db() in E:\localuser\Galaxyglassart\wwwroot\necklace.php on line 6