Created
June 8, 2024 12:35
-
-
Save int2001/f95b2dab62be8eb6136619c2d79cea16 to your computer and use it in GitHub Desktop.
PHP Scripts to create a small image out of wavelog/cloudlog to show where one is QRV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array ( | |
'servername' => "127.0.0.1", | |
'username' => "DBUSER", | |
'password' => "DBPASS", | |
'dbname'=> "DBNAME" | |
); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$call=$_GET["call"]; | |
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); | |
header("Cache-Control: post-check=0, pre-check=0", false); | |
header("Pragma: no-cache"); | |
header("Content-Type: image/png"); | |
$im = @imagecreate(190, 20) | |
or die("Cannot Initialize new GD image stream"); | |
$background_color = imagecolorallocate($im, 255, 255, 255); | |
$text_color = imagecolorallocate($im, 11, 11, 11); | |
$cl=get_qrg($call); | |
if ($cl === "") { | |
$cl="Off Air"; | |
} | |
imagestring($im, 5, 5, 3, $cl, $text_color); | |
imagepng($im); | |
imagedestroy($im); | |
function get_qrg($call) { | |
$configs = include('qrg_config.php'); | |
$conn = new mysqli($configs['servername'], $configs['username'], $configs['password'], $configs['dbname']); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
$sql = <<<EOD | |
SELECT u.user_callsign, c.frequency,c.mode,c.timestamp FROM cat c inner join users u on (u.user_id=c.user_id) where c.id in | |
(select id from | |
(select c2.user_id,max(timestamp) as mt from cat c2 group by c2.user_id) y | |
inner join (select c3.id,c3.user_id,c3.timestamp from cat c3) z on (z.timestamp=y.mt and z.user_id=y.user_id) | |
) and u.user_callsign=? and c.mode!='ERROR' and c.frequency>0 and TIMESTAMPDIFF(MINUTE,c.timestamp,UTC_TIMESTAMP())<30 order by c.timestamp desc | |
EOD; | |
$sth = $conn->prepare($sql); | |
$sth->bind_param("s",$call); | |
$sth->execute(); | |
$result=$sth->get_result(); | |
$out=''; | |
if ($result->num_rows > 0) { | |
// output data of each row | |
while($row = $result->fetch_assoc()) { | |
$out.= ($row["frequency"]/1000000). " MHz // " . $row["mode"]; | |
} | |
} else { | |
$out=""; | |
} | |
$result->close(); | |
$sth->close(); | |
$conn->close(); | |
return $out; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment