[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / couteau_suisse / couteau_suisse / outils / horloge_fonctions.php
diff --git a/www/plugins/auto/couteau_suisse/couteau_suisse/outils/horloge_fonctions.php b/www/plugins/auto/couteau_suisse/couteau_suisse/outils/horloge_fonctions.php
new file mode 100644 (file)
index 0000000..b518d73
--- /dev/null
@@ -0,0 +1,37 @@
+<?php\r
+// action speciale, si cs_dateserveur=oui\r
+if(!isset($GLOBALS['cs_fonctions']) && isset($_GET['cs_dateserveur'])) {\r
+       header('Content-Type: text/xml');\r
+       echo '<?xml version="1.0" encoding="UTF-8"?>',\r
+               '<curTime><U>', date("U"), '</U><Z>', date("Z"), '</Z></curTime>';\r
+       exit;\r
+}\r
+\r
+// La balise #HORLOGE\r
+function balise_HORLOGE_dist($p) {\r
+       $i = 1; $args = array();\r
+       while(($a = interprete_argument_balise($i++,$p)) != NULL) $args[] = $a;\r
+       $args = count($args)?join(".'||'.", $args):"''";\r
+       $p->code = "horloge_params($args)";\r
+       $p->interdire_scripts = false;\r
+       return $p;\r
+}\r
+\r
+function horloge_params($args) {\r
+       $t = array();\r
+       $bal = 'span'; $def='99:99';\r
+       $args = explode('||', $args);\r
+       foreach($args as $a) {\r
+               list($a, $b) = explode('=', $a, 2);\r
+               if($b=="''" || $b=='""') $b = '';\r
+               if(strlen($a)) {\r
+                       if($a=='id') $id = 'jclock'.$b;\r
+                       elseif($a=='defaut') $def = $b;\r
+                       elseif($a=='balise') $bal = $b;\r
+                       else $t[$a] = "$a=$b";\r
+               }\r
+       }\r
+       return "<$bal class=\"jclock" . (isset($id)?" $id\" id=\"$id":'')\r
+               .'" title="'.join('||',$t)."\">$def</$bal> ";\r
+}\r
+?>
\ No newline at end of file