public function template_redirect()
 {
     if (is_404()) {
         $options = red_get_options();
         if (isset($options['expire_404']) && $options['expire_404'] >= 0) {
             RE_404::create($this->get_url(), $this->get_user_agent(), $this->get_ip(), $this->get_referrer());
         }
     }
 }
Exemple #2
0
 public static function schedule()
 {
     $options = red_get_options();
     if ($options['expire_redirect'] > 0 || $options['expire_404'] > 0) {
         if (!wp_next_scheduled(self::DELETE_HOOK)) {
             wp_schedule_event(time(), self::DELETE_FREQ, self::DELETE_HOOK);
         }
     } else {
         Red_Flusher::clear();
     }
 }
 public function update($data)
 {
     include_once dirname(dirname(__FILE__)) . '/models/htaccess.php';
     $save = array('location' => isset($data['location']) ? $data['location'] : false, 'canonical' => isset($data['canonical']) ? $data['canonical'] : false);
     if (!empty($this->location) && $save['location'] !== $this->location) {
         // Location has moved. Remove from old location
         $htaccess = new Red_Htaccess();
         $htaccess->save($this->location, '');
     }
     $this->load($save);
     if ($save['location'] && $this->flush_module() === false) {
         return __('Cannot write to chosen location - check path and permissions.', 'redirection');
     }
     $options = red_get_options();
     $options['modules'][self::MODULE_ID] = $save;
     update_option('redirection_options', $options);
     return true;
 }
 public function ajax_module_save()
 {
     global $hook_suffix;
     $hook_suffix = '';
     $module_id = intval($_POST['id']);
     $options = red_get_options();
     $this->check_ajax_referer('red_module_save_' . $module_id);
     $module = Red_Module::get($module_id);
     if ($module) {
         $module->update($_POST);
         $pager = new Redirection_Module_Table($options['token']);
         $json = array('html' => $pager->column_name($module));
     } else {
         $json['error'] = __('Unable to perform action') . ' - could not find module';
     }
     $this->output_ajax_response($json);
 }
Exemple #5
0
 function visit($url, $target)
 {
     if ($this->tracking && $this->id) {
         global $wpdb, $redirection;
         // Update the counters
         $count = $this->last_count + 1;
         $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}redirection_items SET last_count=%d, last_access=NOW() WHERE id=%d", $count, $this->id));
         if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
         } elseif (isset($_SERVER['REMOTE_ADDR'])) {
             $ip = $_SERVER['REMOTE_ADDR'];
         }
         $options = red_get_options();
         if (isset($options['expire_redirect']) && $options['expire_redirect'] >= 0) {
             $log = RE_Log::create($url, $target, $_SERVER['HTTP_USER_AGENT'], $ip, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', array('redirect_id' => $this->id, 'module_id' => $this->module_id, 'group_id' => $this->group_id));
         }
     }
 }
 static function get_for_select()
 {
     $options = red_get_options();
     return array(WordPress_Module::MODULE_ID => Red_Module::get(WordPress_Module::MODULE_ID), Apache_Module::MODULE_ID => Red_Module::get(Apache_Module::MODULE_ID), Nginx_Module::MODULE_ID => Nginx_Module::get(Nginx_Module::MODULE_ID));
 }
 function prepare_items($type = '', $id = 0)
 {
     global $wpdb;
     $options = red_get_options();
     $columns = $this->get_columns();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, array(), $sortable);
     $this->items = Red_Module::get_for_select();
     $this->total_items = count($this->items);
     $this->set_pagination_args(array('total_items' => $this->total_items, 'per_page' => 100, 'total_pages' => ceil($this->total_items / 100)));
 }
 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);
 }