[Dxspider-support] index.php

Allen arharvie at gmail.com
Sun Oct 16 10:50:23 BST 2016


<?php

	// Turn off all error reporting -> error_reporting(0);
	error_reporting(0);

Function showSpots(){

	//Open the activation Database
	$con=mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
	// Check connection
	if (mysqli_connect_errno())
   	{
   		echo "Failed to connect to MySQL: " . mysqli_connect_error();
   		exit();
   	}

	// Only show last 8 hrs. 1 day = 86400 seconds (24 * 60 * 60))
	date_default_timezone_set('UTC');
	$curDate = date('Y-m-d H:i:s');
	$time = strtotime($curDate);
	$selDate = $time -  7200 ;
	$time = date('Y-m-d H:i:s',$selDate);

	// Must be Ok if got this far so read table
	// $sql="SELECT * FROM activations WHERE actTime > '". $time . "' ORDER 
by actTime Desc";
	$sql="SELECT * FROM activations WHERE (actTime > '". $time . "' AND 
actTime < '" . $curDate . "') ORDER by actTime Desc";
	$result = mysqli_query($con,$sql);
	if (!$result)
	{
    		die('Error: ' . mysqli_error($con));
	}

	$findme = "VK";
	$getFirst = TRUE;
	while ($row = mysqli_fetch_array($result))
     {

         $pos = FALSE;
         // Check session for all SPots
         if ($_SESSION['ALLSpots'] == TRUE){
        		$pos = TRUE;
        	} else {
     		//SOTA Filtering
        		if ($_SESSION['ALLSOTASpots'] == TRUE){
  				$pos = TRUE;
        		}else {
  				//Search for VK entries and highlight
     			$search = substr($row['actCallsign'], 0, 2);
     			$pos = strpos($search, $findme);
     			if ($pos === false){
     				//AX ??
     			$pos = strpos($search, 'AX');
     			}
       			if ($pos === false){
     				//AX ??
     				$pos = strpos($search, 'VI');
     			}  	
     			if ($pos === false){
     				//ZL ??
     				$pos = strpos($search, 'ZL');
     			}
         		// Spotted by VK?
         		if ($pos === false){
         			$search = substr($row['actSpoter'], 0, 2);
     				$pos = strpos($search, $findme);
     			}
         	}
           	
           	// Check session before Showing DX Cluster entries
     		if (($row['actClass'] == 'DX') AND ($_SESSION['showDX'] != TRUE)){
        			$pos = FALSE;
        		}
        		
        		// Check session before Showing DX WWFF entries
     		if (($row['actClass'] == 'WWFFDX') AND ($_SESSION['showDXWWFF'] 
!= TRUE)){
        			$pos = FALSE;
        		}
         }

         if ($pos === false) {
         	// To Do: Logging
         }else{
     		
     		//Save first Entry
     		if ($getFirst)
     		{
     			$latestUpdate = strtotime($row['actTime']);
     			$ActClass = $row['actClass'];
     		}
     		
     		// Want to add link to sota references
     		// <a 
href="http://www.sotawatch.org/summits.php?summit=OH/JS-064"><strong>OH/JS-064</strong></a>
     		
     		echo '<p>';
     		$bHighlight=FALSE;
     		if ($row['actTime'] > date('Y-m-d H:i:s',(strtotime($curDate)-900)))
         	{
         		$bHighlight=TRUE;
         		echo '<p><strong>';
         	}
         	echo date('T D,d-m-y G:i',strtotime($row['actTime']));
        		echo " " . $row['actClass'] . " ";

        		// Add SOTA link to entries in SOTA Database
        		if ($row['actClass'] == "SOTA"){
        			/* Add link to SOTA site
        			* <a 
href="http://www.sotawatch.org/summits.php?summit=OH/JS-064" 
target="_blank"><strong>OH/JS-064</strong></a>
        			*/    			
        			// echo "<a 
href='http://www.sotawatch.org/summits.php?summit=" . $row['actLocation'];
        			// echo "' target='_blank'>" . $row['actLocation'] . "</a> ";
        			// Use my site - 
http://parksnpeaks.org/getSummit.php?actSummit=VK3/VC-024
        			echo "<a 
href='http://parksnpeaks.org/getSummit.php?actSummit=" . 
$row['actLocation'];
        			echo "' target='_blank'>" . $row['actLocation'] . "</a> ";
        		}else{
        			// Standard Format
        			echo " ". $row['actLocation']. " ";
        		}

        		if ($row['WWFFid'] <> ""){
             	// Show the WWFF ID
        			// echo "(". $row['WWFFid']. ") ";	
        			if ($row['actClass'] == "WWFFDX"){
        				//Can't show detail; for WWF DX yet
        				echo " (" . $row['WWFFid'] .") ";
        			}else{
        				// Can show details
        				echo "<a href='http://parksnpeaks.org/getPark.php?actPark=" 
. $row['WWFFid'] ."' target='_blank'> (". $row['WWFFid']. ")</a> ";
				}
        			if ($getFirst){$ActClass = "WWFF";};  		
        		}
        		echo " - " . $row['actCallsign']." on ";

        		// mldx://tune?freq=14.100&mode=CW
        		//if ($row['actMode'] == ''){
        		//	echo $row['actFreq'] . " " . $row['actComments']. ". Posted 
by " . $row['actSpoter'];
        		//}else{
        		// 	$mldx = "<a href='mldx://tune?freq=" .$row['actFreq'] 
."&mode=" . $row['actMode']."'style='text-decoration:none' 
'alink='black'>". $row['actFreq']."</a>";
        		//	echo $mldx. " " . $row['actMode']. " " . 
$row['actComments']. ". Posted by " . $row['actSpoter'];
        		//}
        		

			if (($row['actClass'] === "WWFFDX") OR ($row['actClass'] === "DX")) {
				 $freq = number_format(($row['actFreq']/1000), 4);
			}else{
				$freq = $row['actFreq'];
			}

        		echo $freq . " " . $row['actMode']. " " . $row['actComments']. 
". Posted by " . $row['actSpoter'];
         	if ($row['altClass'] <> ""){
        			// Show the contents of altClass and altLocation as well
        			echo'</p>';
        			switch ($row['altClass']) {
			case 'VKFF':
				echo '<ul><li>WWFF '. getWWFFName($row['WWFFid']). ' ('. 
$row['WWFFid']. ')</li></ul>';
				break;

			default:
				echo '<ul><li>' . $row['altClass']. " in ". $row['altLocation']. 
'</li></ul>';
				break;
        			
        			}	
			if ($getFirst){$ActClass = $row['altClass'];};
        		}
         	if ($bHighlight){echo '</strong>';};
         	echo '</p>';
         	$getFirst = FALSE;
         }
     }				

	// Close Connection
	mysqli_close($con);
	return array($latestUpdate,$ActClass);
	
}

?>

<?php
	/* @package php-login
  	* @author Panique
  	* @link https://github.com/panique/php-login/
  	* @license http://opensource.org/licenses/MIT MIT License
  	*/

	// include the configs / constants for the database connection
	require_once("translations/en.php");
	require_once("config/config.php");
	
	// include the email library
	require_once("libraries/common.php");
	require_once("libraries/PHPMailer.php");

	// load the login class
	require_once("libraries/password_compatibility_library.php");
	require_once("classes/Login.php");

	// create a login object. when this object is created, it will do all 
login/logout stuff automatically
	// so this single line handles the entire login process. in 
consequence, you can simply ...
	$login = new Login();
?>
<!doctype html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="180" />
<meta name="description" content="Site for posting amateur radio 
portable activity" />
<meta name="keywords" content="SOTA WWFF KRMNPA SANPCPA QRP Portable" />
<meta name="author" content="Allen Harvie" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>VK - Current Activity</title>
</head>
<body>
<div id="wrapper">
<?php include('views/_header.php'); ?>
<?php include('views/nav.php'); ?>

<div id="content">
<h2>Status</h2><p>
<?php
	date_default_timezone_set('UTC');
	echo "<p>Last Update - " . gmdate('D, j M Y G:i T') . " ";
	date_default_timezone_set('Australia/Melbourne');
	// Time Format - T D,d-m-y G:i
	//  D, j M Y G:i:s T
	echo " - " . date('D, j M Y G:i T') . "</p>";
	date_default_timezone_set('UTC');
	// ... ask if we are logged in here:
	if ($login->isUserLoggedIn() == true){
     	// the user is logged in.
     	include("views/logged_in.php");
	} else {
     	// the user is not logged in.
     	include("views/not_logged_in.php");
	}
	
?>
<hr/><h2>Current Spots</h2>
<?php
	// echo "<a type=\"application/rss+xml\" 
href=\"http://parksnpeaks.org/feed/index.php\">RSS feed for Spots</a>";
	// echo SOTARSSfeed("http://www.sota.org.uk/RssFeed/");
	// echo DXClusterfeed("http://dxcluster.co.uk/api/all");
	$latestUpdate = showSpots();	
	// Audio Alert ??
     if ($login->isUserLoggedIn() == true){
     	// the user is logged in.
     	// echo $_SESSION['latestUpdate'] . " - " .$latestUpdate[0]. " - " 
. $latestUpdate[1];
     	if (isset($_SESSION['latestUpdate'])) {
     		//Compare as already set
     		// echo $latestUpdate . " -> ". $_SESSION['latestUpdate'];
     		if ($latestUpdate[0] > $_SESSION['latestUpdate']){
     			// Alert as new data
     			if (($latestUpdate[1] == 'SOTA') AND ($_SESSION['SOTAAudioAlert']))
     			{
     				soundBleet();
     			}
     			
     			if (($latestUpdate[1] == 'WWFF') AND ($_SESSION['PARKAudioAlert']))
     			{
     				soundLaugh();
     			}
     			// Update with latest time
     			$_SESSION['latestUpdate'] = $latestUpdate[0];
     		}
     	} else{
     		// Set as first update
     		$_SESSION['latestUpdate'] = $latestUpdate[0];
     	}
     }	
?>

</div> <!-- end #content -->
<?php include('views/sidebar.php'); ?>
<?php include('views/_footer.php'); ?>

</div> <!-- End #wrapper -->
</body>
</html>



More information about the Dxspider-support mailing list