You are here

function autoban_export_form in Automatic IP ban (Autoban) 7

Export autoban rules.

1 string reference to 'autoban_export_form'
autoban_menu in ./autoban.module
Implements hook_menu().

File

./autoban.admin.inc, line 732
Configuration for autoban module.

Code

function autoban_export_form($form, &$form_state) {
  $form = array();
  $export = array();

  // Rules ID
  $rid = arg(5) ? arg(5) : NULL;
  $rules = autoban_get_rules($rid);
  if (!empty($rules)) {
    if ($rid) {
      $rules = array(
        $rules,
      );
    }
    foreach ($rules as $rule) {
      $rule_arr = (array) $rule;
      unset($rule_arr['rid']);
      $export[] .= autoban_var_json_export($rule_arr);
    }
  }
  $form['export'] = array(
    '#title' => t('Export'),
    '#type' => 'textarea',
    '#rows' => 10,
    '#default_value' => implode(AUTOBAN_EXPORT_SEPARATOR, $export),
    '#description' => t('For importing copy the content of the text area and paste it into the import page.'),
  );
  return $form;
}