function admin_screen_options()
 {
     if (isset($_POST['regenerate']) && check_admin_referer('redirection-update_options')) {
         $options = $this->get_options();
         $options['token'] = md5(uniqid());
         update_option('redirection_options', $options);
         $this->render_message(__('Your options were updated', 'redirection'));
     } elseif (isset($_POST['update']) && check_admin_referer('redirection-update_options')) {
         $options['monitor_post'] = stripslashes($_POST['monitor_post']);
         $options['auto_target'] = stripslashes($_POST['auto_target']);
         $options['support'] = isset($_POST['support']) ? true : false;
         $options['token'] = stripslashes($_POST['token']);
         $options['expire_redirect'] = min(intval($_POST['expire_redirect']), 60);
         $options['expire_404'] = min(intval($_POST['expire_404']), 60);
         if (trim($options['token']) == '') {
             $options['token'] = md5(uniqid());
         }
         update_option('redirection_options', $options);
         $this->render_message(__('Your options were updated', 'redirection'));
     } elseif (isset($_POST['delete']) && check_admin_referer('redirection-delete_plugin')) {
         include dirname(__FILE__) . '/models/database.php';
         $db = new RE_Database();
         $db->remove(__FILE__);
         $this->render_message(__('Redirection data has been deleted and the plugin disabled', 'redirection'));
         return;
     } elseif (isset($_POST['import']) && check_admin_referer('redirection-import')) {
         include dirname(__FILE__) . '/models/file_io.php';
         $count = Red_FileIO::import($_POST['group'], $_FILES['upload']);
         if ($count > 0) {
             $this->render_message(sprintf(_n('%d redirection was successfully imported', '%d redirections were successfully imported', $count, 'redirection'), $count));
         } else {
             $this->render_message(__('No items were imported', 'redirection'));
         }
     }
     $groups = Red_Group::get_for_select();
     $this->render_admin('options', array('options' => $this->get_options(), 'groups' => $groups));
 }
 function admin_screen_options()
 {
     if (isset($_POST['regenerate']) && check_admin_referer('redirection-update_options')) {
         $options = red_get_options();
         $options['token'] = md5(uniqid());
         update_option('redirection_options', $options);
         $this->render_message(__('Your options were updated', 'redirection'));
     } elseif (isset($_POST['update']) && check_admin_referer('redirection-update_options')) {
         $options['monitor_post'] = stripslashes($_POST['monitor_post']);
         $options['auto_target'] = stripslashes($_POST['auto_target']);
         $options['support'] = isset($_POST['support']) ? true : false;
         $options['token'] = stripslashes($_POST['token']);
         $options['expire_redirect'] = min(intval($_POST['expire_redirect']), 60);
         $options['expire_404'] = min(intval($_POST['expire_404']), 60);
         if (trim($options['token']) == '') {
             $options['token'] = md5(uniqid());
         }
         update_option('redirection_options', $options);
         Red_Flusher::schedule();
         $this->render_message(__('Your options were updated', 'redirection'));
     } elseif (isset($_POST['delete']) && check_admin_referer('redirection-delete_plugin')) {
         $this->plugin_uninstall();
         $current = get_option('active_plugins');
         array_splice($current, array_search(basename(dirname(REDIRECTION_FILE)) . '/' . basename(REDIRECTION_FILE), $current), 1);
         update_option('active_plugins', $current);
         $this->render_message(__('Redirection data has been deleted and the plugin disabled', 'redirection'));
         return;
     } elseif (isset($_POST['import']) && check_admin_referer('redirection-import')) {
         $count = Red_FileIO::import($_POST['group'], $_FILES['upload']);
         if ($count > 0) {
             $this->render_message(sprintf(_n('%d redirection was successfully imported', '%d redirections were successfully imported', $count, 'redirection'), $count));
         } else {
             $this->render_message(__('No items were imported', 'redirection'));
         }
     }
     $groups = Red_Group::get_for_select();
     $this->render('options', array('options' => red_get_options(), 'groups' => $groups));
 }
 private function get_module_column($module_id, $export_type)
 {
     $json['error'] = __('Invalid module', 'redirection');
     $module = Red_Module::get($module_id);
     $exporter = Red_FileIO::create($export_type);
     if ($module && $exporter) {
         global $hook_suffix;
         $hook_suffix = '';
         $options = red_get_options();
         $pager = new Redirection_Module_Table($options['token']);
         $items = Red_Item::get_all_for_module($module_id);
         $json = array('html' => $pager->column_name($module));
         $json['html'] .= '<textarea readonly="readonly" class="module-export" rows="10">' . esc_textarea($exporter->get($items)) . '</textarea>';
         $json['html'] .= '<div class="table-actions"><a href="?page=redirection.php&amp;token=' . $options['token'] . '&amp;sub=' . $export_type . '&amp;module=' . $module_id . '"><input class="button-primary" type="button" value="' . __('Download', 'redirection') . '"/></a> ';
         $json['html'] .= '<input class="button-secondary" type="submit" name="cancel" value="' . __('Cancel', 'redirection') . '"/>';
     }
     $this->output_ajax_response($json);
 }