function cpu_info()
{
    $results = array();
    $ar_buf = array();
    $results['bogomips'] = 0;
    //        if ($fd = fopen('/proc/cpuinfo', 'r')) {
    //           while ($buf = fgets($fd, 4096)) {
    $cpuinfo = file('/proc/cpuinfo');
    // Loop through our array, show HTML source as HTML source; and line numbers too.
    foreach ($cpuinfo as $line_num => $line) {
        //            list($key, $value) = preg_split('/\s+:\s+/', trim($buf), 2);
        if (trim($line) != '') {
            list($key, $value) = preg_split('/\\s+:\\s+/', trim($line), 2);
            switch ($key) {
                case 'model name':
                    $results['model'] = $value;
                    break;
                case 'cpu MHz':
                    $results['mhz'] = sprintf('%.2f', $value);
                    break;
                case 'clock':
                    /* For PPC arch (damn borked POS) */
                    $results['mhz'] = sprintf('%.2f', $value);
                    break;
                case 'cpu':
                    /* For PPC arch (damn borked POS) */
                    $results['model'] = $value;
                    break;
                case 'revision':
                    /* For PPC arch (damn borked POS) */
                    $results['model'] .= ' ( rev: ' . $value . ')';
                    break;
                case 'cache size':
                    $results['cache'] = $value;
                    break;
                case 'bogomips':
                    $results['bogomips'] += $value;
                    break;
            }
        }
        //            fclose($fd);
    }
    $keys = compat_array_keys($results);
    $keys2be = array('model', 'mhz', 'cache', 'bogomips', 'cpus');
    while ($ar_buf = each($keys2be)) {
        if (!compat_in_array($ar_buf[1], $keys)) {
            $results[$ar_buf[1]] = 'N.A.';
        }
    }
    return $results;
}
function sys_cpu()
{
    $results = array();
    $ar_buf = array();
    if ($fd = fopen('/proc/cpuinfo', 'r')) {
        while ($buf = fgets($fd, 4096)) {
            list($key, $value) = preg_split('/\\s+:\\s+/', trim($buf), 2);
            // All of the tags here are highly architecture dependant.
            // the only way I could reconstruct them for machines I don't
            // have is to browse the kernel source.  So if your arch isn't
            // supported, tell me you want it written in. <*****@*****.**>
            switch ($key) {
                case 'model name':
                    $results['model'] = $value;
                    break;
                case 'cpu MHz':
                    $results['mhz'] = sprintf('%.2f', $value);
                    break;
                case 'clock':
                    // For PPC arch (damn borked POS)
                    $results['mhz'] = sprintf('%.2f', $value);
                    break;
                case 'cpu':
                    // For PPC arch (damn borked POS)
                    $results['model'] = $value;
                    break;
                case 'revision':
                    // For PPC arch (damn borked POS)
                    $results['model'] .= ' ( rev: ' . $value . ')';
                    break;
                case 'cache size':
                    $results['cache'] = $value;
                    break;
                case 'bogomips':
                    $results['bogomips'] += $value;
                    break;
                case 'processor':
                    $results['cpus'] += 1;
                    break;
            }
        }
        fclose($fd);
    }
    $keys = compat_array_keys($results);
    $keys2be = array('model', 'mhz', 'cache', 'bogomips', 'cpus');
    while ($ar_buf = each($keys2be)) {
        if (!compat_in_array($ar_buf[1], $keys)) {
            $results[$ar_buf[1]] = 'N.A.';
        }
    }
    return $results;
}