| Server IP : 10.200.247.200 / Your IP : 216.73.217.19 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/usa_sites/newusafunding.com/vx/lib/ |
Upload File : |
<?
if(!function_exists('phone_number'))
{
function phone_number($PHONE)
{
if(!empty($PHONE))
{
$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)
return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $PHONE);
elseif(strlen($PHONE) == 11)
return preg_replace("/([0-9]{1})([0-9]{3})([0-9]{3})([0-9]{4})/", "+$1 ($2) $3-$4", $PHONE);
else
return $PHONE;
}
else
{
return '0';
}
}
}
if(!function_exists('cookieName'))
{
function cookieName()
{
$result = array();
$host = $_SERVER['HTTP_HOST'];
$siteURL = explode('.', $host);
if(strpos($host, 'www.') !== false)
{
$site = $siteURL[1];
$domain = $siteURL[1].".".$siteURL[2];
}
else
{
$site = $siteURL[0];
$domain = $siteURL[0].".".$siteURL[1];
}
$result['site'] = $site;
$result['domain'] = $domain;
return $result;
}
}
if(!function_exists('echoPre'))
{
function echoPre($array, $color)
{
echo '<pre class="'.$color.'">';
print_r($array);
echo '</pre>';
}
}
if(!function_exists('trunc'))
{
function trunc($str, $len)
{
if($len > strlen($str))
{
return substr($str, 0, $len);
}
else
{
return $str;
}
}
}
if(!function_exists('prettyJSON'))
{
function prettyJSON($json)
{
$result = '';
$level = 0;
$in_quotes = false;
$in_escape = false;
$ends_line_level = NULL;
$json_length = strlen( $json );
for( $i = 0; $i < $json_length; $i++ ) {
$char = $json[$i];
$new_line_level = NULL;
$post = "";
if( $ends_line_level !== NULL ) {
$new_line_level = $ends_line_level;
$ends_line_level = NULL;
}
if ( $in_escape ) {
$in_escape = false;
} else if( $char === '"' ) {
$in_quotes = !$in_quotes;
} else if( ! $in_quotes ) {
switch( $char ) {
case '}': case ']':
$level--;
$ends_line_level = NULL;
$new_line_level = $level;
break;
case '{': case '[':
$level++;
case ',':
$ends_line_level = $level;
break;
case ':':
$post = " ";
break;
case " ": case "\t": case "\n": case "\r":
$char = "";
$ends_line_level = $new_line_level;
$new_line_level = NULL;
break;
}
} else if ( $char === '\\' ) {
$in_escape = true;
}
if( $new_line_level !== NULL ) {
$result .= "\n".str_repeat( "\t", $new_line_level );
}
$result .= $char.$post;
}
return $result;
}
}
if(!function_exists('siid'))
{
/**
* Returns a unique session ID
*
* @param none
* @return string Returns a unique session id.
*/
function siid()
{
return sprintf(
'%04x%04x%04x%04x%04x%04x%04x%04x',
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535),
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)
);
}
}
if(!function_exists('fieldSort'))
{
/**
* Sort an associative array of elements
*
* @param array $array Array structure of elements.
* @param string $sort The field within the array to sort by.
* @param string $direction The direction of sorting ASC/DESC.
* @return array Returns a newly sorted array.
*/
function fieldSort($array, $sort, $direction)
{
$bArray = array();
$cArray = array();
foreach($array as $key => $value)
{
$bArray[$key] = strtolower($value[$sort]);
}
if($direction == "DESC")
{
arsort($bArray);
}
else
{
asort($bArray);
}
foreach($bArray as $key => $value)
{
$cArray[] = $array[$key];
}
return $cArray;
}
}
if(!function_exists('escape'))
{
/**
* Use native PHP functions to clean a string before inserting into a database
*
* @param string $string The string to be cleaned.
* @return string Returns a clean string.
*/
function escape($string)
{
$string = clean($string);
$string = htmlentities($string);
return $string;
}
}
if(!function_exists('dollarFormat'))
{
/**
* Formats float, integer or string to a $0.00 US dollar format
*
* @param mixed[] $amount The number to format.
* @return float Returns a formatted US dollar amount.
*/
function dollarFormat($amount)
{
$formattedAmount = number_format(floor($amount * 100) / 100, 2, '.', '');
return $formattedAmount;
}
}
if(!function_exists('cleanInput'))
{
/**
* Used in the sanitize function to clean a string of any possibly hazardous elements
*
* @param array $input The array to be stripped of tags.
* @return string Returns a string cleaned of hazardous tags.
*/
function cleanInput($input)
{
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
$output = preg_replace($search, '', $input);
return $output;
}
}
//if(!function_exists('validEmail'))
//{
/**
* Validates the formatting of an email address
*
* @param string $email The email address as a string.
* @return boolean Returns true if the string is a valid email address and false if it is not.
*/
/*
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if($localLen < 1 || $localLen > 64)
{
$isValid = false;
}
else if($domainLen < 1 || $domainLen > 255)
{
$isValid = false;
}
else if($local[0] == '.' || $local[$localLen-1] == '.')
{
$isValid = false;
}
else if(preg_match('/\\.\\./', $local))
{
$isValid = false;
}
else if(!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
$isValid = false;
}
else if(preg_match('/\\.\\./', $domain))
{
$isValid = false;
}
else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local)))
{
if(!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
{
$isValid = false;
}
}
return $isValid;
}
*/
//}
if(!function_exists('categoryIcon'))
{
function categoryIcon($cat) {
if($cat == "grant_writing")
{
$categoryIcon = "chronicle";
}
else if($cat == "proposal_tips")
{
$categoryIcon = "thumbs-up";
}
else if($cat == "categories")
{
$categoryIcon = "cluster";
}
else if($cat == "federal_grants")
{
$categoryIcon = "scale-classic";
}
else if($cat == "researching")
{
$categoryIcon = "binoculars";
}
return $categoryIcon;
}
}
if(!function_exists('num_to_letter'))
{
function num_to_letter($num, $cap)
{
switch($num) {
case "1" : ($cap)?$letter="A":$letter = "a"; break;
case "2" : ($cap)?$letter="B":$letter = "b"; break;
case "3" : ($cap)?$letter="C":$letter = "c"; break;
case "4" : ($cap)?$letter="D":$letter = "d"; break;
case "5" : ($cap)?$letter="E":$letter = "e"; break;
case "6" : ($cap)?$letter="F":$letter = "f"; break;
case "7" : ($cap)?$letter="G":$letter = "g"; break;
case "8" : ($cap)?$letter="H":$letter = "h"; break;
case "9" : ($cap)?$letter="I":$letter = "i"; break;
case "10" : ($cap)?$letter="J":$letter = "j"; break;
case "11" : ($cap)?$letter="K":$letter = "k"; break;
case "12" : ($cap)?$letter="L":$letter = "l"; break;
case "13" : ($cap)?$letter="M":$letter = "m"; break;
case "14" : ($cap)?$letter="N":$letter = "n"; break;
case "15" : ($cap)?$letter="X":$letter = "x"; break;
case "16" : ($cap)?$letter="P":$letter = "p"; break;
case "17" : ($cap)?$letter="Q":$letter = "q"; break;
case "18" : ($cap)?$letter="R":$letter = "r"; break;
case "19" : ($cap)?$letter="S":$letter = "s"; break;
case "20" : ($cap)?$letter="T":$letter = "t"; break;
case "21" : ($cap)?$letter="U":$letter = "u"; break;
case "22" : ($cap)?$letter="V":$letter = "v"; break;
case "23" : ($cap)?$letter="W":$letter = "w"; break;
case "24" : ($cap)?$letter="X":$letter = "x"; break;
case "25" : ($cap)?$letter="Y":$letter = "y"; break;
case "26" : ($cap)?$letter="Z":$letter = "z"; break;
default: $letter = "No letter for that number";
}
return $letter;
}
}
if(!function_exists('gen_64key'))
{
function gen_64key()
{
$invite_key = "";
for($i=0; $i<64; $i++) {
$is_alpha_1 = rand(0,5);
$is_alpha_2 = rand(0,5);
if($is_alpha_2 == $is_alpha_1)
{
if($is_alpha_2<4)
{
$is_alpha_2 = $is_alpha_2+1;
}
else
{
$is_alpha_2 = rand(0,4);
}
}
$invite_key .= ($is_alpha_1 == 1 || $is_alpha_2 == 1) ? num_to_letter(rand(1, 26),1) : rand(1, 9);
}
return $invite_key;
}
}
if(!function_exists('gen_256key'))
{
function gen_256key()
{
$invite_key = "";
for($i = 0; $i < 256; $i++)
{
$is_alpha_1 = rand(0,5);
$is_alpha_2 = rand(0,5);
if($is_alpha_2 == $is_alpha_1)
{
if($is_alpha_2<4)
{
$is_alpha_2 = $is_alpha_2+1;
}
else
{
$is_alpha_2 = rand(0,4);
}
}
$invite_key .= ($is_alpha_1 == 1 || $is_alpha_2 == 1) ? num_to_letter(rand(1, 26),1) : rand(1, 9);
}
return $invite_key;
}
}
$passed = 0;
if(!function_exists('pass_keys'))
{
function pass_keys($form, $db, $passed = 0)
{
$keyUsed = $db->query("SELECT id FROM grdb.grd_authentication WHERE id = '".escape($form)."' ");
if(count($keyUsed) > 0 && $passed < 10)
{
$passed = ($passed + 1);
$newKey = key_pass(gen_256key(), $db, $passed);
return $newKey;
}
else if(count($keyUsed) == 0 && $passed > 10)
{
return "failed";
}
else
{
return $form;
}
}
}
if(!function_exists('key_pass'))
{
function key_pass($key, $db, $passed = 0)
{
$keyUsed = $db->query("SELECT id FROM grdb.grd_authentication WHERE id = '".escape($form)."' ");
if(count($keyUsed) > 0 && $passed < 10)
{
$passed = ($passed + 1);
$newKey = pass_keys(gen_256key(), $db, $passed);
return $newKey;
}
else if(count($keyUsed) == 0 && $passed > 10)
{
return "failed";
}
else
{
return $form;
}
}
}
if(!function_exists('valid_key'))
{
function valid_key($key, $db)
{
$validKey = $db->query("
SELECT
id
FROM grdb.grd_authentication
WHERE
id = '".escape($key)."'
AND
datetime_expires > NOW()
");
if(count($validKey) > 0)
{
$db->query("
UPDATE grdb.grd_authentication
SET
datetime_expires = '".date("Y-m-d H:i:s", strtotime("+4 hours"))."'
WHERE
id = '".escape($key)."'
");
return true;
}
else
{
$genCount = $db->query("
SELECT
*
FROM grdb.grd_authentication
WHERE
datetime_expires < NOW()
AND
datetime_expires != '0000-00-00 00:00:00'
");
for($i=0; $i<count($genCount); $i++)
{
$newKey = pass_keys(gen_256key(), $db);
$validKey = $db->query("
INSERT INTO grdb.grd_authentication
SET
id = '".escape($newKey)."'
");
}
$db->query("
DELETE FROM grdb.grd_authentication
WHERE
datetime_expires < NOW()
AND
datetime_expires != '0000-00-00 00:00:00'
");
return false;
}
}
}
if(!function_exists('getMenuObj'))
{
function getMenuObj($menu, $db)
{
if(is_numeric($menu))
{
$menu = ($menu * 1);
if($menu > 0)
{
$menuObj = array();
$menuData = $db->query("
SELECT
menu,
title,
class,
description
FROM lc2systems.menus
WHERE
menu = '$menu'
LIMIT 1
");
$menuObj['data'] = $menuData[0];
$menuItems = $db->query("
SELECT
class,
title,
description,
icon,
label,
link,
action
FROM lc2systems.menu_items
WHERE
menu = '$menu'
AND
status = 'active'
ORDER BY priority ASC
");
$menuObj['items'] = $menuItems;
return $menuObj;
}
}
}
}
if(!function_exists('validUser'))
{
function validUser($user, $userDB, $db)
{
$userData = array();
$userData['user'] = "";
$userData['email'] = "";
if(!empty($userDB))
{
$validUser = $db->query("SELECT * FROM $userDB.lc_reseller WHERE id = '".clean($user)."' ");
if(count($validUser) == 0)
{
$validEmail = $db->query("
SELECT
*
FROM $userDB.lc_reseller
WHERE
email = '".clean($user)."'
OR
user = '".clean($user)."'
");
if(count($validEmail) > 0)
{
$userData['user'] = $validEmail[0]['id'];
$userData['email'] = $validEmail[0]['email'];
$_SESSION['user'] = $validEmail[0]['id'];
$_SESSION['email'] = $validEmail[0]['email'];
}
else
{
return false;
}
}
else
{
$userData['user'] = $validUser[0]['id'];
$userData['email'] = $validUser[0]['email'];
$_SESSION['user'] = $validUser[0]['id'];
$_SESSION['email'] = $validUser[0]['email'];
}
if($userData['user'] > 0)
{
return $userData;
}
}
else
{
return false;
}
}
}
if(!function_exists('PlusChar'))
{
/**
Cyptify a string by incrementing all ascii letters then base64 encoding it
*/
function PlusChar($input)
{
return chr(ord($input)+1);
}
}
if(!function_exists('MinusChar'))
{
function MinusChar($input)
{
return chr(ord($input)-1);
}
}
if(!function_exists('Cryptify'))
{
function Cryptify($input)
{
return base64_encode(implode('',array_map('PlusChar',str_split($input))));
}
}
if(!function_exists('UnCryptify'))
{
function UnCryptify($input)
{
if(is_array($input))
{
return implode('|',$input);
}
else
{
return implode('',array_map('MinusChar',str_split(base64_decode($input))));
}
}
}
if(!function_exists('sanitize'))
{
/**
Cleans bad string data
Works for multi-deminsional arrays of strings or just a single string value
*/
function sanitize($input)
{
if (is_array($input))
{
foreach($input as $var => $val)
{
$output[$var] = sanitize($val);
}
}
else
{
if (get_magic_quotes_gpc())
{
$input = stripslashes($input);
}
$output = cleanInput($input);
}
return $output;
}
}
if(!function_exists('validEmail'))
{
/**
Validate an email address.
Provide email address (raw input)
Returns true if the email address has the email
address format and the domain exists.
validEmail taken from http://www.linuxjournal.com/article/9585
*/
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
}
if(!function_exists('make_seed'))
{
/* Seed the random number generator */
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
}
if(!function_exists('getPage'))
{
/*
* Make an http page request using cURL
*/
function getPage($url, $method, $post, $referer, $cookie_jar, $proxy)
{
if(!empty($post))
{
$url .= (strpos($url, '?') !== false) ? '' : '?';
$first = true;
foreach($post as $k => $v)
{
$url .= (strpos($url,'&')!==false || !$first) ? '&'.urlencode($k).'='.urlencode($v) : urlencode($k).'='.urlencode($v);
$first = false;
}
}
$data = file_get_contents($url);
return trim($data);
}
}
if(!function_exists('get_categories'))
{
/**
* Get Grant Categories
*/
function get_categories()
{
$cat_json = '';
$file = $_SERVER['DOCUMENT_ROOT'].'/api/lcapi/app_cache/categories';
if(!$cat_json =@ file_get_contents($file))
{
$cat_json = file_get_contents('https://surfcrm.com/lcapi/GetProfileCategories.php');
file_put_contents($file, $cat_json);
}
$categories = json_decode($cat_json, $assoc = true);
if(!isset($categories['expires']) || $categories['expires'] < time()) {
unlink($file);
$categories = get_categories();
}
return $categories;
}
}
if(!function_exists('get_education_questions'))
{
/**
* Get Education Questions
*/
function get_education_questions() {
$cat_json = '';
$file = $_SERVER['DOCUMENT_ROOT'].'/api/lcapi/app_cache/education_questions';
if(!$cat_json =@ file_get_contents($file)) {
$cat_json = file_get_contents('https://surfcrm.com/lcapi/GetEducationQuestions.php');
file_put_contents($file, $cat_json);
}
$education = json_decode($cat_json, $assoc = true);
if(!isset($education['expires']) || $education['expires'] < time()) {
unlink($file);
$education = get_education_questions();
}
return $education;
}
}
if(!function_exists('get_disability_questions'))
{
/**
* Get Disability Questions
*/
function get_disability_questions() {
$cat_json = '';
$file = $_SERVER['DOCUMENT_ROOT'].'/api/lcapi/app_cache/disability_questions';
if(!$cat_json =@ file_get_contents($file))
{
$cat_json = file_get_contents('https://surfcrm.com/lcapi/GetDisabilityQuestions__.php');
file_put_contents($file, $cat_json);
}
$disability = json_decode($cat_json, $assoc = true);
if(!isset($disability['expires']) || $disability['expires'] < time())
{
unlink($file);
$disability = get_disability_questions();
}
return $disability;
}
}
if(!function_exists('get_business_questions'))
{
/**
* Get Business Questions
*/
function get_business_questions()
{
$cat_json = '';
$file = $_SERVER['DOCUMENT_ROOT'].'/api/lcapi/app_cache/business_questions';
if(!$cat_json =@ file_get_contents($file))
{
$cat_json = file_get_contents('https://surfcrm.com/lcapi/GetBusinessQuestions.php');
file_put_contents($file, $cat_json);
}
$business = json_decode($cat_json, $assoc = true);
if(!isset($business['expires']) || $business['expires'] < time())
{
unlink($file);
}
return $business;
}
}
if(!function_exists('mailgun_send_message'))
{
/**
* Sends an email using mailgun.org for tracking and stuff
*
* @param string $to The email address you are sending the email to
* @param string $from The email address you are sending the email from (support@americasgotfunding.com)
* @param string $subject The subject of the email
* @param string $message The body of the email you are sending
* @param boolean $is_html Is the message html. Set to false for plaintext.
* @param string $tag A tag for tracking this email (confirmation, renewal, newsletter, etc)
* @param string $cc A comma delimited list of emails to cc on the email
* @param string $bcc A comma delimited list of emails to bcc on the email
* @return object Returns an object with id (auto generated email id), message (either an error message, or a confirmation message), and status (Success or Fail)
* */
function mailgun_send_message($to='',$from='',$subject='',$message='',$is_html=0,$tag='',$cc='',$bcc='',$site_code='',$client_id=0,$attachments = array(),$replyTo='',$maskReplyTo=0) {
$arr = explode('@',$from);
$domain = 'mg.'.$arr[1];
if(strpos($from,'<')!==false) {
$email = preg_match('/.*<(.*)>.*/',$from,$matches);
$arr = explode('@',$matches[1]);
$domain = 'mg.'.$arr[1];
}
$post = array();
$post['from'] = $from;
$post['h:sender'] = $from;
$post['to'] = $to;
$post['subject'] = $subject;
if($is_html) {
$plain = strip_tags(str_replace('</p',"\n</p",str_replace('<br',"\n<br",$message)));
if(strpos($message,'<!DOCTYPE')===false) {
if(strpos($message,'<html>')===false) {
$message = '<!DOCTYPE HTML><html><head></head><body>'.$message.'</body></html>';
} else {
$message = '<!DOCTYPE HTML>'.$message;
}
}
$post['html'] = $message;
$post['text'] = $plain;
} else {
$post['text'] = $message;
}
if(!empty($tag)) {
$post['o:tag'] = $tag;
}
if(!empty($cc)) {
$post['cc'] = $cc;
}
if(!empty($bcc)) {
$post['bcc'] = $bcc;
}
if(!empty($attachments)) {
foreach($attachments as $k=>$v) {
$post['attachment['.$k.']'] = curl_file_create($v,system_extension_mime_type($v),basename($v));
}
}
if(!empty($replyTo)) {
$post['h:Reply-To'] = $replyTo;
if($maskReplyTo==1) {
$post['from'] = $replyTo;
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/'.$domain.'/messages');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:key-99068d6d99148b8d743a828fcb233242');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
unset($ch);
$return = json_decode($data);
if(empty($return)) {
$return = (object) array('status'=>'');
}
$return->status = ($info['http_code']=='200') ? 'Success' : 'Fail';
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/mysql.php');
$mailgun_id = str_replace('<','',str_replace('>','',$return->id));
$mailgun_db = new MySQL('db.syndbs.com', 'lc2user', 'SYN57CRUZ', 'mailgun');
$mailgun_db->query("INSERT INTO mailgun.sent_emails
(
site_code
,client_id
,email_type
,sent_date
,mailgun_id
,email_sent_to
) VALUES (
'".$mailgun_db->clean($site_code)."'
,'".$mailgun_db->clean($client_id)."'
,'".$mailgun_db->clean($tag)."'
,NOW()
,'".$mailgun_db->clean($mailgun_id)."'
,'".$mailgun_db->clean($to)."'
)");
$message_id = $mailgun_db->last_insert_id();
$mailgun_db->query("INSERT INTO mailgun.sent_emails_actual_email
(
email_id
,email_to
,email_from
,email_subject
,email_body
,email_cc
) VALUES (
'".$mailgun_db->clean($message_id)."'
,'".$mailgun_db->clean($to)."'
,'".$mailgun_db->clean($from)."'
,'".$mailgun_db->clean($subject)."'
,'".$mailgun_db->clean($message)."'
,'".$mailgun_db->clean($cc)."'
)");
if($return->status=='Fail') {
$mailgun_db->query("INSERT INTO mailgun.email_actions
(
mailgun_id
,action
,response
,ts
) VALUES (
'".$mailgun_db->clean($mailgun_id)."'
,'Sending to Mailgun'
,'Fail'
,NOW()
)");
}
return $return;
}
}
if(!function_exists('getSiteData'))
{
function getSiteData($db, $debug, $debugDomain)
{
if($debug && !empty($debugDomain))
{
$siteDomain = $debugDomain;
}
else
{
$siteDomain = $_SERVER['HTTP_HOST'];
}
$siteData = $db->query("SELECT * FROM lc2admin.site WHERE site_domain = '".clean($siteDomain)."'");
if(count($siteData) == 0)
{
$siteWorkingDirectory = explode('/', getcwd()); // /home/nusaf/public_html/
$siteCode = $siteWorkingDirectory[1];
if($siteCode == 'home')
{
if($siteWorkingDirectory[2] == "usfund") {
$siteCode = 'usforg';
}
else if($siteWorkingDirectory[2] == "usfundingtank") {
$siteCode = 'usft';
}
else {
$siteCode = $siteWorkingDirectory[2];
}
}
$siteData = $db->query("SELECT * FROM lc2admin.site WHERE site_code = '".clean($siteCode)."'");
}
return $siteData[0];
}
}
if(!function_exists('track_member_action')) {
function track_member_action($action_type,$action_details) {
global $siteCode;
global $db;
if(!empty($_SESSION['user']) && !empty($siteCode)) {
$db->query("INSERT INTO tracker.member_actions
(
site_code
,client_id
,action
,ts
,action_details
) VALUES (
'".clean($siteCode)."'
,'".clean($_SESSION['user'])."'
,'".clean($action_type)."'
,NOW()
,'".clean($action_details)."'
)");
}
}
}
if(!function_exists('paging_title')) {
function paging_title($page,$count,$per) {
$max_page = ceil($count/$per);
if($page<1) {
$page = 1;
}
if($page>$max_page) {
$page = $max_page;
}
$min = ($page-1)*$per + 1;
if($min<1) {
$min = 1;
}
$max = $min + $per - 1;
if($max > $count) {
$max = $count;
}
return 'Page '.$page.': '.$min.' - '.$max;
}
}
if(!function_exists('pretty_state_list')) {
function pretty_state_list($states) {
include($_SERVER['DOCUMENT_ROOT'].'/vx/lib/States.php');
if($states=='Any') {
return 'All U.S. States';
} else {
$list = array();
$arr = explode(',',$states);
foreach($arr as $a) {
$a = trim($a);
if(!empty($_STATES[$a])) {
$list[$_STATES[$a]] = $_STATES[$a];
}
}
return implode(', ',$list);
}
}
}
if(!function_exists('pretty_gender_list')) {
function pretty_gender_list($gender) {
if(strtolower($gender)=='f') {
return 'Female';
}
if(strtolower($gender)=='m') {
return 'Male';
}
return '';
}
}
if(!function_exists('strip_imported_junk')) {
function strip_imported_junk($str) {
$str = str_replace('style=','non_style=',$str);
$str = mb_convert_encoding($str, "HTML-ENTITIES", 'UTF-8');
$str = str_replace('\n',"\n",$str);
$str = str_replace('\"','"',$str);
return $str;
}
}
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/mailgun.php');
?>