root/trunk/common/tb.php

Revision 776, 2.3 KB (checked in by michiel, 9 months ago)

update copyright year.

Closes #180

  • Property svn:keywords set to Id
Line 
1<?php
2/**
3 * MvBlog -- An open source no-nosense blogtool
4 *
5 * Copyright (C) 2005-2008, 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-2008 Michiel van Baak
19 */
20require("mvblog.php");
21$mvblog = new MvBlog();
22
23function 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);
45if (!$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
54if (!$tb_id) {
55    tb_response(1, "You need to supply a postID.");
56}
57
58if (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);
72if (PEAR::isError($res)) {
73    tb_response(1, "Something went wrong with inserting your trackback in the comments system. error:".$res->getMessage());
74}
75tb_response();
76?>
Note: See TracBrowser for help on using the browser.