<?php
// $Id$

/**
 * @file
 * Custom functions for this site.
 */

/**
 * Valid permissions for this module
 * Impements hook_perm().
 * @return array An array of valid permissions for the Country Ban module
 */
function countryban_perm() {
  return array('access countryban content');
} // function countryban_perm()

/**
 * Impements hook_admin().
 */
function countryban_admin() {
  $form = array();
  $form['countryban_readonly'] = array(
    '#type' => 'textfield',
    '#title' => t('Read Only Message'),
    '#default_value' => variable_get('countryban_readonly', "Accounts Disabled."),
    '#size' => 60,
    '#weight' => -10,
    '#maxlength' => 128,
    '#required' => TRUE,
);

$form['countryban_completeban'] = array(
  '#type' => 'textfield',
  '#title' => t('Complete Ban Message'),
  '#default_value' => variable_get('countryban_completeban', "Access Denied."),
  '#size' => 60,
  '#weight' => -9,
  '#maxlength' => 128,
  '#required' => TRUE,
);

$form['refresh_instructions'] = array(
  '#weight' => -8,
  '#value' =>  t('The ip-to-country.csv file *must* be manually downloaded from <a href=http://ip-to-country.webhosting.info/node/view/6>http://ip-to-country.webhosting.info/node/view/6</a> 
	  and added to the Country Ban module directory.  Click the button below to refresh your database after the file has been added.<br />
		<br />
		The ip-to-country.csv file is maintained by Webhosting.info.  Feel free to refresh your data, using this same method, with their future releases in order to maintain
		the most up-to-date ip to country traceability.<br /><br />'),
);

$form['upload'] = array(
  '#type' => 'submit',
  '#value' => t('Refresh CSV File'),
  '#submit' => array('CSV_submit'),
  '#weight' => -7,
);

$form['countryban_afghanistan'] = array('#type' => 'radios', '#title' => t('Afghanistan'), '#default_value' => variable_get('countryban_afghanistan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_albania'] = array('#type' => 'radios', '#title' => t('Albania'), '#default_value' => variable_get('countryban_albania', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_algeria'] = array('#type' => 'radios', '#title' => t('Algeria'), '#default_value' => variable_get('countryban_algeria', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_americansamoa'] = array('#type' => 'radios', '#title' => t('American Samoa'), '#default_value' => variable_get('countryban_americansamoa', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_andorra'] = array('#type' => 'radios', '#title' => t('Andorra'), '#default_value' => variable_get('countryban_andorra', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_angola'] = array('#type' => 'radios', '#title' => t('Angola'), '#default_value' => variable_get('countryban_angola', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_anguilla'] = array('#type' => 'radios', '#title' => t('Anguilla'), '#default_value' => variable_get('countryban_anguilla', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_antarctica'] = array('#type' => 'radios', '#title' => t('Antarctica'), '#default_value' => variable_get('countryban_antarctica', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_antiguaandbarbuda'] = array('#type' => 'radios', '#title' => t('Antigua And Barbuda'), '#default_value' => variable_get('countryban_antiguaandbarbuda', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_argentina'] = array('#type' => 'radios', '#title' => t('Argentina'), '#default_value' => variable_get('countryban_argentina', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_armenia'] = array('#type' => 'radios', '#title' => t('Armenia'), '#default_value' => variable_get('countryban_armenia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_aruba'] = array('#type' => 'radios', '#title' => t('Aruba'), '#default_value' => variable_get('countryban_aruba', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_australia'] = array('#type' => 'radios', '#title' => t('Australia'), '#default_value' => variable_get('countryban_australia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_austria'] = array('#type' => 'radios', '#title' => t('Austria'), '#default_value' => variable_get('countryban_austria', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_azerbaijan'] = array('#type' => 'radios', '#title' => t('Azerbaijan'), '#default_value' => variable_get('countryban_azerbaijan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bahamas'] = array('#type' => 'radios', '#title' => t('Bahamas'), '#default_value' => variable_get('countryban_bahamas', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bahrain'] = array('#type' => 'radios', '#title' => t('Bahrain'), '#default_value' => variable_get('countryban_bahrain', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bangladesh'] = array('#type' => 'radios', '#title' => t('Bangladesh'), '#default_value' => variable_get('countryban_bangladesh', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_barbados'] = array('#type' => 'radios', '#title' => t('Barbados'), '#default_value' => variable_get('countryban_barbados', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_belarus'] = array('#type' => 'radios', '#title' => t('Belarus'), '#default_value' => variable_get('countryban_belarus', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_belgium'] = array('#type' => 'radios', '#title' => t('Belgium'), '#default_value' => variable_get('countryban_belgium', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_belize'] = array('#type' => 'radios', '#title' => t('Belize'), '#default_value' => variable_get('countryban_belize', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_benin'] = array('#type' => 'radios', '#title' => t('Benin'), '#default_value' => variable_get('countryban_benin', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bermuda'] = array('#type' => 'radios', '#title' => t('Bermuda'), '#default_value' => variable_get('countryban_bermuda', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bhutan'] = array('#type' => 'radios', '#title' => t('Bhutan'), '#default_value' => variable_get('countryban_bhutan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bolivia'] = array('#type' => 'radios', '#title' => t('Bolivia'), '#default_value' => variable_get('countryban_bolivia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bosniaandherzegovina'] = array('#type' => 'radios', '#title' => t('Bosnia And Herzegovina'), '#default_value' => variable_get('countryban_bosniaandherzegovina', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_botswana'] = array('#type' => 'radios', '#title' => t('Botswana'), '#default_value' => variable_get('countryban_botswana', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bouvetisland'] = array('#type' => 'radios', '#title' => t('Bouvet Island'), '#default_value' => variable_get('countryban_bouvetisland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_brazil'] = array('#type' => 'radios', '#title' => t('Brazil'), '#default_value' => variable_get('countryban_brazil', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_britishindianoceanterritory'] = array('#type' => 'radios', '#title' => t('British Indian Ocean Territory'), '#default_value' => variable_get('countryban_britishindianoceanterritory', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bruneidarussalam'] = array('#type' => 'radios', '#title' => t('Brunei Darussalam'), '#default_value' => variable_get('countryban_bruneidarussalam', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_bulgaria'] = array('#type' => 'radios', '#title' => t('Bulgaria'), '#default_value' => variable_get('countryban_bulgaria', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_burkinafaso'] = array('#type' => 'radios', '#title' => t('Burkina Faso'), '#default_value' => variable_get('countryban_burkinafaso', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_burundi'] = array('#type' => 'radios', '#title' => t('Burundi'), '#default_value' => variable_get('countryban_burundi', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_cambodia'] = array('#type' => 'radios', '#title' => t('Cambodia'), '#default_value' => variable_get('countryban_cambodia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_cameroon'] = array('#type' => 'radios', '#title' => t('Cameroon'), '#default_value' => variable_get('countryban_cameroon', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_canada'] = array('#type' => 'radios', '#title' => t('Canada'), '#default_value' => variable_get('countryban_canada', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_capeverde'] = array('#type' => 'radios', '#title' => t('Cape Verde'), '#default_value' => variable_get('countryban_capeverde', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_caymanislands'] = array('#type' => 'radios', '#title' => t('Cayman Islands'), '#default_value' => variable_get('countryban_caymanislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_centralafricanrepublic'] = array('#type' => 'radios', '#title' => t('Central African Republic'), '#default_value' => variable_get('countryban_centralafricanrepublic', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_chad'] = array('#type' => 'radios', '#title' => t('Chad'), '#default_value' => variable_get('countryban_chad', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_chile'] = array('#type' => 'radios', '#title' => t('Chile'), '#default_value' => variable_get('countryban_chile', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_china'] = array('#type' => 'radios', '#title' => t('China'), '#default_value' => variable_get('countryban_china', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_colombia'] = array('#type' => 'radios', '#title' => t('Colombia'), '#default_value' => variable_get('countryban_colombia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_comoros'] = array('#type' => 'radios', '#title' => t('Comoros'), '#default_value' => variable_get('countryban_comoros', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_congo'] = array('#type' => 'radios', '#title' => t('Congo'), '#default_value' => variable_get('countryban_congo', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_cookislands'] = array('#type' => 'radios', '#title' => t('Cook Islands'), '#default_value' => variable_get('countryban_cookislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_costarica'] = array('#type' => 'radios', '#title' => t('Costa Rica'), '#default_value' => variable_get('countryban_costarica', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_cotedivoire'] = array('#type' => 'radios', '#title' => t('Cote D\'ivoire'), '#default_value' => variable_get('countryban_cotedivoire', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_croatia'] = array('#type' => 'radios', '#title' => t('Croatia'), '#default_value' => variable_get('countryban_croatia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_cuba'] = array('#type' => 'radios', '#title' => t('Cuba'), '#default_value' => variable_get('countryban_cuba', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_cyprus'] = array('#type' => 'radios', '#title' => t('Cyprus'), '#default_value' => variable_get('countryban_cyprus', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_czechrepublic'] = array('#type' => 'radios', '#title' => t('Czech Republic'), '#default_value' => variable_get('countryban_czechrepublic', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_democraticpeoplesrepublicofkorea'] = array('#type' => 'radios', '#title' => t('Democratic People\'s Republic Of Korea'), '#default_value' => variable_get('countryban_democraticpeoplesrepublicofkorea', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_denmark'] = array('#type' => 'radios', '#title' => t('Denmark'), '#default_value' => variable_get('countryban_denmark', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_djibouti'] = array('#type' => 'radios', '#title' => t('Djibouti'), '#default_value' => variable_get('countryban_djibouti', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_dominica'] = array('#type' => 'radios', '#title' => t('Dominica'), '#default_value' => variable_get('countryban_dominica', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_dominicanrepublic'] = array('#type' => 'radios', '#title' => t('Dominican Republic'), '#default_value' => variable_get('countryban_dominicanrepublic', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_ecuador'] = array('#type' => 'radios', '#title' => t('Ecuador'), '#default_value' => variable_get('countryban_ecuador', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_egypt'] = array('#type' => 'radios', '#title' => t('Egypt'), '#default_value' => variable_get('countryban_egypt', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_elsalvador'] = array('#type' => 'radios', '#title' => t('El Salvador'), '#default_value' => variable_get('countryban_elsalvador', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_equatorialguinea'] = array('#type' => 'radios', '#title' => t('Equatorial Guinea'), '#default_value' => variable_get('countryban_equatorialguinea', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_eritrea'] = array('#type' => 'radios', '#title' => t('Eritrea'), '#default_value' => variable_get('countryban_eritrea', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_estonia'] = array('#type' => 'radios', '#title' => t('Estonia'), '#default_value' => variable_get('countryban_estonia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_ethiopia'] = array('#type' => 'radios', '#title' => t('Ethiopia'), '#default_value' => variable_get('countryban_ethiopia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_falklandislands(malvinas)'] = array('#type' => 'radios', '#title' => t('Falkland Islands (malvinas)'), '#default_value' => variable_get('countryban_falklandislands(malvinas)', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_faroeislands'] = array('#type' => 'radios', '#title' => t('Faroe Islands'), '#default_value' => variable_get('countryban_faroeislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_federatedstatesofmicronesia'] = array('#type' => 'radios', '#title' => t('Federated States Of Micronesia'), '#default_value' => variable_get('countryban_federatedstatesofmicronesia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_fiji'] = array('#type' => 'radios', '#title' => t('Fiji'), '#default_value' => variable_get('countryban_fiji', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_finland'] = array('#type' => 'radios', '#title' => t('Finland'), '#default_value' => variable_get('countryban_finland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_france'] = array('#type' => 'radios', '#title' => t('France'), '#default_value' => variable_get('countryban_france', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_frenchguiana'] = array('#type' => 'radios', '#title' => t('French Guiana'), '#default_value' => variable_get('countryban_frenchguiana', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_frenchpolynesia'] = array('#type' => 'radios', '#title' => t('French Polynesia'), '#default_value' => variable_get('countryban_frenchpolynesia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_frenchsouthernterritories'] = array('#type' => 'radios', '#title' => t('French Southern Territories'), '#default_value' => variable_get('countryban_frenchsouthernterritories', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_gabon'] = array('#type' => 'radios', '#title' => t('Gabon'), '#default_value' => variable_get('countryban_gabon', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_gambia'] = array('#type' => 'radios', '#title' => t('Gambia'), '#default_value' => variable_get('countryban_gambia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_georgia'] = array('#type' => 'radios', '#title' => t('Georgia'), '#default_value' => variable_get('countryban_georgia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_germany'] = array('#type' => 'radios', '#title' => t('Germany'), '#default_value' => variable_get('countryban_germany', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_ghana'] = array('#type' => 'radios', '#title' => t('Ghana'), '#default_value' => variable_get('countryban_ghana', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_gibraltar'] = array('#type' => 'radios', '#title' => t('Gibraltar'), '#default_value' => variable_get('countryban_gibraltar', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_greece'] = array('#type' => 'radios', '#title' => t('Greece'), '#default_value' => variable_get('countryban_greece', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_greenland'] = array('#type' => 'radios', '#title' => t('Greenland'), '#default_value' => variable_get('countryban_greenland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_grenada'] = array('#type' => 'radios', '#title' => t('Grenada'), '#default_value' => variable_get('countryban_grenada', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_guadeloupe'] = array('#type' => 'radios', '#title' => t('Guadeloupe'), '#default_value' => variable_get('countryban_guadeloupe', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_guam'] = array('#type' => 'radios', '#title' => t('Guam'), '#default_value' => variable_get('countryban_guam', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_guatemala'] = array('#type' => 'radios', '#title' => t('Guatemala'), '#default_value' => variable_get('countryban_guatemala', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_guinea'] = array('#type' => 'radios', '#title' => t('Guinea'), '#default_value' => variable_get('countryban_guinea', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_guinea-bissau'] = array('#type' => 'radios', '#title' => t('Guinea-bissau'), '#default_value' => variable_get('countryban_guinea-bissau', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_guyana'] = array('#type' => 'radios', '#title' => t('Guyana'), '#default_value' => variable_get('countryban_guyana', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_haiti'] = array('#type' => 'radios', '#title' => t('Haiti'), '#default_value' => variable_get('countryban_haiti', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_holysee(vaticancitystate)'] = array('#type' => 'radios', '#title' => t('Holy See (vatican City State)'), '#default_value' => variable_get('countryban_holysee(vaticancitystate)', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_honduras'] = array('#type' => 'radios', '#title' => t('Honduras'), '#default_value' => variable_get('countryban_honduras', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_hongkong'] = array('#type' => 'radios', '#title' => t('Hong Kong'), '#default_value' => variable_get('countryban_hongkong', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_hungary'] = array('#type' => 'radios', '#title' => t('Hungary'), '#default_value' => variable_get('countryban_hungary', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_iceland'] = array('#type' => 'radios', '#title' => t('Iceland'), '#default_value' => variable_get('countryban_iceland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_india'] = array('#type' => 'radios', '#title' => t('India'), '#default_value' => variable_get('countryban_india', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_indonesia'] = array('#type' => 'radios', '#title' => t('Indonesia'), '#default_value' => variable_get('countryban_indonesia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_iraq'] = array('#type' => 'radios', '#title' => t('Iraq'), '#default_value' => variable_get('countryban_iraq', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_ireland'] = array('#type' => 'radios', '#title' => t('Ireland'), '#default_value' => variable_get('countryban_ireland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_islamicrepublicofiran'] = array('#type' => 'radios', '#title' => t('Islamic Republic Of Iran'), '#default_value' => variable_get('countryban_islamicrepublicofiran', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_israel'] = array('#type' => 'radios', '#title' => t('Israel'), '#default_value' => variable_get('countryban_israel', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_italy'] = array('#type' => 'radios', '#title' => t('Italy'), '#default_value' => variable_get('countryban_italy', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_jamaica'] = array('#type' => 'radios', '#title' => t('Jamaica'), '#default_value' => variable_get('countryban_jamaica', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_japan'] = array('#type' => 'radios', '#title' => t('Japan'), '#default_value' => variable_get('countryban_japan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_jordan'] = array('#type' => 'radios', '#title' => t('Jordan'), '#default_value' => variable_get('countryban_jordan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_kazakhstan'] = array('#type' => 'radios', '#title' => t('Kazakhstan'), '#default_value' => variable_get('countryban_kazakhstan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_kenya'] = array('#type' => 'radios', '#title' => t('Kenya'), '#default_value' => variable_get('countryban_kenya', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_kiribati'] = array('#type' => 'radios', '#title' => t('Kiribati'), '#default_value' => variable_get('countryban_kiribati', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_kuwait'] = array('#type' => 'radios', '#title' => t('Kuwait'), '#default_value' => variable_get('countryban_kuwait', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_kyrgyzstan'] = array('#type' => 'radios', '#title' => t('Kyrgyzstan'), '#default_value' => variable_get('countryban_kyrgyzstan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_laopeoplesdemocraticrepublic'] = array('#type' => 'radios', '#title' => t('Lao People\'s Democratic Republic'), '#default_value' => variable_get('countryban_laopeoplesdemocraticrepublic', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_latvia'] = array('#type' => 'radios', '#title' => t('Latvia'), '#default_value' => variable_get('countryban_latvia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_lebanon'] = array('#type' => 'radios', '#title' => t('Lebanon'), '#default_value' => variable_get('countryban_lebanon', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_lesotho'] = array('#type' => 'radios', '#title' => t('Lesotho'), '#default_value' => variable_get('countryban_lesotho', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_liberia'] = array('#type' => 'radios', '#title' => t('Liberia'), '#default_value' => variable_get('countryban_liberia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_libyanarabjamahiriya'] = array('#type' => 'radios', '#title' => t('Libyan Arab Jamahiriya'), '#default_value' => variable_get('countryban_libyanarabjamahiriya', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_liechtenstein'] = array('#type' => 'radios', '#title' => t('Liechtenstein'), '#default_value' => variable_get('countryban_liechtenstein', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_lithuania'] = array('#type' => 'radios', '#title' => t('Lithuania'), '#default_value' => variable_get('countryban_lithuania', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_luxembourg'] = array('#type' => 'radios', '#title' => t('Luxembourg'), '#default_value' => variable_get('countryban_luxembourg', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_macao'] = array('#type' => 'radios', '#title' => t('Macao'), '#default_value' => variable_get('countryban_macao', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_madagascar'] = array('#type' => 'radios', '#title' => t('Madagascar'), '#default_value' => variable_get('countryban_madagascar', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_malawi'] = array('#type' => 'radios', '#title' => t('Malawi'), '#default_value' => variable_get('countryban_malawi', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_malaysia'] = array('#type' => 'radios', '#title' => t('Malaysia'), '#default_value' => variable_get('countryban_malaysia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_maldives'] = array('#type' => 'radios', '#title' => t('Maldives'), '#default_value' => variable_get('countryban_maldives', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mali'] = array('#type' => 'radios', '#title' => t('Mali'), '#default_value' => variable_get('countryban_mali', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_malta'] = array('#type' => 'radios', '#title' => t('Malta'), '#default_value' => variable_get('countryban_malta', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_marshallislands'] = array('#type' => 'radios', '#title' => t('Marshall Islands'), '#default_value' => variable_get('countryban_marshallislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_martinique'] = array('#type' => 'radios', '#title' => t('Martinique'), '#default_value' => variable_get('countryban_martinique', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mauritania'] = array('#type' => 'radios', '#title' => t('Mauritania'), '#default_value' => variable_get('countryban_mauritania', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mauritius'] = array('#type' => 'radios', '#title' => t('Mauritius'), '#default_value' => variable_get('countryban_mauritius', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mayotte'] = array('#type' => 'radios', '#title' => t('Mayotte'), '#default_value' => variable_get('countryban_mayotte', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mexico'] = array('#type' => 'radios', '#title' => t('Mexico'), '#default_value' => variable_get('countryban_mexico', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_monaco'] = array('#type' => 'radios', '#title' => t('Monaco'), '#default_value' => variable_get('countryban_monaco', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mongolia'] = array('#type' => 'radios', '#title' => t('Mongolia'), '#default_value' => variable_get('countryban_mongolia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_montserrat'] = array('#type' => 'radios', '#title' => t('Montserrat'), '#default_value' => variable_get('countryban_montserrat', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_morocco'] = array('#type' => 'radios', '#title' => t('Morocco'), '#default_value' => variable_get('countryban_morocco', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_mozambique'] = array('#type' => 'radios', '#title' => t('Mozambique'), '#default_value' => variable_get('countryban_mozambique', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_myanmar'] = array('#type' => 'radios', '#title' => t('Myanmar'), '#default_value' => variable_get('countryban_myanmar', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_namibia'] = array('#type' => 'radios', '#title' => t('Namibia'), '#default_value' => variable_get('countryban_namibia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_nauru'] = array('#type' => 'radios', '#title' => t('Nauru'), '#default_value' => variable_get('countryban_nauru', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_nepal'] = array('#type' => 'radios', '#title' => t('Nepal'), '#default_value' => variable_get('countryban_nepal', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_netherlands'] = array('#type' => 'radios', '#title' => t('Netherlands'), '#default_value' => variable_get('countryban_netherlands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_netherlandsantilles'] = array('#type' => 'radios', '#title' => t('Netherlands Antilles'), '#default_value' => variable_get('countryban_netherlandsantilles', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_newcaledonia'] = array('#type' => 'radios', '#title' => t('New Caledonia'), '#default_value' => variable_get('countryban_newcaledonia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_newzealand'] = array('#type' => 'radios', '#title' => t('New Zealand'), '#default_value' => variable_get('countryban_newzealand', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_nicaragua'] = array('#type' => 'radios', '#title' => t('Nicaragua'), '#default_value' => variable_get('countryban_nicaragua', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_niger'] = array('#type' => 'radios', '#title' => t('Niger'), '#default_value' => variable_get('countryban_niger', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_nigeria'] = array('#type' => 'radios', '#title' => t('Nigeria'), '#default_value' => variable_get('countryban_nigeria', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_niue'] = array('#type' => 'radios', '#title' => t('Niue'), '#default_value' => variable_get('countryban_niue', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_norfolkisland'] = array('#type' => 'radios', '#title' => t('Norfolk Island'), '#default_value' => variable_get('countryban_norfolkisland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_northernmarianaislands'] = array('#type' => 'radios', '#title' => t('Northern Mariana Islands'), '#default_value' => variable_get('countryban_northernmarianaislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_norway'] = array('#type' => 'radios', '#title' => t('Norway'), '#default_value' => variable_get('countryban_norway', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_oman'] = array('#type' => 'radios', '#title' => t('Oman'), '#default_value' => variable_get('countryban_oman', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_pakistan'] = array('#type' => 'radios', '#title' => t('Pakistan'), '#default_value' => variable_get('countryban_pakistan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_palau'] = array('#type' => 'radios', '#title' => t('Palau'), '#default_value' => variable_get('countryban_palau', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_palestinianterritoryoccupied'] = array('#type' => 'radios', '#title' => t('Palestinian Territory, Occupied'), '#default_value' => variable_get('countryban_palestinianterritoryoccupied', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_panama'] = array('#type' => 'radios', '#title' => t('Panama'), '#default_value' => variable_get('countryban_panama', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_papuanewguinea'] = array('#type' => 'radios', '#title' => t('Papua New Guinea'), '#default_value' => variable_get('countryban_papuanewguinea', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_paraguay'] = array('#type' => 'radios', '#title' => t('Paraguay'), '#default_value' => variable_get('countryban_paraguay', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_peru'] = array('#type' => 'radios', '#title' => t('Peru'), '#default_value' => variable_get('countryban_peru', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_philippines'] = array('#type' => 'radios', '#title' => t('Philippines'), '#default_value' => variable_get('countryban_philippines', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_poland'] = array('#type' => 'radios', '#title' => t('Poland'), '#default_value' => variable_get('countryban_poland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_portugal'] = array('#type' => 'radios', '#title' => t('Portugal'), '#default_value' => variable_get('countryban_portugal', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_puertorico'] = array('#type' => 'radios', '#title' => t('Puerto Rico'), '#default_value' => variable_get('countryban_puertorico', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_qatar'] = array('#type' => 'radios', '#title' => t('Qatar'), '#default_value' => variable_get('countryban_qatar', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_republicofkorea'] = array('#type' => 'radios', '#title' => t('Republic Of Korea'), '#default_value' => variable_get('countryban_republicofkorea', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_republicofmoldova'] = array('#type' => 'radios', '#title' => t('Republic Of Moldova'), '#default_value' => variable_get('countryban_republicofmoldova', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_reunion'] = array('#type' => 'radios', '#title' => t('Reunion'), '#default_value' => variable_get('countryban_reunion', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_romania'] = array('#type' => 'radios', '#title' => t('Romania'), '#default_value' => variable_get('countryban_romania', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_russianfederation'] = array('#type' => 'radios', '#title' => t('Russian Federation'), '#default_value' => variable_get('countryban_russianfederation', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_rwanda'] = array('#type' => 'radios', '#title' => t('Rwanda'), '#default_value' => variable_get('countryban_rwanda', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_saintkittsandnevis'] = array('#type' => 'radios', '#title' => t('Saint Kitts And Nevis'), '#default_value' => variable_get('countryban_saintkittsandnevis', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_saintlucia'] = array('#type' => 'radios', '#title' => t('Saint Lucia'), '#default_value' => variable_get('countryban_saintlucia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_saintpierreandmiquelon'] = array('#type' => 'radios', '#title' => t('Saint Pierre And Miquelon'), '#default_value' => variable_get('countryban_saintpierreandmiquelon', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_saintvincentandthegrenadines'] = array('#type' => 'radios', '#title' => t('Saint Vincent And The Grenadines'), '#default_value' => variable_get('countryban_saintvincentandthegrenadines', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_samoa'] = array('#type' => 'radios', '#title' => t('Samoa'), '#default_value' => variable_get('countryban_samoa', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_sanmarino'] = array('#type' => 'radios', '#title' => t('San Marino'), '#default_value' => variable_get('countryban_sanmarino', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_saotomeandprincipe'] = array('#type' => 'radios', '#title' => t('Sao Tome And Principe'), '#default_value' => variable_get('countryban_saotomeandprincipe', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_saudiarabia'] = array('#type' => 'radios', '#title' => t('Saudi Arabia'), '#default_value' => variable_get('countryban_saudiarabia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_senegal'] = array('#type' => 'radios', '#title' => t('Senegal'), '#default_value' => variable_get('countryban_senegal', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_serbiaandmontenegro'] = array('#type' => 'radios', '#title' => t('Serbia And Montenegro'), '#default_value' => variable_get('countryban_serbiaandmontenegro', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_seychelles'] = array('#type' => 'radios', '#title' => t('Seychelles'), '#default_value' => variable_get('countryban_seychelles', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_sierraleone'] = array('#type' => 'radios', '#title' => t('Sierra Leone'), '#default_value' => variable_get('countryban_sierraleone', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_singapore'] = array('#type' => 'radios', '#title' => t('Singapore'), '#default_value' => variable_get('countryban_singapore', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_slovakia'] = array('#type' => 'radios', '#title' => t('Slovakia'), '#default_value' => variable_get('countryban_slovakia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_slovenia'] = array('#type' => 'radios', '#title' => t('Slovenia'), '#default_value' => variable_get('countryban_slovenia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_solomonislands'] = array('#type' => 'radios', '#title' => t('Solomon Islands'), '#default_value' => variable_get('countryban_solomonislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_somalia'] = array('#type' => 'radios', '#title' => t('Somalia'), '#default_value' => variable_get('countryban_somalia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_southafrica'] = array('#type' => 'radios', '#title' => t('South Africa'), '#default_value' => variable_get('countryban_southafrica', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_southgeorgiaandthesouthsandwichislands'] = array('#type' => 'radios', '#title' => t('South Georgia And The South Sandwich Islands'), '#default_value' => variable_get('countryban_southgeorgiaandthesouthsandwichislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_spain'] = array('#type' => 'radios', '#title' => t('Spain'), '#default_value' => variable_get('countryban_spain', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_srilanka'] = array('#type' => 'radios', '#title' => t('Sri Lanka'), '#default_value' => variable_get('countryban_srilanka', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_sudan'] = array('#type' => 'radios', '#title' => t('Sudan'), '#default_value' => variable_get('countryban_sudan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_suriname'] = array('#type' => 'radios', '#title' => t('Suriname'), '#default_value' => variable_get('countryban_suriname', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_swaziland'] = array('#type' => 'radios', '#title' => t('Swaziland'), '#default_value' => variable_get('countryban_swaziland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_sweden'] = array('#type' => 'radios', '#title' => t('Sweden'), '#default_value' => variable_get('countryban_sweden', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_switzerland'] = array('#type' => 'radios', '#title' => t('Switzerland'), '#default_value' => variable_get('countryban_switzerland', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_syrianarabrepublic'] = array('#type' => 'radios', '#title' => t('Syrian Arab Republic'), '#default_value' => variable_get('countryban_syrianarabrepublic', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_taiwan'] = array('#type' => 'radios', '#title' => t('Taiwan'), '#default_value' => variable_get('countryban_taiwan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_tajikistan'] = array('#type' => 'radios', '#title' => t('Tajikistan'), '#default_value' => variable_get('countryban_tajikistan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_thailand'] = array('#type' => 'radios', '#title' => t('Thailand'), '#default_value' => variable_get('countryban_thailand', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_thedemocraticrepublicofthecongo'] = array('#type' => 'radios', '#title' => t('The Democratic Republic Of The Congo'), '#default_value' => variable_get('countryban_thedemocraticrepublicofthecongo', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_theformeryugoslavrepublicofmacedonia'] = array('#type' => 'radios', '#title' => t('The Former Yugoslav Republic Of Macedonia'), '#default_value' => variable_get('countryban_theformeryugoslavrepublicofmacedonia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_timor-leste'] = array('#type' => 'radios', '#title' => t('Timor-leste'), '#default_value' => variable_get('countryban_timor-leste', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_togo'] = array('#type' => 'radios', '#title' => t('Togo'), '#default_value' => variable_get('countryban_togo', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_tokelau'] = array('#type' => 'radios', '#title' => t('Tokelau'), '#default_value' => variable_get('countryban_tokelau', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_tonga'] = array('#type' => 'radios', '#title' => t('Tonga'), '#default_value' => variable_get('countryban_tonga', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_trinidadandtobago'] = array('#type' => 'radios', '#title' => t('Trinidad And Tobago'), '#default_value' => variable_get('countryban_trinidadandtobago', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_tunisia'] = array('#type' => 'radios', '#title' => t('Tunisia'), '#default_value' => variable_get('countryban_tunisia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_turkey'] = array('#type' => 'radios', '#title' => t('Turkey'), '#default_value' => variable_get('countryban_turkey', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_turkmenistan'] = array('#type' => 'radios', '#title' => t('Turkmenistan'), '#default_value' => variable_get('countryban_turkmenistan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_turksandcaicosislands'] = array('#type' => 'radios', '#title' => t('Turks And Caicos Islands'), '#default_value' => variable_get('countryban_turksandcaicosislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_tuvalu'] = array('#type' => 'radios', '#title' => t('Tuvalu'), '#default_value' => variable_get('countryban_tuvalu', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_uganda'] = array('#type' => 'radios', '#title' => t('Uganda'), '#default_value' => variable_get('countryban_uganda', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_ukraine'] = array('#type' => 'radios', '#title' => t('Ukraine'), '#default_value' => variable_get('countryban_ukraine', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_unitedarabemirates'] = array('#type' => 'radios', '#title' => t('United Arab Emirates'), '#default_value' => variable_get('countryban_unitedarabemirates', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_unitedkingdom'] = array('#type' => 'radios', '#title' => t('United Kingdom'), '#default_value' => variable_get('countryban_unitedkingdom', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_unitedrepublicoftanzania'] = array('#type' => 'radios', '#title' => t('United Republic Of Tanzania'), '#default_value' => variable_get('countryban_unitedrepublicoftanzania', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_unitedstates'] = array('#type' => 'radios', '#title' => t('United States'), '#default_value' => variable_get('countryban_unitedstates', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_unitedstatesminoroutlyingislands'] = array('#type' => 'radios', '#title' => t('United States Minor Outlying Islands'), '#default_value' => variable_get('countryban_unitedstatesminoroutlyingislands', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_uruguay'] = array('#type' => 'radios', '#title' => t('Uruguay'), '#default_value' => variable_get('countryban_uruguay', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_uzbekistan'] = array('#type' => 'radios', '#title' => t('Uzbekistan'), '#default_value' => variable_get('countryban_uzbekistan', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_vanuatu'] = array('#type' => 'radios', '#title' => t('Vanuatu'), '#default_value' => variable_get('countryban_vanuatu', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_venezuela'] = array('#type' => 'radios', '#title' => t('Venezuela'), '#default_value' => variable_get('countryban_venezuela', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_vietnam'] = array('#type' => 'radios', '#title' => t('Viet Nam'), '#default_value' => variable_get('countryban_vietnam', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_virginislandsbritish'] = array('#type' => 'radios', '#title' => t('Virgin Islands, British'), '#default_value' => variable_get('countryban_virginislandsbritish', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_virginislandsu.s.'] = array('#type' => 'radios', '#title' => t('Virgin Islands, U.S.'), '#default_value' => variable_get('countryban_virginislandsu.s.', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_wallisandfutuna'] = array('#type' => 'radios', '#title' => t('Wallis And Futuna'), '#default_value' => variable_get('countryban_wallisandfutuna', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_yemen'] = array('#type' => 'radios', '#title' => t('Yemen'), '#default_value' => variable_get('countryban_yemen', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_zambia'] = array('#type' => 'radios', '#title' => t('Zambia'), '#default_value' => variable_get('countryban_zambia', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));
$form['countryban_zimbabwe'] = array('#type' => 'radios', '#title' => t('Zimbabwe'), '#default_value' => variable_get('countryban_zimbabwe', 0), '#options' => array(t('No Ban'), t('Read Only'), t('Complete Ban')));

  _countryban_add_files();
  return system_settings_form($form);
}

/**
 * Impements hook_menu().
 */
function countryban_menu() {
  $items = array();
  $items['admin/settings/countryban'] = array(
    'title' => 'Country Ban', 
    'description' => 'Set countries to read only or ban them entirely.', 
    'page callback' => 'drupal_get_form', 
    'page arguments' => array('countryban_admin'), 
    'access arguments' => array('access administration pages'), 
    'type' => MENU_NORMAL_ITEM, );
  return $items;
}

function _countryban_add_files() {
  $path = drupal_get_path('module', 'countryban');
  drupal_add_css($path . '/countryban.css');
}

/**
 * Impements hook_user().
 */
function countryban_user($op, &$edit, &$account, $category = NULL)  {
  global $user; 
  $form = '';
  $ipstring = ip_address();
  $country_query  = "SELECT countrycode2, countryname FROM {countryban_iptocountry} ".
    "WHERE ip_from<=inet_aton('$ipstring') ".
    "AND ip_to>=inet_aton('$ipstring') ";

  $country_exec = db_query($country_query);
  $ccode_array=db_fetch_array($country_exec);
  $country_code=$ccode_array['countrycode2'];
  $country_name=$ccode_array['countryname'];

  $country_name = drupal_strtolower(str_replace(' ', '', $country_name));
  $country_name = str_replace('\'', '', $country_name);
  $variable_name = "countryban_" . $country_name; 
  $banvalue = variable_get($variable_name, -1);

  if ($GLOBALS['user']->uid != 1) {
    switch ($op) {
      case 'register':
        if ( ($banvalue == 1) || ($banvalue == 2) ) {
          drupal_set_message(variable_get('countryban_readonly', "Accounts Disabled."), 'error');
          drupal_goto();
        }
        break; 
      case 'login':
        if ( ($banvalue == 1) || ($banvalue == 2) ) {
          // Destroy the current session:
          module_invoke_all('user', 'logout', NULL, $user);
          // Load the anonymous user
          $user = drupal_anonymous_user();
          drupal_set_message(variable_get('countryban_readonly', "Accounts Disabled."));
          drupal_goto();
        }
        break;
      case 'load':
        if ($banvalue == 2) {
          // Destroy the current session:
          session_destroy();
          module_invoke_all('user', 'logout', NULL, $user);
          // Load the anonymous user
          $user = drupal_anonymous_user();
          drupal_set_message(variable_get('countryban_completeban', "Access Denied."), 'error');
          drupal_goto();
        }
        break;
    }
  }
  return $form;
}

function CSV_submit($form, &$form_state) {
  $path = drupal_get_path('module', 'countryban');

  // Our CSV file is from the very kind people at: http://ip-to-country.webhosting.info/node/view/6
  // It must be downloaded and pushed up with this module in order for it to work!

  $csvfile = $path . '/ip-to-country.csv';
  if (($handle = fopen($csvfile, "r")) !== FALSE)  {
    $query = "TRUNCATE TABLE {countryban_iptocountry}";
    db_query($query);    
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)  {
      $query = 'INSERT INTO {countryban_iptocountry} VALUES ("' . $data[0] . '", "' .
        $data[1] . '", "' . $data[2] . '", "' . $data[3] . '", "' . str_replace(',', '', str_replace('\'', '', $data[4])) . '")';  
      db_query($query);
    }
    fclose($handle);
  } 
}