[ Index ] |
|
Code source de Phorum 5.1.25 |
1 <?php 2 3 //////////////////////////////////////////////////////////////////////////////// 4 // // 5 // Copyright (C) 2006 Phorum Development Team // 6 // http://www.phorum.org // 7 // // 8 // This program is free software. You can redistribute it and/or modify // 9 // it under the terms of either the current Phorum License (viewable at // 10 // phorum.org) or the Phorum License that was distributed with this file // 11 // // 12 // This program 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. // 15 // // 16 // You should have received a copy of the Phorum License // 17 // along with this program. // 18 //////////////////////////////////////////////////////////////////////////////// 19 define('phorum_page','list'); 20 21 include_once ("./common.php"); 22 include_once ("./include/format_functions.php"); 23 24 // set all our common URL's 25 phorum_build_common_urls(); 26 27 if(!phorum_check_read_common()) { 28 return; 29 } 30 31 32 if(empty($PHORUM["forum_id"])){ 33 $dest_url = phorum_get_url(PHORUM_INDEX_URL); 34 phorum_redirect_by_url($dest_url); 35 exit(); 36 } 37 38 // somehow we got to a folder in list.php 39 if($PHORUM["folder_flag"]){ 40 $dest_url = phorum_get_url(PHORUM_INDEX_URL, $PHORUM["forum_id"]); 41 phorum_redirect_by_url($dest_url); 42 exit(); 43 } 44 45 // check for markread 46 if (!empty($PHORUM["args"][1]) && $PHORUM["args"][1] == 'markread'){ 47 // setting all posts read 48 unset($PHORUM['user']['newinfo']); 49 phorum_db_newflag_allread(); 50 51 // redirect to a fresh list without markread in url 52 $dest_url = phorum_get_url(PHORUM_LIST_URL); 53 phorum_redirect_by_url($dest_url); 54 exit(); 55 56 } 57 58 if ($PHORUM["DATA"]["LOGGEDIN"]) { // reading newflags in 59 $PHORUM['user']['newinfo']=phorum_db_newflag_get_flags(); 60 } 61 62 // figure out what page we are on 63 if (empty($PHORUM["args"]["page"]) || !is_numeric($PHORUM["args"]["page"]) || $PHORUM["args"]["page"] < 0){ 64 $page=1; 65 } else { 66 $page=intval($PHORUM["args"]["page"]); 67 } 68 $offset=$page-1; 69 70 // check the moderation-settings 71 $PHORUM["DATA"]["MODERATOR"] = phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_MESSAGES); 72 73 $build_move_url=false; 74 if($PHORUM["DATA"]["MODERATOR"]) { 75 // find out how many forums this user can moderate 76 $forums=phorum_db_get_forums(0,-1,$PHORUM['vroot']); 77 78 $modforums=0; 79 foreach($forums as $id=>$forum){ 80 if($forum["folder_flag"]==0 && phorum_user_moderate_allowed($id)){ 81 $modforums++; 82 } 83 if($modforums > 1) { 84 $build_move_url=true; 85 break; 86 } 87 } 88 } 89 // Get the threads 90 $rows = array(); 91 92 // get the thread set started 93 $rows = phorum_db_get_thread_list($offset); 94 95 // redirect if invalid page 96 if(count($rows) < 1 && $offset > 0){ 97 $dest_url = phorum_get_url(PHORUM_LIST_URL); 98 phorum_redirect_by_url($dest_url); 99 exit(); 100 } 101 102 if($PHORUM['threaded_list']) { // make it simpler :) 103 $PHORUM["list_length"] = $PHORUM['list_length_threaded']; 104 } else { 105 $PHORUM["list_length"] = $PHORUM['list_length_flat']; 106 } 107 108 // Figure out paging for threaded and flat mode. Sticky messages 109 // are in the thread_count, but because these are handled as a separate 110 // list (together with the announcements), they should not be included 111 // in the pages computation. 112 $pages=ceil(($PHORUM["thread_count"] - $PHORUM['sticky_count']) / $PHORUM["list_length"]); 113 114 // If we only have stickies and/of announcements, the number of pages 115 // will be zero. In that case, simply use one page. 116 if ($pages == 0) $pages = 1; 117 118 if($pages<=11){ 119 $page_start=1; 120 } elseif($pages-$page<5) { 121 $page_start=$pages-10; 122 } elseif($pages>11 && $page>6){ 123 $page_start=$page-5; 124 } else { 125 $page_start=1; 126 } 127 128 $pageno=1; 129 for($x=0;$x<11 && $x<$pages;$x++){ 130 $pageno=$x+$page_start; 131 $PHORUM["DATA"]["PAGES"][] = array( 132 "pageno"=>$pageno, 133 "url"=>phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$pageno") 134 ); 135 } 136 137 $PHORUM["DATA"]["CURRENTPAGE"]=$page; 138 $PHORUM["DATA"]["TOTALPAGES"]=$pages; 139 140 if($page_start>1){ 141 $PHORUM["DATA"]["URL"]["FIRSTPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=1"); 142 } 143 144 if($pageno<$pages){ 145 $PHORUM["DATA"]["URL"]["LASTPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$pages"); 146 } 147 148 if($pages>$page){ 149 $nextpage=$page+1; 150 $PHORUM["DATA"]["URL"]["NEXTPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$nextpage"); 151 } 152 if($page>1){ 153 $prevpage=$page-1; 154 $PHORUM["DATA"]["URL"]["PREVPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$prevpage"); 155 } 156 157 $min_id=0; 158 if ($PHORUM["threaded_list"]){ 159 160 // loop through and read all the data in. 161 foreach($rows as $key => $row){ 162 163 if($PHORUM["count_views"]) { // show viewcount if enabled 164 if($PHORUM["count_views"] == 2) { // viewcount as column 165 $PHORUM["DATA"]["VIEWCOUNT_COLUMN"]=true; 166 $rows[$key]["viewcount"]=$row['viewcount']; 167 } else { // viewcount added to the subject 168 $rows[$key]["subject"]=$row["subject"]." ({$row['viewcount']} " . strtolower($PHORUM['DATA']['LANG']['Views']) . ")"; 169 } 170 } 171 172 $rows[$key]["datestamp"] = phorum_date($PHORUM["short_date"], $row["datestamp"]); 173 $rows[$key]["lastpost"] = phorum_date($PHORUM["short_date"], $row["modifystamp"]); 174 $rows[$key]["url"] = phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["message_id"]); 175 176 if($row["message_id"] == $row["thread"]){ 177 $rows[$key]["threadstart"] = true; 178 }else{ 179 $rows[$key]["threadstart"] = false; 180 } 181 182 $rows[$key]["delete_url1"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_MESSAGE, $row["message_id"]); 183 $rows[$key]["delete_url2"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_TREE, $row["message_id"]); 184 if($build_move_url) { 185 $rows[$key]["move_url"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_MOVE_THREAD, $row["message_id"]); 186 } 187 $rows[$key]["merge_url"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_MERGE_THREAD, $row["message_id"]); 188 189 $rows[$key]["new"] = ""; 190 // recognizing moved threads 191 if(isset($row['meta']['moved']) && $row['meta']['moved'] == 1) { 192 $rows[$key]['moved']=1; 193 } elseif ($PHORUM["DATA"]["LOGGEDIN"]){ 194 195 // newflag, if its NOT in newinfo AND newer (min than min_id, 196 // then its a new message 197 198 // newflag for collapsed special threads (sticky and announcement) 199 if (($rows[$key]['sort'] == PHORUM_SORT_STICKY || 200 $rows[$key]['sort'] == PHORUM_SORT_ANNOUNCEMENT) && 201 isset($row['meta']['message_ids']) && 202 is_array($row['meta']['message_ids'])) { 203 foreach ($row['meta']['message_ids'] as $cur_id) { 204 if(!isset($PHORUM['user']['newinfo'][$cur_id]) && $cur_id > $PHORUM['user']['newinfo']['min_id']) 205 $rows[$key]["new"] = $PHORUM["DATA"]["LANG"]["newflag"]; 206 } 207 } 208 // newflag for regular messages 209 else { 210 if (!isset($PHORUM['user']['newinfo'][$row['message_id']]) && $row['message_id'] > $PHORUM['user']['newinfo']['min_id']) { 211 $rows[$key]["new"]=$PHORUM["DATA"]["LANG"]["newflag"]; 212 } 213 } 214 } 215 216 if ($row["user_id"]){ 217 $url = phorum_get_url(PHORUM_PROFILE_URL, $row["user_id"]); 218 $rows[$key]["profile_url"] = $url; 219 $rows[$key]["linked_author"] = "<a href=\"$url\">".htmlspecialchars($row['author'])."</a>"; 220 }else{ 221 $rows[$key]["profile_url"] = ""; 222 if(!empty($row['email'])) { 223 $email_url = phorum_html_encode("mailto:$row[email]"); 224 // we don't normally put HTML in this code, but this makes it easier on template builders 225 $rows[$key]["linked_author"] = "<a href=\"".$email_url."\">".htmlspecialchars($row["author"])."</a>"; 226 } else { 227 $rows[$key]["linked_author"] = htmlspecialchars($row["author"]); 228 } 229 } 230 if($min_id == 0 || $min_id > $row['message_id']) 231 $min_id = $row['message_id']; 232 } 233 // don't move this up. We want it to be conditional. 234 include_once ("./include/thread_sort.php"); 235 236 $rows = phorum_sort_threads($rows); 237 238 }else{ 239 240 // loop through and read all the data in. 241 foreach($rows as $key => $row){ 242 243 $rows[$key]["lastpost"] = phorum_date($PHORUM["short_date"], $row["modifystamp"]); 244 $rows[$key]["datestamp"] = phorum_date($PHORUM["short_date"], $row["datestamp"]); 245 $rows[$key]["url"] = phorum_get_url(PHORUM_READ_URL, $row["thread"]); 246 $rows[$key]["newpost_url"] = phorum_get_url(PHORUM_READ_URL, $row["thread"],"gotonewpost"); 247 248 $rows[$key]["new"] = ""; 249 250 if($PHORUM["count_views"]) { // show viewcount if enabled 251 if($PHORUM["count_views"] == 2) { // viewcount as column 252 $PHORUM["DATA"]["VIEWCOUNT_COLUMN"]=true; 253 $rows[$key]["viewcount"]=$row['viewcount']; 254 } else { // viewcount added to the subject 255 $rows[$key]["subject"]=$row["subject"]." ({$row['viewcount']} " . strtolower($PHORUM['DATA']['LANG']['Views']) . ")"; 256 } 257 } 258 259 // recognizing moved threads 260 if(isset($row['meta']['moved']) && $row['meta']['moved'] == 1) { 261 $rows[$key]['moved']=1; 262 } else { 263 $rows[$key]['moved']=0; 264 } 265 266 // default thread-count 267 $thread_count=$row["thread_count"]; 268 269 if ($PHORUM["DATA"]["LOGGEDIN"]){ 270 271 if($PHORUM["DATA"]["MODERATOR"]){ 272 $rows[$key]["delete_url1"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_MESSAGE, $row["message_id"]); 273 $rows[$key]["delete_url2"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_TREE, $row["message_id"]); 274 if($build_move_url) { 275 $rows[$key]["move_url"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_MOVE_THREAD, $row["message_id"]); 276 } 277 $rows[$key]["merge_url"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_MERGE_THREAD, $row["message_id"]); 278 // count could be different with hidden or unapproved posts 279 if(!$PHORUM["threaded_read"] && isset($row["meta"]["message_ids_moderator"])) { 280 $thread_count=count($row["meta"]["message_ids_moderator"]); 281 } 282 } 283 284 if(!$rows[$key]['moved'] && isset($row['meta']['message_ids']) && is_array($row['meta']['message_ids'])) { 285 foreach ($row['meta']['message_ids'] as $cur_id) { 286 if(!isset($PHORUM['user']['newinfo'][$cur_id]) && $cur_id > $PHORUM['user']['newinfo']['min_id']) 287 $rows[$key]["new"] = $PHORUM["DATA"]["LANG"]["newflag"]; 288 289 if($min_id == 0 || $min_id > $cur_id) 290 $min_id = $cur_id; 291 } 292 } 293 } 294 295 if ($row["user_id"]){ 296 $url = phorum_get_url(PHORUM_PROFILE_URL, $row["user_id"]); 297 $rows[$key]["profile_url"] = $url; 298 $rows[$key]["linked_author"] = "<a href=\"$url\">".htmlspecialchars($row["author"])."</a>"; 299 }else{ 300 $rows[$key]["profile_url"] = ""; 301 if(!empty($row['email'])) { 302 $email_url = phorum_html_encode("mailto:$row[email]"); 303 // we don't normally put HTML in this code, but this makes it easier on template builders 304 $rows[$key]["linked_author"] = "<a href=\"".$email_url."\">".htmlspecialchars($row["author"])."</a>"; 305 } else { 306 $rows[$key]["linked_author"] = htmlspecialchars($row["author"]); 307 } 308 } 309 310 $pages=1; 311 // thread_count computed above in moderators-section 312 if(!$PHORUM["threaded_read"] && $thread_count>$PHORUM["read_length"]){ 313 314 $pages=ceil($thread_count/$PHORUM["read_length"]); 315 316 if($pages<=5){ 317 $page_links=array(); 318 for($x=1;$x<=$pages;$x++){ 319 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$x"); 320 $page_links[]="<a href=\"$url\">$x</a>"; 321 } 322 $rows[$key]["pages"]=implode(", ", $page_links); 323 } else { 324 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=1"); 325 $rows[$key]["pages"]="<a href=\"$url\">1</a> "; 326 $rows[$key]["pages"].="... "; 327 $pageno=$pages-2; 328 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno"); 329 $rows[$key]["pages"].="<a href=\"$url\">$pageno</a>, "; 330 $pageno=$pages-1; 331 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno"); 332 $rows[$key]["pages"].="<a href=\"$url\">$pageno</a>, "; 333 $pageno=$pages; 334 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno"); 335 $rows[$key]["pages"].="<a href=\"$url\">$pageno</a> "; 336 } 337 } 338 if(isset($row['meta']['recent_post'])) { 339 if($pages>1){ 340 $rows[$key]["last_post_url"]=phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["meta"]["recent_post"]["message_id"], "page=$pages"); 341 } else { 342 $rows[$key]["last_post_url"]=phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["meta"]["recent_post"]["message_id"]); 343 } 344 345 $row['meta']['recent_post']['author'] = htmlspecialchars($row['meta']['recent_post']['author']); 346 if ($row["meta"]["recent_post"]["user_id"]){ 347 $url = phorum_get_url(PHORUM_PROFILE_URL, $row["meta"]["recent_post"]["user_id"]); 348 $rows[$key]["last_post_profile_url"] = $url; 349 $rows[$key]["last_post_by"] = "<a href=\"$url\">{$row['meta']['recent_post']['author']}</a>"; 350 }else{ 351 $rows[$key]["profile_url"] = ""; 352 $rows[$key]["last_post_by"] = $row["meta"]["recent_post"]["author"]; 353 } 354 } else { 355 $rows[$key]["last_post_by"] = ""; 356 } 357 358 } 359 } 360 361 // run list mods 362 $rows = phorum_hook("list", $rows); 363 364 // if we retrieve the body too we need to setup some more variables for the messages 365 // to make it a little more similar to the view in read.php 366 if(isset($PHORUM['TMP']['bodies_in_list']) && $PHORUM['TMP']['bodies_in_list'] == 1) { 367 368 foreach ($rows as $id => $row) { 369 370 // is the message unapproved? 371 $row["is_unapproved"] = ($row['status'] < 0) ? 1 : 0; 372 373 // check if its the first message in the thread 374 if($row["message_id"] == $row["thread"]) { 375 $row["threadstart"] = true; 376 } else{ 377 $row["threadstart"] = false; 378 } 379 380 // mask host if not a moderator 381 if(empty($PHORUM["user"]["admin"]) && (empty($PHORUM["DATA"]["MODERATOR"]) || !PHORUM_MOD_IP_VIEW)){ 382 if($PHORUM["display_ip_address"]){ 383 if($row["moderator_post"]){ 384 $row["ip"]=$PHORUM["DATA"]["LANG"]["Moderator"]; 385 } elseif(is_numeric(str_replace(".", "", $row["ip"]))){ 386 $row["ip"]=substr($row["ip"],0,strrpos($row["ip"],'.')).'.---'; 387 } else { 388 $row["ip"]="---".strstr($row["ip"], "."); 389 } 390 391 } else { 392 $row["ip"]=$PHORUM["DATA"]["LANG"]["IPLogged"]; 393 } 394 } 395 396 // add the edited-message to a post if its edited 397 if(isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) { 398 $editmessage = str_replace ("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]); 399 $editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date"],$row['meta']['edit_date']), $editmessage); 400 $editmessage = str_replace ("%lastuser%", $row['meta']['edit_username'], $editmessage); 401 $row["body"].="\n\n\n\n$editmessage"; 402 } 403 404 405 if($PHORUM["max_attachments"]>0 && isset($row["meta"]["attachments"])){ 406 $PHORUM["DATA"]["ATTACHMENTS"]=true; 407 $row["attachments"]=$row["meta"]["attachments"]; 408 // unset($row["meta"]["attachments"]); 409 foreach($row["attachments"] as $key=>$file){ 410 $row["attachments"][$key]["size"]=phorum_filesize($file["size"]); 411 $row["attachments"][$key]["name"]= 412 htmlentities($file['name'], ENT_COMPAT, 413 $PHORUM["DATA"]["CHARSET"]); 414 $row["attachments"][$key]["url"]= 415 phorum_get_url(PHORUM_FILE_URL, "file={$file['file_id']}"); 416 } 417 } 418 $rows[$id] = $row; 419 } 420 } 421 422 // format messages 423 $rows = phorum_format_messages($rows); 424 425 426 // set up the data 427 $PHORUM["DATA"]["ROWS"] = $rows; 428 429 $PHORUM["DATA"]["URL"]["MARKREAD"] = phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "markread"); 430 if($PHORUM["DATA"]["MODERATOR"]) { 431 $PHORUM["DATA"]["URL"]["UNAPPROVED"] = phorum_get_url(PHORUM_PREPOST_URL); 432 } 433 434 // updating new-info for first visit (last message on first page is first new) 435 if ($PHORUM["DATA"]["LOGGEDIN"] && $PHORUM['user']['newinfo']['min_id'] == 0 && !isset($PHORUM['user']['newinfo'][$min_id]) && $min_id != 0){ 436 // setting it as min-id 437 438 // set it -1 as the comparison is "post newer than min_id" 439 $min_id--; 440 phorum_db_newflag_add_read($min_id); 441 } 442 443 include phorum_get_template("header"); 444 phorum_hook("after_header"); 445 446 // include the correct template 447 if ($PHORUM["threaded_list"]){ 448 include phorum_get_template("list_threads"); 449 }else{ 450 include phorum_get_template("list"); 451 } 452 453 phorum_hook("before_footer"); 454 include phorum_get_template("footer"); 455 456 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 12:22:27 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |