name = $pp_name; $this->headitem = $pp_descr['headitem']; $this->ipclass = IPClass::create($pp_descr['ipclass']); } } class ProviderProxy { var $pp; function ProviderProxy() { $this->pp = NULL; } static function create($pproxy = NULL) { $thiz = new ProviderProxy(); if ($pproxy != NULL) $thiz->update($pproxy); return ($thiz); } function clean() { if ($this->pp != NULL) { foreach ($this->pp as $pp_key => $pp_value) { fprintf(STDERR, "PHP PPN: %s\n", $pp_key); unset($this->pp[$pp_key]); } unset($this->pp); $this->pp = NULL; } } function update($pproxy) { $this->clean(); $this->pp = array(); foreach ($pproxy as $pp_key => $pp_value) { $this->pp[$pp_key] = new ProviderProxyItem($pp_key, $pp_value); } } function realip(&$header, $ip) { fprintf(STDERR, "PP realip: [%d]\n", count($this->pp)); if ($this->pp != NULL) { foreach ($this->pp as $pp_name => $pp_item) { // fprintf(STDERR, "PP loop: [%s][%s]\n", $pp_name, $ip); if ($pp_item->ipclass->check($ip)) { if (isset($header[$pp_item->headitem])) { fprintf(STDERR, "PP: match public proxy [%s][%s]\n", $pp_name, $header[$pp_item->headitem]); $ret = $header['POST_'.$pp_item->headitem] = $header[$pp_item->headitem]; unset($header[$pp_item->headitem]); return ($ret); } } } } return ($ip); } } ?>