Salve a tutti,
ho provato con diversi plugin per inserire codice php ( Jumi,DirectPHP,Sourcerer) ma non riesco a fare in modo che la pagina php che ho creato (e che caricato da sola in file .php viene visualizzato tutto perfettamente) venga mostrata come contenuto dell'articolo che voglio io.
Questo il codice che devo inserire....
<?php
// inserisce una pagina web in un array e la stampa. In questo esempio useremo il protocollo
// HTTP per ottenere il sorgente di un URL
$indirizzo = "http://alfeuss.dyndns.tv/B/";
$contenuto = implode('', file ($indirizzo.'clientraw.txt'));
$valore = explode(" ", $contenuto);
$contenuto2 = implode('', file ($indirizzo.'clientrawdaily.txt'));
$valore2 = explode(" ", $contenuto2);
$contenuto3 = implode('', file ($indirizzo.'clientrawextra.txt'));
$valore3 = explode(" ", $contenuto3); //Ora nell'array valore sono contenuti tutti i singoli valori separati dallo spazio
$chill = 13.12 + (0.6215 * $valore[4]) - (11.37 * pow($valore[1], 0.16)) + (0.3965 * $valore[4] * pow($valore[1], 0.16));
if ($chill >= $valore[4]){$chill = $valore[4];};
$far = ((9 / 5) * $valore[4]) + 32; //calcolo heat index
$heatfar = -42.379 + (2.04901523 * $far) + (10.14333127 * $valore[5]) - (0.22475541 * $valore[5] * $far) - (0.00683783 * pow($far, 2)) - (0.05481717 * pow($valore[5], 2)) + (0.00122874 * (pow($far, 2) * $valore[5])) + (0.00085282 * (pow($valore[5], 2) * $far)) - (0.00000199 * pow($valore[5], 2) * pow($far, 2));
$heat = ($heatfar - 32) * 5 / 9;
if (($valore[4] <= 24) or ($heat <= $valore[4])){$heat = $chill;};
$chill = number_format($chill,1,'.','');
$heat = number_format($heat,1,'.','');
$temperatura1 = $valore[4];
$wind1 = $valore[2];
$rain1 = $valore[10];
function getheatColor ($heat) {
// used to add colored heatColorWord
$testotemp = array (
'Confortevole', 'Caldo Estremo', 'Molto Caldo', 'Caldo',
'Caldo Sopportabile', 'Fresco', 'Freddo', 'Molto Freddo', 'Freddo Estremo');
$fg = $bg = $hw = "";
$parola = $testotemp[0];
switch (true) {
case ($heat > 42) : $fg = "white"; $bg = "#990066"; $hw = $testotemp[ 1]; break; // Caldo Estremo
case ($heat > 37) : $fg = "white"; $bg = "#990000"; $hw = $testotemp[ 2]; break; // Molto Caldo
case ($heat > 33) : $fg = "white"; $bg = "#FF0000"; $hw = $testotemp[ 3]; break; // Caldo
case ($heat > 28) : $fg = "#444444"; $bg = "#FF9900"; $hw = $testotemp[ 4]; break; // Caldo Sopportabile
case ($heat < -15) : $fg = "white"; $bg = "#000000"; $hw = $testotemp[8]; break; // Freddo Estremo
case ($heat < -1) : $fg = "white"; $bg = "#0000FF"; $hw = $testotemp[7]; break; // Molto Freddo
case ($heat < 7) : $fg = "white"; $bg = "#00CCFF"; $hw = $testotemp[6]; break; // Freddo
case ($heat < 16) : $fg = "#444444"; $bg = "#00FFFF"; $hw = $testotemp[ 5]; break; // Fresco
case (($heat >= 16) and ($heat <= 28 )) :$fg = "#444444"; $bg = "#00CC99"; $hw = $testotemp[ 0]; break;// Comfortable
}
return (($fg == "") ? $parola : '<span style="border: solid 2px #CCCCCC; color: ' . $fg . '; background-color: ' . $bg . ';"> ' . $hw . ' </span>' );
}
function vvento ($wind1) {
// used to add colored heatColorWord
$testotemp = array (
'Calma di vento', 'Bava di vento', 'Brezza leggera', 'Brezza tesa', 'Vento moderato', 'Vento teso', 'Vento forte', 'Quasi burrasca', 'Burrasca', 'Burrasca forte', 'Tempesta', 'Fortunale', 'Uragano');
$fg = $bg = $hw = "";
$parola = $testotemp[0];
switch (true) {
case ($wind1 > 63) : $fg = "white"; $bg = "#000000"; $hw = $testotemp[ 12]; break; // u
case ($wind1 > 55) : $fg = "white"; $bg = "#003366"; $hw = $testotemp[ 11]; break; // f
case ($wind1 > 47) : $fg = "white"; $bg = "#990066"; $hw = $testotemp[ 10]; break; // t
case ($wind1 > 40) : $fg = "white"; $bg = "#990000"; $hw = $testotemp[ 9]; break; // bf
case ($wind1 > 33) : $fg = "white"; $bg = "#FF0000"; $hw = $testotemp[ 8]; break; // b
case ($wind1 > 27) : $fg = "#444444"; $bg = "#FF9900"; $hw = $testotemp[ 7]; break; // qb
case ($wind1 > 21) : $fg = "#444444"; $bg = "#FFCC00"; $hw = $testotemp[ 6]; break; // vf
case ($wind1 > 16) : $fg = "#444444"; $bg = "#00FF66"; $hw = $testotemp[ 5]; break; // vt
case ($wind1 > 10) : $fg = "#444444"; $bg = "#00CCFF"; $hw = $testotemp[4]; break; // vm
case ($wind1 > 6) : $fg = "#444444"; $bg = "#00FFFF"; $hw = $testotemp[3]; break; // bt
case ($wind1 > 2) : $fg = "#444444"; $bg = "#99FFFF"; $hw = $testotemp[2]; break; // bl
case ($wind1 > 0.5) : $fg = "#444444"; $bg = "#CCFFFF"; $hw = $testotemp[ 1]; break; // b di v
case ($wind1 > -1) :$fg = "#444444"; $bg = "#FFFFFF"; $hw = $testotemp[ 0]; break;// C di v
}
return (($fg == "") ? $parola : '<span style="border: solid 2px #CCCCCC; color: ' . $fg . '; background-color: ' . $bg . ';"> ' . $hw . ' </span>' );
}
function ipioggia ($rain1) {
// used to add colored heatColorWord
$testotemp = array (
'Nessun fenomeno', 'Pioggia debole', 'Pioggia moderata', 'Pioggia forte', 'Rovescio', 'Nubifragio');
$fg = $bg = $hw = "";
$parola = $testotemp[0];
switch (true) {
case ($rain1 > 1) : $fg = "white"; $bg = "#990066"; $hw = $testotemp[ 5]; break; // nu
case ($rain1 > 0.167) : $fg = "white"; $bg = "#0000FF"; $hw = $testotemp[4]; break; // ro
case ($rain1 > 0.1) : $fg = "#444444"; $bg = "#00CCFF"; $hw = $testotemp[3]; break; // pf
case ($rain1 > 0.032) : $fg = "#444444"; $bg = "#00FFFF"; $hw = $testotemp[2]; break; // pm
case ($rain1 > 0.01) : $fg = "#444444"; $bg = "#CCFFFF"; $hw = $testotemp[ 1]; break; // pd
case ($rain1 > -1) :$fg = "#444444"; $bg = "#FFFFFF"; $hw = $testotemp[ 0]; break;// nf
}
return (($fg == "") ? $parola : '<span style="border: solid 2px #CCCCCC; color: ' . $fg . '; background-color: ' . $bg . ';"> ' . $hw . ' </span>' );
}
//Gestione della direzione del vento
function direzioneVento ($gradi)
{
$windlabel = array("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
return $windlabel[floor((($gradi + 11) / 22.5) % 16 )];
}
function conv_date ($data)
{
list ($mese, $giorno, $anno) = explode ("/" , $data);
echo $giorno ."/". $mese ."/". $anno ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<style type="text/css">
<!--
.bordotab {
border: 3px double #333333;
}
.tabellaext {
border: 3px solid #CCCCCC;
box-shadow:2px 2px 2px #777777;
border-radius: 8px 8px 8px 8px;
}
.titolocella {
position:relative;
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 10px;
font-weight: bold;
color: #FFFFFF;
background-image: url(tab6files/sfondo.jpg);
background-repeat: repeat-x;
line-height: 20px;
text-shadow:1px 1px 1px #222222;
z-index:1;
}
.avvisi {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 11px;
font-weight: normal;
color: #000000;
}
.bordoalto {
border-top-width: 1px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #CCCCCC;
border-right-color: #CCCCCC;
border-bottom-color: #CCCCCC;
border-left-color: #CCCCCC;
}
.minpiccolo {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 11px;
font-weight: normal;
color: #0000FF;
text-decoration: none;
}
.maxpiccolo {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 11px;
font-weight: normal;
color: #FF0000;
text-decoration: none;
}
.scrittine {
font-family: Tahoma, "Times New Roman", "Trebuchet MS";
font-size: 10px;
color: #009999;
}
.temp {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 22px;
color: #666666;
}
.max {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 12px;
color: #FF0000;
}
.valori {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 12px;
color: #14528A;
}
.valor2 {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 18px;
color: #666666;
}
.blu { font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 12px;
color: #0000FF;
}
.valori2 {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 14px;
color: #666666;
}
.valori3 {
font-family: Tahoma, "Trebuchet MS", "Times New Roman";
font-size: 12px;
color: #FFFFFF;
}
</style>
</head>
<body>
<div align="center"><span class="valori3">Dati aggiornati il </span><span class="valori3"><strong>
<?php conv_date($valore[74]); ?></strong><span class="valori3"> alle ore</span> <strong><?php echo $valore[29] ?>.<?php echo $valore[30] ?></strong></span><br />
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="10"></td>
</tr>
</table>
<table width="670" border="0" cellpadding="0" cellspacing="0" class="tabellaext">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="2" bgcolor="#EEDEEE">
<tr>
<td width="240" class="titolocella"><div align="center">Temperatura</div></td>
<td width="230" class="titolocella"><div align="center">Vento</div></td>
<td class="titolocella"><div align="center">Precipitazioni</div></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" rowspan="2"><div align="center" class="scrittine"><img src="tab6files/<? if (($valore[4] > -30) and ($valore[4] <= 0)){print "t-icon1.jpg";}
if (($valore[4] > 0) and ($valore[4] <= 29.9)){print "t-icon.jpg";}
if (($valore[4] > 29.9) and ($valore[4] <= 50)){print "t-icon2.jpg";} ?>" alt="*" /></div></td>
<td width="102" height="70" background="tab6files/<? if ($valore3[569] < $valore[4]){print "rising.gif";}
else{print "falling.gif";} ?>"><div align="center" class="scrittine">
<div align="left">Temperatura:<br />
<span class="temp"><strong><?php echo $valore[4] ?> </strong></span><span class="valor2">°C</span><br />
</div>
</div></td>
<td><span class="scrittine">Umidità:</span><br />
<span class="temp"><strong><?php echo $valore[5] ?> </strong></span><span class="valor2">%</span></td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20"><div align="center"><span class="avvisi"><span class="scrittine">Percepita: </span><span class="valori2"><strong>
<?php echo round($heat,0); ?>
</strong>°C</span></span></div></td>
</tr>
<tr>
<td height="20"><div align="center"><span class="avvisi">
<?php echo getheatColor($heat); ?>
</span></div></td>
</tr>
<tr>
<td height="8"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="2" bgcolor="#5B8FC8"></td>
</tr>
<tr>
<td bgcolor="#DEFFFF"><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="125" rowspan="2"><table width="120" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="20" class="scrittine"> </td>
<td class="scrittine"><div align="center">Oggi</div></td>
<td class="scrittine"><div align="center">Ieri</div></td>
</tr>
<tr>
<td width="20" height="22"><div align="center"><img src="tab6files/max.gif" alt="*" width="14" height="14" /></div></td>
<td><div align="center"><span class="max"><strong><?php echo $valore[46] ?></strong>°C</span></div></td>
<td><div align="center"><span class="maxpiccolo">(<strong><?php echo $valore2[31] ?></strong>)</span></div></td>
</tr>
<tr>
<td width="20" height="22"><div align="center"><img src="tab6files/min.gif" alt="*" width="14" height="14" /></div></td>
<td><div align="center"><span class="blu"><strong><?php echo $valore[47] ?></strong>°C</span></div></td>
<td><div align="center"><span class="minpiccolo">(<strong><?php echo $valore2[62] ?></strong>)</span></div></td>
</tr>
</table></td>
<td height="40"><div align="center"><span class="scrittine">Dew Point: </span><br />
<span class="valori"><strong><?php echo $valore[72] ?></strong>°C </span></div></td>
</tr>
<tr>
<td height="40" class="bordoalto"><div align="center"><span class="scrittine">Pressione:<br />
<span class="valori"><strong><?php echo $valore[6] ?></strong> hPa</span></span></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="230" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" rowspan="2"><div align="center" class="scrittine">
<div align="right"><img src="tab6files/<? if (($valore[2] > -1) and ($valore[2] <= 5)){print "wind-icon1.jpg";}
if (($valore[2] > 5) and ($valore[2] <= 15)){print "wind-icon2.jpg";}
if (($valore[2] > 15) and ($valore[2] <= 28)){print "wind-icon3.jpg";}
if (($valore[2] > 28) and ($valore[2] <= 40)){print "wind-icon4.jpg";}
if (($valore[2] > 40) and ($valore[2] <= 200)){print "wind-icon5.jpg";} ?>" alt="*" width="60" height="60" /></div>
</div></td>
<td height="70"><div align="center" class="scrittine">
<div align="center">Velocità attuale:<br />
<span class="temp"><strong>
<?php $conv=$valore[2]*1.852; echo round($conv,1); ?>
</strong> </span><span class="valor2">Km/h <strong><?php echo direzioneVento($valore[3]) ?></strong> </span></div>
</div></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20"><div align="center"><span class="avvisi"><span class="scrittine">Media: </span><span class="valori2"><strong>
<?php $conv=$valore[1]*1.852; echo round($conv,1); ?>
</strong>Km/h</span></span></div></td>
</tr>
<tr>
<td height="20"><div align="center"><span class="avvisi">
<?php echo vvento($wind1); ?>
</span></div></td>
</tr>
<tr>
<td height="8"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="2" bgcolor="#5B8FC8"></td>
</tr>
<tr>
<td bgcolor="#DEFFFF"><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="40" colspan="3"><div align="center"><span class="scrittine">Raffica giornaliera:</span><br />
<span class="max"><strong>
<img src="tab6files/max.gif" alt="*" width="14" height="14" />
<?php $conv=$valore[71]*1.852; echo round($conv,1); ?>
</strong> Km/h</span></div>
<div align="center"></div></td>
</tr>
<tr>
<td class="bordoalto"><div align="center"><span class="scrittine">Media Max:</span><br />
<span class="valori"> <strong>
<?php $conv=$valore[113]*1.852; echo round($conv,1); ?>
</strong> </span><span class="valori">Km/h</span></div></td>
<td width="5"> </td>
<td height="40" class="bordoalto"><div align="center"><span class="scrittine">Wind Chill:</span><br />
<span class="valori"><strong><?php echo $valore[44] ?></strong>°C</span></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" rowspan="2"><div align="center" class="scrittine">
<div align="right"><img src="tab6files/<? if (($valore[10] > -1) and ($valore[10] <= 0.01)){print "rain-icon1.jpg";}
if (($valore[10] > 0.01) and ($valore[10] <= 0.01)){print "rain-icon2.jpg";}
if (($valore[10] > 0.01) and ($valore[10] <= 50)){print "rain-icon3.jpg";} ?>" alt="*" /></div>
</div></td>
<td height="70"><div align="center" class="scrittine">
<div align="center">Pioggia giorno: <br />
<span class="temp"><strong><?php echo $valore[7] ?></strong> </span><span class="valor2">mm</span></div>
</div></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20"><div align="center"><span class="scrittine">Intensità:</span> <span class="valori2"><strong>
<?php $conv=$valore[10]*60; echo round($conv,1); ?>
</strong>mm/h</span></div></td>
</tr>
<tr>
<td height="20"><div align="center"><span class="avvisi">
<?php echo ipioggia($rain1); ?>
</span></div></td>
</tr>
<tr>
<td height="8"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="2" bgcolor="#5B8FC8"></td>
</tr>
<tr>
<td bgcolor="#DEFFFF"><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="40" colspan="3"><div align="center"><span class="scrittine">Intensità massima:</span><br />
<span class="max"><strong>
<img src="tab6files/max.gif" alt="*" width="14" height="14" />
<?php $conv=$valore[11]*60; echo round($conv,1); ?>
</strong> mm/h </span></div>
<div align="center"></div></td>
</tr>
<tr>
<td class="bordoalto"><div align="center"><span class="scrittine">Pioggia Mese:<br />
<span class="valori"><strong><?php echo $valore[8] ?></strong> mm</span></span></div></td>
<td width="5"> </td>
<td height="40" class="bordoalto"><div align="center"><span class="scrittine">Pioggia Anno: <br />
<span class="valori"><strong><?php echo $valore[9] ?></strong> mm</span></span></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="7"></td>
</tr>
</table>
<span class="scrittine">Stato Centralina: <?php if ($valore[5] == "0") {print '<span style="border: solid 2px #CCCCCC; color: #FFFFFF; background-color: #FF0000;"><strong> PERDITA DATI </strong></span>';}
else {print '<span style="border: solid 2px #CCCCCC; color: #FFFFFF; background-color: #00CC00;"><strong> ONLINE </strong></span>';} ?>
</span></div>
</body>
</html>
questo invece è il risultato funzionante con lo stesso codice al di fuori di joomla
Usando DirectPHP per esempio ,
ho questo codice di errore:
Fatal error: Cannot redeclare getheatColor() (previously declared in /web/htdocs/www.valentano.net/home/portale/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code:24) in /web/htdocs/www.valentano.net/home/portale/templates/jsn_metro_pro/index.php on line 721
Utilizzo joomla 3.1.5 Stable
PHP Version 5.4.17
Qualcuno mi può aiutare?
grazie