1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
<?php
echo "<html><head><title>international Clock</title>
</head>
<body style='font-family: arial; font-color: #444444; background-color: #bd0f1e;'>";
echo "<div style='width: 300px; padding: 5px;color: #000; text-shadow: 2px 2px 4px #730912;'>Horloge Internationale<br />";
$bi="alger|bruxelles|bucarest|budapest|casablanca|hanoi|hochiminh|hongkong|istanbul|kiev|londres|moscou|newyork|paris|pekin|saintpeter|shanghai|tunis|varsovie";
$bi_fr="Alger|Bruxelles|Bucarest|Budapest|Casablanca|Hanoi|Hô Chi Minh|Hong Kong|Istanbul|Kiev|Londres|Moscou|Newyork|Paris|Pékin|Saint Pétersbourg|Shanghai|Tunis|Varsovie";
$all_bi=explode("|",$bi);
$all_bi_fr=explode("|",$bi_fr);
$nbre_bi=(count($all_bi));
$coord_bi="36.718058/3.106984|50.842619/4.370044|44.447923/26.097879|47.496902/19.069511|33.60404/-7.636442|21.028551/105.843186|10.758000/106.653400|22.283337/114.159447|41.079009/29.018077|50.453629/30.503828|51.525887/-0.085402|55.762740/37.614868|40.757241/-73.983862|48.865608/2.305520|39.953043/116.471558|59.939039/30.315785|31.223482/121.479027|36.811700/10.176100|52.241899/21.012071";
$all_coord_bi=explode("|",$coord_bi);
$nbre_coord_bi=(count($all_coord_bi));
//select city
echo "<select name='city' id='city' size='1' onchange=\"document.getElementById('affichage').innerHTML = document.getElementById(this.value).innerHTML;\">";
echo '<option value="">';
for($j=0;$j < $nbre_bi; $j++){
echo '<option value="'.$all_bi[$j].'">';
echo $all_bi_fr[$j];
echo '</option>';
}
echo '</select>';
echo '<div id="affichage" style="width: 300px;"></div>';
$i=0;
//passage h12/h24
echo "<script> function switchclock(){
if (document.getElementById('coche_".$j."').checked){
alert(document.getElementById('coche_".$j."').value);
alert(document.getElementById('coche_".$j."').checked);
document.getElementById('ampm_".$j."').style.display = 'block';
document.getElementById('h24_".$j."').style.display = 'none';
}else{
document.getElementById('ampm_".$j."').style.display = 'none';
document.getElementById('h24_".$j."').style.display = 'block';
}
}
</script>";
//recuperation données horaires XML + transformation
for($i=0;$i < $nbre_bi; $i++){
$url="http://www.earthtools.org/timezone/".$all_coord_bi[$i];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$xmlResponse = curl_exec($ch);
curl_close($ch);
if (!is_string($xmlResponse) || !strlen($xmlResponse)) {echo $this->_set_error( "Failure Contacting Server" );}
else{echo "<script> function h24_".$i."(){
if (document.getElementById('coche_".$i."').checked){
document.getElementById('ampm_".$i."').style.display = 'block';
document.getElementById('h24_".$i."').style.display = 'none';
}else{
document.getElementById('ampm_".$i."').style.display = 'none';
document.getElementById('h24_".$i."').style.display = 'block';}
}
</script>";
$a = json_decode(json_encode((array) simplexml_load_string($xmlResponse)),1);
echo '
<script type="text/javascript">
function date_heure(id)
{
var office='.$all_bi[$i].';
var date = new Date();
annee = date.getFullYear();
moi = date.getMonth();
mois = new Array(\'Janvier\',\'Février\',\'Mars\',\'Avril\',\'Mai\',\'Juin\',\'Juillet\',\'Août\',\'Septembre\',\'Octobre\',\'Novembre\',\'Décembre\');
j = date.getDate(); jour = date.getDay();
jours = new Array(\'Dimanche\',\'Lundi\',\'Mardi\',\'Mercredi\',\'Jeudi\',\'Vendredi\',\'Samedi\');
h = (date.getHours()+'.$utc.')-1;
if(h<10)
{h = "0"+h;}
m = date.getMinutes();
if(m<10)
{m = "0"+m;}
s = date.getSeconds();
if(s<10)
{s = "0"+s;}
resultat = \'<font color="orange"><b>'.$all_bi[$i].'</b> : \'+h+\':\'+m+\':\'+s+\'</font>\';
document.getElementById(id).innerHTML = resultat;
setTimeout(\'date_heure("\'+id+\'");\',\'1000\');
return true;
}
</script>
';
$heure_h24=substr($a[localtime],-8);
$heure=substr($a[localtime], -8,-3); // heure sans les secondes
$minutes=substr($a[localtime], -5,-3);
$h12=substr($a[localtime], -8,-6);
$m12=substr($a[localtime], -5,-3);
if ($h12 > '12'){
$h12=($h12-12);
if(strlen($h12)<'2'){$h12='0'.$h12;}
$heure_h24=$h12.':'.$m12.' <font style="font-size: 12px;">PM</font>';}
else{$heure_h24=$h12.':'.$m12.' <font style="font-size: 12px; vertical-align: top;">AM</font>';}
$jour=substr($a[localtime], 0, -8);
if (substr($a[offset],0,1)==="-"){
$utc=$a[offset];
}
else{$utc= "+".$a[offset];}
echo "<div id='".$all_bi[$i]."' style='display: none;width: 300px;'>";
echo "<div><span id='date_heure'></span><br />";
?>
<script type="text/javascript">
window.onload =date_heure('date_heure');
</script>
<?php '</div>';
echo "</div>";
echo "</div></div>";
}
}
echo '
</div>
</body>
</html>
';
?> |
Partager