File: xmms_stats.php

package info (click to toggle)
xmms-stats 0.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 116 kB
  • ctags: 74
  • sloc: ansic: 433; makefile: 70; php: 56
file content (76 lines) | stat: -rw-r--r-- 1,954 bytes parent folder | download
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
<HTML>
<BODY bgcolor=black text=white>
<?php
$fichier = "xmms_stats.xml";
$is_time = 0;

function gestionnaire_texte($id_analyseur, $texte)
{	
    global $is_time;
    global $is_unix_time;
    if (!($texte== "\n")){
	if($is_time==0)
	     print $texte;
	else if ($is_time==1){
	    print (intval($texte/1000/60))."m ".(($texte/1000)%60)."s";
	    $is_time=0;
	}
	else if ($is_time==2){
    	    echo gmdate("M d Y H:i:s", $texte);
	    $is_time=0;
	}
	
        
    }
}

function startElement($parser, $name, $attrs) {

    global $is_time;
    if($name == "SONG")
	print "<TR>\n";
    else if($name == "LENGTH" || $name == "LISTENTIME"){
	$is_time=1;
	print "<TD><CENTER><font size=1>";
    }
    else if($name == "HITS"){
	print "<TD><CENTER><font size=1>";
    }
    else if($name == "TITLE")
	print "<TD><font size=1>";
    else if($name == "LAST"){
	$is_time=2;
	print "<TD><CENTER><font size=1>";

    }
    
}

function endElement($parser, $name) {
    if($name == "/SONG")
	print "</TR>\n";
    else if($name == "/LENGTH" || $name == "/HITS")
	    print "</FONT></CENTER></TD>";
    else if($name == "/TITLE")
	print "</FONT></TD>";
}

$id_fichier = fopen($fichier,"r");
$donnee_XML = fread($id_fichier, filesize($fichier));

$id_analyseur = xml_parser_create();

xml_parser_set_option($id_analyseur, XML_OPTION_CASE_FOLDING, true);
xml_set_character_data_handler($id_analyseur, "gestionnaire_texte");
xml_set_element_handler($id_analyseur,"startElement", "endElement");

print "<TABLE border=0>\n";
print "<TR>\n<TD><CENTER>Titre<BR><BR></CENTER></TD><TD> Nombre d'&eacute;coute <BR><BR></TD><TD>Dur&eacute;e<BR><BR></TD><TD>Temps d'&eacute;coute<BR><BR></TD><TD>Derniere &eacute;coute<BR><BR></TD></TR>";
xml_parse($id_analyseur, $donnee_XML, feof($id_fichier));

print "</TABLE>\n";

xml_parser_free($id_analyseur);
?>
<p align="right"><a href="http://oute.org/mystuff/xmms_stats_stuff.php">Powered by xmms-stats</a></font></p>
</BODY></HTML>