Calcula tu ascendiente disponible pronto, a pocos días de paciencia ...
|
|
|
|
'minute', 'min' => 0, 'max' => 59),
array('name' => 'heure', 'min' => 0, 'max' => 23),
array('name' => 'jour', 'min' => 1, 'max' => 31),
array('name' => 'mois', 'min' => 1, 'max' => 12),
array('name' => 'annee', 'min' => 1901, 'max' => intval(date('Y'))),
array('name' => 'ville', 'min' => 0, 'max' => count($villes)-1)
);
// defaults
$params = array('minute'=>0,'heure'=>0,'jour'=>1,'mois'=>1,'annee'=>1970,'ville'=>0);
$result = '';
if(isset($_POST) and count($_POST)!=0)
{
foreach ($validParams as $param)
{
if(!isset($_POST[$param['name']])){continue;}
if(intval($_POST[$param['name']]) < $param['min'] or $param['max'] < intval($_POST[$param['name']])){continue;}
$params[$param['name']] = intval($_POST[$param['name']]);
}
function sun_times($time, $lat, $lon, $offset, $format, $dst) {
$offset += $dst;
$offset = $offset == 13 ? -11 : $offset;
$math = array(1.5708, 4.71239, 3.14159, 6.28319, (0.0174533 * $lat), (0.0174533 * $lon), (0.261799 * $offset));
$data = array('astronomical' => -.309017, 'nautical' => -.207912, 'civil' => -.104528, 'sun' => -.0145439);
$sd = explode(' ', date('n j Y z', $time));
$times = array();
foreach ($data as $a => $b) {
for ($x = 0; $x <= 1; $x++) {
$e = $sd[3] + (($math[$x] - $math[5]) / $math[3]);
$f = ($e * .017202) - .0574039;
$g = $f + .0334405 * sin($f);
$g += 4.93289 + (3.49066E-04) * sin(2 * $f);
while ($g < 0) {
$g += $math[3];
}
while ($g >= $math[3]) {
$g -= $math[3];
}
$g += ($g / $math[0]) - intval($g / $math[0]) == 0 ? 4.84814E-06 : 0;
$h = sin($g) / cos($g);
$h = atan2(.91746 * $h, 1);
$h += $g > $math[1] ? $math[3] : ($g > $math[0] ? $math[2] : 0);
$i = .39782 * sin($g);
$i = $i / sqrt (-$i * $i + 1);
$i = atan2($i, 1);
$j = $b - (sin($i) * sin($math[4]));
$j = $j / (cos($i) * cos($math[4]));
$j = $j / sqrt(-$j * $j + 1);
$j = $math[0] - atan2($j, 1);
if (!$x) {
$j = $math[3] - $j;
}
$k = $j + $h - 0.0172028 * $e - 1.73364;
$l = $k - $math[5];
$n = $l + $math[6];
$key = ($a != 'sun' ? ($x ? 'end' : 'start') : ($x ? $a . 'set' : $a . 'rise'));
if (is_nan($n)) {
$times[$a][$key] = '-';
} else {
while ($n < 0) {
$n += $math[3];
}
while ($n >= $math[3]) {
$n -= $math[3];
}
$n = $n * 3.81972;
$hour = intval($n);
$mins = intval((($n - $hour) * 60) + 0.5);
$times[$a][$key] = date($format, mktime($hour, $mins, 0, $sd[0], $sd[1], $sd[2]));
}
}
}
return($times);
}
if(isset($villes[$params['ville']]))
{
$zodiacSigns = array(
0 => 'Aries',
1 => 'Taureau',
2 => 'Gémeau',
3 => 'Cáncer',
4 => 'León',
5 => 'Vierge',
6 => 'Balance',
7 => 'Escorpión',
8 => 'Sagitaire',
9 => 'Capricornio',
10 => 'Acuario',
11 => 'Poisson'
);
$zodiac = 0;
switch ($params['mois'])
{
case 1:
$zodiac = ($params['jour'] > 20) ? 10 : 9;
break;
case 2:
$zodiac = ($params['jour'] > 19) ? 11 : 10;
break;
case 3:
$zodiac = ($params['jour'] > 20) ? 0 : 11;
break;
case 4:
$zodiac = ($params['jour'] > 20) ? 1 : 0;
break;
case 5:
$zodiac = ($params['jour'] > 21) ? 2 : 1;
break;
case 6:
$zodiac = ($params['jour'] > 21) ? 3 : 2;
break;
case 7:
$zodiac = ($params['jour'] > 23) ? 4 : 3;
break;
case 8:
$zodiac = ($params['jour'] > 23) ? 5 : 4;
break;
case 9:
$zodiac = ($params['jour'] > 23) ? 6 : 5;
break;
case 10:
$zodiac = ($params['jour'] > 23) ? 7 : 6;
break;
case 11:
$zodiac = ($params['jour'] > 22) ? 8 : 7;
break;
case 12:
$zodiac = ($params['jour'] > 22) ? 9 : 8;
break;
}
$time = mktime($params['heure'],$params['minute'],0,$params['mois'],$params['jour'],$params['annee']);
$parts = explode('|', $villes[$params['ville']]);
// pour le moment, on ne tiendra pas compte du DST car il y a beacoup trop de regles diff�rentes,
// ce qui complexifiraient inutilement le programme. possible de le modifer par apr�s
$data = sun_times($time,$parts[1],$parts[2],$parts[3],'H:i',0);
$sunrise = $data['sun']['sunrise'];
$btime = date('H:i', $time);
$ascendant = $zodiac;
if($btime < $sunrise)
{
$i=0;
while(date('H:i', $time+($i+1)*60*60*2)<$sunrise){++$i;}
$ascendant = ($zodiac+12-$i)%12;
}
else
{
$i=1;
while(date('H:i', $time-$i*60*60*2)>$sunrise){++$i;}
$ascendant = ($zodiac+$i)%12;
}
$result = $zodiacSigns[$zodiac].' ascendant '.$zodiacSigns[$ascendant];
}
}
?>
|
|