From bb736bb631788574137742f60dfaa2a808573af8 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 7 Dec 2008 17:11:22 -0500 Subject: Moved pingbacks to a seperate table Because pingbacks just aren't comments, they shouldn't be stored in the comments table. So, a new table has been created for them and the blog post view pages have been accomodated to show them at the bottom just like the related posts are shown. --- includes/footer.php | 9 +++------ includes/functions.php | 4 ++-- index.php | 2 +- pages/blog.php | 21 +++++++++++++++++++++ theme/comments.tpl | 4 ++-- theme/pingbacks.tpl | 14 ++++++++++++++ theme/related.tpl | 2 ++ xmlrpc.php | 32 ++++---------------------------- 8 files changed, 49 insertions(+), 39 deletions(-) create mode 100755 theme/pingbacks.tpl diff --git a/includes/footer.php b/includes/footer.php index 8cb0f2d..204aaf5 100755 --- a/includes/footer.php +++ b/includes/footer.php @@ -176,12 +176,9 @@ if (!isset($noRightbar)) break; } - if ($name != 'Pingback') - { - $template->adds_block('TOP', array( 'USERNAME' => $name, - 'COUNT' => $count)); - $i++; - } + $template->adds_block('TOP', array( 'USERNAME' => $name, + 'COUNT' => $count)); + $i++; } $gethits = "SELECT * FROM config WHERE name = \"hits\""; diff --git a/includes/functions.php b/includes/functions.php index 3e9382a..ee19391 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -166,12 +166,12 @@ function recalcPop($id) $popularity += ($getpost3['views']*2); $popularity += ($getpost3['rating']*5); - $getcomments = "SELECT COUNT(*) FROM comments WHERE page_id = \"updates-" . $id . "\" AND username <> \"Pingback\""; + $getcomments = "SELECT COUNT(*) FROM comments WHERE page_id = \"updates-" . $id . "\""; $getcomments2 = mysql_query($getcomments); $getcomments3 = mysql_fetch_array($getcomments2); $popularity += ($getcomments3[0] * 10); - $getpings = "SELECT COUNT(*) FROM comments WHERE page_id = \"updates-" . $id . "\" AND username = \"Pingback\""; + $getpings = "SELECT COUNT(*) FROM pingbacks WHERE post_id = " . $id; $getpings2 = mysql_query($getpings); $getpings3 = mysql_fetch_array($getpings2); $popularity += ($getpings3[0] * 25); diff --git a/index.php b/index.php index 12ba2ab..c7e6d5b 100755 --- a/index.php +++ b/index.php @@ -20,7 +20,7 @@ require('headerproc.php'); -header('X-Pingback: http://www.fourisland.com/xmlrpc.php'); +header('X-Pingback: http://fourisland.com/xmlrpc.php'); include('../security/config.php'); include('includes/db.php'); diff --git a/pages/blog.php b/pages/blog.php index c3f656b..ab198a0 100755 --- a/pages/blog.php +++ b/pages/blog.php @@ -105,6 +105,27 @@ if (isset($_GET['post'])) { $template->display(); } + + $getpings = "SELECT * FROM pingbacks WHERE post_id = " . $getpost3['id']; + $getpings2 = mysql_query($getpings); + $i=0; + while ($getpings3[$i] = mysql_fetch_array($getpings2)) + { + if ($i==0) + { + $template = new FITemplate('pingbacks'); + } + + $template->adds_block('PINGBACK', array( 'TITLE' => $getpings3[$i]['title'], + 'URL' => $getpings3[$i]['url'], + 'DATE' => date('F d<\S\U\P>S Y', strtotime($getpings3[$i]['pubDate'])))); + $i++; + } + + if ($i > 0) + { + $template->display(); + } } else { generateError('404'); } diff --git a/theme/comments.tpl b/theme/comments.tpl index 341d933..d814292 100755 --- a/theme/comments.tpl +++ b/theme/comments.tpl @@ -1,7 +1,7 @@ - + - +
diff --git a/theme/pingbacks.tpl b/theme/pingbacks.tpl new file mode 100755 index 0000000..0414fdb --- /dev/null +++ b/theme/pingbacks.tpl @@ -0,0 +1,14 @@ +
+ +
+
+
+
+ + on
+ +
+
+
+ Pingbacks +
diff --git a/theme/related.tpl b/theme/related.tpl index c070359..5875f3c 100755 --- a/theme/related.tpl +++ b/theme/related.tpl @@ -1,3 +1,5 @@ +
+
diff --git a/xmlrpc.php b/xmlrpc.php index 69990da..9ca47c4 100755 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -58,33 +58,15 @@ function ping($xmlrpcmsg) $title = $from; } - preg_match_all('/HREF="([^"]+)">([^>]+)<\/A>/i',$page_data,$matches); - for ($i=0;$i',"\n",$text); - $text = str_ireplace('
',"\n",$text); - $text = str_replace("\t", ' ', $text); - $text = preg_replace('/' . "\n" . '([ ]*)' . "\n" . '/i', '', $text); - - $commentText = "[url=" . $from . "]" . $title . "[/url]\n\n[....] " . $text . " [....]"; - - $getping = "SELECT * FROM comments WHERE page_id = \"updates-" . $getpost3['id'] . "\" AND comment = \"" . addslashes($commentText) . "\""; + $getping = "SELECT * FROM pingbacks WHERE post_id = " . $getpost3['id'] . " AND url = \"" . mysql_real_escape_string($from) . "\""; $getping2 = mysql_query($getping); $getping3 = mysql_fetch_array($getping2); - if ($getping3['comment'] == $commentText) + if ($getping3['url'] == $from) { return new xmlrpcresp(0, 48, "Target uri cannot be used as target"); } else { - $insping = "INSERT INTO comments (page_id,username,comment) VALUES (\"updates-" . $getpost3['id'] . "\",\"Pingback\",\"" . $commentText . "\")"; + $insping = "INSERT INTO pingbacks (post_id,title,url) VALUES (" . $getpost3['id'] . ",\"" . mysql_real_escape_string($title) . "\",\"" . mysql_real_escape_string($from) . "\")"; $insping2 = mysql_query($insping); recalcPop($getpost3['id']); @@ -101,13 +83,7 @@ function ping($xmlrpcmsg) } } -function rr($xmlrpcmsg) -{ - return new xmlrpcresp(new xmlrpcval(0, "int")); -} - $s = new xmlrpc_server(array( - "pingback.ping" => array("function" => "ping"), - "InstaDisc.checkRegistration" => array("function" => "rr"))); + "pingback.ping" => array("function" => "ping"))); ?> -- cgit 1.4.1