if (isset($meta)) {
echo $meta;
} else {
echo '';
} ?>
/*** BEGIN GEN FUNCTIONS **/
function intFmt($str){ return number_format($str, 0); };
function usd($str){ return number_format($str,2); };
function toDate($time){ return date('Y-m-d H:i:s', $time); } //returns date formatted for mysql entry
function niceDate($time){ return date('M d, Y h:i a', strtotime( $time ) ) . " "; }
function dateOnly($time){ return date('M d, Y', strtotime( $time ) ); }
function monthYear($time){ return date('M / Y', strtotime( $time ) ); }
function niceDateNoYear($time){ return date('M d, h:i a', strtotime( $time ) ); }
function niceDateNoYear_utc($utc){ return date('M d, h:i a', $utc); }
function ago($m){ //pass in minutes ago value
if ($m <= 90) return round($m) . ' min. ago';
if ($m <= (60*2)) return 'less than 2 hrs ago';
if ($m <= (60*2+30)) return 'about 2 hrs ago';
if ($m <= (60*24)) return 'about ' . round($m/60). ' hrs ago';
$dayCnt = round($m/60/24);
if ($dayCnt>1) return $dayCnt . ' days ago';
else return $dayCnt . ' day ago';
}
function daysAgo( $numOfDays, $roundDay=false ){ //returns a unix timestamp of $numOfDays ago from now
if ($roundDay){
$now = time();
$arr = getdate( $now );
return ( $now - (60 * 60 * 24 * $numOfDays ) - ($arr["hours"] * 60 * 60 ) - ($arr["minutes"] * 60 ) - $arr["seconds"] );
}
return time() - ( 60 * 60 * 24 * $numOfDays );
}
function oi($ob, $key, $default_value = null) {
if (!is_object($ob)) return $default_value;
foreach($ob as $k=>$v) if ($k==$key) return $v;
return $default_value;
}
function prop_exists($ob,$key){
foreach($ob as $k=>$v) if ($k==$key) return true;
return false;
}
function ai($array, $key, $default_value = null){
return is_array($array) ? ( array_key_exists($key, $array) ? $array[$key] : $default_value) : $default_value;
}
function si(&$someVar, $returnIfNotSet=null ){
if (isset( $someVar )) return $someVar;
return $returnIfNotSet;
}
function validInt($str){
if ( preg_match("/[^0-9]/",$str) ) return false;
return true;
}
function validFloat($str){
if ( preg_match("/[^0-9\.]/",$str) ) return false;
return true;
}
function deleteAt(&$arr,$i){
array_splice($arr,$i, 1);
return $arr;
}
function cleanSpaces($str){
$str=preg_replace("/ */"," ",$str);
$str=preg_replace("/\r/","\n",$str);
$str=preg_replace("/\n\n*/","\n",$str);
if (substr($str,0,1)=="\n") $str=substr($str,1);
if (substr($str,-1,1)=="\n") $str=substr($str,0, strlen($str)-1);
return $str;
}
function trimWord($str,$max){
if (strlen($str)<$max) return $str;
$a=substr($str,0,$max-1);
//echo "\ntrimming: $str";
$b=trimWord( substr($str,$max-1), $max );
return "$a- $b";
}
function trimWordLen($str, $max){ //cut words longer than max chars
$str=cleanSpaces($str);
$lines=explode("\n",$str);
$ss="";
foreach($lines as $i=>$line){
$words=explode(" ",$line);
foreach($words as $j=>$w) $ss.=trimWord($w,$max)." ";
$ss.="\n";
}
return cleanSpaces($ss);
}
class EmailHandler {
public $subject, $body, $to;
public function __construct( $subject='', $body='', $from="vjbalyan@gmail.com"){
$hdr="From: $from\r\n";
$hdr.="Reply-To: $from\r\n";
$hdr.="X-Mailer: PHP/".phpversion();
$this->hdr=$hdr;
$this->subject = $subject;
$this->body = $body;
$this->from=$from;
}
public function useHTML(){
$hdr='MIME-Version: 1.0' . "\r\n";
$hdr.='Content-type: text/html; charset=iso-8859-1' . "\r\n";
$hdr="From: $this->from\r\n";
$hdr.="Reply-To: $this->from\r\n";
$hdr.="X-Mailer: PHP/".phpversion();
$this->hdr=$hdr;
}
public function sendToActioner( $subject=null, $body=null ){
global $global_acl;
if ($subject) $this->subject = $subject;
if ($body) $this->body = $body;
$this->to = $global_acl->get_email();
return $this->send();
}
public function sendToUser( $userID, $subject=null, $body=null ){
global $global_acl;
if ($subject) $this->subject = $subject;
if ($body) $this->body = $body;
$this->to = $global_acl->get_email($userID);
return $this->send();
}
public function send(){
if ( mail($this->to, $this->subject, $this->body, $this->hdr) ) return true;
return false;
}
}
function encryptCC($db, $ccNum, $ccv, $actioner_id){
//WE MUST ENCRYPT THE CC #, using the u_ID, ccv, and SECRET
//generate the key
$key = $ccv . PAINFULLY_SECRET . $actioner_id;
return " AES_ENCRYPT('" . $ccNum. "', '". $db->escape($key) . "') ";
}
function decryptCC($db, $ccv, $actioner_id){
//WE MUST ENCRYPT THE CC #, using the u_ID, ccv, and SECRET
//generate the key
$key = $ccv . PAINFULLY_SECRET . $actioner_id;
return " AES_DECRYPT(uacc.number, '". $db->escape($key) . "') ";
}
function ParseAddress($multiLineAddrStr){
//parse address lines
$addrLines = explode("\n",$multiLineAddrStr);
$addr1=$addrLines[0]; $addr2=""; $addr3="";
if (count($addrLines)>1) $addr2=$addrLines[1];
//merge all lines after line 2 into 1 line
if (count($addrLines)>2) for($i=2; $i