/[drupal]/contributions/modules/troll/troll.module
ViewVC logotype

Diff of /contributions/modules/troll/troll.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.26.2.11.2.6, Fri Apr 10 14:56:04 2009 UTC revision 1.26.2.11.2.7, Sat Jun 13 02:55:13 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: troll.module,v 1.26.2.11 2008/09/21 12:12:48 jaydub Exp $  // $Id: troll.module,v 1.26.2.11.2.6 2009/04/10 14:56:04 deekayen Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 590  function troll_blacklist_parse_save($fil Line 590  function troll_blacklist_parse_save($fil
590            $net = $longip & $netmasks[$matches[2]];            $net = $longip & $netmasks[$matches[2]];
591            $bcast = $longip | ($netmasks[$matches[2]] ^ -1);            $bcast = $longip | ($netmasks[$matches[2]] ^ -1);
592          }          }
593          db_query('DELETE FROM {troll_blacklist} WHERE net = %d AND bcast = %d', $net, $bcast);          db_query('DELETE FROM {troll_blacklist} WHERE net = %f AND bcast = %f', $net, $bcast);
594          db_query('INSERT INTO {troll_blacklist} (net, bcast) VALUES (%d, %d)', $net, $bcast);          db_query('INSERT INTO {troll_blacklist} (net, bcast) VALUES (%f, %f)', $net, $bcast);
595          $i++;          $i++;
596        }        }
597      }      }
# Line 655  function troll_blacklist_search($ip_addr Line 655  function troll_blacklist_search($ip_addr
655      $sql = "SELECT net, bcast FROM {troll_blacklist}";      $sql = "SELECT net, bcast FROM {troll_blacklist}";
656    }    }
657    else {    else {
658      $sql = "SELECT net, bcast FROM {troll_blacklist} WHERE net <= %d AND bcast >= %d";      $sql = "SELECT net, bcast FROM {troll_blacklist} WHERE net <= %f AND bcast >= %f";
659      $longip = _troll_longip($ip_address);      $longip = _troll_longip($ip_address);
660    }    }
661    $headers = array(    $headers = array(
# Line 767  function troll_whitelist_form_submit($fo Line 767  function troll_whitelist_form_submit($fo
767      $longip2 = $temp;      $longip2 = $temp;
768      unset($temp);      unset($temp);
769    }    }
770    db_query("REPLACE INTO {troll_whitelist} (net, bcast) VALUES (%d, %d)", $longip1, $longip2);    db_query("REPLACE INTO {troll_whitelist} (net, bcast) VALUES (%f, %f)", $longip1, $longip2);
771    drupal_set_message(t('IP range %ip1 to %ip2 whitelisted.', array('%ip1' => long2ip($longip1), '%ip2' => long2ip($longip2))));    drupal_set_message(t('IP range %ip1 to %ip2 whitelisted.', array('%ip1' => long2ip($longip1), '%ip2' => long2ip($longip2))));
772  }  }
773    
# Line 951  function troll_confirm_delete_ip_form_su Line 951  function troll_confirm_delete_ip_form_su
951   * @param integer $bcast IP in long format   * @param integer $bcast IP in long format
952   */   */
953  function troll_confirm_delete_black_block_form($net, $bcast) {  function troll_confirm_delete_black_block_form($net, $bcast) {
954    $result = db_result(db_query('SELECT COUNT(net) FROM {troll_blacklist} WHERE net = %d AND bcast = %d', $net, $bcast));    $result = db_result(db_query('SELECT COUNT(net) FROM {troll_blacklist} WHERE net = %f AND bcast = %f', $net, $bcast));
955    if (empty($result)) {    if (empty($result)) {
956      drupal_set_message(t('No such IP range found in the database.'));      drupal_set_message(t('No such IP range found in the database.'));
957      drupal_goto('admin/user/troll/ip_blacklist/search');      drupal_goto('admin/user/troll/ip_blacklist/search');
# Line 990  function troll_confirm_delete_black_bloc Line 990  function troll_confirm_delete_black_bloc
990   * @param integer $bcast IP in long format   * @param integer $bcast IP in long format
991   */   */
992  function troll_confirm_delete_white_block_form($net, $bcast) {  function troll_confirm_delete_white_block_form($net, $bcast) {
993    $result = db_result(db_query('SELECT COUNT(net) FROM {troll_whitelist} WHERE net = %d AND bcast = %d', $net, $bcast));    $result = db_result(db_query('SELECT COUNT(net) FROM {troll_whitelist} WHERE net = %f AND bcast = %f', $net, $bcast));
994    if (empty($result)) {    if (empty($result)) {
995      drupal_set_message(t('No such IP range found in the database.'));      drupal_set_message(t('No such IP range found in the database.'));
996      drupal_goto('admin/user/troll/ip_blacklist/whitelist');      drupal_goto('admin/user/troll/ip_blacklist/whitelist');
# Line 1290  function troll_remove_ip($iid) { Line 1290  function troll_remove_ip($iid) {
1290   * @param $edit array   * @param $edit array
1291   */   */
1292  function troll_remove_blacklist($net, $bcast) {  function troll_remove_blacklist($net, $bcast) {
1293    if (db_query('DELETE FROM {troll_blacklist} WHERE net = %d AND bcast = %d', $net, $bcast)) {    if (db_query('DELETE FROM {troll_blacklist} WHERE net = %f AND bcast = %f', $net, $bcast)) {
1294      drupal_set_message(t('Blacklist block removed.'));      drupal_set_message(t('Blacklist block removed.'));
1295    }    }
1296    else {    else {
# Line 1304  function troll_remove_blacklist($net, $b Line 1304  function troll_remove_blacklist($net, $b
1304   * @param $edit array   * @param $edit array
1305   */   */
1306  function troll_remove_whitelist($net, $bcast) {  function troll_remove_whitelist($net, $bcast) {
1307    if (db_query('DELETE FROM {troll_whitelist} WHERE net = %d AND bcast = %d', $net, $bcast)) {    if (db_query('DELETE FROM {troll_whitelist} WHERE net = %f AND bcast = %f', $net, $bcast)) {
1308      drupal_set_message(t('IP whitelist removed.'));      drupal_set_message(t('IP whitelist removed.'));
1309    }    }
1310    else {    else {
# Line 1400  function troll_is_blacklisted() { Line 1400  function troll_is_blacklisted() {
1400      return FALSE;      return FALSE;
1401    }    }
1402    else {    else {
1403      $blacklisted = db_result(db_query('SELECT COUNT(b.net) FROM {troll_blacklist} b WHERE b.net <= %d AND b.bcast >= %d', $longip, $longip));      $whitelisted = (bool)db_result(db_query_range('SELECT 1 FROM {troll_whitelist} w WHERE w.net <= %f AND w.bcast >= %f', $longip, $longip, 0, 1));
1404      $whitelisted = db_result(db_query('SELECT COUNT(w.net) FROM {troll_whitelist} w WHERE w.net <= %d AND w.bcast >= %d', $longip, $longip));      if ($whitelisted) {
1405      return $whitelisted ? FALSE : $blacklisted;        return FALSE;
1406        }
1407        return (bool)db_result(db_query_range('SELECT 1 FROM {troll_blacklist} b WHERE b.net <= %f AND b.bcast >= %f', $longip, $longip, 0, 1));
1408    }    }
1409  }  }
1410    

Legend:
Removed from v.1.26.2.11.2.6  
changed lines
  Added in v.1.26.2.11.2.7

  ViewVC Help
Powered by ViewVC 1.1.2