[ Index ] |
|
Code source de Dotclear 1.2.5 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2004 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 # Chemin vers la racine de l'application (si vous changer le fichier de place) 24 $app_path = '/'; 25 require dirname(__FILE__).$app_path.'/inc/prepend.php'; 26 27 28 # Si on est là, alors on a un _POST 29 # Connexion et création du blog 30 header('Content-Type: text/xml'); 31 echo '<?xml version="1.0" encoding="'.dc_encoding.'"?>'."\n"; 32 echo '<response>'."\n"; 33 34 $content = ''; 35 36 if (empty($_GET['id'])) 37 { 38 $content = '<error>1</error>'."\n". 39 '<message>No ID.</message>'; 40 } 41 else 42 { 43 $id = $_GET['id']; 44 45 $con = new Connection(DB_USER,DB_PASS,DB_HOST,DB_DBASE); 46 47 if($con->error()) 48 { 49 $content = '<error>1</error>'."\n". 50 '<message>MySQL connection error : '.$con->error().'</message>'; 51 } 52 else 53 { 54 $blog = new blog($con,DB_PREFIX,1,dc_encoding); 55 56 $blog->setURL('post',dc_blog_url.dc_format_post_url); 57 58 $post = $blog->getPostByID($id); 59 60 if ($post->isEmpty()) 61 { 62 $content = '<error>1</error>'."\n". 63 '<message>No post for this ID.</message>'; 64 } 65 elseif (!dc_allow_trackbacks || !$post->f('post_open_tb') 66 || (dc_comments_ttl!=0 && time()-(dc_comments_ttl*86400) > $post->getTS())) 67 { 68 $content = '<error>1</error>'."\n". 69 '<message>Trackbacks are not allowed for this post or weblog.</message>'; 70 } 71 elseif (isset($_REQUEST['__info'])) 72 { 73 $content = 74 '<error>0</error>'."\n". 75 '<engine>DotClear</engine>'."\n". 76 '<version>'.DC_VERSION.'</version>'."\n". 77 '<encoding>'.dc_encoding.'</encoding>'."\n"; 78 } 79 elseif (!empty($_REQUEST['__mode']) && $_REQUEST['__mode'] == 'rss') 80 { 81 $tb_url = 'http://'.$_SERVER['HTTP_HOST'].dc_trackback_uri.'&id='.$id; 82 83 if ($post->f('post_chapo') != '') { 84 $post_excerpt = $post->f('post_chapo'); 85 } else { 86 $post_excerpt = $post->f('post_content'); 87 } 88 $post_excerpt = util::cutString(strip_tags($post_excerpt),255); 89 90 $content = 91 '<error>0</error>'."\n". 92 '<rss version="0.91"><channel>'."\n". 93 '<title>'.dc_blog_name.' - Trackback</title>'."\n". 94 '<link>'.$tb_url.'</link>'."\n". 95 '<description>TrackBack item for this blog</description>'."\n". 96 '<language>fr</language>'."\n". 97 '<item>'."\n". 98 '<title>'.$blog->toXML($post->f('post_titre'),0).'</title>'."\n". 99 '<link>'.util::getHost().$post->getPermURL().'</link>'."\n". 100 '<description>'.$post_excerpt.'</description>'."\n". 101 '</item>'."\n". 102 '</channel>'."\n". 103 '</rss>'; 104 } 105 elseif (empty($_REQUEST['url'])) 106 { 107 $content = 108 '<error>1</error>'."\n". 109 '<message>URL parameter is requiered.</message>'; 110 } 111 else 112 { 113 $url = $_REQUEST['url']; 114 $title = (!empty($_REQUEST['title'])) ? $_REQUEST['title'] : $url; 115 $excerpt = (!empty($_REQUEST['excerpt'])) ? $_REQUEST['excerpt'] : ''; 116 $blog_name = (!empty($_REQUEST['blog_name'])) ? $_REQUEST['blog_name'] : ''; 117 118 $title = strip_tags(trim($title)); 119 $excerpt = strip_tags($excerpt); 120 $blog_name = strip_tags($blog_name); 121 122 if ($title == '') { 123 $title = $url; 124 } 125 126 if (strlen($excerpt) > 255) { 127 $excerpt = util::cutString($excerpt,252).'...'; 128 } 129 130 $is_utf8 = util::isUTF8($title) || util::isUTF8($excerpt) || util::isUTF8($blog_name); 131 132 if (dc_encoding != 'UTF-8' && $is_utf8) 133 { 134 $title = utf8_decode($title); 135 $excerpt = utf8_decode($excerpt); 136 $blog_name = utf8_decode($blog_name); 137 } 138 elseif (dc_encoding == 'UTF-8' && !$is_utf8) 139 { 140 $title = utf8_encode($title); 141 $excerpt = utf8_encode($excerpt); 142 $blog_name = utf8_encode($blog_name); 143 } 144 145 $comment = '<!-- TB -->'."\n". 146 '<p><strong>'.$title.'</strong></p>'."\n". 147 '<p>'.$excerpt.'</p>'; 148 149 if ($blog->addComment($id,$blog_name,'',$url,$comment,true) !== false) 150 { 151 $content = '<error>0</error>'; 152 153 if (dc_comment_notification && $post->f('user_email') != '') 154 { 155 $n_titre = $blog->removeEntities($post->f('post_titre')); 156 $n_mail = $post->f('user_email'); 157 $n_subject = util::mimeEncode('['.dc_blog_name.'] '.$n_titre,dc_encoding); 158 159 $n_content = 160 sprintf(__('Trackback for entry %s'),$n_titre)."\n\n". 161 sprintf(__('By: %s'),$blog_name)."\n". 162 sprintf(__('Website: %s'),$url)."\n". 163 "\n".$title."\n\n".$excerpt."\n". 164 "--\n". 165 util::getHost().$post->getPermURL(); 166 167 $n_headers = 168 'From: '.$n_mail."\r\n". 169 'Content-Type: text/plain; charset='.dc_encoding.";\r\n". 170 "X-Mailer: DotClear\r\n". 171 'X-Blog: '.util::getHost().dc_blog_url; 172 173 @mail($n_mail,$n_subject,$n_content,$n_headers); 174 } 175 } 176 else 177 { 178 $err = $blog->error(0); 179 $content = 180 '<error>1</error>'."\n". 181 '<message>'.$err[0][1].'</message>'; 182 } 183 } 184 185 $con->close(); 186 } 187 } 188 189 echo $content."\n"; 190 echo '</response>'; 191 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 21:40:15 2007 | par Balluche grâce à PHPXref 0.7 |