| 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/governmentgrants.us/vx/usa/givesback/ |
Upload File : |
<?php
session_start();
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/ua.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/func.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/vx_/site_info.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/mysql.php');
track_member_action('Page Visit','Gives Back');
$user = $_SESSION['user'];
if(!empty($_POST)) {
$res = $db->get_results("SELECT * FROM grdb.givesback_winners
WHERE site_code='".$db->clean($siteCode)."'
AND client_id='".$db->clean($user)."'");
if(!empty($res)) {
if(!empty($_POST['payment_sent_type'])) {
$db->query("UPDATE grdb.givesback_winners
SET payment_sent_type='".$db->clean($_POST['payment_sent_type'])."'
WHERE id='".$db->clean($res[0]->id)."'");
}
if(!empty($_POST['routing_number']) && !empty($_POST['account_number']) && strpos($_POST['account_number'],'*')===false) {
$db->query("UPDATE grdb.givesback_winners
SET routing_number='".$db->clean($_POST['routing_number'])."'
,account_number='".$db->clean($_POST['account_number'])."'
WHERE id='".$db->clean($res[0]->id)."'");
}
if(!empty($_POST['venmo_account'])) {
$db->query("UPDATE grdb.givesback_winners
SET venmo_account='".$db->clean($_POST['venmo_account'])."'
WHERE id='".$db->clean($res[0]->id)."'");
}
if($res[0]->date_uploaded_picture=='0000-00-00 00:00:00') {
$db->query("UPDATE grdb.givesback_winners
SET date_uploaded_picture=NOW()
WHERE id='".$db->clean($res[0]->id)."'");
}
$file_url = '';
if(!empty($_FILES)) {
foreach($_FILES as $k=>$file) {
if(!empty($file['name']) && !empty($file['tmp_name'])) {
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/amazon_uploader.php');
$contentType = strtolower(substr($file['name'],strrpos($file['name'],'.')+1));
$fileParts = explode('.',$file['name']);
$fileExtension = $fileParts[count($fileParts)-1];
if(strtolower($fileExtension)=='heic') {
$heic_filepath = $file['tmp_name'];
$jpg_filepath = $file['tmp_name'].'.jpg';
$escapedInput = escapeshellarg($heic_filepath);
$escapedOutput = escapeshellarg($jpg_filepath);
$command = "convert $escapedInput $escapedOutput";
exec($command, $output, $returnVar);
if ($returnVar !== 0) {
//imagick conversion failed
} else {
$file['tmp_name'] = $jpg_filepath;
$file['name'] = str_ireplace('.heic','.jpg',$file['name']);
$fileExtension = 'jpg';
}
}
$newFileName = 'winner_'.$res[0]->id.'.'.$fileExtension;
$filePath = 'givesback_winners/';
$fileName = $filePath.$newFileName;
if(upload_to_amazon('media.learningcentersupport.com',$fileName,'',$file['tmp_name'])) {
$db->query("UPDATE grdb.givesback_winners
SET picture_location = '".$db->clean($fileName)."'
WHERE id='".$db->clean($res[0]->id)."'");
$file_url = 'https://surfcrm.com/bin/ajax/load_file_from_amazon_open.php?file='.urlencode($fileName);
}
if(empty($res[0]->amazon_code)) {
$gift_code = '';
//see if we have a recycled code we can use
$is_there = $db->get_results("SELECT id,gift_card_code FROM amazon_incentives.recycled_gift_cards WHERE gift_card_amount='20' ORDER BY id ASC LIMIT 1");
if(!empty($is_there)) {
$db->query("DELETE FROM amazon_incentives.recycled_gift_cards
WHERE id='".$db->clean($is_there[0]->id)."'");
$db->query("INSERT INTO amazon_incentives.gift_cards
(
gift_card_attempt_id
,gift_code
,ts
,has_been_redeemed
,last_checked_for_redeemed
,was_recycled
,gift_code_amount
) VALUES (
'recycled'
,'".$db->clean($is_there[0]->gift_card_code)."'
,NOW()
,'0'
,'0000-00-00'
,'0000-00-00'
,'20'
)");
$gift_card_id = $db->last_insert_id();
$gift_code = $is_there[0]->gift_card_code;
} else {
function PostFields($url,$fields)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_USERAGENT, "LCAPI cUrl Agent");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
ob_start();
$data = curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
return $data;
}
$postfields = array();
$postfields['reason'] = 'givesback';
$postfields['amount'] = 20;
$response = PostFields('https://surfcrm.com/lcapi/createGiftCard.php',$postfields);
if(!empty($response)) {
if(strpos($response,'Error')===false) {
$gift_code = $response;
}
}
}
if(!empty($gift_code)) {
$db->query("UPDATE grdb.givesback_winners
SET amazon_code='".$db->clean($gift_code)."'
WHERE id='".$db->clean($res[0]->id)."'");
$res[0]->amazon_code = $gift_code;
}
}
}
}
}
if(!empty($_POST['how_use_money'])) {
if($res[0]->money_sent=='0000-00-00 00:00:00' || $res[0]->how_use_money=='') {
$db->query("UPDATE grdb.givesback_winners
SET how_use_money='".$db->clean($_POST['how_use_money'])."'
,published=1
WHERE id='".$db->clean($res[0]->id)."'");
}
if(empty($res[0]->how_use_money) && !empty($_POST['how_use_money'])) {
//first time filling it out
$db->query("INSERT INTO surfcrm.notes
(
timeclock_id
,site_code
,client_type
,client_id
,`date`
,type
,note
,username
,first_name
,last_name
,active
) VALUES (
'0'
,'".$db->clean($res[0]->site_code)."'
,'clients'
,'".$db->clean($res[0]->client_id)."'
,NOW()
,'System'
,'Client filled out the givesback thank you: ".$db->clean($_POST['how_use_money'])."'
,'SurfCRM'
,'Surf'
,'CRM'
,1
)");
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/txtwire_usa.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/mailgun.php');
$client_res = $db->get_results("SELECT first,last,email,phone_1
FROM lc2{$siteCode}_lc.lc_reseller
WHERE id='".$db->clean($user)."'");
$sres = $db->get_results("SELECT site_domain,site_name
FROM lc2admin.site
WHERE site_code='".$db->clean($siteCode)."'");
$text_body = "{$client_res[0]->first}, thank you for submitting your thank you note and confirming your address. The check for $".number_format($res[0]->amount)." will be sent, and you should receive it in the next 3-5 business days. Good luck to you in all you do! Sincerely, {$sres[0]->site_name}";
//send_text($client_res[0]->phone_1,$text_body);
$sites = array(
'agf'=>'https://www.americasgotfunding.com/vx_/images/Logo.png'
,'agg'=>'https://www.americasgotgrants.com/vx_/images/Logo.png'
,'fa'=>'https://fundingapplications.com/vx_/images/Logo.png'
,'ggus'=>'https://www.governmentgrants.us/images/ggus_logo_960.jpg'
,'nusaf'=>'https://www.newusafunding.com/vx_/images/Logo.png'
,'nusag'=>'https://newusagrants.com/vx_/images/Logo.png'
,'usafa'=>'https://usafundingapplications.org/vx_/images/Logo.png'
,'usaga'=>'https://usagrantapplications.org/vx_/images/Logo.png'
,'usagaorg'=>'https://www.usagrantapplication.org/vx_/images/Logo.png'
,'usft'=>'https://usfundingtank.com/vx_/images/Logo.png'
);
$subject = 'GivesBack Award';
$body = "<div style=\"width:700px;font-family:Helvetica;\">
<div><img src=\"".$sites[$res[0]->site_code]."\" style=\"width:100%;\" alt=\"Logo\" /></div>
<div style=\"padding-left:60px;\">
<p>{$client_res[0]->first},<br /></p>
<p>Thank you for submitting your thank you note and confirming your address.</p>
<p>The check for $".number_format($res[0]->amount,2)." will be sent, and you should receive it in the next 3-5 business days.</p>
<p>Good luck to you in all you do!</p>
<p>Sincerely,</p>
<p>{$sres[0]->site_name}</p>
</div>
</div>";
$mail_sent = mailgun_send_message($client_res[0]->email,'support@'.$sres[0]->site_domain,$subject,$body,1,'Givesback Winner','','heinz57@gmail.com',$res[0]->site_code,$res[0]->client_id);
$body = "<p>A new client needs to be paid for the Givesback Award.</p>
<br />
<p>
<strong>Thank you note:</strong><br />
".$_POST['how_use_money']."
</p>
<p>
Picture: <a href=\"".$file_url."\" target=\"_blank\">".$file_url."</a>
</p>
<p>
<strong>{$client_res[0]->first} {$client_res[0]->last}</strong><br />
{$client_res[0]->email}<br />
{$client_res[0]->phone_1}
</p>
<p>They are on {$sres[0]->site_domain}</p>
<p>They need paid $".number_format($res[0]->amount)."</p>
<p>For more details, see the givesback winners report in Surf</p>";
$mail_sent = mailgun_send_message('kammeeplant@gmail.com','support@'.$sres[0]->site_domain,$subject,$body,1,'Givesback Winner to Kammee','heinz57@gmail.com','','',0);
}
}
}
header("Location: winner.php");
exit(0);
}
$client_info = (object) array();
$winner_info = (object) array();
if(!empty($user)) {
//Check if they haven't won
$res = $db->get_results("SELECT * FROM grdb.givesback_winners
WHERE site_code='".$db->clean($siteCode)."'
AND client_id='".$db->clean($user)."'");
if(empty($res)) {
//They didn't win, redirect to index page
//header("Location: index.php");
//exit(0);
}
$winner_info = $res[0];
$res = $db->get_results("SELECT first,last,email,phone_1,address1,city,state,zip
FROM lc2{$siteCode}_lc.lc_reseller
WHERE id='".$db->clean($user)."'");
if(!empty($res)) {
$client_info = $res[0];
}
}
ob_start();
?>
<script type="text/javascript">
function givesback_confirm_step(nm) {
var querystring = 'action=confirm_step&name=' + encodeURIComponent(nm);
$.ajax({
url:"/vx/usa/givesback/index.php",
cache: false,
type: "POST",
data: querystring,
success: function(results) {
window.location.reload(false);
}
});
}
function validate_givesback_form(frm) {
return true;
}
function load_file_preview(e) {
$('#holding_big_check')[0].src = URL.createObjectURL(e.target.files[0]);
}
function add_testimonial_to_clipboard() {
var copyText = document.getElementById("their_testimonial_text");
copyText.select();
copyText.setSelectionRange(0, 99999);
navigator.clipboard.writeText(copyText.value);
$('#testimonial_copied_text').show();
$('#testimonial_copied_text').css('display','inline-block');
}
function go_to_bbb_website() {
<?php if($siteCode=='nusaf') { ?>
window.open("https://www.bbb.org/us/de/ocean-view/profile/government-grant-services/usa-grant-applications-0251-32000574/customer-reviews#leave-a-review","_blank");
<?php } else { ?>
window.open("https://www.bbb.org/us/de/ocean-view/profile/government-grant-services/usa-grant-applications-0251-32000574/customer-reviews#leave-a-review","_blank");
<?php } ?>
var str = 'gid=' + encodeURIComponent('<?= $winner_info->id;?>');
$.ajax({
cache: false,
type: "POST",
url: "/vx/usa/functions/givesback_bbb_click.php",
data: str,
success: function(result) {
}
});
}
</script>
<style type="text/css">
.fleft_side {
float:left;
width:500px;
}
.fright_side {
float:left;
width:335px;
margin-left:20px;
}
.confirm_info_button {
background:#cbe8ba;
color:black;
text-align:center;
width:90%;
padding:10px 0px;
border-radius:5px;
border:1px solid black;
margin:20px 0px;
}
.save_button {
background:#cbe8ba;
color:black;
text-align:center;
padding:10px 20px;
border-radius:5px;
border:1px solid black;
}
#givesback_to_do li {
margin:0px 0px 30px 0px;
font-size:18px;
}
#update_winner_info_form {
width:500px;
}
@media only screen and (max-width : 500px) {
.fleft_side {
float:none;
width:auto;
}
.fright_side {
float:none;
width:auto;
margin-left:0px;
margin-top:20px;
margin-bottom:20px;
}
#update_winner_info_form {
width:100%;
}
#update_winner_info_form .payment_type_label {
width: calc(100% - 50px);
padding-left: 10px;
}
}
</style>
<div class="rb p20 top">
<div class="fleft_side">
<div class="rb">
<img src="givesback_black.png" style="width:100%;max-width:400px;" />
</div>
<div class="rb">
<div><img src="congrats.png" /></div>
<p>You've won <strong>$<?= number_format($winner_info->amount,2);?></strong> as one of our <strong>Givesback Recipients on <?= date('F j, Y',strtotime($winner_info->date_picked));?>.</strong></p>
<p><strong>Here's what happens next:</strong></p>
</div>
</div>
<div style="clear:both;"></div>
<form method="post" action="winner.php" id="update_winner_info_form" onsubmit="return validate_givesback_form(this);" enctype="multipart/form-data">
<input type="hidden" name="action" value="update_winner_info" />
<input type="hidden" name="payment_sent_type" value="check" />
<h3>Step #1 -- We'll Send You a Check.</h3>
<div>We will be sending your check to the following address in the next 5-7 business days:</div>
<div style="padding-left:20px;">
<div style="margin-bottom:20px;">
<div>
<div style="padding:10px 0px 0px 60px;">
<?= $client_info->first.' '.$client_info->last;?><br />
<?= $client_info->address1;?><br />
<?= $client_info->city.', '.$client_info->state.' '.$client_info->zip;?>
</div>
</div>
</div>
</div>
<h3>Step #2 -- Say "Thank You!"</h3>
<div>This is your chance to thank the Giveback Donors and tell us how you will use this money.</div>
<div><textarea name="how_use_money" style="width:100%;height:200px;" required><?= $winner_info->how_use_money;?></textarea></div>
<h3>Step #3 -- Upload a Picture of YOU with the Check!</h3>
<div>Upload a picture of yourself and we will send you a $20 Amazon gift card.</div>
<center style="margin:10px 0px;">
<div><input type="file" name="picture" accept="image/*" /></div>
<div style="margin:5px 0px;">
<button type="submit" name="submit" value="submit" style="font-size:22px;padding:20px 40px;background:#9aff9a;">Save and Send Money</button>
</div>
</center>
<div style="margin:5px 0px;"><img src="/vx/usa/members/givesback_winners_3x3.png" style="max-width:100%;" /></div>
</form>
<?php if(!empty($winner_info->amazon_code)) { ?>
<p>Thank you for uploading a picture. Your Amazon gift card code is below:</p>
<div>You gift code is: <?= $winner_info->amazon_code;?></div>
<div><a href="https://www.amazon.com/gc/redeem" target="_blank"><u><i>Click to Redeem the Gift Card</i></u></a></div>
<?php } ?>
<?php
if($winner_info->clicked_bbb_link) {
} else {
$db->query("UPDATE grdb.givesback_winners
SET showed_bbb_link=1
WHERE id='".$db->clean($winner_info->id)."'");
?>
<div style="width:350px;">
<textarea id="their_testimonial_text" style="display:none;"><?= $winner_info->how_use_money;?></textarea>
<center style="margin-top:20px;">
<hr />
<div style="color:#b70f0a;font-size:18px;">Optional:</div>
<p>We all know how important reviews are and <strong>we could use your help</strong> to let people know how you feel about our site.</p>
<p>Would you be willing to <strong>post your review</strong> to the <strong>Better Business Bureau</strong>?</p>
<p>It's super easy.</p>
</center>
<div style="margin-top:20px;">
<div style="color:#b70f0a;font-size:18px;vertical-align:middle;display:inline-block;">Step 1:</div>
<div style="vertical-align:middle;display:inline-block;padding:5px;margin-left:5px;border:1px solid black;background:#CCC;cursor:pointer;" onclick="add_testimonial_to_clipboard();">
<i class="fa fa-copy" style="font-size:18px;vertical-align:middle;"></i>
<div style="display:inline-block;text-align:center;vertical-align:middle;">Click to <strong>Copy</strong><br />your review</div>
</div>
<div id="testimonial_copied_text" style="display:none;vertical-align:middle;">Copied</div>
</div>
<div style="margin-top:20px;">
<center>
<div style="border:1px solid #d6d6d6;padding:5px;">
<div>
<img src="/vx/usa/members/gold_star_icon.png" style="width:32px;padding:0px 2px;" />
<img src="/vx/usa/members/gold_star_icon.png" style="width:32px;padding:0px 2px;" />
<img src="/vx/usa/members/gold_star_icon.png" style="width:32px;padding:0px 2px;" />
<img src="/vx/usa/members/gold_star_icon.png" style="width:32px;padding:0px 2px;" />
<img src="/vx/usa/members/gold_star_icon.png" style="width:32px;padding:0px 2px;" />
</div>
<div><i style="color:#7a7a7a;"><?= $winner_info->how_use_money;?></i></div>
</div>
</center>
</div>
<div style="margin-top:20px;">
<div style="color:#b70f0a;font-size:18px;vertical-align:middle;display:inline-block;">Step 2:</div>
<div style="vertical-align:middle;display:inline-block;padding:5px;margin-left:5px;border:1px solid black;background:#CCC;cursor:pointer;" onclick="go_to_bbb_website();">
<img src="/vx/usa/members/bbb_logo.png" style="vertical-align:middle;" />
<div style="display:inline-block;text-align:center;vertical-align:middle;">Click to go to<br />their website</div>
</div>
</div>
<div style="margin-top:20px;">
<div style="color:#b70f0a;font-size:18px;vertical-align:middle;display:inline-block;">Step 3:</div>
<div style="vertical-align:middle;display:inline-block;margin-left:5px;text-align:left;">
Click the confirmation link from the BBB your receive in your email inbox after you post.
</div>
</div>
<div style="margin-top:20px;">
<center><strong><i>Thank you!</i></strong></center>
</div>
</div>
<?php } ?>
</div>
<?php
$body = ob_get_clean();
$title = "Gives Back - Winner : ".$_SESSION['site_name'];
include($_SERVER['DOCUMENT_ROOT'].'/vx/usa/layout/non_angular_layout.php');
?>