| [ Index ] |
PHP Cross Reference of E107 v0.7.22 code documentation |
[Summary view] [Print] [Text view]
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: /cvs_backup/e107_0.7/comment.php,v $ 14 | $Revision: 11499 $ 15 | $Date: 2010-04-25 16:17:51 -0400 (Sun, 25 Apr 2010) $ 16 | $Author: e107steved $ 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 { 26 header("location:".e_BASE."index.php"); 27 exit; 28 } 29 30 $cobj = new comment; 31 32 $temp_query = explode(".", e_QUERY); 33 $action = $temp_query[0]; // Usually says 'comment' - may say 'reply' 34 $table = $temp_query[1]; // Table containing item associated with comment(s) 35 $id = intval(varset($temp_query[2], "")); // ID of item associated with comments (e.g. news ID) 36 // For reply with nested comments, its the ID of the comment 37 $nid = intval(varset($temp_query[3], "")); // Action - e.g. 'edit'. Or news ID for reply with nested comments 38 $xid = intval(varset($temp_query[4], "")); // ID of target comment 39 global $comment_edit_query; 40 $comment_edit_query = $temp_query[0].".".$temp_query[1].".".$temp_query[2]; 41 unset($temp_query); 42 43 $redirectFlag = 0; 44 if (isset($_POST['commentsubmit']) || isset($_POST['editsubmit'])) 45 { // New comment, or edited comment, being posted. 46 if(!ANON && !USER) 47 { 48 header("location: ".e_BASE."index.php"); 49 exit; 50 } 51 52 if($table == "poll") 53 { 54 if (!$sql->db_Select("polls", "poll_title", "`poll_id` = '{$id}' AND `poll_comment` = 1")) 55 { 56 header("location: ".e_BASE."index.php"); 57 exit; 58 } 59 } 60 elseif($table == "news") 61 { 62 if (!$sql->db_Select("news", "news_allow_comments", "`news_id` = '{$id}' AND `news_allow_comments` = 0")) 63 { 64 header("location: ".e_BASE."index.php"); 65 exit; 66 } 67 } 68 69 $pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies) 70 71 $editpid = intval(varset($_POST['editpid'], 0)); // ID of the specific comment being edited (in-line comments) 72 73 $clean_authorname = $_POST['author_name']; 74 $clean_comment = $_POST['comment']; 75 $clean_subject = $_POST['subject']; 76 77 $cobj->enter_comment($clean_authorname, $clean_comment, $table, $id, $pid, $clean_subject); 78 if ($table == "news") 79 { 80 $e107cache->clear("news"); 81 } 82 else 83 { 84 $e107cache->clear("comment.php?{$table}.{$id}"); 85 } 86 87 if($editpid) 88 { 89 $redirectFlag = $id; 90 /* $redir = preg_replace("#\.edit.*#si", "", e_QUERY); 91 header("Location: ".e_SELF."?{$redir}"); 92 exit; */ 93 } 94 } 95 96 97 if (isset($_POST['replysubmit'])) 98 { // Reply to nested comment being posted 99 if ($table == "news" && !$sql->db_Select("news", "news_allow_comments", "news_id='{$nid}' ")) 100 { 101 header("location:".e_BASE."index.php"); 102 exit; 103 } 104 else 105 { 106 $row = $sql->db_Fetch(); 107 if (!$row['news_id']) 108 { 109 $pid = (isset($_POST['pid']) ? $_POST['pid'] : 0); 110 $pid = intval($pid); 111 112 $clean_authorname = $_POST['author_name']; 113 $clean_comment = $_POST['comment']; 114 $clean_subject = $_POST['subject']; 115 116 $cobj->enter_comment($clean_authorname, $clean_comment, $table, $nid, $pid, $clean_subject); 117 $e107cache->clear("comment.php?{$table}.{$id}"); 118 } 119 $redirectFlag = $nid; 120 } 121 } 122 123 if ($redirectFlag) 124 { // Need to go back to original page 125 126 // Check plugin e_comment.php files 127 $plugin_redir = false; 128 $e_comment = $cobj->get_e_comment(); 129 if ($table == $e_comment[$table]['eplug_comment_ids']) 130 { 131 $plugin_redir = TRUE; 132 $reply_location = str_replace("{NID}", $redirectFlag, $e_comment[$table]['reply_location']); 133 } 134 135 if ($plugin_redir) 136 { 137 echo "<script type='text/javascript'>document.location.href='{$reply_location}'</script>\n"; 138 exit; 139 } 140 else 141 { 142 switch ($table) 143 { 144 case "news" : 145 case "poll" : 146 echo "<script type='text/javascript'>document.location.href='".e_HTTP."comment.php?comment.{$table}.{$redirectFlag}'</script>\n"; 147 exit; 148 break; 149 case "download" : 150 echo "<script type='text/javascript'>document.location.href='".e_HTTP."download.php?view.{$redirectFlag}'</script>\n"; 151 exit; 152 break; 153 case "page" : 154 echo "<script type='text/javascript'>document.location.href='".e_HTTP."page.php?{$redirectFlag}'</script>\n"; 155 exit; 156 break; 157 } 158 } 159 } 160 161 $comment_ob_start = FALSE; 162 if ($action == "reply") 163 { 164 if (!$pref['nested_comments']) 165 { 166 header("Location: ".e_BASE."comment.php?comment.{$table}.{$nid}"); 167 exit; 168 } 169 170 $query = "`comment_id` = '{$id}' LIMIT 0,1"; 171 if ($sql->db_Select("comments", "comment_subject", "`comment_id` = '{$id}'")) 172 { 173 list($comments['comment_subject']) = $sql->db_Fetch(); 174 $subject = $comments['comment_subject']; 175 $subject_header = $tp->toHTML($comments['comment_subject']); 176 } 177 178 if ($subject == "") 179 { 180 switch ($table) 181 { 182 case "news" : 183 if (!$sql->db_Select("news", "news_title", "news_id='{$nid}' ")) 184 { 185 header("location: ".e_BASE."index.php"); 186 exit; 187 } 188 else 189 { 190 list($news['news_title']) = $sql->db_Fetch(); 191 $subject = $news['news_title']; 192 $title = COMLAN_100; 193 } 194 case "poll" : 195 if (!$sql->db_Select("polls", "poll_title", "poll_id='{$nid}' ")) 196 { 197 header("location:".e_BASE."index.php"); 198 exit; 199 } 200 else 201 { 202 list($poll['poll_title']) = $sql->db_Fetch(); 203 $subject = $poll['poll_title']; 204 $title = COMLAN_101; 205 } 206 break; 207 case 'download' : 208 if ($sql->db_Select('download','download_name',"download_id={$nid} ")) 209 { 210 $row = $sql->db_Fetch(); 211 $subject = $row['download_name']; 212 $title = COMLAN_106; 213 } 214 else 215 { 216 header("location:".e_BASE."index.php"); 217 exit; 218 } 219 break; 220 } 221 } 222 define('e_PAGETITLE', $title." / ".COMLAN_99." / ".COMLAN_102.$subject.""); 223 require_once(HEADERF); 224 } 225 elseif ($action == 'comment') 226 { // Default code if not reply 227 228 // Check cache 229 if ($cache = $e107cache->retrieve("comment.php?{$table}.{$id}")) 230 { 231 require_once(HEADERF); 232 echo $cache; 233 require_once(FOOTERF); 234 exit; 235 } 236 else 237 { 238 switch ($table) 239 { 240 case "news" : 241 if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) 242 { 243 $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 244 LEFT JOIN #user AS u ON n.news_author = u.user_id 245 LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id 246 LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id 247 WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' 248 AND n.news_id={$id} 249 AND n.news_allow_comments=0 250 GROUP by n.news_id"; 251 } 252 else 253 { 254 $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n 255 LEFT JOIN #user AS u ON n.news_author = u.user_id 256 LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id 257 WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' 258 AND n.news_id={$id} 259 AND n.news_allow_comments=0"; 260 } 261 262 if (!$sql->db_Select_gen($query)) 263 { 264 header("location:".e_BASE."index.php"); 265 exit; 266 } 267 else 268 { 269 $news = $sql->db_Fetch(); 270 $subject = $tp->toForm($news['news_title']); 271 define("e_PAGETITLE", COMLAN_100." / ".COMLAN_99." / {$subject}"); 272 require_once(HEADERF); 273 ob_start(); 274 $comment_ob_start = TRUE; 275 $ix = new news; 276 $ix->render_newsitem($news, "extend"); // extend so that news-title-only news text is displayed in full when viewing comments. 277 $field = $news['news_id']; 278 } 279 break; 280 case "poll" : 281 if (!$sql->db_Select("polls", "*", "poll_id='{$id}'")) 282 { 283 header("location:".e_BASE."index.php"); 284 exit; 285 } 286 else 287 { 288 $row = $sql->db_Fetch(); 289 $comments_poll = $row['poll_comment']; 290 $subject = $row['poll_title']; 291 define("e_PAGETITLE", COMLAN_101." / ".COMLAN_99." / ".$subject.""); 292 $poll_to_show = $id; // Need to pass poll number through to display routine 293 require_once(HEADERF); 294 require(e_PLUGIN."poll/poll_menu.php"); 295 $field = $row['poll_id']; 296 if(!$comments_poll) 297 { 298 require_once(FOOTERF); 299 exit; 300 } 301 } 302 break; 303 case 'download' : 304 if ($sql->db_Select('download','download_name',"download_id={$id} ")) 305 { 306 $row = $sql->db_Fetch(); 307 $subject = $row['download_name']; 308 $title = COMLAN_106; 309 $field = $id; 310 require_once(HEADERF); 311 } 312 else 313 { 314 header("location:".e_BASE."index.php"); 315 exit; 316 } 317 break; 318 default : // Hope its a plugin table 319 $e_comment = $cobj->get_e_comment(); 320 if ($table == $e_comment[$table]['eplug_comment_ids']) 321 { 322 if ($sql->db_Select($table,$e_comment[$table]['db_title'],$e_comment[$table]['db_id']."={$id} ")) 323 { 324 $row = $sql->db_Fetch(); 325 $subject = $row[$e_comment[$table]['db_title']]; 326 $title = $e_comment[$table]['plugin_name']; 327 $field = $id; 328 require_once(HEADERF); 329 } 330 else 331 { 332 header("location:".e_BASE."index.php"); 333 exit; 334 } 335 } 336 else 337 { // Error - emit some debug code 338 require_once(HEADERF); 339 if (E107_DEBUG_LEVEL) 340 { 341 echo "Comment error: {$table} Field: {$e_comment['db_id']} ID {$id} Title: {$e_comment['db_title']}<br />"; 342 echo "<pre>"; 343 var_dump($e_comment); 344 echo "</pre>"; 345 } 346 else 347 { 348 header('location:'.e_BASE.'index.php'); 349 exit; 350 } 351 } 352 } 353 } 354 } 355 else 356 { // Invalid action - just exit 357 header("location:".e_BASE."index.php"); 358 exit; 359 } 360 361 if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news") 362 { 363 echo "<span class='smalltext'><b>".$pref['trackbackString']."</b> ".SITEURLBASE.e_PLUGIN_ABS."trackback/trackback.php?pid={$id}</span>"; 364 } 365 366 $field = ($field ? $field : ($id ? $id : "")); // ID of associated source item 367 $width = (isset($width) && $width ? $width : ""); 368 $cobj->compose_comment($table, $action, $field, $width, $subject, $rate=FALSE); 369 370 371 372 if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'] && $table == "news") 373 { 374 if($sql->db_Select("trackback", "*", "trackback_pid={$id}")) 375 { 376 $tbArray = $sql -> db_getList(); 377 378 if (file_exists(THEME."trackback_template.php")) { 379 require_once(THEME."trackback_template.php"); 380 } else { 381 require_once(e_THEME."templates/trackback_template.php"); 382 } 383 384 $text = ""; 385 386 foreach($tbArray as $trackback) 387 { 388 extract($trackback); 389 $TITLE = $trackback_title; 390 $EXCERPT = $trackback_excerpt; 391 $BLOGNAME = "<a href='{$trackback_url}' rel='external'>{$trackback_blogname}</a>"; 392 $text .= preg_replace("/\{(.*?)\}/e", '$\1', $TRACKBACK); 393 } 394 395 if($TRACKBACK_RENDER_METHOD) 396 { 397 $ns->tablerender("<a name='track'></a>".COMLAN_315, $text); 398 } 399 else 400 { 401 echo "<a name='track'></a>".$text; 402 } 403 } 404 else 405 { 406 echo "<a name='track'></a>".COMLAN_316; 407 } 408 if (ADMIN && getperms("B")) { 409 echo "<div style='text-align:right'><a href='".e_PLUGIN_ABS."trackback/modtrackback.php?".$id."'>".COMLAN_317."</a></div><br />"; 410 } 411 } 412 413 414 //if (!strstr(e_QUERY, "poll")) 415 // If output buffering started, cache the result 416 if ($comment_ob_start) 417 { 418 $cache = ob_get_contents(); 419 $e107cache->set("comment.php?{$table}.{$field}", $cache); 420 ob_end_flush(); // dump the buffer we started 421 } 422 423 424 require_once(FOOTERF); 425 426 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Aug 3 00:19:13 2010 |