Ejemplo n.º 1
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));
         }
     }
 }
Ejemplo n.º 2
0
 function template_redirect()
 {
     global $redirection;
     if (is_404() && !$redirection->hasMatched()) {
         $url = $_SERVER['REQUEST_URI'];
         $redirects = Red_Item::get_for_url($url, '404');
         if (!empty($redirects)) {
             foreach ($redirects as $key => $item) {
                 if ($item->matches($url)) {
                     $redirection->setMatched(true);
                     $this->matched = $item;
                     break;
                 }
             }
         }
         if (empty($this->matched)) {
             $modules = Red_Module::get_by_type('404');
             if (count($modules) > 0) {
                 foreach ($modules as $module) {
                     // Log 404 errors
                     if ($module->log_404) {
                         if (isset($_SERVER['REMOTE_ADDR'])) {
                             $myip = $_SERVER['REMOTE_ADDR'];
                         } else {
                             if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                                 $myip = $_SERVER['HTTP_X_FORWARDED_FOR'];
                             }
                         }
                         $options = $redirection->get_options();
                         if ($options['log_404s']) {
                             $log = RE_Log::create($_SERVER['REQUEST_URI'], '', $_SERVER['HTTP_USER_AGENT'], $myip, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', 'NULL', $module->id);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 function visit($url, $target)
 {
     if ($this->tracking && $this->id) {
         global $wpdb, $redirection;
         // Update the counters
         $count = $this->last_count + 1;
         $wpdb->query("UPDATE {$wpdb->prefix}redirection_items SET last_count='{$count}', last_access=NOW() WHERE id='{$this->id}'");
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $ip = $_SERVER['REMOTE_ADDR'];
         } else {
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
             }
         }
         $options = $redirection->get_options();
         if ($options['log_redirections']) {
             $log = RE_Log::create($url, $target, $_SERVER['HTTP_USER_AGENT'], $ip, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', $this->id, $this->module_id, $this->group_id);
         }
     }
 }