| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 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 | |
|---|
| 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 | tb_response(); |
|---|
| 76 | ?> |
|---|