Created
February 3, 2024 13:56
-
-
Save int2001/81a30bca14323a1750d732881ec97f07 to your computer and use it in GitHub Desktop.
Current QRV-State as image from Wavelog // Quick Hack
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' => "localhost", | |
'username' => "dbusername", | |
'password' => "dbpassword", | |
'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 cloudlog_jo30.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 cloudlog_jo30.cat c2 group by c2.user_id) y | |
inner join (select c3.id,c3.user_id,c3.timestamp from cloudlog_jo30.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