/**
 * Create the table rows for displaying the statistics
 *
 * @param array $ar Containing the data which needs to be formatted
 * @param int $multiplier The multiplier defining the width of the diagrams
 * @param array $builds Associating OS build numbers with readable OS versions
 * @param string $mode If the data needs to get special treatment, this
 *                     indicates it
 * @return string The assembled table, organizing the data
 */
function mkTbl(&$ar, $multiplier, $builds, $mode = NULL)
{
    if (is_numeric($_GET['interval'])) {
        $interval = "&interval=" . $_GET['interval'];
    }
    $tbl = "<table>";
    for ($i = 0; $i < count($ar); $i++) {
        // If we arrived at the osvers, replace the buildNOs by meaningful OS names
        if ($ar[$i]['osver']) {
            $osver = replaceOsVersion($ar[$i], $builds);
        }
        // If we arrived at the OS precision, replace the bool by 32/64bit
        if ($ar[$i]['is64'] == '1') {
            $precision = "64bit";
        } elseif ($ar[$i]['is64'] == '0') {
            $precision = "32bit";
        } else {
            $precision = NULL;
        }
        if ($ar[$i]['lcd'] == '1') {
            $lcd = "Yes";
        } elseif ($ar[$i]['lcd'] == '0') {
            $lcd = "No";
        } else {
            $lcd = NULL;
        }
        // Get the real percentage for the bar image's alt tag
        if ($multiplier != 100 && $multiplier != 0) {
            $alt = round($ar[$i]['share'] / $multiplier * 100, 2);
        }
        $row = "<tr>\n\t    <td>\n\t      <a href=\"index.php?page=main&item=" . ($mode ? $mode : urlencode(key(current($ar)))) . "&member=" . ($mode == "osver" ? urlencode($ar[$i]['osver']) : urlencode($ar[$i][key(current($ar))])) . $interval . "\">" . ($ar[$i]['is64'] != NULL || $ar[$i]['lcd'] != NULL ? $precision . $lcd : $ar[$i][key(current($ar))]) . " " . $osver . "</a>\n\t    </td>\n\t    <td>\n\t      <img src=\"blue.png\" valign=\"middle\" height=\"14\" alt=\"" . $alt . "%\" title=\"" . $alt . "%\" width=\"" . $ar[$i]['share'] . "\" /> <b>" . number_format($ar[$i]['count']) . "</b>\n\t    </td>\n\t  </tr>";
        // Append rXX snapshots, prepend official releases
        if ($ar[$i]['compiled']) {
            if ($ar[$i]['compiled'][0] == "r") {
                $tbl .= $row;
            } else {
                $tbl = $row . $tbl;
            }
        } else {
            $tbl .= $row;
        }
    }
    $tbl = "<table>" . $tbl;
    $tbl .= "</table>";
    return $tbl;
}
Exemple #2
0
    if (basename($filename) == $page . ".php") {
        $included = TRUE;
    }
}
if (!$included) {
    exit("Script can't run on its own.");
}
// Compose the WHERE clause of the queries if we want to filter
// and replace OS numbers by meaningful names for the header on the website
//
if (isset($_GET['item']) && isset($_GET['member'])) {
    $_GET['item'] = urldecode($_GET['item']);
    $_GET['member'] = urldecode($_GET['member']);
    $where = " AND " . mysql_real_escape_string($_GET['item']) . " = '" . mysql_real_escape_string($_GET['member']) . "'";
    if ($_GET['item'] == "osver") {
        $osver = replaceOsVersion($_GET['member']);
    }
}
// Check if we want to narrow results on a certain interval
// (use config default otherwise)
if (isset($_GET['interval'])) {
    if (is_numeric($_GET['interval'])) {
        $interval = $_GET['interval'] . " day";
        $timewhere = " AND seen >= NOW() - INTERVAL " . $interval;
    } else {
        $err[] = "You entered an invalid date interval. Falling back to default.";
        $timewhere = "";
    }
} else {
    $timewhere = "";
}