Example #1
0
    die("SQL Error!");
}
/*
 * SQL queries
 * Get data to display
 */
$sQuery = "\n    SELECT COUNT(" . $sIndexColumn . ")\n    FROM   {$sTable}\n    {$sWhere}\n    {$sOrder}\n";
$db->query($sQuery);
list($iFilteredTotal) = $db->get_row($sQuery, ARRAY_N);
/*
 * Output
 */
$output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
$sQuery = "\n    SELECT " . str_replace(" , ", " ", implode(", ", $aColumns)) . "\n    FROM   {$sTable}\n    {$sWhere}\n    {$sOrder}\n    {$sLimit}\n";
foreach ((array) $db->get_results($sQuery, ARRAY_A) as $aRow) {
    $row = array();
    list($rank) = $db->get_row("select count(*)+1 from user where local_ac>" . $aRow["local_ac"] . " or \n        (local_ac=" . $aRow["local_ac"] . " and total_ac>" . $aRow["total_ac"] . ") or \n        (local_ac=" . $aRow["local_ac"] . " and total_ac=" . $aRow["total_ac"] . " and total_submit<" . $aRow["total_submit"] . ") or \n        (local_ac=" . $aRow["local_ac"] . " and total_ac=" . $aRow["total_ac"] . " and total_submit=" . $aRow["total_submit"] . " and username<'" . $aRow["username"] . "' )", ARRAY_N);
    $row[] = $rank;
    for ($i = 1; $i < count($aColumns); $i++) {
        if ($aColumns[$i] == "nickname") {
            $row[] = change_out_nick($aRow[$aColumns[$i]]);
        } else {
            if ($aColumns[$i] != ' ') {
                /* General output */
                $row[] = $aRow[$aColumns[$i]];
            }
        }
    }
    $output['aaData'][] = $row;
}
echo json_encode($output);
Example #2
0
     }
 }
 //Penalty
 if ($imerge) {
     echo "<th class='anim:constant tcid'>CID</th>";
 } else {
     echo "<th style='display:none' class='anim:constant tcid'>CID</th>";
 }
 echo "<th class='tidentii anim:id' style='display:none'>ID</th>";
 echo "</tr></thead>\n<tbody>";
 if ($iid > $maxrank) {
     $iid = $maxrank;
 }
 for ($i = 0; $i < $iid; $i++) {
     //  print_r($Name_ary[$i]);
     $nick = change_out_nick($Name_ary[$i][4]);
     if ($nick == '') {
         $nick = "No nickname.";
     }
     $rnick = htmlentities($nick, ENT_QUOTES);
     $cduser = $cuser = substr($Name_ary[$i][3], 0, strrpos($Name_ary[$i][3], '('));
     echo "<tr>";
     if ($cidtype[$Name_ary[$i]['contest_belong']] == 0 || $cidtype[$Name_ary[$i]['contest_belong']] == 1) {
         echo "<td>" . ($i + 1) . "</td>" . "<td class='tnickname' style='display:none'><a href='userinfo.php?name={$cuser}' title='{$rnick}'>" . $nick . "</a></td>" . "<td class='tusername'><a target='_blank' href='userinfo.php?name={$cuser}' title='{$cuser}'>" . $cduser . "</a></td>" . "<td>" . $Name_ary[$i][sum] . "</td>";
     } else {
         echo "<td>" . ($i + 1) . "</td>" . "<td class='tnickname' style='display:none' title='{$rnick}'>" . $nick . "</td>" . "<td class='tusername' title='{$cuser}'>" . $cduser . "</td>" . "<td>" . $Name_ary[$i][sum] . "</td>";
     }
     //ac_num
     foreach ($map as $value) {
         if ($Name_ary[$i][$value] != -1 && array_key_exists($value, $Name_ary[$i])) {
             if ($ctype == 0 || $ctype == 99) {