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.

193 lines
5.5 KiB

  1. <?php
  2. /**
  3. * @package Dynamic Script Forum
  4. * @file includes/classes/secure.php
  5. * @version 1.0.x, 07-04-2008, 20:43
  6. * @copyright 2008(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/dsf.html
  8. * @license GNU GPL v3
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class Secure
  15. {
  16. function forum_exists($fid)
  17. {
  18. global $lng;
  19. $sql = "SELECT * FROM ".FORUMS_TABLE." WHERE f_id='$fid'";
  20. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain forum information.');
  21. $result = mysql_fetch_array($query);
  22. $result = $result['f_id'];
  23. if ($result=='')
  24. {
  25. message_forum($lng['no_forum'],'index.php');
  26. }
  27. }
  28. function UseCensorList($text)
  29. {
  30. global $forum_config;
  31. if ($forum_config['use_censorlist'])
  32. {
  33. $sql = "SELECT * FROM ".CENSORLIST_TABLE.";";
  34. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain censorlist information.');
  35. while($word = mysql_fetch_array($query))
  36. {
  37. $text = str_replace($word['word'],'[censored]', $text);
  38. }
  39. }
  40. return $text;
  41. }
  42. function generate_code()
  43. {
  44. $number = array(
  45. 1 => 1,
  46. 2 => 2,
  47. 3 => 4,
  48. 4 => 6,
  49. 5 => 10,
  50. 6 => 20,
  51. 7 => 30,
  52. 8 => 40,
  53. 9 => 50,
  54. 10 => 60,
  55. 11 => 70,
  56. 12 => 80,
  57. 13 => 90,
  58. 14 => 100
  59. );
  60. $first_id = rand(1,14);
  61. $second_id = rand(1,14);
  62. $first_num = $number[$first_id];
  63. $second_num = $number[$second_id];
  64. return array($first_num, $second_num, ($first_num + $second_num));
  65. }
  66. function message_u_exists($mid)
  67. {
  68. global $lng;
  69. $sql = "SELECT * FROM ".PM_INBOX_TABLE." WHERE m_id='$mid'";
  70. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
  71. $result = mysql_fetch_array($query);
  72. $result = $result['m_id'];
  73. if ($result=='')
  74. {
  75. message_forum($lng['no_message'],'pms.php');
  76. }
  77. }
  78. function message_author_loged($mid)
  79. {
  80. global $lng;
  81. $sql = "SELECT * FROM ".PM_SENTBOX_TABLE." WHERE m_id='$mid'";
  82. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
  83. $result = mysql_fetch_array($query);
  84. $result = $result['u_n_id'];
  85. if ($result!=$_SESSION['uid'])
  86. {
  87. message_forum($lng['merror_1'],'index.php');
  88. }
  89. }
  90. function message_user_loged($mid)
  91. {
  92. global $lng;
  93. $sql = "SELECT * FROM ".PM_INBOX_TABLE." WHERE m_id='$mid'";
  94. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
  95. $result = $result['u_id'];
  96. if ($result!=$_SESSION['uid'])
  97. {
  98. message_forum($lng['merror_2'],'index.php');
  99. }
  100. }
  101. function message_a_exists($mid)
  102. {
  103. global $lng;
  104. $sql = "SELECT * FROM ".PM_SENTBOX_TABLE." WHERE m_id='$mid'";
  105. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
  106. $result = $result['m_id'];
  107. if ($result=='')
  108. {
  109. message_forum($lng['no_message'],'index.php');
  110. }
  111. }
  112. function topic_exists($tid)
  113. {
  114. global $lng;
  115. $sql = "SELECT * FROM `".TOPICS_TABLE."` WHERE `t_id`='$tid'";
  116. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain topic information.');
  117. $result = mysql_fetch_array($query);
  118. $result = $result['t_id'];
  119. if ($result=='')
  120. {
  121. message_forum($lng['no_topic'],'index.php');
  122. }
  123. }
  124. function post_exists($pid)
  125. {
  126. global $lng;
  127. $sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id='$pid'";
  128. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain topic information.');
  129. $result = mysql_fetch_array($query);
  130. $result = $result['p_id'];
  131. if ($result=='')
  132. {
  133. message_forum($lng['no_post'],'pms.php');
  134. }
  135. }
  136. function user_exists($uid)
  137. {
  138. global $lng;
  139. $sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid'";
  140. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
  141. $result = $result['u_id'];
  142. if (($result=='') or ($result=='-1'))
  143. {
  144. message_forum($lng['no_user'],'index.php');
  145. }
  146. }
  147. function group_exists($gid)
  148. {
  149. global $lng;
  150. $sql = "SELECT `g_id` FROM `".GROUPS_TABLE."` WHERE g_id='$gid'";
  151. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain group information.'));
  152. $result = $result['g_id'];
  153. if ($result=='')
  154. {
  155. message_forum($lng['no_group'],'groups.php');
  156. }
  157. }
  158. function TagsReplace($text)
  159. {
  160. $text = strip_tags($text,ALLOWED_TAGS);
  161. $text = str_replace('?>', '?&gt;', $text);
  162. $text = str_replace('<?', '&lt;?', $text);
  163. $text = str_replace('javascript:', '', $text);
  164. $text = Secure::UseCensorlist($text);
  165. $text = Post::SmilesReplace($text);
  166. return $text;
  167. }
  168. function TopicLocked($tid)
  169. {
  170. global $lng;
  171. $sql = "SELECT `f_id`,`lock` FROM `".TOPICS_TABLE."` WHERE `t_id`='$tid'";
  172. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain topic information'));
  173. $fid = $result['f_id'];
  174. $sql2 = "SELECT `lock` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
  175. $result2 = mysql_fetch_array(DataBase::sql_query($sql2,'GENERAL','Could not obtain forum information'));
  176. if (($result['lock']=='1') or ($result2['lock']=='1'))
  177. {
  178. message_forum($lng['no_posting_topic_locked'],'topic.php?t='.$tid);
  179. }
  180. }
  181. function ForumLocked($fid)
  182. {
  183. global $lng;
  184. $sql = "SELECT `lock` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
  185. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
  186. if ($result['lock']=='1')
  187. {
  188. message_forum($lng['no_posting_forum_locked'],'forum.php?f='.$fid);
  189. }
  190. }
  191. }
  192. ?>