This is ODD: The php file() function returns an empty array when reading /proc/asound/cards.
PHP Ver:
PHP 4.3.9 (cgi) (built: Oct 20 2004 14:52:04)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
ALSA Ver:
[.......]# cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.6 (Sun Aug 15 07:17:53 2004 UTC).
Compiled on Nov 2 2004 for kernel 2.6.9-1.667.
Nothing too odd there.
Example code reading /proc/cpuinfo and /proc/asound/cards. Each /proc file is read two different ways and only the file('/proc/asound/cards') returns empty info.
<html>
<head>
<title>WTF</title>
</head>
<body>
<?PHP
showproc('/proc/cpuinfo');
showproc('/proc/asound/cards');
function showproc($proc){
echo "<hr>";
echo " proc info for [$proc]";
echo "<hr>";
echo "<pre>";
$cards = file($proc);
print_r($cards);
echo "</pre>";
echo "<hr>";
echo "<pre>";
system( "cat $proc");
echo "</pre>";
echo "<hr>";
return;
}
?>
</body>
</html>
From this code I get:
proc info for [/proc/cpuinfo]
Array
(
[0] => processor : 0
[1] => vendor_id : GenuineIntel
[2] => cpu family : 5
[3] => model : 2
[4] => model name : Pentium 75 - 200
[5] => stepping : 12
[6] => cpu MHz : 132.915
[7] => fdiv_bug : no
[8] => hlt_bug : no
[9] => f00f_bug : yes
[10] => coma_bug : no
[11] => fpu : yes
[12] => fpu_exception : yes
[13] => cpuid level : 1
[14] => wp : yes
[15] => flags : fpu vme de pse tsc msr mce cx8
[16] => bogomips : 259.07
[17] =>
)
processor : 0
vendor_id : GenuineIntel
cpu family : 5
model : 2
model name : Pentium 75 - 200
stepping : 12
cpu MHz : 132.915
fdiv_bug : no
hlt_bug : no
f00f_bug : yes
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr mce cx8
bogomips : 259.07
proc info for [/proc/asound/cards]
Array
(
)
0 [YMF724 ]: YMF724 - Yamaha DS-XG (YMF724)
Yamaha DS-XG (YMF724) at 0x41000000, irq 11
I've just tried this on a box with
PHP 5.0.4 (cli) (built: May 9 2005 11:21:11)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies
And it works: the array has info on the alsa card(s) in it, so it looks like a fixed bug. Can anyone confirm this? (please)
Cheers - Grant.