can't query".$sql.""); } return $result; } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "", $theNull="yes") { $theNull = strtolower($theNull); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . addslashes($theValue) . "'" : (($theNull == "yes") ? "NULL" : "''"); break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : (($theNull == "yes") ? "NULL" : 0); break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : (($theNull == "yes") ? "NULL" : 0); break; case "date": $theValue = ($theValue != "") ? "'" . addslashes($theValue) . "'" : (($theNull == "yes") ? "NULL" : "''"); break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> "); } function CheckEmail($member_email_address = "") { if (!(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/', $member_email_address))) return false; else return true; } function Duration($timeposted, $timenow) { $timeleft = $timenow - $timeposted; $days = floor($timeleft / 86400); $hours = floor(($timeleft - $days * 86400) / 3600); $mins = floor(($timeleft - $days * 86400 - $hours * 3600) / 60); $secs = floor($timeleft - $days * 86400 - $hours * 3600 - $mins * 60); return $days; } function CurrencyFormat1($number) { return number_format($number, 2); } $key = "encryption"; function Encrypt($string, $key) { $result = ''; for ($i = 1; $i <= strlen($string); $i++) { $char = substr($string, $i - 1, 1); $keychar = substr($key, ($i % strlen($key)) - 1, 1); $char = chr(ord($char) + ord($keychar)); $result .= $char; } return $result; } function Decrypt($string, $key) { $result = ''; for ($i = 1; $i <= strlen($string); $i++) { $char = substr($string, $i - 1, 1); $keychar = substr($key, ($i % strlen($key)) - 1, 1); $char = chr(ord($char) - ord($keychar)); $result .= $char; } return $result; } function CurrencyFormat($part1 = "", $part2 = "") { $num1 = ($part1 == "") ? 0 : (int) $part1; $num2 = ($part2 == "") ? 0 : (int) $part2; if ($num2 < 10) $num2 = "0" . $num2; return (string) $num1 . "." . (string) $num2; } function DatetimeFormat($timeStamp) { $date = getdate($timeStamp); return ($date["mon"] . "/" . $date["mday"] . "/" . $date["year"]); } function DatetimeFullFormat($timeStamp) { $date = getdate($timeStamp); $str = $date["weekday"] . ", " . $date["month"] . " " . $date["mday"] . ", " . $date["year"]; return $str; } function Gettime($hour, $mi, $se, $mon, $day, $year, $AMPM) { if (strtolower($AMPM) == "pm" && $hour < 13) $hour = 12 + $hour; if (strtolower($AMPM) == "am" && $hour > 12) $hour = $hour - 12; return mktime($hour, $mi, $se, $mon, $day, $year); } function generatePassword ($length = 8) { $password = ""; // Define allowable characters $allowed = "0123456789bcdfghjkmnpqrstvwxyz"; // Set up a counter $i = 0; // Add random characters to $password until $length is reached while ($i < $length) { // Pick a random character from the allowable ones $char = substr($allowed, mt_rand(0, strlen($allowed) - 1), 1); // Exclude duplicates if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function getAffiliateLink() { global $admincbvid; $alink = "Powered By: Viral Minisites"; return $alink; } ?>