Ejemplo n.º 1
0
 function loadsettings()
 {
     $settingsQ = mysql_query_cache("SELECT setting, value FROM settings");
     foreach ($settingsQ as $settingsR) {
         $setting = $settingsR->setting;
         $value = $settingsR->value;
         $this->settingsarray[$setting] = $value;
     }
 }
Ejemplo n.º 2
0
 private function getRealAnomTypeID($typeName, $whClassID)
 {
     global $whConn;
     $anomSQL = sprintf("SELECT dgmTypeAttributes.typeID FROM " . EVEDB_NAME . ".dgmTypeAttributes INNER JOIN " . EVEDB_NAME . ".dgmAttributeTypes USING(attributeID) WHERE typeID = (SELECT invTypes.typeID FROM " . EVEDB_NAME . ".invTypes WHERE UPPER(typeName) LIKE '%%%s%% CLASS %d%%') LIMIT 1", strtoupper($typeName), $whClassID);
     $rsAnomaly = mysql_query_cache($anomSQL, $whConn);
     if (is_array($rsAnomaly)) {
         if (!empty($rsAnomaly)) {
             return $rsAnomaly[0]["typeID"];
         }
     }
     return null;
 }
Ejemplo n.º 3
0
<?php

require_once 'singleserver.php';
$sql = "\n        SELECT `dataID`, `dataTitle`\n        FROM `tbldata`\n        WHERE `dataTypeID` BETWEEN 2 AND 2093\n        AND `dataStatusID` IN (1,2,3,4)\n        AND `dataTitle` LIKE '%something%'\n        ORDER BY `dataDate` DESC\n        LIMIT 10\n    ";
# Antes: Sin Memcached
$rSlowQuery = mysql_query($sql);
# $rSlowQuery is a MySQL resource
$rows = mysql_num_rows($rSlowQuery);
for ($i = 0; $i < $rows; $i++) {
    $dataID = intval(mysql_result($rSlowQuery, $i, "dataID"));
    $dataTitle = mysql_result($rSlowQuery, $i, "dataTitle");
    echo "<a href=\"/somewhere/{$dataID}\">{$dataTitle}</a><br />\n";
}
# Despues Con Memcache
$rSlowQuery = mysql_query_cache($sql);
# $rSlowQuery is an array
$rows = count($rSlowQuery);
for ($i = 0; $i < $rows; $i++) {
    $dataID = intval($rSlowQuery[$i]["dataID"]);
    $dataTitle = $rSlowQuery[$i]["dataTitle"];
    echo "<a href=\"/somewhere/{$dataID}\">{$dataTitle}</a><br />\n";
}
Ejemplo n.º 4
0
    //if (mysql_num_rows($result) > 0)
    //	mysql_data_seek($result, 0);
    foreach ($result as $resultrow) {
        echo "<td>" . $resultrow->hashrate . "</td>";
    }
    echo "</tbody></table><br />\n";
    //echo "</div><div class=\"clear\"></div><div id=\"stats_wrap_4\" class=\"top_spacing\">";
    // USER HASHRATE OVER LAST MONTH GRAPH *************************************************************************************************************************
    // http://www.filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/
    // table is hidden, graph follows
    echo "<table id=\"user_hashrate_lastmonth\" class=\"hide\">";
    echo "<caption>" . $userInfo->username . "'s Hashrate over the Last Month</caption>";
    echo "<thead><tr><td></td>";
    $query = "SELECT DATE_FORMAT(timestamp, '%b %e') as day, hashrate FROM userHashrates WHERE timestamp > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND userId = " . $userInfo->id;
    $query .= " GROUP BY EXTRACT(MONTH FROM timestamp), EXTRACT(DAY FROM timestamp)";
    $result = mysql_query_cache($query);
    foreach ($result as $resultrow) {
        echo "<th scope=\"col\">" . $resultrow->day . "</th>";
    }
    echo "</thead><tbody><tr><th scope=\"row\">" . $userInfo->username . "'s Hashrate</th>";
    // re-iterate through results
    //if (mysql_num_rows($result) > 0)
    //	mysql_data_seek($result, 0);
    foreach ($result as $resultrow) {
        echo "<td>" . $resultrow->hashrate . "</td>";
    }
    echo "</tbody></table><br />\n";
    //echo "</div><div class=\"clear\"></div><div id=\"stats_wrap_5\" class=\"top_spacing\">";
}
echo "<div class=\\'clear'></div></div><br />\n";
include "includes/footer.php";
Ejemplo n.º 5
0
if ($OJ_SIM) {
    $old = $sql;
    $sql = "select * from ({$sql} order by solution_id desc limit 20) solution left join `sim` on solution.solution_id=sim.s_id WHERE 1 ";
    if (isset($_GET['showsim']) && intval($_GET['showsim']) > 0) {
        $showsim = intval($_GET['showsim']);
        $sql = "select * from ({$old} ) solution \n                     left join `sim` on solution.solution_id=sim.s_id WHERE result=4 and sim>={$showsim}";
        $sql = "SELECT * FROM ({$sql}) `solution`\n                        left join(select solution_id old_s_id,user_id old_user_id from solution) old\n                        on old.old_s_id=sim_s_id WHERE  old_user_id!=user_id and sim_s_id!=solution_id ";
        $str2 .= "&showsim={$showsim}";
    }
    //$sql=$sql.$order_str." LIMIT 20";
}
$sql = $sql . $order_str . " LIMIT 20";
//echo $sql;
if ($OJ_MEMCACHE) {
    require "./include/memcache.php";
    $result = mysql_query_cache($sql) or die("Error! " . mysql_error());
    $rows_cnt = count($result);
} else {
    $result = mysql_query($sql) or die("Error! " . mysql_error());
    $rows_cnt = mysql_num_rows($result);
}
$top = $bottom = -1;
$cnt = 0;
if ($start_first) {
    $row_start = 0;
    $row_add = 1;
} else {
    $row_start = $rows_cnt - 1;
    $row_add = -1;
}
for ($i = 0; $i < $rows_cnt; $i++) {
Ejemplo n.º 6
0
    $view_rank[$i][1] = "<div class=center><a href='userinfo.php?user="******"'>" . $row['user_id'] . "</a>" . "</div>";
    $view_rank[$i][2] = "<div class=center>" . htmlspecialchars($row['nick']) . "</div>";
    $view_rank[$i][3] = "<div class=center><a href='status.php?user_id=" . $row['user_id'] . "&jresult=4'>" . $row['solved'] . "</a>" . "</div>";
    $view_rank[$i][4] = "<div class=center><a href='status.php?user_id=" . $row['user_id'] . "'>" . $row['submit'] . "</a>" . "</div>";
    if ($row['submit'] == 0) {
        $view_rank[$i][5] = "0.000%";
    } else {
        $view_rank[$i][5] = sprintf("%.03lf%%", 100 * $row['solved'] / $row['submit']);
    }
}
if (!$OJ_MEMCACHE) {
    mysql_free_result($result);
}
if ($OJ_MEMCACHE) {
    // require("./include/memcache.php");
    $result = mysql_query_cache($view_total_sql);
    // or die("Error! ".mysql_error());
    if ($result) {
        $rows_cnt = count($result);
    } else {
        $rows_cnt = 0;
    }
} else {
    $result = mysql_query($view_total_sql);
    // or die("Error! ".mysql_error());
    if ($result) {
        $rows_cnt = mysql_num_rows($result);
    } else {
        $rows_cnt = 0;
    }
}
Ejemplo n.º 7
0
if ($prevtop_sql != "") {
    $prevtop_sql = $prevtop_sql . " ORDER BY `solution_id` ASC LIMIT 20";
    $prev_result = mysql_query($prevtop_sql);
    $prev_rows_cnt = 0;
    if ($prev_result) {
        $prev_rows_cnt = mysql_num_rows($prev_result);
    }
    for ($i = 0; $i < $prev_rows_cnt; $i++) {
        $prev_row = mysql_fetch_array($prev_result);
        $prev_top = $prev_row['solution_id'];
    }
    mysql_free_result($prev_result);
}
if ($OJ_MEMCACHE) {
    require "./include/memcache.php";
    $result = mysql_query_cache($sql);
    // or die("Error! ".mysql_error());
    if ($result) {
        $rows_cnt = count($result);
    } else {
        $rows_cnt = 0;
    }
} else {
    $result = mysql_query($sql);
    // or die("Error! ".mysql_error());
    if ($result) {
        $rows_cnt = mysql_num_rows($result);
    } else {
        $rows_cnt = 0;
    }
}
Ejemplo n.º 8
0
 // Get the top corp in alliance ship types
 $topCorpShips = $topCorp->shipTypes;
 if (is_array($topCorpShips)) {
     arsort($topCorpShips, SORT_NUMERIC);
     // $bigKillShips contains a list of ship typeIDs together with the number of
     // times they were used.  In order to get the total count of ship CLASSES we
     // have to build a convoluted SQL query using UNIONs in order to add a column
     // containing the counts-per-ship, and then aggregating them into a
     // total-per-class, which is what we display.
     $bigShipJoinSQL = "LEFT JOIN (";
     foreach ($topCorpShips as $sName => $sKills) {
         $bigShipJoinSQL .= sprintf("SELECT %d AS typeID, %d AS useCnt%s", $sName, $sKills, $sName != end(array_keys($topCorpShips)) ? " UNION " : "");
     }
     $bigShipJoinSQL .= ") sK USING(typeID)";
     $shipClassSQL = sprintf("SELECT ig.groupName, SUM(sK.useCnt) AS timesUsed FROM " . EVEDB_NAME . ".invTypes it LEFT JOIN " . EVEDB_NAME . ".invGroups ig USING(groupID) %s WHERE (it.typeID IN (%s) AND NOT it.typeID = 0) AND ig.anchorable = 0 GROUP BY ig.groupName ORDER BY timesUsed DESC", $bigShipJoinSQL, implode(",", array_keys($topCorpShips)));
     $rsShipClass = mysql_query_cache($shipClassSQL);
     if (is_array($rsShipClass)) {
         if (!empty($rsShipClass)) {
             $classCnt = 1;
             $classCount = count($rsShipClass);
             //$bigKillShipID = key($topCorpShips);
             printf('Their favourite ship class%s %s <span class="h5">%s</span> (%0.1f%% of total)', $classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "es" : "", $classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1 ? "include" : "is", $rsShipClass[0]["groupName"], $rsShipClass[0]["timesUsed"] / $classCount * 100);
             if ($classCount > 1 && EVEKILL_MAX_SHIP_CLASSES_TO_SHOW > 1) {
                 $clAry = array();
                 for ($s = 1; $s < count($rsShipClass) && $classCnt++ < EVEKILL_MAX_SHIP_CLASSES_TO_SHOW; $s++) {
                     $clAry[] = sprintf('%s (%0.1f%%)', $rsShipClass[$s]["groupName"], $rsShipClass[$s]["timesUsed"] / $classCount * 100);
                 }
                 printf(", %s.  ", isset($clAry) ? implode(", ", $clAry) : "");
             } else {
                 printf(".  ");
             }
Ejemplo n.º 9
0
function getSystemName($id)
{
    $lociiSQL = sprintf("SELECT solarSystemName FROM " . EVEDB_NAME . ".mapSolarSystems WHERE solarSystemID=%s%%", $id);
    $rsLocii = mysql_query_cache($lociiSQL, false, MEMCACHE_STATICDATA_TIMEOUT, true);
    if (is_array($rsLocii)) {
        if (!empty($rsLocii)) {
            return $rsLocii[0]["solarSystemName"];
        }
    }
}
Ejemplo n.º 10
0
    if (is_numeric($settings->getsetting("sitepercent"))) {
        $sitePercent = $settings->getsetting("sitepercent");
    }
    $totalUserShares = $stats->usersharecount($userid);
    //Get current round share information, estimated total earnings
    $totalOverallShares = $stats->currentshares();
    //Prevent divide by zero
    if ($totalUserShares > 0 && $totalOverallShares > 0) {
        //Get site percentage
        $sitePercent = 0;
        if (is_numeric($settings->getsetting('sitepercent'))) {
            $sitePercent = $settings->getsetting('sitepercent') / 100;
        }
        if ($totalOverallShares > $bitcoinDifficulty) {
            $estimatedTotalEarnings = $totalUserShares / $totalOverallShares;
        } else {
            $estimatedTotalEarnings = $totalUserShares / $bitcoinDifficulty;
        }
        $estimatedTotalEarnings *= $bonusCoins * (1 - $sitePercent);
        //The expected BTC to be givin out
        $user->estimated_rewards = round($estimatedTotalEarnings, 8);
    }
}
$resultW = mysql_query_cache("SELECT username FROM pool_worker WHERE associatedUserId = {$userid}", 300);
foreach ($resultW as $workerobj) {
    $worker = new Worker();
    $worker->alive = $stats->workerhashrate($workerobj->username) > 0;
    $worker->hashrate = $stats->workerhashrate($workerobj->username);
    $user->workers[$workerobj->username] = $worker;
}
echo json_encode($user);
Ejemplo n.º 11
0
 private function getIDOrNameFromEveAPI($nameArray, $searchType = EVE_API_ID_SEARCH)
 {
     global $whConn;
     // Convert nameArray to array if it is a string
     if (!is_array($nameArray)) {
         $tmpAry = array();
         $tmpAry[] = $nameArray;
         $nameArray = $tmpAry;
         unset($tmpAry);
     }
     $idArray = array();
     // First interrogate the database cache, any entries we find in there we can exclude from the API run
     $dbNameArray = $nameArray;
     for ($n = 0; $n < sizeof($dbNameArray); $n++) {
         $dbNameArray[$n] = strtoupper(mysql_real_escape_string($dbNameArray[$n]));
     }
     if ($searchType == EVE_API_ID_SEARCH) {
         $idLookupSQL = sprintf("SELECT eve_id, eve_name FROM " . WHDB_NAME . ".idMap WHERE UPPER(eve_name) IN ('%s')", implode($dbNameArray, "','"));
     } else {
         $idLookupSQL = sprintf("SELECT eve_id, eve_name FROM " . WHDB_NAME . ".idMap WHERE eve_id IN (%s)", implode($dbNameArray, ","));
     }
     //dprintf("getIDOrNameFromEveAPI(): SQL query: %s", $idLookupSQL);
     $rsLookup = mysql_query_cache($idLookupSQL, $whConn);
     if (is_array($rsLookup)) {
         if (!empty($rsLookup)) {
             //printf("<p>Found %d/%d results in cache.", mysql_num_rows($rsLookup), sizeof($nameArray));
             // We have some cached IDs in the database, so add them to the "final" array, and remove them
             // from the list of names we have to poll the EVE API for.
             // We have to create a temporary array to uppercase the entries because the database writes
             // the EVE API result as the names are in game, which is not necessarily what they will be on
             // the kills (strange but true)
             $ucArray = $nameArray;
             for ($n = 0; $n < sizeof($ucArray); $n++) {
                 $ucArray[$n] = strtoupper($ucArray[$n]);
             }
             // For each database row we have, we remove the result from the nameArray table
             for ($s = 0; $s < count($rsLookup); $s++) {
                 //dprintf("result: %d, %s", $sRow->eve_id, $sRow->eve_name);
                 $idArray[] = array("id" => $rsLookup[$s]["eve_id"], "name" => $rsLookup[$s]["eve_name"]);
                 if (($nKey = array_search(strtoupper($searchType == EVE_API_ID_SEARCH ? $rsLookup[$s]["eve_name"] : $rsLookup[$s]["eve_id"]), $ucArray)) !== false) {
                     unset($nameArray[$nKey]);
                 }
             }
             unset($ucArray);
             // Re-index the nameArray
             $nameArray = array_values($nameArray);
         }
     }
     unset($dbNameArray);
     //print_r($nameArray);
     // We might not have any names left to search for..
     if (sizeof($nameArray) > 0) {
         //dprintf("%d results were missing from cache, need to query EVE API to complete.", sizeof($nameArray));
         // We urlencode the individual names, but not the whole query
         for ($n = 0; $n < sizeof($nameArray); $n++) {
             $nameArray[$n] = urlencode($nameArray[$n]);
         }
         set_error_handler("eve_api_warning_catcher", E_WARNING);
         try {
             libxml_use_internal_errors(true);
             $apiXml = simplexml_load_file(sprintf($searchType == EVE_API_ID_SEARCH ? EVE_API_ID_LOOKUP_URL : EVE_API_NAME_LOOKUP_URL, implode($nameArray, ",")));
             //dprintf("API: %s", sprintf(($searchType == EVE_API_ID_SEARCH) ? EVE_API_ID_LOOKUP_URL : EVE_API_NAME_LOOKUP_URL, implode($nameArray,",")));
             if (isset($apiXml->result->rowset->row)) {
                 foreach ($apiXml->result->rowset->row as $aChar) {
                     // Add this ID to the database cache
                     $idLookupSQL = sprintf("INSERT IGNORE INTO " . WHDB_NAME . ".idMap (eve_id, eve_name) VALUES (%d, '%s')", $aChar["characterID"], mysql_real_escape_string($aChar["name"]));
                     //dprintf("SQL insert: %s", $idLookupSQL);
                     mysql_query($idLookupSQL);
                     $idArray[] = array("id" => intval($aChar["characterID"]), "name" => strval($aChar["name"]));
                 }
             }
         } catch (Exception $e) {
             printf('<p><span class="advisoryBad">Error: Unable to update kill data from EVE KILL - error reported %s.</span></p>', $e->getMessage());
             error_log("EVE API error: " . $e->getMessage(), 0);
         }
         restore_error_handler();
     }
     // Returns the populated array to the calling function, or null if we have no IDs
     return sizeof($idArray) > 0 ? $idArray : null;
 }