Source for file tb.php

Documentation is available at tb.php

  1. <?php
  2. /**
  3.  * MvBlog -- An open source no-nosense blogtool
  4.  *
  5.  * Copyright (C) 2005-2007, Michiel van Baak
  6.  * Michiel van Baak <mvanbaak@users.sourceforge.net>
  7.  *
  8.  * See http://www.mvblog.org for more information on MvBlog.
  9.  * That page also provides Bugtrackers, Filereleases etc.
  10.  *
  11.  * This program is free software, distributed under the terms of
  12.  * the GNU General Public License Version 2. See the LICENSE file
  13.  * at the top of the source tree.
  14.  *
  15.  * @package MvBlog
  16.  * @author Michiel van Baak
  17.  * @version %%VERSION%%
  18.  * @copyright 2005-2007 Michiel van Baak
  19.  */
  20. require("mvblog.php");
  21. $mvblog new MvBlog();
  22.  
  23. function tb_response($error=0$errorstr=""{
  24.     header("Content-Type: text/xml; charset=UTF-8");
  25.     if ($error{
  26.         echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
  27.         echo "<response>\n";
  28.         echo "<error>1</error>\n";
  29.         echo "<message>$errorstr</message>\n";
  30.         echo "</response>";
  31.         die();
  32.     else {
  33.         echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
  34.         echo "<response>\n";
  35.         echo "<error>0</error>\n";
  36.         echo "</response>";
  37.     }
  38.     exit();
  39. }
  40. $tb_id $_GET["id"];
  41. /* check to see if this article is here */
  42. $sql sprintf("SELECT COUNT(*) AS count FROM articles WHERE active = 1 AND public = 1 AND id = %d"$tb_id);
  43. $res =$mvblog->db->query($sql);
  44. $row $res->fetchRow(MDB2_FETCHMODE_ASSOC);
  45. if (!$row["count"]{
  46.     tb_response(1"Invalid post.");
  47. }
  48. $tb_url    $_POST["url"];
  49. $title     $_POST["title"];
  50. $excerpt   $_POST["excerpt"];
  51. $blog_name $_POST["blog_name"];
  52. $charset   $_POST["charset"];
  53.  
  54. if (!$tb_id{
  55.     tb_response(1"You need to supply a postID.");
  56. }
  57.  
  58. if (empty($title&& empty($tb_url&& empty($blog_name)) {
  59.     tb_response(1"You need to supply some data.");
  60. }
  61.  
  62. $sql sprintf("INSERT INTO comments (name, website, email, comment, date, articles_id, title) VALUES ('%s', '%s', '%s', '%s', %d, %d, '%s'",
  63.     preg_quote(strip_tags($blog_name)"'"),
  64.     preg_quote(strip_tags($tb_url)"'"),
  65.      " ",
  66.     "<strong>".preg_quote(strip_tags($title)"'")."</strong>\n\n".preg_quote(strip_tags($excerpt)"'"),
  67.     mktime(),
  68.     $tb_id,
  69.     preg_quote(strip_tags($title)"'")
  70. );
  71. $res =$mvblog->db->exec($sql);
  72. if (PEAR::isError($res)) {
  73.     tb_response(1"Something went wrong with inserting your trackback in the comments system. error:".$res->getMessage());
  74. }
  75. ?>

Documentation generated on Fri, 28 Dec 2007 13:17:42 +0100 by phpDocumentor 1.4.1