| 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/favorites/ |
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','Favorite Grants');
$user = $_SESSION['user'];
ob_start();
?>
<script type="text/javascript">
<?php if(empty($_SESSION['subscriptions']['2'])) { ?>
window.needs_upsell = 1;
<?php } else { ?>
window.needs_upsell = 0;
<?php } ?>
</script>
<div class="rb p20 top">
<h2><span class="fas fa-heart" style="color:red;"></span> Favorite Applications</h2>
<hr />
<center style="<?= ($phone) ? '' : 'width:400px;margin:0px auto;';?>">
<?php if(!empty($all_favorites)) { ?>
<div style="display:flex;flex-direction:row;">
<div style="flex:45%;text-align:center;">
<a href="/vx/usa/favorites/" style="display:block;padding:10px;font-size:18px;color:red;background:white;border:2px solid red;">MY Favorites</a>
</div>
<div style="flex:10%;text-align:center;">
<img src="/vx/usa/favorites/swap_options.png" style="margin-top:12px;transform:rotate(180deg);" />
</div>
<div style="flex:45%;text-align:center;">
<a href="/vx/usa/favorites/all.php" style="display:block;padding:10px;font-size:18px;background:red;color:white;border:2px solid red;">ALL Favorites</a>
</div>
</div>
<?php } else { ?>
<div style="display:flex;flex-direction:row;">
<div style="flex:45%;text-align:center;">
<a href="/vx/usa/favorites/" style="display:block;padding:10px;font-size:18px;background:red;color:white;border:2px solid red;">MY Favorites</a>
</div>
<div style="flex:10%;text-align:center;">
<img src="/vx/usa/favorites/swap_options.png" style="margin-top:12px;" />
</div>
<div style="flex:45%;text-align:center;">
<a href="/vx/usa/favorites/all.php" style="display:block;padding:10px;font-size:18px;color:red;background:white;border:2px solid red;">ALL Favorites</a>
</div>
</div>
<?php } ?>
<br />
<p>Click between "My Favorites" and "ALL Favorites" by clicking on one of the buttons above. "ALL Favorities" include all favorites from all of our users that were favorited this month. Click the "Heart" icon to add it to "My Favorites."</p>
</center>
<?php
$not_ignored_where = " AND gg.grants_id NOT IN (SELECT grants_id FROM grdb.grd_usa_ignored_grants WHERE site_code='".$db->clean($siteCode)."' AND client_id='".$db->clean($_SESSION['user'])."')";
if(!empty($_GET['ignored'])) {
$not_ignored_where = " AND gg.grants_id IN (SELECT grants_id FROM grdb.grd_usa_ignored_grants WHERE site_code='".$db->clean($siteCode)."' AND client_id='".$db->clean($_SESSION['user'])."')";
}
$page = 1;
$per_page = 20;
if(!empty($_REQUEST['page'])) {
$page = $_REQUEST['page'];
}
$gets_new_stuff = '';
if(empty($_SESSION['subscriptions'][2])) {
$gets_new_stuff = " AND gg.ts < '".date('Y-m-d',strtotime('-30 day'))." 00:00:00'";
}
if(!empty($all_favorites)) {
$res = $db->get_results("SELECT COUNT(DISTINCT(gusg.grants_id)) as c
FROM grdb.grd_usa_saved_grants AS gusg
LEFT JOIN grdb.grd_grants gg ON gg.grants_id=gusg.grants_id
WHERE
gusg.ts_added >= '".date('Y-m-d',strtotime('-1 month'))." 00:00:00'
AND (gg.deadline='0000-00-00' OR gg.deadline >= CURDATE())
AND gg.bad_url=0
{$gets_new_stuff}
{$not_ignored_where}
");
} else {
$res = $db->get_results("SELECT COUNT(DISTINCT(gusg.grants_id)) as c
FROM grdb.grd_usa_saved_grants AS gusg
LEFT JOIN grdb.grd_grants gg ON gg.grants_id=gusg.grants_id
WHERE
gusg.site_code = '$siteCode'
AND gusg.client_id = '$user'
AND (gg.deadline='0000-00-00' OR gg.deadline >= CURDATE())
AND gg.bad_url=0
{$not_ignored_where}
");
}
$total_count = $res[0]->c;
$my_favorites_count = 0;
$res = $db->get_results("SELECT COUNT(DISTINCT(gusg.grants_id)) as c
FROM grdb.grd_usa_saved_grants AS gusg
LEFT JOIN grdb.grd_grants gg ON gg.grants_id=gusg.grants_id
WHERE
gusg.site_code = '$siteCode'
AND gusg.client_id = '$user'
AND (gg.deadline='0000-00-00' OR gg.deadline >= CURDATE())
AND gg.bad_url=0
{$not_ignored_where}
");
$my_favorites_count = $res[0]->c;
$max_page = ceil($total_count/$per_page);
if($page<1) {
$page = 1;
}
if($page>$max_page) {
$page = $max_page;
}
$limit = '';
if($total_count >= $per_page) {
$limit = "LIMIT ".(($page-1)*$per_page).", ".$per_page;
}
if(!empty($all_favorites)) {
$all_list = $db->get_results("SELECT gusg.grants_id,COUNT(*) as c
FROM grdb.grd_usa_saved_grants AS gusg
LEFT JOIN grdb.grd_grants gg ON gg.grants_id=gusg.grants_id
WHERE
gusg.ts_added >= '".date('Y-m-d',strtotime('-1 month'))." 00:00:00'
AND (gg.deadline='0000-00-00' OR gg.deadline >= CURDATE())
AND gg.bad_url=0
{$not_ignored_where}
GROUP BY grants_id
ORDER BY c DESC
{$limit}");
$grant_list = array();
$grant_ids = array();
if(!empty($all_list)) {
foreach($all_list as $g) {
$grant_ids[] = $g->grants_id;
}
}
if(!empty($grant_ids)) {
$res = $db->get_results("SELECT
gg.*,
gusg.id AS favorite,
gga.did_apply,
gga.how_much_applied_for,
gt.name AS grant_type,
ggl.bg_color_hex,
ggl.logo_url
FROM grdb.grd_grants AS gg
LEFT JOIN grdb.grd_usa_saved_grants AS gusg
ON gg.grants_id = gusg.grants_id
AND gusg.client_id = '$user'
AND gusg.site_code = '$siteCode'
LEFT JOIN grdb.grd_grants_applied AS gga
ON
gga.grants_id = gg.grants_id
AND
gga.user = gusg.client_id
AND
gga.site_code = gusg.site_code
LEFT JOIN grdb.grd_types AS gt
ON gt.types_id = gg.types_id
LEFT JOIN grdb.grd_site_logos ggl ON ggl.site_domain=gg.base_url AND ggl.status='active'
WHERE gg.grants_id IN ('".implode("','",$grant_ids)."')
GROUP BY gg.grants_id
ORDER BY favorited DESC");
if(!empty($res)) {
foreach($res as $r) {
$grant_list[] = $r;
}
}
}
} else {
$grant_list = $db->get_results("SELECT
gg.*,
gusg.id AS favorite,
gga.did_apply,
gga.how_much_applied_for,
gt.name AS grant_type,
ggl.bg_color_hex,
ggl.logo_url
FROM grdb.grd_usa_saved_grants AS gusg
LEFT JOIN grdb.grd_grants AS gg
ON gg.grants_id = gusg.grants_id
LEFT JOIN grdb.grd_grants_applied AS gga
ON
gga.grants_id = gg.grants_id
AND
gga.user = gusg.client_id
AND
gga.site_code = gusg.site_code
LEFT JOIN grdb.grd_types AS gt
ON gt.types_id = gg.types_id
LEFT JOIN grdb.grd_site_logos ggl ON ggl.site_domain=gg.base_url AND ggl.status='active'
WHERE
gusg.client_id = '$user'
AND
gusg.site_code = '$siteCode'
AND (gg.deadline='0000-00-00' OR gg.deadline >= CURDATE())
AND gg.bad_url=0
{$not_ignored_where}
GROUP BY gg.grants_id
ORDER BY favorited DESC
{$limit}
");
}
if(empty($grant_list)) {
?>
<div class="rb light-gray-bg p10 left dropshadow-light" style="max-width:500px;">
<div class="rb white-bg p20 left">
<div class="f18 bold">
Wait! You haven't favorited any grants yet.
</div>
<div class="rb pt20">
<div class="container-fluid">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<div class="rb cc"
style="">
<div class="cd gray">
<span class="favorite glyphicons glyphicons-heart f50 pointer"></span>
</div>
<div class="cdl" style="width:0px; height:100%; margin-left:-3px;">
</div>
</div>
<div class="rb cc pt10">
<div class="relative iblock fa fa-hand-pointer-o f26"></div>
</div>
</div>
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
<span class="f16 bblue bold">
Keeping track of the grants you like is easy. To add a grant to your favorites list, click the star icon found in the grant details.
</span>
</div>
</div>
</div>
</div>
<hr>
<div class="f18 bold">
Start now by searching our database of thousands of grants to find the grant that is right for you.
<br>
<br>
<div class="rb cc">
<span class="glyphicons glyphicons-database-search <?=$phone ? 'f40' : 'f26'?>" style="margin-top:-10px;"></span>
<?=$phone ? '<br>' : ''?>
<a href="/vx/usa/search/">
<span class="rollover-underline bblue bold pointer">
Search Our Database
</span>
</a>
</div>
</div>
</div>
</div>
<?php
} else {
if(!empty($limit)) {
?>
<div id="paging">
<center>
<h3><?= paging_title($page,$total_count,$per_page);?> of <?= $total_count;?></h3>
<button onclick="grant_list_change_page('1'); return false;" title="<?= paging_title(1,$total_count,$per_page);?>"><<</button>
<button onclick="grant_list_change_page('<?= $page-1;?>'); return false;" title="<?= paging_title($page-1,$total_count,$per_page);?>"><</button>
<?php for($i=$page-5;$i<$page+5;$i++) {
if($i>=1 && $i<=$max_page) { ?>
<button onclick="grant_list_change_page('<?= $i;?>'); return false;" <?= ($i==$page) ? 'class="selected_page"' : '';?> title="<?= paging_title($i,$total_count,$per_page);?>"><?= $i;?></button>
<?php } ?>
<?php } ?>
<button onclick="grant_list_change_page('<?= $page+1;?>'); return false;" title="<?= paging_title($page+1,$total_count,$per_page);?>">></button>
<button onclick="grant_list_change_page('<?= $max_page;?>'); return false;" title="<?= paging_title($max_page,$total_count,$per_page);?>">>></button>
</center>
</div>
<?php } ?>
<div id="grantList">
<?php
$showFavoritesIcon = 1;
if($phone) {
include($_SERVER['DOCUMENT_ROOT'].'/vx/usa/layout/inc/non_angular_grant_list_mobile.php');
} else {
include($_SERVER['DOCUMENT_ROOT'].'/vx/usa/layout/inc/non_angular_grant_list.php');
} ?>
</div>
<?php
if(!empty($limit)) {
?>
<div id="paging">
<center>
<h3><?= paging_title($page,$total_count,$per_page);?> of <?= $total_count;?></h3>
<button onclick="grant_list_change_page('1'); return false;" title="<?= paging_title(1,$total_count,$per_page);?>"><<</button>
<button onclick="grant_list_change_page('<?= $page-1;?>'); return false;" title="<?= paging_title($page-1,$total_count,$per_page);?>"><</button>
<?php for($i=$page-5;$i<$page+5;$i++) {
if($i>=1 && $i<=$max_page) { ?>
<button onclick="grant_list_change_page('<?= $i;?>'); return false;" <?= ($i==$page) ? 'class="selected_page"' : '';?> title="<?= paging_title($i,$total_count,$per_page);?>"><?= $i;?></button>
<?php } ?>
<?php } ?>
<button onclick="grant_list_change_page('<?= $page+1;?>'); return false;" title="<?= paging_title($page+1,$total_count,$per_page);?>">></button>
<button onclick="grant_list_change_page('<?= $max_page;?>'); return false;" title="<?= paging_title($max_page,$total_count,$per_page);?>">>></button>
</center>
</div>
<?php } ?>
<?php } ?>
</div>
<?php
$body = ob_get_clean();
$title = "Favorite Grants : ".$_SESSION['site_name'];
include($_SERVER['DOCUMENT_ROOT'].'/vx/usa/layout/non_angular_layout.php');
?>