+ function ipclass_update($ip_out_s, $ip_in)
+ {
+ fprintf(STDERR, "N_IN: %d\n", count($ip_in));
+
+ $ip_out = &$this->$ip_out_s;
+
+ // if already set clean the ban_list property
+ if ($ip_out) {
+ $ct = count($ip_out);
+ for ($i = 0 ; $i < $ct ; $i++) {
+ unset($ip_out[$i]);
+ }
+ unset($ip_out);
+ }
+
+ $ip_out = array();
+ for ($i = 0 ; $i < count($ip_in) ; $i++) {
+ $ip_out[$i] = new IPClass($ip_in[$i]);
+ }
+ }
+
+ function reload($is_first, $ban_list, $black_list)
+ {
+ fprintf(STDERR, "RELOAD STUFF (%d)(%d)\n", count($ban_list), count($black_list));
+
+ if (defined('CURL_DE_SAC_VERS')) {
+ if (brisk_cds_reload($this) == FALSE) {
+ exit(12);
+ }
+ }
+ $this->ipclass_update("ban_list", $ban_list);
+ $this->ipclass_update("black_list", $black_list);
+
+ if (!$is_first) {
+ $this->banned_kickoff();
+ $this->garbage_manager(TRUE);
+ }
+ }
+
+ function banned_kickoff()
+ {
+ $is_ban = FALSE;
+
+ for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ $table_cur = $this->table[$table_idx];
+ // if the table is complete and exists we check users IP
+
+ if ($table_cur->player_n == PLAYERS_N) {
+ if (isset($this->match[$table_idx]) &&
+ $table_cur->table_token == $bin5->table_token) {
+ log_main("PLAYERS == N TABLE ".$table_idx);
+
+ $bin5 = $this->match[$table_idx];
+
+ $is_ban |= $bin5->banned_kickoff();
+ }
+ }
+ }
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+
+ if ($user_cur->sess == "")
+ continue;
+
+ // check if the IP is blacklisted
+ if ($this->black_check($user_cur->ip)) {
+ $user_cur->lacc = 0;
+ $is_ban = TRUE;
+ continue;
+ }
+
+ // if authorized not check if banlisted
+ if ($user_cur->is_auth()) {
+ continue;
+ }
+
+ if ($this->ban_check($user_cur->ip)) {
+ $user_cur->lacc = 0;
+ $is_ban = TRUE;
+ }
+ }
+
+ return $is_ban;
+ }
+
+ function ban_check($ip_str)
+ {
+ $ip = ip2long($ip_str);
+ fprintf(STDERR, "Brisk::ban_check %d\n", count($this->ban_list));
+ for ($i = 0 ; $i < count($this->ban_list) ; $i++) {
+ fprintf(STDERR, "ban_list[%d] = %x (%x)\n", $i,
+ $this->ban_list[$i]->addr, $this->ban_list[$i]->mask);
+ if ($this->ban_list[$i]->match($ip)) {
+ fprintf(STDERR, "\n\nMATCHA!\n\n");
+ return(TRUE);
+ }
+ }
+ return (FALSE);
+ }
+
+ function black_check($ip_str)
+ {
+ $ip = ip2long($ip_str);
+ fprintf(STDERR, "Brisk::black_check %d\n", count($this->black_list));
+ for ($i = 0 ; $i < count($this->black_list) ; $i++) {
+ fprintf(STDERR, "black_list[%d] = %x (%x)\n", $i,
+ $this->black_list[$i]->addr, $this->black_list[$i]->mask);
+ if ($this->black_list[$i]->match($ip)) {
+ fprintf(STDERR, "\n\nMATCHA!\n\n");
+ return(TRUE);
+ }
+ }
+ return (FALSE);
+ }
+