[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/comment.php,v $ 14 | $Revision: 1.53 $ 15 | $Date: 2007/01/05 08:59:18 $ 16 | $Author: lisa_ $ 17 +----------------------------------------------------------------------------+ 18 */ 19 require_once ("class2.php"); 20 require_once(e_HANDLER."news_class.php"); 21 require_once(e_HANDLER."comment_class.php"); 22 define("PAGE_NAME", COMLAN_99); 23 24 if (!e_QUERY) { 25 header("location:".e_BASE."index.php"); 26 exit; 27 } 28 29 $cobj =& new comment; 30 31 $temp_query = explode(".", e_QUERY); 32 $action = $temp_query[0]; 33 $table = $temp_query[1]; 34 $id = (isset($temp_query[2]) ? intval($temp_query[2]) : ""); 35 $nid = (isset($temp_query[3]) ? intval($temp_query[3]) : ""); 36 $xid = (isset($temp_query[4]) ? intval($temp_query[4]) : ""); 37 unset($temp_query); 38 39 if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit'])) { 40 if(!ANON && !USER) 41 { 42 header("location: ".e_BASE."index.php"); 43 exit; 44 } 45 46 if($table == "poll") { 47 if (!$sql->db_Select("polls", "poll_title", "`poll_id` = {$id} AND `poll_comment` = 1")) { 48 header("location: ".e_BASE."index.php"); 49 exit; 50 } 51 } else if($table == "news") { 52 if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = {$id} AND `news_allow_comments` = 0")) { 53 header("location: ".e_BASE."index.php"); 54 exit; 55 } 56 } 57 58 $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0); 59 $pid = intval($pid); 60 61 $editpid = intval((isset($_POST['editpid']) ? $_POST['editpid'] : false)); 62 63 $clean_authorname = $_POST['author_name']; 64 $clean_comment = $_POST['comment']; 65 $clean_subject = $_POST['subject']; 66 67 $cobj->enter_comment($clean_authorname, $clean_comment, $table, $id, $pid, $clean_subject); 68 if ($table == "news") { 69 $e107cache->clear("news"); 70 } else { 71 $e107cache->clear("comment.php?{$table}.{$id}"); 72 } 73 74 if($editpid) { 75 $redir = preg_replace("#\.edit.*#si", "", e_QUERY); 76 header("Location: ".e_SELF."?{$redir}"); 77 exit; 78 } 79 } 80 81 if (isset($_POST['replysubmit'])) 82 { 83 84 if ($table == "news" && !$sql->db_Select("news", "news_allow_comments", "news_id='{$nid}' ")) { 85 header("location:".e_BASE."index.php"); 86 exit; 87 } else { 88 $row = $sql->db_Fetch(); 89 if (!$row['news_id']) { 90 $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0); 91 $pid = intval($pid); 92 93 $clean_authorname = $_POST['author_name']; 94 $clean_comment = $_POST['comment']; 95 $clean_subject = $_POST['subject']; 96 97 $cobj->enter_comment($clean_authorname, $clean_comment, $table, $nid, $pid, $clean_subject); 98 $e107cache->clear("comment.php?{$table}.{$id}"); 99 } 100 //plugin e_comment.php files 101 $plugin_redir = false; 102 $e_comment = $cobj->get_e_comment(); 103 if ($table == $e_comment[$table]['eplug_comment_ids']){ 104 $plugin_redir = TRUE; 105 $reply_location = str_replace("{NID}", $nid, $e_comment[$table]['reply_location']); 106 } 107 108 if ($plugin_redir) 109 { 110 echo "<script type='text/javascript'>document.location.href='{$reply_location}'</script>\n"; 111 exit; 112 } elseif ($table == "news" || $table == "poll") 113 { 114 echo "<script type='text/javascript'>document.location.href='".e_BASE."comment.php?comment.{$table}.{$nid}'</script>\n"; 115 exit; 116 } elseif($table == "bugtrack") 117 { 118 echo "<script type='text/javascript'>document.location.href='".e_PLUGIN."bugtracker/bugtracker.php?show.{$nid}'</script>\n"; 119 exit; 120 } elseif($table == "faq") 121 { 122 echo "<script type='text/javascript'>document.location.href='".e_PLUGIN."faq/faq.php?cat.{$xid}.{$nid}'</script>\n"; 123 exit; 124 } elseif ($table == "content") 125 { 126 echo "<script type='text/javascript'>document.location.href='".e_BASE."content.php?{$_POST['content_type']}.{$nid}'</script>\n"; 127 exit; 128 } elseif ($table == "download") 129 { 130 echo "<script type='text/javascript'>document.location.href='".e_BASE."download.php?view.{$nid}'</script>\n"; 131 exit; 132 } elseif ($table == "page") 133 { 134 echo "<script type='text/javascript'>document.location.href='".e_BASE."page.php?{$nid}'</script>\n"; 135 exit; 136 } 137 } 138 } 139 140 if ($action == "reply") { 141 if (!$pref['nested_comments']) { 142 header("Location: ".e_BASE."comment.php?comment.{$table}.{$nid}"); 143 exit; 144 } 145 $query = "`comment_id` = '{$id}' LIMIT 0,1"; 146 if ($sql->db_Select("comments", "comment_subject", "`comment_id` = '{$id}'")) { 147 list($comments['comment_subject']) = $sql->db_Fetch(); 148 $subject = $comments['comment_subject']; 149 $subject_header = $tp->toHTML($comments['comment_subject']); 150 } 151 if ($subject == "") { 152 if ($table == "news") { 153 if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' ")) { 154 header("location: ".e_BASE."index.php"); 155 exit; 156 } else { 157 list($news['news_title']) = $sql->db_Fetch(); 158 $subject = $news['news_title']; 159 $title = COMLAN_100; 160 } 161 } elseif ($table == "poll") { 162 if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' ")) { 163 header("location:".e_BASE."index.php"); 164 exit; 165 } else { 166 list($poll['poll_title']) = $sql->db_Fetch(); 167 $subject = $poll['poll_title']; 168 $title = COMLAN_101; 169 } 170 } elseif ($table == "content") { 171 $sql->db_Select("content", "content_heading", "content_id='{$nid}'"); 172 $subject = $content['content_heading']; 173 } elseif ($table == "bugtracker") { 174 $sql->db_Select("bugtrack", "bugtrack_summary", "bugtrack_id='{$nid}'"); 175 $subject = $content['content_heading']; 176 } 177 } 178 if ($table == "content") { 179 $sql->db_Select("content", "content_type", "content_id='{$nid}'"); 180 list($content['content_type']) = $sql->db_Fetch(); 181 if ($content['content_type'] == "0") { 182 $content_type = "article"; 183 $title = COMLAN_103; 184 } elseif ($content['content_type'] == "3") { 185 $content_type = "review"; 186 $title = COMLAN_104; 187 } elseif ($content['content_type'] == "1") { 188 $content_type = "content"; 189 $title = COMLAN_105; 190 } 191 } 192 193 define('e_PAGETITLE', $title." / ".COMLAN_99." / ".COMLAN_102.$subject.""); 194 require_once(HEADERF); 195 } else { 196 197 198 if ($cache = $e107cache->retrieve("comment.php?{$table}.{$id}")) { 199 require_once(HEADERF); 200 echo $cache; 201 require_once(FOOTERF); 202 exit; 203 } else { 204 if ($table == "news") { 205 /* 206 changes by jalist 19/01/05: 207 updated db query removed one call 208 */ 209 210 if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) { 211 $query = "SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n 212 LEFT JOIN #user AS u ON n.news_author = u.user_id 213 LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id 214 LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id 215 WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' 216 AND n.news_id={$id} 217 AND n.news_allow_comments=0 218 GROUP by n.news_id"; 219 } else { 220 $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n 221 LEFT JOIN #user AS u ON n.news_author = u.user_id 222 LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id 223 WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' 224 AND n.news_id={$id} 225 AND n.news_allow_comments=0"; 226 } 227 228 if (!$sql->db_Select_gen($query)) { 229 header("location:".e_BASE."index.php"); 230 exit; 231 } else { 232 $news = $sql->db_Fetch(); 233 $subject = $tp->toForm($news['news_title']); 234 define("e_PAGETITLE", COMLAN_100." / ".COMLAN_99." / {$subject}"); 235 require_once(HEADERF); 236 ob_start(); 237 $ix = new news; 238 $ix->render_newsitem($news, "extend"); // extend so that news-title-only news text is displayed in full when viewing comments. 239 $field = $news['news_id']; 240 $comtype = 0; 241 } 242 } 243 else if($table == "poll") { 244 if (!$sql->db_Select("polls", "*", "poll_id='{$id}'")) { 245 header("location:".e_BASE."index.php"); 246 exit; 247 } else { 248 $row = $sql->db_Fetch(); 249 $comments_poll = $row['poll_comment']; 250 $subject = $row['poll_title']; 251 define("e_PAGETITLE", COMLAN_101." / ".COMLAN_99." / ".$subject.""); 252 require_once(HEADERF); 253 require(e_PLUGIN."poll/poll_menu.php"); 254 $field = $row['poll_id']; 255 $comtype = 4; 256 257 if(!$comments_poll) 258 { 259 require_once(FOOTERF); 260 exit; 261 } 262 } 263 } 264 require_once(HEADERF); 265 } 266 } 267 268 if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news"){ 269 echo "<span class='smalltext'><b>".$pref['trackbackString']."</b> ".$e107->http_path.e_PLUGIN."trackback/trackback.php?pid={$id}</span>"; 270 } 271 $field = ($field ? $field : ($id ? $id : "")); 272 $width = (isset($width) && $width ? $width : ""); 273 $cobj->compose_comment($table, $action, $field, $width, $subject, $rate=FALSE); 274 275 if (!strstr(e_QUERY, "poll")) { 276 $cache = ob_get_contents(); 277 $e107cache->set("comment.php?{$table}.{$field}", $cache); 278 } 279 ob_end_flush(); // dump the buffer we started 280 281 282 if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news"){ 283 if($sql->db_Select("trackback", "*", "trackback_pid={$id}")) 284 { 285 $tbArray = $sql -> db_getList(); 286 287 if (file_exists(THEME."trackback_template.php")) { 288 require_once(THEME."trackback_template.php"); 289 } else { 290 require_once(e_THEME."templates/trackback_template.php"); 291 } 292 293 $text = ""; 294 295 foreach($tbArray as $trackback) 296 { 297 extract($trackback); 298 $TITLE = $trackback_title; 299 $EXCERPT = $trackback_excerpt; 300 $BLOGNAME = "<a href='{$trackback_url}' rel='external'>{$trackback_blogname}</a>"; 301 $text .= preg_replace("/\{(.*?)\}/e", '$\1', $TRACKBACK); 302 } 303 304 if($TRACKBACK_RENDER_METHOD) 305 { 306 $ns->tablerender("<a name='track'></a>".COMLAN_315, $text); 307 } 308 else 309 { 310 echo "<a name='track'></a>".$text; 311 } 312 } 313 else 314 { 315 echo "<a name='track'></a>".COMLAN_316; 316 } 317 if (ADMIN && getperms("B")) { 318 echo "<div style='text-align:right'><a href='".e_PLUGIN."trackback/modtrackback.php?".$id."'>".COMLAN_317."</a></div><br />"; 319 } 320 } 321 322 323 require_once(FOOTERF); 324 325 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |