Only in ip2cc-new/: ip-to-country.csv diff -ur ip2cc/ip2cc.info ip2cc-new/ip2cc.info --- ip2cc/ip2cc.info 2007-12-03 07:05:57.000000000 -0500 +++ ip2cc-new/ip2cc.info 2008-02-16 12:03:19.000000000 -0500 @@ -1,9 +1,11 @@ ; $Id: ip2cc.info,v 1.3 2007/10/25 16:53:36 sugree Exp $ name = IP to Country description = Provide APIs for converting IP to Country +core = 6.x ; Information added by drupal.org packaging script on 2007-12-03 version = "HEAD" +core = "6.x" project = "ip2cc" -datestamp = "1196683557" +datestamp = "1196683599 diff -ur ip2cc/ip2cc.module ip2cc-new/ip2cc.module --- ip2cc/ip2cc.module 2007-10-25 12:53:36.000000000 -0400 +++ ip2cc-new/ip2cc.module 2008-02-16 12:23:51.000000000 -0500 @@ -10,8 +10,8 @@ /** * Implementation of hook_help(). */ -function ip2cc_help($section = 'admin/help#ip2cc') { - switch ($section) { +function ip2cc_help($path = 'admin/help#ip2cc', $arg) { + switch ($path) { case 'admin/modules#description': return t('Adds support for ip-to-country.com for other modules.'); break; @@ -93,13 +93,13 @@ '#type' => 'checkbox', '#title' => t('Display in node feeds (optional)'), '#return_value' => '1', - '#default_value' => variable_get('ip2cc_node',0), + '#default_value' => variable_get('ip2cc_node', 0), ); $form['ip2cc_placement']['ip2cc_comment'] = array( '#type' => 'checkbox', '#title' => t('Display in comment feeds (optional)'), '#return_value' => '1', - '#default_value' => variable_get('ip2cc_comment',0), + '#default_value' => variable_get('ip2cc_comment', 0), ); return system_settings_form($form); @@ -148,12 +148,12 @@ return $form; } -function ip2cc_update_form_submit($form_id, $form_values) { - if ($form_values['flush']) { +function ip2cc_update_form_submit($form, &$form_state) { + if ($form_state['values']['flush']) { db_query("DELETE FROM {ip2cc}"); } - _ip2cc_batch_insert("ipdb.mysql", (int)$form_values['start'], (int)$form_values['end']); - drupal_set_message(t("Successfully updated entry %start to %end", array('%start' => $form_values['start'], '%end' => $form_values['end']))); + _ip2cc_batch_insert("ipdb.mysql", (int)$form_state['values']['start'], (int)$form_state['values']['end']); + drupal_set_message(t("Successfully updated entry %start to %end", array('%start' => $form_state['values']['start'], '%end' => $form_state['values']['end']))); } /** @@ -182,10 +182,10 @@ function ip2cc_set_node($node) { $node_count = db_result(db_query("SELECT COUNT(hostname) FROM {ip2cc_node} WHERE nid = %d", $node->nid)); if ($node_count == 0) { - db_query("INSERT INTO {ip2cc_node} (nid, hostname) VALUES (%d, '%s')", $node->nid, $_SERVER['REMOTE_ADDR']); + db_query("INSERT INTO {ip2cc_node} (nid, hostname) VALUES (%d, '%s')", $node->nid, ip_address()); } else { - db_query("UPDATE {ip2cc_node} SET hostname = '%s' WHERE nid = %d", $_SERVER['REMOTE_ADDR'], $node->nid); + db_query("UPDATE {ip2cc_node} SET hostname = '%s' WHERE nid = %d", ip_address(), $node->nid); } } @@ -220,7 +220,7 @@ function ip2cc_get_country($addr) { $ip = _ip2cc_inet_aton($addr); - $result = db_query("SELECT i.*,c.* FROM {ip2cc} i LEFT JOIN {iso3166} c ON i.country_code = c.country_code2 WHERE ip_from <= %s AND ip_to >= %s",$ip,$ip); + $result = db_query("SELECT i.*, c.* FROM {ip2cc} i LEFT JOIN {iso3166} c ON i.country_code = c.country_code2 WHERE ip_from <= %s AND ip_to >= %s", $ip, $ip); while ($co = db_fetch_object($result)) { $co->ip = $addr; return $co; @@ -231,7 +231,7 @@ function ip2cc_get_country_json() { $addr = arg(3); if (empty($addr)) { - $addr = $_SERVER['REMOTE_ADDR']; + $addr = ip_address(); } $country = ip2cc_get_country($addr); print drupal_to_js($country); @@ -255,13 +255,14 @@ if (user_access('view network name')) { $title .= " $co->net_name"; } - } else { + } + else { $cc = 'unknown'; $title = (empty($addr))?'unknown':$addr; } - $path = drupal_get_path('module','ip2cc') . "/flags/$cc.png"; + $path = drupal_get_path('module', 'ip2cc') ."/flags/$cc.png"; $attribs = array('width' => 14, height => 14); - return theme('image',$path,$cc,$title,$attribs,FALSE); + return theme('image', $path, $cc, $title, $attribs, FALSE); } function theme_ip2cc_ip_flag($addr) { @@ -291,7 +292,7 @@ function _ip2cc_batch_count($filename) { $count = 0; - if ($fd = fopen(drupal_get_path('module','ip2cc').'/'.$filename, 'r')) { + if ($fd = fopen(drupal_get_path('module', 'ip2cc') .'/'. $filename, 'r')) { while (!feof($fd)) { $line = fgets($fd); $count++; @@ -301,14 +302,14 @@ return $count; } -function _ip2cc_batch_insert($filename,$start=0,$end=-1) { - if ($fd = fopen(drupal_get_path('module','ip2cc').'/'.$filename, 'r')) { - for($i=0; $i<$start; $i++) { +function _ip2cc_batch_insert($filename, $start = 0, $end = -1) { + if ($fd = fopen(drupal_get_path('module', 'ip2cc') .'/'. $filename, 'r')) { + for ($i = 0; $i < $start; $i++) { $line = fgets($fd); } $i = $start; while (($i <= $end || $end == -1) && !feof($fd)) { - $line = substr(rtrim(fgets($fd)),0,-1); + $line = substr(rtrim(fgets($fd)), 0, -1); db_query($line); $line = NULL; $i++; @@ -317,4 +318,3 @@ } } -?>