Mercurial > defr > DualBlog
comparison tb.php @ 0:629389204276
Import initial
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Sat, 20 Oct 2007 14:15:10 +0200 |
parents | |
children | 434751e80c88 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:629389204276 |
---|---|
1 <?php | |
2 header("Content-Type: text/xml"); | |
3 echo("<?xml version='1.0' encoding='utf-8'?>"); | |
4 include("classes.php"); | |
5 $id = $_GET['id']; | |
6 $Data->Query("SELECT * FROM Messages WHERE num_mess=$id"); | |
7 $post_infos = $Data->GetRow(); | |
8 $titre = array_key_exists("title", $_POST)?$_POST['title']:"Undefined"; | |
9 $url = array_key_exists("url", $_POST)?$_POST['url']:"#"; | |
10 $info = array_key_exists("__info", $_POST)?$_POST['__info']:-1; | |
11 if($info == 1) { | |
12 $error = 0; | |
13 $message = "Some informations"; | |
14 } else if($url == "#") { | |
15 $error = 1; | |
16 $message = "The url field is needed for trackback to do something usefull !"; | |
17 } else if($post_infos === 0) { | |
18 $error = 1; | |
19 $message = "There's no post with this id"; | |
20 } else { | |
21 $excerpt = $_POST['excerpt']; | |
22 $DateComment = gmdate("Y-m-d H:i:s"); | |
23 if(strlen($excerpt) > 255) $excerpt = substr($excerpt, 0, 255) . "..."; | |
24 $Data = new DataAccess(); | |
25 $Data->Query("INSERT INTO Commentaires(MessId, Auteur, Adresse, Comment, DateComment, isTrackback) | |
26 VALUES({$id}, '{$titre}', '{$url}', '{$excerpt}', '{$DateComment}', 1)"); | |
27 $Data->Query("UPDATE Mess SET NbCommentaires=NbCommentaires+1 WHERE num_mess={$id}"); | |
28 $error = 0; | |
29 $excerpt = htmlentities(urlencode(substr(strip_tags($post_infos['Message']), 0, 252) . "...") | |
30 } | |
31 | |
32 echo "<response> | |
33 <error>$error</error> | |
34 <message>$message</message> | |
35 <engine>Dual Blog custom made PHP script</engine> | |
36 <encoding>UTF-8</encoding> | |
37 <blog>Dual Blog</blog> | |
38 <title>{$post_infos['Titre']}</title> | |
39 <url>http://defr.org/post/{$post_infos['num_mess']}</url> | |
40 <excerpt>$excerpt</excerpt> | |
41 </response>"; | |
42 ?> |