403Webshell
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/usa/functions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/usa_sites/newusafunding.com/vx/usa/functions/getMoreGrants.php
<?
include_once($_SERVER['DOCUMENT_ROOT']."/vx/lib/xinc.php");
if(!empty($_POST['tracking_action'])) {
	track_member_action($_POST['tracking_action'],$_POST['tracking_details']);
}
include_once($_SERVER['DOCUMENT_ROOT']."/vx/usa/lib/formalizeGrants.php");
if(empty($user) || $guest)
{
	return false;
	exit;
}
else
{
	$profile_where = '';
	//Heinz will probably change his mind and want this filtering by category again, so I'm not deleting this yet.
	/*$profile = $db->query("
							SELECT p.profile_category_id,p.gender,r.state
							FROM lc2{$siteCode}_lc.lc_reseller r
							LEFT JOIN lc2{$siteCode}_lc.lc_leads l
								ON l.customerID=r.id
							LEFT JOIN lc2{$siteCode}_lc.lead_profile p
								ON p.lead_id=l.id
							WHERE r.id='{$user}'
						");
	*/

	$glist = clean($_POST['glist']);
	$glistQuery = "";

	if(!empty($glist))
	{
		$glistQuery = " AND gg.grants_id NOT IN ($glist) ";
	}

	$state = $_POST['state'];
	if(!empty($state) && $state != 'Any')
	{
		$state = clean($state);
		$stateData = $db->query(" SELECT * FROM geo.states WHERE state = '$state' ");
		$state = $stateData[0]['state_short'];
		//$profile_where .= " AND (gg.only_available_state LIKE '%".clean($state)."%' OR gg.only_available_state LIKE '%any%' OR gg.only_available_state = '') ";
		$profile_where .= " AND gg.only_available_state LIKE '%".clean($state)."%'";
	}
	
	if(!empty($_POST['newest_apps_only'])) {
		$profile_where .= " AND DATE(gg.ts) >= '".date('Y-m-d',strtotime('-30 day'))."'";
	} else {
		$profile_where .= " AND DATE(gg.ts) <= '".date('Y-m-d',strtotime('-30 day'))."'";
	}
	
	/*
	$category_set = false;
	$subcategory_set = false;
	$minority_set = false;
	$industry_set = false;
	
	if(!empty($_REQUEST['sub_sub_categories_id']) && $_REQUEST['sub_sub_categories_id']!='undefined') {
		$category_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_categories
									WHERE categories_id = '".clean($_REQUEST['sub_sub_categories_id'])."'
								) ";
	}
	if(!empty($_REQUEST['sub_sub_subcategories_id']) && $_REQUEST['sub_sub_subcategories_id']!='undefined') {
		$subcategory_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_subcategories
									WHERE subcategories_id = '".clean($_REQUEST['sub_sub_subcategories_id'])."'
								) ";
	}
	if(!empty($_REQUEST['sub_sub_industries_id']) && $_REQUEST['sub_sub_industries_id']!='undefined') {
		$industry_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_industries
									WHERE industries_id = '".clean($_REQUEST['sub_sub_industries_id'])."'
								) ";
	}
	if(!empty($_REQUEST['sub_sub_minorities_id']) && $_REQUEST['sub_sub_minorities_id']!='undefined') {
		$minority_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_minorities
									WHERE minorities_id = '".clean($_REQUEST['sub_sub_minorities_id'])."'
								) ";
	}
	
	if(!$category_set && !empty($_REQUEST['sub_categories_id']) && $_REQUEST['sub_categories_id']!='undefined') {
		$category_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_categories
									WHERE categories_id = '".clean($_REQUEST['sub_categories_id'])."'
								) ";
	}
	if(!$subcategory_set && !empty($_REQUEST['sub_subcategories_id']) && $_REQUEST['sub_subcategories_id']!='undefined') {
		$subcategory_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_subcategories
									WHERE subcategories_id = '".clean($_REQUEST['sub_subcategories_id'])."'
								) ";
	}
	if(!$industry_set && !empty($_REQUEST['sub_industries_id']) && $_REQUEST['sub_industries_id']!='undefined') {
		$industry_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_industries
									WHERE industries_id = '".clean($_REQUEST['sub_industries_id'])."'
								) ";
	}
	if(!$minority_set && !empty($_REQUEST['sub_minorities_id']) && $_REQUEST['sub_minorities_id']!='undefined') {
		$minority_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_minorities
									WHERE minorities_id = '".clean($_REQUEST['sub_minorities_id'])."'
								) ";
	}
	
	if(!$category_set && !empty($_REQUEST['categories_id']) && $_REQUEST['categories_id']!='undefined') {
		$category_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_categories
									WHERE categories_id = '".clean($_REQUEST['categories_id'])."'
								) ";
	}
	if(!$subcategory_set && !empty($_REQUEST['subcategories_id']) && $_REQUEST['subcategories_id']!='undefined') {
		$subcategory_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_subcategories
									WHERE subcategories_id = '".clean($_REQUEST['subcategories_id'])."'
								) ";
	}
	if(!$industry_set && !empty($_REQUEST['industries_id']) && $_REQUEST['industries_id']!='undefined') {
		$industry_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_industries
									WHERE industries_id = '".clean($_REQUEST['industries_id'])."'
								) ";
	}
	if(!$minority_set && !empty($_REQUEST['minorities_id']) && $_REQUEST['minorities_id']!='undefined') {
		$minority_set = true;
		$profile_where .= " AND gg.grants_id IN
								(
									SELECT grants_id
									FROM grdb.grd_grants_minorities
									WHERE minorities_id = '".clean($_REQUEST['minorities_id'])."'
								) ";
	}
	*/
	
	if(!empty($_POST['bread_crumb_id'])) {
		$profile_where .= " AND gg.grants_id IN
							(
								SELECT grants_id
								FROM grdb.bread_crumbs_grants
								WHERE bread_crumbs_id='".clean($_POST['bread_crumb_id'])."'
							)";
	}
	if(!in_array($_POST['bread_crumb_id'],array('49','50','51','52','53','54','55','56','57','58','59','60','61','50','51','52','53','54','55','56','57','58','59','60','61','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','133','134','135','136','137','138','139','140','91','92','93','94','95','96'))) {
		$profile_where .= " AND gg.types_id<>'6'";
	}
	
	$grantCollection = $db->query("
									SELECT
											gg.grants_id,
                                            gg.name,
											gg.description,
                                            gg.amount,
                                            gg.url,
                                            gt.name AS type,
                                            gg.who,
                                            gg.deadline,
											gusg.id AS favorite,
                                            gg.featured
									FROM grdb.grd_grants AS gg
									LEFT JOIN grdb.grd_usa_saved_grants AS gusg
										ON
											gusg.grants_id = gg.grants_id
										AND
											gusg.client_id = '$user'
										AND
											gusg.site_code = '$siteCode'
                                    LEFT JOIN grdb.grd_types AS gt
                                        ON gg.types_id = gt.types_id
									WHERE
											(
													gg.deadline >= CURDATE()
												OR
													gg.deadline = '0000-00-00'
											)
											AND gg.status='active'
											{$glistQuery}
											{$profile_where}
									GROUP BY gg.grants_id
									ORDER BY gg.ts DESC
                                    LIMIT 20
								");
	/*if(count($grantCollection) < 20)
	{
		if(!empty($subcategory) || !empty($category))
		{
			$subcategory = ($subcategory * 1);
			$subcategory = ($category * 1);
			if($subcategory > 0)
			{
				$categoryRelationship = $db->query(" SELECT * FROM grdb.grd_category_relationships WHERE subcategory = '$subcategory' ");
				$categoryRelationships = "";
				for($x=0; $x<count($categoryRelationship); $x++)
				{
					$categoryRelationships .= $categoryRelationship[$x]['parent_category'].",";
				}
				$categoryRelationships = rtrim($categoryRelationships, ",");

				if(count($categoryRelationship) > 0)
				{
					$profile_where .= " AND gg.grants_id IN
										(
											SELECT ggc.grants_id
											FROM grdb.grd_grants_categories ggc
											LEFT JOIN grdb.grd_categories gc
												ON gc.categories_id = ggc.categories_id
											WHERE
													gc.categories_id IN (".clean($categoryRelationships).")
										) ";
				}
			}
			else if($category > 0)
			{
				$categoryRelationship = $db->query(" SELECT * FROM grdb.grd_category_relationships WHERE parent_category = '$category' ");
				$categoryRelationships = "";
				for($x=0; $x<count($categoryRelationship); $x++)
				{
					$categoryRelationships .= $categoryRelationship[$x]['subcategory'].",";
				}
				$categoryRelationships = rtrim($categoryRelationships, ",");

				if(count($categoryRelationship) > 0)
				{
					$profile_where .= " OR gg.grants_id IN
										(
											SELECT ggc.grants_id
											FROM grdb.grd_grants_subcategories ggc
											LEFT JOIN grdb.grd_subcategories gc
												ON gc.subcategories_id = ggc.subcategories_id
											WHERE
													gc.subcategories_id IN (".clean($categoryRelationships).")
										) ";
				}
			}
			$grantCollection = $db->query("
											SELECT
													gg.grants_id,
													gg.name,
													gg.amount,
													gg.url,
													gt.name AS type,
													gg.who,
													gg.deadline,
													gusg.id AS favorite,
													gg.featured
											FROM grdb.grd_grants AS gg
											LEFT JOIN grdb.grd_usa_saved_grants AS gusg
												ON
													gusg.grants_id = gg.grants_id
												AND
													gusg.client_id = '$user'
												AND
													gusg.site_code = '$siteCode'
											LEFT JOIN grdb.grd_types AS gt
												ON gg.types_id = gt.types_id
											WHERE
													(
														gg.deadline > NOW()
														OR
														gg.deadline = '0000-00-00'
													)
													{$glistQuery}
													AND
													(
														1=1 {$profile_where}
													)
											GROUP BY gg.grants_id
											ORDER BY gg.".((!empty($state) || $state == 'Any') ? 'only_available_state' : 'amount')." DESC
											LIMIT 20
										");
		}
	}*/
    if(!empty($grantCollection))
	{
		for($i=0; $i<count($grantCollection); $i++)
		{
            $thisGrant = $grantCollection[$i]['grants_id'];
            $thisGrant = ($thisGrant * 1);
			$grantCollection[$i]['name'] = stripslashes($grantCollection[$i]['name']);
			$grantCollection[$i]['description'] = stripslashes($grantCollection[$i]['description']);
            $grantURL = '';
			if(!empty($grantCollection[$i]['url'])) {
				if(strpos($grantCollection[$i]['url'],'http')!==false) {
					$grantURL = parse_url($grantCollection[$i]['url'], PHP_URL_HOST);
				} else {
					$grantURL = parse_url('http://'.$grantCollection[$i]['url'], PHP_URL_HOST);
				}
			}
			$grantURL = clean($grantURL);
            $grantCollection[$i]['height'] = rand(240, 320);
            $siteLogos = $db->query("
											SELECT
													*
											FROM grdb.grd_site_logos
											WHERE site_domain = '$grantURL'
											LIMIT 1
										");
			if(!empty($siteLogos)) {
				$grantCollection[$i]['logo'] = $siteLogos[0];
			} else {
				$grantCollection[$i]['logo'] = array();
			}
			$grantCategory = $db->query("
											SELECT
													gc.name,
                                                    gc.categories_id
											FROM grdb.grd_grants_categories AS ggc
                                            LEFT JOIN grdb.grd_categories AS gc
                                                ON gc.categories_id = ggc.categories_id
											WHERE ggc.grants_id = '$thisGrant'
										");
            $grantCollection[$i]['categories'] = (!empty($grantCategory)) ? $grantCategory : array();
			$grantTags = $db->query("
										SELECT
												gt.name,
                                                gt.tags_id
										FROM grdb.grd_grants_tags AS ggt
                                        LEFT JOIN grdb.grd_tags AS gt
                                            ON gt.tags_id = ggt.tags_id
										WHERE ggt.grants_id = '$thisGrant'
									");
            $grantCollection[$i]['tags'] = (!empty($grantTags)) ? $grantTags : array();
			$grant = $thisGrant;
			$grantHeight = $grantCollection[$i]['height'];
			if(!empty($siteLogos[0])) {
				$logoBgColor = $siteLogos[0]['bg_color_class'];
				$logoUrl = $siteLogos[0]['logo_url'];
				/* This doesn't work on the new server (We have ports blocked for interacting with other servers without using curl)
				$file_headers = @get_headers($logoUrl);
				if(!$file_headers || strpos($file_headers[0],'404')!==false) {
					$logoUrl = '';
				}*/
			} else {
				$logoBgColor = '#FFFFFF';
				$logoUrl = '';
			}
			$grantName = $grantCollection[$i]['name'];
			$grantAmount = $grantCollection[$i]['amount'];
			$grantFeatured = 'no';
			$grantFavorited = $grantCollection[$i]['favorite'];
			$grantCategoryName = (!empty($grantCollection[$i]['categories']['name'])) ? $grantCollection[$i]['categories']['name'] : '';
			$grantCategoryName = str_replace("/", " / ", $grantCategoryName);
			$grantCategoryName = ucwords(strtolower($grantCategoryName));
			$grantCategoryName = trim($grantCategoryName);
			$grantType = $grantCollection[$i]['type'];
			if($grantType == "Other")
			{
				$grantType = "Grant";
			}
			$grantDescription = $grantCollection[$i]['description'];
			$grantWho = $grantCollection[$i]['who'];
			if(empty($grantCategoryName))
			{
				$grantCategoryName = '<i class="fa fa-star" aria-hidden="true"></i>&nbsp;&nbsp;';
			}
			$grantCategoryName = $grantCategoryName." ".$grantType;
			ob_start();
			?>
			<div id="grant<?=$grant?>" class="<?=$grantFeatured == 'no' ? 'grantPlug' : 'grantFeatured'?> rb"
				style="width:<?=$phone ? '100%' : '240px'?>; <?=$phone ? 'margin:0px; margin-bottom:20px;' : ''?>">
				<table style="width:100%; height:100%;" border="0">
					<?
					if(!empty($grantCategoryName))
					{
					?>
					<tr>
						<td class="top left">
							<div class="rb f20 white <?=$grantFeatured == 'no' ? 'blue-bg' : 'green-bg'?> uppercase p10" style="line-height:1; font-weight:600">
								<?=$grantCategoryName?>
							</div>
						</td>
					</tr>
					<?
					}
					if(!empty($logoUrl))
					{
					?>
					<tr>
						<td class="top left <?=$logoBgColor?>-bg"
							style=" height:auto;
								">
							<div class="rb cc p10">
								<img src="<?=$logoUrl?>" class="rib img-responsive" style="max-width:200px;" />
							</div>
							<div class="rb f11 gray" style="display:none;">
								<?=$grant?>
							</div>
						</td>
					</tr>
					<?
					}
					?>
					<tr>
						<td class="top left">
							<div class="rb p10">
								<div class="rb">
									<span class="f20 normal blue">
										<?=$grantName?>
									</span>
								</div>
								<div class="rb">
									<?
									if($grantAmount != '0.00' && ($grantAmount * 1) > 0)
									{
									?>
									<span class="f24 bold">
										$<?=number_format($grantAmount, 2, ".", ",")?>
									</span>
									<?
									}
									else
									{
									?>
									<span class="f24 bold">
										Amount Varies
									</span>
									<?
									}
									?>
								</div>
							</div>
						</td>
					</tr>
					<?
					if(!empty($grantDescription))
					{
					?>
					<tr>
						<td>
							<div class="rb f12 p10" style="padding-top:0px;">
								<?=$grantDescription?>
							</div>
						</td>
					</tr>
					<?
					}
					else if(!empty($grantWho))
					{
					?>
					<tr>
						<td>
							<div class="rb f12 p10" style="padding-top:0px;">
								<strong>Who can apply:</strong>&nbsp;<?=$grantWho?>
							</div>
						</td>
					</tr>
					<?
					}
					?>
					<tr>
						<td style="height:46px; border-top:1px solid rgba(0,0,0,0.15);">
							<div class="rb right">
								<div class="aib pointer" style="left:12px; top:<?=$grantFeatured == "yes" ? 5 : 12?>px;">
									<?
									if($grantFavorited)
									{
									?>
									<i class="fa fa-heart f20 bred" aria-hidden="true"
										onclick="favoriteGrant('<?=$grant?>', this)"></i>
									<?
									}
									else
									{
									?>
									<i class="fa fa-heart-o f20 gray" aria-hidden="true"
										onclick="favoriteGrant('<?=$grant?>', this)"></i>
									<?
									}
									?>
								</div>
								<div class="rib cc goGrant pointer" ng-click="loadGrantDetails('<?=$grant?>')"
									style="width:auto; height:<?=$grantFeatured == 'no' ? '46' : '32'?>px; margin-bottom:-5px; right:12px; top:3px;">
									<div class="rib" style="top:<?=$grantFeatured == 'no' ? '-8' : '-1'?>px; margin-right:5px;">
										<?=$grantFeatured == 'no' ? 'See More' : 'Learn More'?>
									</div>
									<i class="fa <?=$grantFeatured == 'no' ? 'fa-arrow-circle-o-right f35' : 'fa-arrow-right f18 green'?>" aria-hidden="true"></i>
								</div>
							</div>
						</td>
					</tr>
				</table>
			</div>
			<div class="dummy"></div>
			<?php
			$grantCollection[$i]['grant_html'] = ob_get_clean();
		}
	}

	$data['grants'] = $grantCollection;
	function utf8ize( $mixed ) {
		if (is_array($mixed)) {
			foreach ($mixed as $key => $value) {
				$mixed[$key] = utf8ize($value);
			}
		} elseif (is_string($mixed)) {
			return mb_convert_encoding($mixed, "UTF-8", "UTF-8");
		}
		return $mixed;
	}
   $data = utf8ize($data);
	$json = json_encode($data);
	if(!$json) {
		echo json_last_error_msg();
	} else {
		echo $json;
	}
}
?>


Youez - 2016 - github.com/yon3zu
LinuXploit