1:
define('BR_CODE', 1 ); ?> sdsrss: xml extension is not loaded error

' . "\n"; } $rssurl = $tmplname = ''; $rssurl = $rss_data; $rss_mode = 0; switch($mode) { case '1': $tmplname = ''; break; case '2': $tmplname = 'menubar'; break; case '3': $tmplname = 'recent'; break; case '4': $tmplname = 'rich'; $rss_mode = 1; break; } $class = 'sdsrss_html_' . $tmplname; if (! class_exists($class)) $class = 'sdsrss_html'; list($rc,$rss,$header,$query) = sdsrss_get_rss($rssurl,$rss_mode); if( $rc != '200') return 'E'; $obj = new $class($rss); //項目が少ない if ($obj->get_line() <= MINI_RSS_LINE ) return 'L' ; list( $xdate ,$data) = $obj->toString(); //内部コードはEUCとする $data = mb_convert_encoding($data, 'EUC-JP', 'utf-8'); return $data ; // $xdate はRSS内の最終更新日 // $rcはHTTPステータス 通常は200以外だとエラー // return $rc."
".$xdate . $data."
".$header."
".$query ; } // Create HTML from RSS array() class sdsrss_html { var $items = array(); var $class = ''; var $i=1; function sdsrss_html($rss) { foreach ($rss as $date=>$items) { foreach ($items as $item) { $link = $item['LINK']; $title = $item['TITLE']; if(LINK_NOT == 1){ $link = '<>'.$title.'<>' ; }else{ $link = '' .$this->html_mode. $title . ''; } $this->items[$date][] = $this->format_link($link); if($this->i++ >= MAX_RSS_LINE) break; } if($this->i >= MAX_RSS_LINE) break; } } function get_line() { return $this->i -1; } function format_link($link) { return $link . "
\n"; } function format_list($date, $str) { return $str; } function format_body($str) { return $str; } function toString() { $retval = ''; $item = 0; foreach ($this->items as $date=>$items){ if( $item == 0) $xdate = $date; $item++; $retval .= $this->format_list($date, join('', $items)); } //$xdate $retval = $this->format_body($retval); return array($xdate ,$retval); } } class sdsrss_html_menubar extends sdsrss_html { var $class = ' class="small"'; function format_link($link) { return '
  • ' . $link . '
  • ' . "\n"; } function format_body($str) { return '' . "\n"; } } class sdsrss_html_recent extends sdsrss_html { var $class = ' class="small"'; function format_link($link) { return '
  • ' . $link . "
  • \n"; } function format_list($date, $str) { return '' . $date . "\n" . '' . "\n"; } } // rss 配列から html を作る class sdsrss_html_rich extends sdsrss_html { var $items = array(); var $class = 'small'; var $i = 1; var $countn = 1; // コンストラクタ function sdsrss_html_rich($rss) { foreach ($rss as $date=>$items) { foreach ($items as $item) { $link = $item['LINK']; $title = $item['TITLE']; if(LINK_NOT == 1){ $link = $title ; }else{ $link = '' .$this->html_mode. $title . ''; } $this->items[$date][] = $this->format_link($link, $item['DESCRIPTION']); if($this->i++ >= MAX_RSS_LINE) break; } if($this->i >= MAX_RSS_LINE) break; } } function format_link($link, $desc) { if(RSS_CSS_ATT){ $ct = $this->countn++; return '
    '."$link\n
    $desc

    \n"; } return ''.$link."\n
    $desc

    \n"; } function format_body($str) { if( $str == '' ) return ''; // return "
    \n$str
    \n"; return "
    \n$str
    \n"; } } // Get RSS function sdsrss_get_rss($target,$rss_mode) { $buf = ''; // Newly get RSS $data = http_request($target); $rc = $data['rc']; if($rc != '200' ) return array($rc , "" ,$header,$query); $buf = $data['data']; $query = $data['query']; $header = $data['header']; // Parse $obj = new sdsrss_XML($rss_mode); return array($rc ,$obj->parse($buf),$header,$query); } // Get RSS and array() them class sdsrss_XML { var $items; var $item; var $is_item; var $tag; var $encoding; var $html_mode; function sdsrss_XML($mode) { $this->html_mode = $mode; } function parse($buf) { $this->items = array(); $this->item = array(); $this->is_item = FALSE; $this->tag = ''; // Detect encoding $this->encoding = mb_detect_encoding($buf); //とりあえず utf-8に変換 // if (! in_array(strtolower($this->encoding), array('us-ascii', 'iso-8859-1', 'utf-8'))) { $buf = mb_convert_encoding($buf, 'utf-8', $this->encoding); $this->encoding = 'utf-8'; // } $xml_parser = xml_parser_create($this->encoding); xml_set_element_handler($xml_parser, array(& $this, 'start_element'), array(& $this, 'end_element')); xml_set_character_data_handler($xml_parser, array(& $this, 'character_data')); if (! xml_parse($xml_parser, $buf, 1)) { return(sprintf('XML error: %s at line %d in %s', xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser), $buf)); } xml_parser_free($xml_parser); return $this->items; } function escape($str) { if($this->html_mode == 0){ // Unescape already-escaped chars (<, >, &, ...) in RSS body before htmlspecialchars() $str = ereg_replace('\<[^<]*\>', '', $str); $str = ereg_replace('\ \;', ' ', $str); $str = ereg_replace('\&nbsp\;', ' ', $str); // $str = strtr($str, array_flip(get_html_translation_table(ENT_COMPAT))); // Escape $str = htmlspecialchars($str); } // Encoding conversion //内部コードはEUCとする // $str = mb_convert_encoding($str, 'EUC-JP', $this->encoding); return trim($str); } // Tag start function start_element($parser, $name, $attrs) { if ($this->is_item) { $this->tag = $name; } else if ($name == 'ITEM') { $this->is_item = TRUE; } } // Tag end function end_element($parser, $name) { if (! $this->is_item || $name != 'ITEM') return; $item = array_map(array(& $this, 'escape'), $this->item); $this->item = array(); if (isset($item['DC:DATE'])) { $time = sdsrss_get_timestamp($item['DC:DATE']); } else if (isset($item['PUBDATE'])) { $time = sdsrss_get_timestamp($item['PUBDATE']); } else if (isset($item['DESCRIPTION']) && ($description = trim($item['DESCRIPTION'])) != '' && ($time = strtotime($description)) != -1) { $time -= LOCALZONE; } else { $time = time() - LOCALZONE; } $item['_TIMESTAMP'] = $time; $date = date('Y-m-d', $item['_TIMESTAMP']); $this->items[$date][] = $item; $this->is_item = FALSE; } function character_data($parser, $data) { if (! $this->is_item) return; if (! isset($this->item[$this->tag])) $this->item[$this->tag] = ''; $this->item[$this->tag] .= $data; } } function sdsrss_get_timestamp($str) { if (($str = trim($str)) == '') return UTIME; $matches = array(); if (! preg_match('/(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(([+-])(\d{2}):(\d{2}))?/', $str, $matches)) { $time = strtotime($str); return ($time == -1) ? UTIME : $time - LOCALZONE; } $str = $matches[1]; $time = strtotime($matches[1] . ' ' . $matches[2]); if (! empty($matches[3])) { $diff = ($matches[5] * 60 + $matches[6]) * 60; $time += ($matches[4] == '-' ? $diff : -$diff); } return $time; } // Max number of 'track' redirection message with 301 or 302 response define('HTTP_REQUEST_URL_REDIRECT_MAX', 2); /* * http_request($url) * Get / Send data via HTTP request * $url : URI started with http:// (http://user:pass@host:port/path?query) * $method : GET, POST, or HEAD * $headers : Additional HTTP headers, ended with "\r\n" * $post : An array of data to send via POST method ('key'=>'value') * $redirect_max : Max number of HTTP redirect * $content_charset : Content charset. Use '' or CONTENT_CHARSET */ function http_request($url, $method = 'GET', $headers = '', $post = array(), $redirect_max = HTTP_REQUEST_URL_REDIRECT_MAX, $content_charset = '') { global $use_proxy, $no_proxy, $proxy_host, $proxy_port; global $need_proxy_auth, $proxy_auth_user, $proxy_auth_pass; $rc = array(); $arr = parse_url($url); // query $arr['query'] = isset($arr['query']) ? '?' . $arr['query'] : ''; // port $arr['port'] = isset($arr['port']) ? $arr['port'] : 80; $url_base = $arr['scheme'] . '://' . $arr['host'] . ':' . $arr['port']; $url_path = isset($arr['path']) ? $arr['path'] : '/'; $url = $url_path . $arr['query']; $query = $method . ' ' . $url . ' HTTP/1.0' . "\r\n"; $query .= 'Host: ' . $arr['host'] . "\r\n"; $query .= 'User-Agent: Sdpm/' . '1.0' . "\r\n"; // Basic-auth for HTTP proxy server if ($need_proxy_auth && isset($proxy_auth_user) && isset($proxy_auth_pass)) $query .= 'Proxy-Authorization: Basic '. base64_encode($proxy_auth_user . ':' . $proxy_auth_pass) . "\r\n"; // (Normal) Basic-auth for remote host if (isset($arr['user']) && isset($arr['pass'])) $query .= 'Authorization: Basic '. base64_encode($arr['user'] . ':' . $arr['pass']) . "\r\n"; $query .= $headers; if (strtoupper($method) == 'POST') { // 'application/x-www-form-urlencoded', especially for TrackBack ping $POST = array(); foreach ($post as $name=>$val) $POST[] = $name . '=' . urlencode($val); $data = join('&', $POST); if (preg_match('/^[a-zA-Z0-9_-]+$/', $content_charset)) { // Legacy but simple $query .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; } else { // With charset (NOTE: Some implementation may hate this) $query .= 'Content-Type: application/x-www-form-urlencoded' . '; charset=' . strtolower($content_charset) . "\r\n"; } $query .= 'Content-Length: ' . strlen($data) . "\r\n"; $query .= "\r\n"; $query .= $data; } else { $query .= "\r\n"; } $errno = 0; $errstr = ''; $fp = @fsockopen( $arr['host'], $arr['port'], $errno, $errstr, 30); if ($fp === FALSE) { return array( 'query' => $query, // Query string 'rc' => $errno, // Error number 'header' => '', // Header 'data' => $errstr // Error message ); } fputs($fp, $query); $response = ''; while (! feof($fp)) $response .= fread($fp, 4096); fclose($fp); $resp = explode("\r\n\r\n", $response, 2); $rccd = explode(' ', $resp[0], 3); // array('HTTP/1.1', '200', 'OK\r\n...') $rc = (integer)$rccd[1]; switch ($rc) { case 301: // Moved Permanently case 302: // Moved Temporarily $matches = array(); if (preg_match('/^Location: (.+)$/m', $resp[0], $matches) && --$redirect_max > 0) { $url = trim($matches[1]); if (! preg_match('/^https?:\//', $url)) { // Relative path to Absolute if ($url{0} != '/') $url = substr($url_path, 0, strrpos($url_path, '/')) . '/' . $url; $url = $url_base . $url; // Add sheme, host } // Redirect return http_request($url, $method, $headers, $post, $redirect_max); } } return array( 'query' => $query, // Query String 'rc' => $rc, // Response Code 'header' => $resp[0], // Header 'data' => $resp[1] // Data ); } ?> file not