<commit_before><?php

// Make sure we are called from index.php
if (!defined('SECURITY'))
  die('Hacking attempt');

class Faucetusers extends Base {
  protected $table = 'users';
  
  /**
   * Log the information from a user faucet request
   **/
  public function logUser() {
    $userIP = getCurrentIP();
    $userAddress = $_POST['userAddress'];
    $stmt = $this->$mysqli->prepare("INSERT INTO $this->table (user_address, user_ip) VALUES (?,?)");
    $stmt->bind_param('ss',$userAddress,$userIP);
    $stmt->execute();
}
  
  /**
   * Fetch users coin address
   * @param userID int UserID
   * @return data string Coin Address
   **/
  public function getCoinAddress($userID) {
    $this->debug->append("STA " . __METHOD__, 4);
    return $this->getSingle($userID, 'user_address', 'id');
}

  public function getUserIP($userIP) {
    $this->debug->append("STA " . __METHOD__, 4);
    return $this->getSingle($userIP, 'user_IP', 'id');
}
  
  /**
   * Convenience function to get IP address, no params is the same as REMOTE_ADDR
   * @param trustremote bool must be FALSE to checkclient or checkforwarded
   * @param checkclient bool check HTTP_CLIENT_IP for a valid ip first
   * @param checkforwarded bool check HTTP_X_FORWARDED_FOR for a valid ip first
   * @return string IP address
   */
  public function getCurrentIP($trustremote=true, $checkclient=false, $checkforwarded=false) {
    $client = (isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : false;
    $fwd = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : false;
    $remote = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : @$_SERVER['REMOTE_ADDR'];
    // shared internet
    if (filter_var($client, FILTER_VALIDATE_IP) && !$trustremote && $checkclient) {
      return $client;
    } else if (strpos($fwd, ',') !== false && !$trustremote && $checkforwarded) {
      // multiple proxies
      $ips = explode(',', $fwd);
      $path = array();
      foreach ($ips as $ip) {
        if (filter_var($ip, FILTER_VALIDATE_IP)) {
          $path[] = $ip;
        }
      }
      return array_pop($path);
    } else if (filter_var($fwd, FILTER_VALIDATE_IP) && !$trustremote && $checkforwarded) {
      // single
      return $fwd;
    } else {
      // as usual
      return $remote;
    }
  }
}
<commit_msg>querying user instead<commit_after><?php

// Make sure we are called from index.php
if (!defined('SECURITY'))
  die('Hacking attempt');

class Faucetusers extends Base {
  protected $table = 'users';
  
  /**
   * Log the information from a user faucet request
   **/
  public function logUser() {
    $userIP = $this->user->getCurrentIP();
    $userAddress = $_POST['userAddress'];
    $stmt = $this->mysqli->prepare("INSERT INTO $this->table (user_address, user_ip) VALUES (?,?)");
    $stmt->bind_param('ss',$userAddress,$userIP);
    $stmt->execute();
}
  
  /**
   * Fetch users coin address
   * @param userID int UserID
   * @return data string Coin Address
   **/
  public function getCoinAddress($userID) {
    $this->debug->append("STA " . __METHOD__, 4);
    return $this->getSingle($userID, 'user_address', 'id');
}

  public function getUserIP($userIP) {
    $this->debug->append("STA " . __METHOD__, 4);
    return $this->getSingle($userIP, 'user_IP', 'id');
}
  
}

{'fraction_non_alphanumeric': 0.1595166163141994, 'fraction_numerical': 0.0012084592145015106, 'mean_word_length': 3.5543328748280607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '815074', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1080, 'n_words': 265}