X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=plugin%2Ftb.inc.php;h=1726e40df22dca4c300309d6bb100be0e90e6dca;hb=e856ef40a5b38d8dc3e482d962c911563d84f131;hp=023bbd92609ac8f540749e706eef5a5834de5add;hpb=bd566050d120a5309ad658ad23314d3fc9ac63cd;p=pukiwiki%2Fpukiwiki.git diff --git a/plugin/tb.inc.php b/plugin/tb.inc.php index 023bbd9..1726e40 100644 --- a/plugin/tb.inc.php +++ b/plugin/tb.inc.php @@ -1,49 +1,60 @@ + * (C) 2003-2005 PukiWiki Developers Team + * (C) 2003 Katsumi Saito * License: GPL * * plugin_tb_action() action - * plugin_tb_save($url, $tb_id) Save or update TrackBack Ping data - * plugin_tb_return($rc, $msg) Return TrackBack ping via HTTP/XML - * plugin_tb_mode_rss($tb_id) ?__mode=rss - * plugin_tb_mode_view($tb_id) ?__mode=view + * plugin_tb_save($url, $tb_id) Save or update TrackBack Ping data + * plugin_tb_output_response($rc, $msg) Show a response code of the ping via HTTP/XML (then exit) + * plugin_tb_output_rsslist($tb_id) Show pings for the page via RSS + * plugin_tb_output_htmllist($tb_id) Show pings for the page via XHTML */ switch(LANG){ -case 'ja': define('PLUGIN_TB_LANGUAGE', 'ja-Jp'); break; +case 'ja': define('PLUGIN_TB_LANGUAGE', 'ja-jp'); break; default : define('PLUGIN_TB_LANGUAGE', 'en-us'); break; } +// ---- + +define('PLUGIN_TB_ERROR', 1); +define('PLUGIN_TB_NOERROR', 0); + function plugin_tb_action() { - global $vars, $trackback; + global $trackback, $vars; - if (isset($vars['url'])) { + if ($trackback && isset($vars['url'])) { // Receive and save a TrackBack Ping (both GET and POST) $url = $vars['url']; $tb_id = isset($vars['tb_id']) ? $vars['tb_id'] : ''; - plugin_tb_save($url, $tb_id); // Send a response (and exit) + list($error, $message) = plugin_tb_save($url, $tb_id); + + // Output the response + plugin_tb_output_response($error, $message); + exit; } else { if ($trackback && isset($vars['__mode']) && isset($vars['tb_id'])) { // Show TrackBacks received (and exit) switch ($vars['__mode']) { - case 'rss' : plugin_tb_mode_rss($vars['tb_id']); break; - case 'view': plugin_tb_mode_view($vars['tb_id']); break; + case 'rss' : plugin_tb_output_rsslist($vars['tb_id']); break; + case 'view': plugin_tb_output_htmllist($vars['tb_id']); break; } - } + exit; - // Show List of pages that TrackBacks reached - $pages = get_existpages(TRACKBACK_DIR, '.txt'); - if (! empty($pages)) { - return array('msg'=>'trackback list', - 'body'=>page_list($pages, 'read', FALSE)); } else { - return array('msg'=>'', 'body'=>''); + // Show List of pages that TrackBacks reached + $pages = get_existpages(TRACKBACK_DIR, '.txt'); + if (! empty($pages)) { + return array('msg'=>'Trackback list', + 'body'=>page_list($pages, 'read', FALSE)); + } else { + return array('msg'=>'', 'body'=>''); + } } } } @@ -58,17 +69,17 @@ function plugin_tb_save($url, $tb_id) if (! $trackback) $die .= 'TrackBack feature disabled. '; if ($url == '') $die .= 'URL parameter is not set. '; if ($tb_id == '') $die .= 'TrackBack Ping ID is not set. '; - if ($die != '') plugin_tb_return(1, $die); + if ($die != '') return array(PLUGIN_TB_ERROR, $die); - if (! file_exists(TRACKBACK_DIR)) plugin_tb_return(1, 'No such directory: TRACKBACK_DIR'); - if (! is_writable(TRACKBACK_DIR)) plugin_tb_return(1, 'Permission denied: TRACKBACK_DIR'); + if (! file_exists(TRACKBACK_DIR)) return array(PLUGIN_TB_ERROR, 'No such directory: TRACKBACK_DIR'); + if (! is_writable(TRACKBACK_DIR)) return array(PLUGIN_TB_ERROR, 'Permission denied: TRACKBACK_DIR'); $page = tb_id2page($tb_id); - if ($page === FALSE) plugin_tb_return(1, 'TrackBack ID is invalid.'); + if ($page === FALSE) return array(PLUGIN_TB_ERROR, 'TrackBack ID is invalid.'); // URL validation (maybe worse of processing time limit) $result = http_request($url, 'HEAD'); - if ($result['rc'] !== 200) plugin_tb_return(1, 'URL is fictitious.'); + if ($result['rc'] !== 200) return array(PLUGIN_TB_ERROR, 'URL is fictitious.'); // Update TrackBack Ping data $filename = tb_get_filename($page); @@ -94,24 +105,30 @@ function plugin_tb_save($url, $tb_id) flock($fp, LOCK_UN); fclose($fp); - plugin_tb_return(0); // Return OK + return array(PLUGIN_TB_NOERROR, ''); } -// Return TrackBack ping via HTTP/XML -function plugin_tb_return($rc, $msg = '') +// Show a response code of the ping via HTTP/XML (then exit) +function plugin_tb_output_response($rc, $msg = '') { + if ($rc == PLUGIN_TB_NOERROR) { + $rc = 0; // for PLUGIN_TB_NOERROR + } else { + $rc = 1; // for PLUGIN_TB_ERROR + } + pkwk_common_headers(); header('Content-Type: text/xml'); echo ''; echo ''; echo ' ' . $rc . ''; - if ($rc !== 0) echo '' . $msg . ''; + if ($rc) echo '' . $msg . ''; echo ''; exit; } -// ?__mode=rss -function plugin_tb_mode_rss($tb_id) +// Show pings for the page via RSS +function plugin_tb_output_rsslist($tb_id) { global $script, $vars, $entity_pattern; @@ -163,21 +180,22 @@ EOD; exit; } -// ?__mode=view -function plugin_tb_mode_view($tb_id) +// Show pings for the page via XHTML +function plugin_tb_output_htmllist($tb_id) { - global $script, $page_title; - global $_tb_title, $_tb_header, $_tb_entry, $_tb_refer, $_tb_date; - global $_tb_header_Excerpt, $_tb_header_Weblog, $_tb_header_Tracked; + pkwk_common_headers(); + echo 'This function had been removed now. It will be created soon.
' . "\n"; + echo 'Sorry for your inconvenience.'; + exit; - $page = tb_id2page($tb_id); - if ($page === FALSE) return FALSE; + // ---- + // Skeleton Logic - $r_page = rawurlencode($page); + global $script; + global $_tb_date; - $tb_title = sprintf($_tb_title, $page); - $tb_refer = sprintf($_tb_refer, '\'' . $page . '\'', '' . $page_title . ''); + $page = tb_id2page($tb_id); + if ($page === FALSE) return FALSE; $data = tb_get(tb_get_filename($page)); @@ -193,38 +211,10 @@ function plugin_tb_mode_view($tb_id) $time = date($_tb_date, $time + LOCALZONE); // May 2, 2003 11:25 AM $tb_body .= << - $title
- $_tb_header_Excerpt $excerpt
- $_tb_header_Weblog $blog_name
- $_tb_header_Tracked $time -
- EOD; } - $msg = << - - - - - $tb_title - - - - -
-
- $_tb_entry
- $script?tb_id=$tb_id

- $tb_refer -
- $tb_body -
- - -EOD; + // Output start pkwk_common_headers(); // BugTrack/466 Care for MSIE trouble @@ -232,6 +222,17 @@ EOD; //header('Content-type: application/xhtml+xml; charset=UTF-8'); header('Content-type: text/html; charset=UTF-8'); // Works well + $meta_content_type = pkwk_output_dtd(PKWK_DTD_XHTML_1_0_TRANSITIONAL, 'UTF-8'); + $msg = << + $meta_content_type + + + $script?tb_id=$tb_id

+ $tb_body + + +EOD; echo mb_convert_encoding($msg, 'UTF-8', SOURCE_ENCODING); exit; }