A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
8.2 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file topic.php
  5. * @version $Id$
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. include('./config.php');
  13. include('./includes/constants.php');
  14. include('./includes/db.php');
  15. include('./includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. include('./includes/sessions.php');
  19. include('./includes/classes/class_user.php');
  20. include('./common.php');
  21. include('./includes/misc_functions.php');
  22. include('./includes/classes/class_forum.php');
  23. include('./includes/classes/class_topic.php');
  24. include('./includes/classes/class_mod.php');
  25. include('./includes/classes/secure.php');
  26. $default_lang = DefaultLang();
  27. include('./lngs/'.$default_lang.'/main.php');
  28. $tid = intval($_GET['t']);
  29. $start = TimeGeneration();
  30. SessDelInvalid();
  31. SessRegister();
  32. SessDeleteOld();
  33. $default_skin = ViewSkinName();
  34. include('./includes/cache/cache_topic.php');
  35. $forum_locked = $forum['lock'];
  36. //add skin variables
  37. $skin = array(
  38. 'lreply'=>(($topic['lock']==1) or ($forum_locked==1)) ?
  39. '<img src="skins/'.$default_skin.'/images/lng_'.$default_lang.'/lock.gif" border="0" alt="reply">'
  40. :
  41. '<a href="posting.php?mode=rpost&amp;id='.$_GET['t'].'">
  42. <img src="skins/'.$default_skin.'/images/lng_'.$default_lang.'/reply.gif"
  43. onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/reply_active.gif\';"
  44. onMouseOut="this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/reply.gif\'" border="0" alt="reply"></a>'
  45. );
  46. $skin = array_push_assoc($skin, GenerateHeader($lng['showtopic'].': '.$topic['name'], '</a>&gt; <a href="forum.php?f='.$fid.'" class="navigator">'.$forum['name'].'</a> &gt; <a href="'.$_SERVER['REQUEST_URI'].'" class="navigator">'.$topic['name']));
  47. //do it!
  48. include('./skins/'.$default_skin.'/overall_header.tpl');
  49. include('./skins/'.$default_skin.'/topic_body.tpl');
  50. $sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".*, ".USERS_TABLE.".u_id AS user_id,".SESSIONS_TABLE.".* FROM `".POSTS_TABLE."` LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id LEFT JOIN ".SESSIONS_TABLE." ON ".SESSIONS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE t_id='$tid' ORDER BY tp_id $limit;";
  51. $query = DataBase::sql_query($sql,CRITICAL,'Could not obtain post information.');
  52. while($item=DataBase::fetch($query))
  53. {
  54. $ua = UserAgent($item['user_agent']);
  55. $warn_pool = ($forum_config['allow_warns'] && $forum_config['warns_in_topic'] ) ? (isset($user_warnlevel[$item['u_id']])) ?
  56. '<a href="warns.php?mode=view&amp;id='.$item['u_id'].'" class="fsmall">'.$lng['warns'].'</a>:
  57. <font color="red"><b>'.($user_warnlevel[$item['u_id']]*10).'%</b></span>' : '<a href="warns.php?mode=view&amp;id='.$item['u_id'].'" class="fsmall">'.$lng['warns'].'</a>:
  58. <font color="green"><b>0%</b></span>' : '&nbsp;';
  59. $skin = array(
  60. 'tp_id' => $item['tp_id'],
  61. 'p_id' => $item['p_id'],
  62. 'u_id' => $item['user_id'],
  63. 'username' => Topic::UserName($item['nick'], $item['rank']),
  64. 'pdate' => GenerateTime($item['ptime']),
  65. 'user_gg' => (($item['allow_gg'])&& ($item['gg']!='0')) ?
  66. '<a href="gg:'.$item['gg'].'"><img border="0" src="skins/'.$default_skin.'/images/gg_small.gif"
  67. alt="gg" onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/gg_small_active.gif\'"
  68. onMouseOut="this.src=\'skins/'.$default_skin.'/images/gg_small.gif\'"></a><br>' : '',
  69. 'edit' => ($_SESSION['uid']>0) ? (($item['u_id']==$_SESSION['uid']) ||(RANK>0)) ?
  70. '<a href="posting.php?mode=edit&amp;id='.$item['p_id'].'">
  71. <img border="0" src="skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small.gif"
  72. alt="edit" onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small_active.gif\'"
  73. onMouseOut="this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small.gif\'"></a><br>' : '' : '',
  74. 'userrank' => User::UserRank($item['rank']),
  75. 'avatar' => ($item['avatar']!='') ? '<img src="'.$item['avatar'].'" alt="av">' : '<img src="skins/'.$default_skin.'/images/no_av.gif" alt="av">',
  76. 'posttext' => Topic::PostText($item['text'], $item['moderated'], $item['p_id']),
  77. 'sig'=>($item['sig']!='') ? '<br><br>----------------<br>'.$item['sig'] : '',
  78. 'posts'=>$item['posts'],
  79. 'regdate' => date('d-m-Y',$item['regdate']),
  80. 'lastvisit' => date('d-m-Y',$item['lastvisit']),
  81. 'warns_pool' => $warn_pool,
  82. 'lstat'=>$lng['stat'],
  83. 'rowspan'=> ($_SESSION['uid']>0) ? ((RANK>0) ? '3' : '2') : '2',
  84. 'L.IP' => ($_SESSION['uid']>0) ? ((($forum_config['ip_post_for_mod'] && (RANK>0)) || (RANK==2) ) ? 'IP: '.$item['post_ip'].' (<a href="http://whois.domaintools.com/'.$item['post_ip'].'" class="fsmall"><i>WHOIS</i></a>)<br>' : '') : '',
  85. 'IP'=>$item['post_ip'],
  86. 'admin'=>$lng['admin_mod_administration'],
  87. 'mode_p_del' => ($item['tp_id']!='1') ?
  88. '<a href="javascript:confirm_action(\''.$lng['c_delete_post'].'\',\'moderate.php?action=postdelete&amp;id='.$item['p_id'].'\')">
  89. <img border="0" src="skins/'.$default_skin.'/images/delete_small.gif" onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/delete_small_active.gif\'"
  90. onMouseOut="this.src=\'skins/'.$default_skin.'/images/delete_small.gif\'"
  91. alt="pdelete"></a><br>' : '',
  92. 'ban'=> $lng['ban'],
  93. 'edit_profile'=>$lng['edit_profile'],
  94. 'add_warn'=>$lng['add_warn'],
  95. 'online'=>($item['time']!=NULL) ? (($item['time']+1250)>time()) ? 'online.gif' : 'offline.gif' : 'offline.gif',
  96. //labels
  97. 'L.warns'=>$lng['warns'],
  98. 'lang'=>$default_lang,
  99. 'L.date'=>$lng['date'],
  100. 'llastvisit'=>$lng['lulastvisit'],
  101. 'lregdate'=>$lng['regdate2'],
  102. 'lposts'=>$lng['posts'],
  103. 'ua_system'=>$ua[0],
  104. 'ua_system_desc'=>$lng['system'].' '.$ua[2],
  105. 'ua_browser'=>$ua[1],
  106. 'ua_browser_desc'=>$lng['browser'].' '.$ua[3],
  107. 'L.no'=>$lng['no.'],
  108. 'L.p_info'=>$lng['postinfo'],
  109. 'lpost'=>$lng['post'],
  110. 'C.delete_post'=>$lng['c_delete_post']
  111. );
  112. //do it!
  113. include('./skins/'.$default_skin.'/topic_post_body.tpl');
  114. }
  115. //generate end template variables
  116. $skin = array(
  117. 'functions_moderate'=> ($_SESSION['uid']>0) ? (RANK>0) ? './skins/'.$default_skin.'/topic_mod_body.tpl' : './skins/'.$default_skin.'/blank.tpl' : './skins/'.$default_skin.'/blank.tpl',
  118. 'lock' => ($topic['lock']==1) ? '<a href="moderate.php?action=unlock&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/unlock.gif" alt="unlock"></a>' : '<a href="moderate.php?action=lock&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/lock.gif" alt="lock"></a>',
  119. 'stick' => ($topic['sticky']==1) ? '<a href="moderate.php?action=unstick&amp;id='.$tid.'">
  120. <img border="0" src="skins/'.$default_skin.'/images/unstick.gif" alt="unstick"></a>'
  121. : '<a href="moderate.php?action=stick&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/stick.gif"
  122. alt="stick"></a>',
  123. 'lmod' => $lng['lmod'],
  124. 'c_delete_topic'=>$lng['c_delete_topic'],
  125. 'option_pages'=>ListPages($page, $count),
  126. 'lwith'=>$lng['with'],
  127. 'lpage'=>$lng['page'],
  128. 'lpages'=>$count
  129. );
  130. $skin['lreply']=(($topic['lock']==1) or ($forum_locked==1))
  131. ? '<img src="skins/'.$default_skin.'/images/lng_'.$default_lang.'/lock.gif" border="0"
  132. alt="reply">' : '<a href="posting.php?mode=rpost&amp;id='.$_GET['t'].'">
  133. <img src="skins/'.$default_skin.'/images/lng_'.$default_lang.'/reply.gif" border="0"
  134. onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/reply_active.gif\'"
  135. onMouseOut="this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/reply.gif\'" border="0" alt="reply"></a';
  136. include('./skins/'.$default_skin.'/topic_end_body.tpl');
  137. if (($_SESSION['uid']>0) and ($topic['lock']==0) and ($forum_locked==0) and ($userdata['allow_qr']=='1'))
  138. {
  139. include './quick_reply.php';
  140. }
  141. if($_SESSION['uid']>0)
  142. {
  143. if(RANK==2)
  144. {
  145. $skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
  146. }
  147. else
  148. {
  149. $skin['pa_link']='';
  150. }
  151. }
  152. else
  153. {
  154. $skin['pa_link']='';
  155. }
  156. $stop = TimeGeneration();
  157. $skin['queries'] = ShowQueries($start, $stop);
  158. include('./skins/'.$default_skin.'/overall_footer.tpl');
  159. ?>