Exemple #1
0
if (!$DB->has_results()) {
    // If user doesn't exist
    header("Location: log.php?search=User+{$UserID}");
}
$Cur = $DB->next_record(MYSQLI_ASSOC, false);
if ($_POST['comment_hash'] != $Cur['CommentHash']) {
    error("Somebody else has moderated this user since you loaded it. Please go back and refresh the page.");
}
//NOW that we know the class of the current user, we can see if one staff member is trying to hax0r us.
if (!check_perms('users_mod', $Cur['Class'])) {
    //Son of a f*****g bitch
    error(403);
    die;
}
if (!empty($_POST['donor_points_submit']) && !empty($_POST['donation_value']) && is_numeric($_POST['donation_value'])) {
    Donations::regular_donate($UserID, $_POST['donation_value'], "Add Points", $_POST['donation_reason'], $_POST['donation_currency']);
} elseif (!empty($_POST['donor_values_submit'])) {
    Donations::update_rank($UserID, $_POST['donor_rank'], $_POST['total_donor_rank'], $_POST['reason']);
}
// If we're deleting the user, we can ignore all the other crap
if ($_POST['UserStatus'] === 'delete' && check_perms('users_delete_users')) {
    Misc::write_log("User account {$UserID} (" . $Cur['Username'] . ") was deleted by " . $LoggedUser['Username']);
    $DB->query("\n\t\tDELETE FROM users_main\n\t\tWHERE id = {$UserID}");
    $DB->query("\n\t\tDELETE FROM users_info\n\t\tWHERE UserID = {$UserID}");
    $Cache->delete_value("user_info_{$UserID}");
    Tracker::update_tracker('remove_user', array('passkey' => $Cur['torrent_pass']));
    header("Location: log.php?search=User+{$UserID}");
    die;
}
// User was not deleted. Perform other stuff.
$UpdateSet = array();
 /**
  * Find and process new donations since the last time this function was called.
  */
 public static function find_new_donations()
 {
     global $Debug;
     if (($OldAmount = G::$Cache->get_value('btc_total_received')) === false) {
         $QueryID = G::$DB->get_query_id();
         G::$DB->query("\n\t\t\t\tSELECT IFNULL(SUM(Amount), 0)\n\t\t\t\tFROM donations_bitcoin");
         list($OldAmount) = G::$DB->next_record(MYSQLI_NUM, false);
         G::$DB->set_query_id($QueryID);
     }
     $NewAmount = self::get_total_received();
     if ($NewAmount < $OldAmount) {
         // This shouldn't happen. Perhaps bitcoind was restarted recently
         // or the block index was removed. Either way, try again later
         send_irc('PRIVMSG ' . LAB_CHAN . " :Bad bitcoin donation data (is {$NewAmount}, was {$OldAmount}). If this persists, something is probably wrong");
         return false;
     }
     if ($NewAmount > $OldAmount) {
         // I really wish we didn't have to do it like this
         $QueryID = G::$DB->get_query_id();
         G::$DB->query("\n\t\t\t\tSELECT BitcoinAddress, SUM(Amount)\n\t\t\t\tFROM donations_bitcoin\n\t\t\t\tGROUP BY BitcoinAddress");
         $OldDonations = G::$DB->to_pair(0, 1, false);
         G::$DB->set_query_id($QueryID);
         $NewDonations = self::get_received();
         foreach ($NewDonations as $Address => &$Amount) {
             if (isset($OldDonations[$Address])) {
                 if ($Amount == $OldDonations[$Address]) {
                     // Direct comparison should be fine as everything comes from bitcoind
                     unset($NewDonations[$Address]);
                     continue;
                 }
                 $Debug->log_var(array('old' => $OldDonations[$Address], 'new' => $Amount), "New donations from {$Address}");
                 // PHP doesn't do fixed-point math, and json_decode has already botched the precision
                 // so let's just round this off to satoshis and pray that we're on a 64 bit system
                 $Amount = round($Amount - $OldDonations[$Address], 8);
             }
             $NewDonations[$Address] = $Amount;
         }
         $Debug->log_var($NewDonations, '$NewDonations');
         foreach (self::get_userids(array_keys($NewDonations)) as $Address => $UserID) {
             Donations::regular_donate($UserID, $NewDonations[$Address], 'Bitcoin Parser', '', 'BTC');
             self::store_donation($Address, $NewDonations[$Address]);
         }
         G::$Cache->cache_value('btc_total_received', $NewAmount, 0);
     }
 }