issue 1763, fixed a bug that trackback is not work.

git-svn-id: http://xe-core.googlecode.com/svn/branches/luminous@11309 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2012-09-18 09:06:10 +00:00
parent f6dfbbc03f
commit 3f6fc389a7
5 changed files with 36 additions and 43 deletions

View file

@ -22,7 +22,9 @@ RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(rss|atom|api)$ ./index.php?vid=$1&
# trackback # trackback
RewriteRule ^([0-9]+)/(.+)/trackback$ ./index.php?document_srl=$1&key=$2&act=trackback [L] RewriteRule ^([0-9]+)/(.+)/trackback$ ./index.php?document_srl=$1&key=$2&act=trackback [L]
RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?mid=$1&document_srl=$2&key=$3&act=trackback [L]
RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&document_srl=$2&key=$3&act=trackback [L] RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&document_srl=$2&key=$3&act=trackback [L]
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&mid=$2&document_srl=$3&key=$4&act=trackback [L]
# administrator page # administrator page
RewriteRule ^admin/?$ ./index.php?module=admin [L] RewriteRule ^admin/?$ ./index.php?module=admin [L]

View file

@ -1125,7 +1125,9 @@ class Context {
'act.mid' =>$is_feed?"$mid/$act":'', 'act.mid' =>$is_feed?"$mid/$act":'',
'act.mid.vid'=>$is_feed?"$vid/$mid/$act":'', 'act.mid.vid'=>$is_feed?"$vid/$mid/$act":'',
'act.document_srl.key' =>($act=='trackback')?"$srl/$key/$act":'', 'act.document_srl.key' =>($act=='trackback')?"$srl/$key/$act":'',
'act.document_srl.key.vid'=>($act=='trackback')?"$vid/$srl/$key/$act":'' 'act.document_srl.key.mid'=>($act=='trackback')?"$mid/$srl/$key/$act":'',
'act.document_srl.key.vid'=>($act=='trackback')?"$vid/$srl/$key/$act":'',
'act.document_srl.key.mid.vid'=>($act=='trackback')?"$vid/$mid/$srl/$key/$act":''
); );
$query = $target_map[$target]; $query = $target_map[$target];

View file

@ -200,4 +200,8 @@
<value xml:lang="jp"><![CDATA[サイト]]></value> <value xml:lang="jp"><![CDATA[サイト]]></value>
<value xml:lang="zh-TW"><![CDATA[網站]]></value> <value xml:lang="zh-TW"><![CDATA[網站]]></value>
</item> </item>
</lang> <item name="msg_trackback_send_failed">
<value xml:lang="ko"><![CDATA[엮인글 발송을 실패하였습니다.]]></value>
<value xml:lang="en"><![CDATA[Failed to send]]></value>
</item>
</lang>

View file

@ -97,7 +97,7 @@
$document_srl = Context::get('target_srl'); $document_srl = Context::get('target_srl');
$oDocumentModel = &getModel('document'); $oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl); $oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists() || !$oDocument->getSummary()) return new Object(); if(!$oDocument->isExists()) return new Object();
if($oDocument->getMemberSrl() != $logged_info->member_srl) return new Object(); if($oDocument->getMemberSrl() != $logged_info->member_srl) return new Object();
// Add a link sent yeokingeul // Add a link sent yeokingeul
$oDocumentController = &getController('document'); $oDocumentController = &getController('document');
@ -278,22 +278,22 @@
*/ */
function sendTrackback($oDocument, $trackback_url, $charset) { function sendTrackback($oDocument, $trackback_url, $charset) {
$oModuleController = &getController('module'); $oModuleController = &getController('module');
// Information sent by // Information sent by
$http = parse_url($trackback_url); $http = parse_url($trackback_url);
$obj->blog_name = str_replace(array('&lt;','&gt;','&amp;','&quot;'), array('<','>','&','"'), Context::getBrowserTitle()); $obj->blog_name = str_replace(array('&lt;','&gt;','&amp;','&quot;'), array('<','>','&','"'), Context::getBrowserTitle());
$oModuleController->replaceDefinedLangCode($obj->blog_name); $oModuleController->replaceDefinedLangCode($obj->blog_name);
$obj->title = $oDocument->getTitleText(); $obj->title = $oDocument->getTitleText();
$obj->excerpt = $oDocument->getSummary(200); $obj->excerpt = $oDocument->getSummary(200);
$obj->url = getFullUrl('','document_srl',$oDocument->document_srl); $obj->url = getFullUrl('','document_srl',$oDocument->document_srl);
// blog_name, title, excerpt, url charset of the string to the requested change // blog_name, title, excerpt, url charset of the string to the requested change
if($charset && function_exists('iconv')) { if($charset && function_exists('iconv')) {
foreach($obj as $key=>$val) { foreach($obj as $key=>$val) {
$obj->{$key} = iconv('UTF-8',$charset,$val); $obj->{$key} = iconv('UTF-8',$charset,$val);
} }
} }
// written information sent to socket
if($http['query']) $http['query'].="&";
if(!$http['port']) $http['port'] = 80;
$content = $content =
sprintf( sprintf(
@ -306,42 +306,27 @@
urlencode($obj->blog_name), urlencode($obj->blog_name),
urlencode($obj->excerpt) urlencode($obj->excerpt)
); );
if($http['query']) $content .= '&'.$http['query'];
$content_length = strlen($content);
// header by
$header =
sprintf(
"POST %s HTTP/1.1\r\n".
"Host: %s\r\n".
"Content-Type: %s\r\n".
"Content-Length: %s\r\n\r\n".
"%s\r\n",
$http['path'],
$http['host'],
"application/x-www-form-urlencoded",
$content_length,
$content
);
if(!$http['host']||!$http['port']) return new Object(-1,'msg_trackback_url_is_invalid');
// Opens a socket on the target server you want to send
$fp = @fsockopen($http['host'], $http['port'], $errno, $errstr, 5);
if(!$fp) return new Object(-1,'msg_trackback_url_is_invalid');
// Header information sent by
fputs($fp, $header);
// Waiting for the results (in particular the server may not be falling EOF
while(!feof($fp)) {
$line = trim(fgets($fp, 4096));
if(preg_match("/^<error>/i",$line)){
$error = preg_replace('/[^0-9]/','',$line);
break;
}
}
// Close socket
fclose($fp);
if($error == "0") return new Object(0, 'msg_trackback_send_success'); $buff = FileHandler::getRemoteResource($trackback_url, $content, 3, 'POST', 'application/x-www-form-urlencoded');
return new Object(-1, 'msg_trackback_send_failed'); $oXmlParser = new XmlParser();
$xmlDoc = $oXmlParser->parse($buff);
if($xmlDoc->response->error->body == '0')
{
return new Object(0, 'msg_trackback_send_success');
}
else
{
if($xmlDoc->response->message->body)
{
return new Object(-1, sprintf('%s: %s', Context::getLang('msg_trackback_send_failed'), $xmlDoc->response->message->body));
}
else
{
return new Object(-1, 'msg_trackback_send_failed');
}
}
} }
/** /**

View file

@ -158,8 +158,8 @@
* @param int $document_srl * @param int $document_srl
* @return string * @return string
*/ */
function getTrackbackUrl($document_srl) { function getTrackbackUrl($document_srl, $mid = NULL) {
$url = getFullUrl('','document_srl',$document_srl,'act','trackback','key',$this->getTrackbackKey($document_srl)); $url = getFullUrl('', 'mid', $mid, 'document_srl',$document_srl,'act','trackback','key',$this->getTrackbackKey($document_srl));
return $url; return $url;
} }