Opened 3 years ago

Closed 3 years ago

#15009 closed defect (bug) (invalid)

Widget RSS unstopable loop on self timeout

Reported by: pentatonicfunk Owned by:
Priority: normal Milestone:
Component: Widgets Version: 3.0.1
Severity: normal Keywords:
Cc:

Description

RSS widget allow us to input our own blog page rss/feed, but on some server it is possible to some page get timeout when RSS widget request feed on that page,
since that page is wordpress page, af course the page will load widget_init (again) and since that page time out, the RSS widget will doing unstopple loop until get the feed,
it is very annoying, and make server busy

Change History (5)

  • Owner set to pentatonicfunk
  • Status changed from new to accepted
  • Resolution set to fixed
  • Status changed from accepted to closed

the solution is just load widget rss when the requester is the client
so i change line

register_widget('WP_Widget_RSS');


with

if($_SERVER['SERVER_ADDR']!=determineIP()){
		register_widget('WP_Widget_RSS');
}
function determineIP() {
   if (checkIP($_SERVER["HTTP_CLIENT_IP"])) {
       return $_SERVER["HTTP_CLIENT_IP"];
   }
   foreach (explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {
       if (checkIP(trim($ip))) {
           return $ip;
       }
   }
   if (checkIP($_SERVER["HTTP_X_FORWARDED"])) {
       return $_SERVER["HTTP_X_FORWARDED"];
   } elseif (checkIP($_SERVER["HTTP_X_CLUSTER_CLIENT_IP"])) {
       return $_SERVER["HTTP_X_CLUSTER_CLIENT_IP"];
   } elseif (checkIP($_SERVER["HTTP_FORWARDED_FOR"])) {
       return $_SERVER["HTTP_FORWARDED_FOR"];
   } elseif (checkIP($_SERVER["HTTP_FORWARDED"])) {
       return $_SERVER["HTTP_FORWARDED"];
   } else {
       return $_SERVER["REMOTE_ADDR"];
   }
}

/* BOB: By Grant Burton @ BURTONTECH.COM (11-30-2008): IP-Proxy-Cluster Fix */
function checkIP($ip) {
   if (!empty($ip) && ip2long($ip)!=-1 && ip2long($ip)!=false) {
       $private_ips = array (
       array('0.0.0.0','2.255.255.255'),
       array('10.0.0.0','10.255.255.255'),
       array('127.0.0.0','127.255.255.255'),
       array('169.254.0.0','169.254.255.255'),
       array('172.16.0.0','172.31.255.255'),
       array('192.0.2.0','192.0.2.255'),
       array('192.168.0.0','192.168.255.255'),
       array('255.255.255.0','255.255.255.255')
       );

       foreach ($private_ips as $r) {
           $min = ip2long($r[0]);
           $max = ip2long($r[1]);
           if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
       }
       return true;
   } else {
       return false;
   }
}
  • Milestone Awaiting Review deleted
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Owner pentatonicfunk deleted
  • Status changed from reopened to assigned
  • Resolution set to invalid
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.