Hallo!
Verwende das Modul Aviation WX.
AviationWX
Download AviationWX for free. Free Joomla! module to display aviation weather in metar/taf code. Free and simple Joomla! module to display aviation weather in…
sourceforge.net
Es ist nur fuer Joomla3 geschrieben und auch schon etwas aelter.
Bin dabei, meine Webseiten von J3 auf J4 umzustellen.
Leider tut die Unterseite, wo ich das Modul AviationWX eingebunden habe,
dann unter J4 nicht mehr.
http://test1.tes-ten.de/index.php/seite-3
Auch wenn ich auf php 7.4.30 zurueckgehe gibt es leider keine Besserung.
Das module ist nur ganz klein, aber kenne mich mit php leider nur ganz ganz
marginal aus, dass ich nicht erkennen kann, was man aendern muss, um
es auch mit J4 zum Laufen zu bekommen.
helper.php:
PHP
<?php
/*
* Helper class for WX module
*/
defined('_JEXEC') or die;
class modWxHelper {
public static function getWx($params) {
jimport('joomla.filesystem.file');
$icaoStr = str_replace(" ", "%20", $params->def('icao', ''));
$sunLat = $params->def('sun_lat', '');
$sunLon = $params->def('sun_lon', '');
$wxArr = array();
if ($icaoStr) {
$metar = "http://aviationweather.gov/adds/metars/?station_ids=".$icaoStr."&std_trans=standard&chk_metars=on&hoursStr=most+recent+only&submitmet=Submit";
$taf = "http://aviationweather.gov/adds/tafs/?station_ids=".$icaoStr."&std_trans=standard&submit_taf=Get+TAFs";
if (ini_get('allow_url_fopen') == 1) {
$wxArr['metar'] = JFile::read($metar);
$wxArr['taf'] = JFile::read($taf);
}
else {
if (function_exists('curl_init')) {
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $metar);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$wxArr['metar'] = curl_exec($ch);
curl_setopt ($ch, CURLOPT_URL, $taf);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$wxArr['taf'] = curl_exec($ch);
curl_close($ch);
}
}
$strReplace = array("\n", "TAF");
$wxArr['metar'] = str_replace($strReplace, "", strip_tags(str_ireplace("<br>", " =<br />",(stristr($wxArr['metar'],"<font"))),"<br>"));
$wxArr['taf'] = str_replace($strReplace, "", strip_tags(str_ireplace("</pre>", "=<br />",(stristr($wxArr['taf'],"<pre>"))),"<br>"));
if (!$wxArr['metar']) $wxArr['metar'] = "<strong>WX-Data not avlb.</strong><br />(due to wrong input of icao-codes or 'allow_url_fopen' is OFF [".ini_get('allow_url_fopen')."] and cURL not enabled [".function_exists('curl_init')."] on this server!)<br />";
}
if ($sunLat) {
$wxArr['sun'] = date_sunrise(time(), SUNFUNCS_RET_STRING, $sunLat, $sunLon, 90.58333, 0) . " / " .date_sunset(time(), SUNFUNCS_RET_STRING, $sunLat, $sunLon, 90.58333, 0);
}
return $wxArr;
}
}
?>
Alles anzeigen
mod_wx.php:
PHP
<?php
/** Aviation WX a Joomla! 2.5.x/3.x module
* @version: mod_wx.php -> 2.0
* @package: mod_wx
* @copyright: This plugin is released under the GNU/GPL License.
* @license: GNU General Public License version 2 or later.
* Author: C.Schneider
*/
// no direct access
defined('_JEXEC') or die;
// Include the syndicate functions only once
require_once __DIR__ . '/helper.php';
$wxArr = modWxHelper::getWx($params);
require JModuleHelper::getLayoutPath('mod_wx');
?>
Alles anzeigen
default.php:
PHP
<?php
defined( '_JEXEC' ) or die;
$sunLbl = $params->def('sun_lbl', '');
$mod_class_sfx = $params->def('mod_class_sfx', '');
if ($wxArr['metar']) {
echo "\n<div style=\"font-size: smaller; float: right;\">[".JText::_('MOD_WX_SOURCE')." <a href=\"http://aviationweather.gov/adds/\" target=\"_blank\" title=\"->Aviation Digital Data Service (ADDS)\">ADDS</a>]</div>\n<span class=\"wx_title".$mod_class_sfx."\" style=\"font-weight: bold;\">".JText::_('MOD_WX_METAR')."</span><br />\n";
echo("<span class=\"wx_metar".$mod_class_sfx."\">".$wxArr['metar']."</span>\n");
echo "<span class=\"wx_title".$mod_class_sfx."\" style=\"font-weight: bold;\">".JText::_('MOD_WX_TAF')."</span><br />\n";
echo("<span class=\"wx_taf".$mod_class_sfx."\">".$wxArr['taf']."</span>\n");
}
if ($wxArr['sun']) {
echo "<span class=\"wx_title".$mod_class_sfx."\" style=\"font-weight: bold;\">".JText::_('MOD_WX_SUN')." </span><span class=\"wx_sun".$mod_class_sfx."\">".$wxArr['sun']." ".JText::_('MOD_WX_UTC')."</span><span style=\"font-size: smaller;\"> (".$sunLbl. " " . date("Y-m-d"). ")</span>";
}
?>
Alles anzeigen
Gruss, Buchi