salut,
cela veux dire qu'il est fait appel à un méthode de manière statique alors qu'elle ne l'est pas.
l'appel statique c'est lorsque l'on ne crée pas d'instance de la classe pour utiliser une méthode (en clair : Moon::jtime($DateSec);)
Ceci n'est possible que sur une méthode déclarée comme statique (public static function jtime($date)){};)
C'est un peu codé comme un cochon avec plein d'appel statique au milieu de tout cela. C'était autorisé sur les anciennes versions de php où le modèle objet n'était pas top, cela est maintenant corrigé.
il 'suffit' de remplacer Moon:: par $this->
ça peux faire ça
<?php
/*
Adaptation en php du script Astro-MoonPhase de Brett Hamilton.
*/
class Moon
{
function phase($Year, $Month, $Day, $Hour, $Minutes, $Seconds)
{
$DateSec = mktime($Hour, $Minutes, $Seconds, $Month, $Day, $Year);
ini_set('precision', '20'); //Defini la precision des calculs
$Epoch= 2444238.5; // 0 janvier 1980
# Soleil
$Elonge= 278.833540;# ecliptic longitude of the Sun at epoch 1980.0
$Elongp= 282.596403;# ecliptic longitude of the Sun at perigee
$Eccent= 0.016718;# eccentricity of Earth's orbit
$Sunsmax= 1.495985e8;# semi-major axis of Earth's orbit, km
$Sunangsiz= 0.533128;# sun's angular size, degrees, at semi-major axis distance
# Lune, epoch 1980.0.
$Mmlong= 64.975464;# moon's mean longitude at the epoch
$Mmlongp= 349.383063;# mean longitude of the perigee at the epoch
$Mlnode= 151.950429;# mean longitude of the node at the epoch
$Minc= 5.145396;# inclination of the Moon's orbit
$Mecc= 0.054900;# eccentricity of the Moon's orbit
$Mangsiz= 0.5181;# moon's angular size at distance a from Earth
$Msmax= 384401.0;# semi-major axis of Moon's orbit in km
$Mparallax= 0.9507;# parallax at distance a from Earth
$Synmonth= 29.53058868;# synodic month (new Moon to new Moon)
$pdate = $this->jtime($DateSec);
$pphase;# illuminated fraction
$mage;# age of moon in days
$dist;# distance in kilometres
$angdia;# angular diameter in degrees
$sudist;# distance to Sun
$suangdia;# sun's angular diameter
# Calcul position soleil.
$Day = $pdate - $Epoch;
$N = $this->fixangle((360 / 365.2422) * $Day);# ano moyenne soleil
$M = $this->fixangle($N + $Elonge - $Elongp);
$Ec = $this->kepler($M, $Eccent);# equation de Kepler
$Ec = sqrt((1 + $Eccent) / (1 - $Eccent)) * tan($Ec / 2);
$Ec = 2 * $this->todeg(atan($Ec));# anomalie vraie
$Lambdasun = $this->fixangle($Ec + $Elongp);# ecliptique geocentrique du soleil
$F = ((1 + $Eccent * cos($this->torad($Ec))) / (1 - $Eccent * $Eccent));
$SunDist = $Sunsmax / $F;# distance au soleil en km
$SunAng = $F * $Sunangsiz;# diametre du soleil en degrés
# Calcul position lune.
# longitude moyenne.
$ml = $this->fixangle(13.1763966 * $Day + $Mmlong);
# Anomalie moyenne
$MM = $this->fixangle($ml - 0.1114041 * $Day - $Mmlongp);
# Noeud ascendant
$MN = $this->fixangle($Mlnode - 0.0529539 * $Day);
$Ev = 1.2739 * sin($this->torad(2 * ($ml - $Lambdasun) - $MM));
# Equation annuelle.
$Ae = 0.1858 * sin($this->torad($M));
# terme de correction
$A3 = 0.37 * sin($this->torad($M));
# Anomalie corrigée
$MmP = $MM + $Ev - $Ae - $A3;
# Correction de l'equation du centre.
$mEc = 6.2886 * sin($this->torad($MmP));
# terme de correction
$A4 = 0.214 * sin($this->torad(2 * $MmP));
# Longitude corrigée.
$lP = $ml + $Ev + $mEc - $Ae + $A4;
# Variation.
$V = 0.6583 * sin($this->torad(2 * ($lP - $Lambdasun)));
# Longitude vraie.
$lPP = $lP + $V;
# Longitude corrigée des noeuds.
$NP = $MN - 0.16 * sin($this->torad($M));
$y = sin($this->torad($lPP - $NP)) * cos($this->torad($Minc));
$x = cos($this->torad($lPP - $NP));
# Longitude de l'ecliptique.
$Lambdamoon = $this->todeg(atan2($y, $x));
$Lambdamoon += $NP;
# Latitude de l'ecliptique.
$BetaM = $this->todeg(asin(sin($this->torad($lPP - $NP)) * sin($this->torad($Minc))));
# Calcul des phases de lune.
# Age de la lune en degrés
$MoonAge = $lPP - $Lambdasun;
# Phase.
$MoonPhase = (1 - cos($this->torad($MoonAge))) / 2;
# Calcul distance lune <-> centre terre
$MoonDist = ($Msmax * (1 - $Mecc * $Mecc)) /
(1 + $Mecc * cos($this->torad($MmP + $mEc)));
# Calcul diametre lune en degres
$MoonDFrac = $MoonDist / $Msmax;
$MoonAng = $Mangsiz / $MoonDFrac;
# Calcul parallaxe.
$MoonPar = $Mparallax / $MoonDFrac;
$pphase = $MoonPhase;# illuminated fraction
$mage = $Synmonth * ($this->fixangle($MoonAge) / 360.0);# age of moon in days
$dist = $MoonDist;# distance in kilometres
$angdia = $MoonAng;# angular diameter in degrees
$sudist = $SunDist;# distance to Sun
$suangdia = $SunAng;# sun's angular diameter
$mpfrac = $this->fixangle($MoonAge) / 360.0;
return array( $pphase, $mage, $dist, $angdia, $sudist, $suangdia, $mpfrac, $mpfrac );
}
# fix angle
function fixangle($x) { return
($x - 360.0 * (floor($x / 360.0)));
}
# deg->rad
function torad($x) { return
($x * (M_PI / 180.0));
}
# rad->deg
function todeg($x) { return
($x * (180.0 / M_PI));
}
function jtime($t)
{
# (seconds /(seconds per day)) + julian date of epoch 2440587.5 / 86400 = 28,24753472222 Days
$julian = ($t / 86400) + 2440587.5;
return ($julian);
}
function kepler($m, $ecc)
{
$EPSILON = 1e-6;
$m = $this->torad($m);
$e = $m;
do{
$delta = $e - $ecc * sin($e) - $m;
$e -= $delta / (1 - $ecc * cos($e));
}while (abs($delta) > $EPSILON);
return $e;
}
}
//Exemple d'utilisation :
if (empty($_REQUEST['mois'])) {
$mois = date('n');
}else{
$mois = $_REQUEST['mois'];
}
if (empty($_REQUEST['jour'])) {
$jour =date('d');
}else{
$jour = $_REQUEST['jour'];
}
if (empty($_REQUEST['an'])) {
$an =date('Y');
}else{
$na = $_REQUEST['an'];
}
if (empty($_REQUEST['hr'])) {
$hr =date('H');
}else{
$hr = $_REQUEST['hr'];
}
if (empty($_REQUEST['mn'])) {
$mn =date('i');
}else{
$mn = $_REQUEST['mn'];
}
if (empty($_REQUEST['se'])) {
$se =date('s');
}else{
$se = $_REQUEST['se'];
}
$m = new Moon();
list($MoonPhase, $MoonAge, $MoonDist, $MoonAng, $SunDist, $SunAng, $mpfrac) = $m->phase($an, $mois, $jour, $hr, $mn, $se);
echo 'Pour le: '. $jour .' ' . $mois.' '.$an. ' à ' . $hr .':' . $mn.':'.$se.'<br>';
echo 'La Lune est éclairée à '.number_format($MoonPhase*100, 2, ',', '').'%'.'<br>';
echo 'Son age est de '.number_format($MoonAge, 8, ',', '').' jours'.'<br>';
echo 'Et elle se situe à une distance de '.number_format($MoonDist, 0, ',', '').' km par rapport à la Terre.'.'<br>';
$position=round($MoonAge,0);
// là ca marchera si vous avez les vues
echo '<img src=\'/lune/moon$position.gif\' width=\'50\' height=\'50\' alt = \'\'>';
a tester.
@+