Query_ID); $this->Query_ID = 0; } function query($Query_String) { if ($this->Query_ID) { $this->free(); } $this->Query_ID = @mysql_query($Query_String); $this->Row = 0; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if (!$this->Query_ID) { $this->halt($this->Errno.": ".$this->Error); } return $this->Query_ID; } function number_rows() { $this->numberRows = @mysql_num_rows($this->Query_ID); $number = $this->numberRows; return $number; } function next_record() { $this->Record = @mysql_fetch_array($this->Query_ID); $this->Row += 1; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if ($this->Errno) { $this->halt($this->Errno.": ".$this->Error); } $stat = is_array($this->Record); if (!$stat) { $this->free(); } return $stat; } function p($Name) { print $this->Record[$Name]; } function f($Name) { return $this->Record[$Name]; } function halt($msg) { print($msg); } function session_initialize($custID = "") { session_set_cookie_params(0, '/', '.' . $_SERVER['DOMAIN']); session_set_save_handler ( array(&$this, '_open'), array(&$this, '_close'), array(&$this, '_read'), array(&$this, '_write'), array(&$this, '_destroy'), array(&$this, '_cleanup') ); session_name('sessid'); session_start(); if($custID) $_SESSION['custID'] = $custID; } function initialize() { $this->session_initialize(); if($custID = $_SESSION['custID']) { return($custID); } else { session_unset(); session_destroy(); header("Location: /logout.html"); exit; } } function initialize_sub() { $this->session_initialize(); if($custID = $_SESSION['custID']) { return($custID); } return(""); } function _open() { return(true); } function _close() { return(true); } function _read($id) { $this->query("SELECT data FROM sg_session WHERE sessID = '$id' LIMIT 1"); if($this->next_record()) { return($this->f("data")); } else { $this->query("INSERT INTO sg_session (sessID) VALUES ('$id')"); return(""); } } function _write($id, $data) { return($this->query("UPDATE sg_session SET custID = '".$_SESSION['custID']."', data = '$data', last_activity = ".time()." WHERE sessID = '$id' LIMIT 1")); } function _destroy($id) { $this->query("SELECT custID FROM sg_session WHERE sessID = '$id' LIMIT 1"); $this->next_record(); $custID = $this->f("custID"); $time = time(); $last_activity = date("Y-m-d H:i:s", $time); $this->query("UPDATE sg_customers SET last_logout = '$last_activity', total_time = (total_time + ('$time' - UNIX_TIMESTAMP(last_login))) WHERE custID = '$custID' LIMIT 1"); return($this->query("DELETE FROM sg_session WHERE sessID = '$id' LIMIT 1")); } function _cleanup($maxlifetime) { return($this->query("DELETE FROM sg_session WHERE last_activity < ".(time()-$maxlifetime))); } function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } function encrypt($value) { if($value) { $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'ecb', ''); srand($this->make_seed()); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); $ks = mcrypt_enc_get_key_size($td); $key = substr(md5($this->crypt_key), 0, $ks); mcrypt_generic_init($td, $key, $iv); $encrypted = mcrypt_generic($td, $value); mcrypt_generic_deinit($td); mcrypt_module_close($td); return(base64_encode(trim($encrypted))); } return ""; } function decrypt($encrypted) { if($encrypted) { $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'ecb', ''); srand($this->make_seed()); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); $ks = mcrypt_enc_get_key_size($td); $key = substr(md5($this->crypt_key), 0, $ks); mcrypt_generic_init($td, $key, $iv); $decrypted = mdecrypt_generic($td, base64_decode($encrypted)); mcrypt_generic_deinit($td); mcrypt_module_close($td); return(trim($decrypted)); } return ""; } function set_cookie($name, $value = "", $delete = false, $path = '/') { if($delete) { setcookie($name, $value, time()-3600); } else { setcookie($name, $value, time()+31536000); } } function format_phone($phone,$country='US') { $phone = preg_replace("/[^0-9+]/", "", $phone); if(strlen($phone) <= 7) { return ""; //preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone); } elseif(strlen($phone) == 10 && $country == "US") { return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1 $2-$3", $phone); } elseif($country != "US") { return $phone; } else { return ""; } } //Function to Send userID and Password from forgotten, but no match found function lostLogin($subject, $email) { $text = ""; $text .= "Dear $email, \r\n\r\n"; $text .= "We're sorry to say that we cannot find a user name or password associated with the email address you gave us. \r\n\r\n"; $text .= "Please contact us by return email to resolve the issue, or register for a new account online. \r\n\r\n"; $text .= "Thank you \r\n\r\n"; $text .= "Pro Mozart Society of Atlanta \r\n\r\n"; $headers = 'From: '."Mozart Atlanta Website "; if ($email != "") { mail($email, $subject, wordwrap($text, 70), $headers); } return "Alerts Sent!"; } //Function to Send userID and Password from forgotten function forgottenLogin($subject, $email, $password, $passURL) { $note = ""; $text = ""; $text .= "Dear $email, \r\n\r\n"; $text .= "Please find your login credentials below. \r\n\r\n"; $text .= "Your user name is ".$email.". \r\n\r\n"; $text .= "Your password is ".$password.". \r\n\r\n"; $text .= "Don't forget to return to the website, and login (".$passURL."?emailAddress=".$email."&password=".$password.") to continue. \r\n\r\n"; $text .= "Thank you \r\n\r\n"; $text .= "Pro Mozart Society of Atlanta \r\n\r\n"; $headers = 'From: '."Mozart Atlanta Website "; if ($email != "") { mail($email, $subject, wordwrap($text, 70), $headers); } return "Alerts Sent!"; } /*function forgottenLogin($subject, $email, $memberID, $fullName, $userName, $password, $passURL) { $note = ""; $text = ""; $text .= "Dear $fullName, \r\n\r\n"; $text .= "Please find your login credentials below. If more than one person on your membership shares this email address, multiple emails will be sent. \r\n\r\n"; $text .= "Your user name is ".$userName.". \r\n\r\n"; $text .= "Your password is ".$password.". \r\n\r\n"; $text .= "Don't forget to return to the website, and login (".$passURL."?userName=".$userName."&password=".$password.") to continue. \r\n\r\n"; $text .= "Thank you \r\n\r\n"; $text .= "Pro Mozart Society of Atlanta \r\n\r\n"; $headers = 'From: '."Mozart Atlanta Website "; if ($email != "") { mail($email, $subject, wordwrap($text, 70), $headers); } return "Alerts Sent!"; }*/ function format_ssn($ssn) { $ssn = preg_replace("/[^0-9+]/", "", $ssn); if(strlen($ssn) != 10) { return $ssn; //preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone); } elseif(strlen($ssn) == 10) { return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1-$2-$3", $ssn); } else { return ""; } } function stripText($text) { $text = strtolower(trim($text)); // replace all white space sections with a dash $text = str_replace(" ", "-", $text); //$text = str_replace(array(".php",".htm",".html"), "", $text); // strip all non alphanum or - $clean = ereg_replace("[^A-Za-z0-9\-]", "", $text); return $clean; } function myUniqId($numStr,$strPrx) { srand((double)microtime()*rand(1000000,9999999)); // Seed random number generator $arrChar=array(); // New array $uId=$strPrx; // Write prefix in the uniq id /*for($i=65;$i<90;$i++) { array_push($arrChar,chr($i)); // Add A-Z to array //array_push($arrChar,strtolower(chr($i))); // Add a-z to array }*/ for($x=0;$x<6;$x++) { for($i=48;$i<57;$i++) { array_push($arrChar,chr($i)); // Add 0-9 to array } } for($i=0;$i<$numStr;$i++) { $uId.=$arrChar[rand(0,count($arrChar))]; // Write random picked chars in the uniq id } return $uId; // Print uniq ID on the screen } } ?>