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.

103 lines
3.6 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/classes/class_mod.php
  5. * @version $Id: classes/class_mod.php 15 2009-05-01 17:06:40Z pioder $
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class Mod
  15. {
  16. function MoveTopic($tid, $fid)
  17. {
  18. $sql = "UPDATE `".TOPICS_TABLE."` SET `f_id`='$fid' WHERE `t_id`='$tid'";
  19. DataBase::sql_query($sql,GENERAL,'Could not update topic');
  20. $sql = "UPDATE `".POSTS_TABLE."` SET `f_id`='$fid' WHERE `t_id`='$tid'";
  21. DataBase::sql_query($sql,GENERAL,'Could not update post');
  22. }
  23. function TopicLocked($tid)
  24. {
  25. global $default_skin;
  26. global $default_lang;
  27. $lock = Topic::TopicInformation($tid,'lock');
  28. if ($lock=='1')
  29. {
  30. return '<a href="moderate.php?action=unlock&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/unlock.gif" width="20" height="20" alt="unlock">';
  31. }
  32. else
  33. {
  34. return '<a href="moderate.php?action=lock&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/lock.gif" width="20" height="20" alt="lock"></a>';
  35. }
  36. }
  37. function DeleteTopic($topicid)
  38. {
  39. $sql="SELECT * FROM ".POSTS_TABLE." WHERE `t_id`='$topicid'";
  40. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain post information');
  41. while($item = DataBase::fetch($query))
  42. {
  43. $uid = Topic::PostInformation($item['p_id'],'u_id');
  44. $posts = User::UserInformation($uid,'posts');
  45. $posts = $posts -1;
  46. $sql = "UPDATE `".USERS_TABLE."` SET `posts`='$posts' WHERE `u_id`='$uid'";
  47. DataBase::sql_query($sql,GENERAL,'Could not update user amout of posts');
  48. }
  49. $sql = "DELETE FROM ".POSTS_TABLE." WHERE t_id='$topicid';";
  50. DataBase::sql_query($sql,GENERAL,'Could not delete topic posts.');
  51. $sql = "DELETE FROM ".TOPICS_TABLE." WHERE t_id='$topicid';";
  52. DataBase::sql_query($sql,GENERAL,'Could not delete topic posts.');
  53. }
  54. function LockTopic($topicid)
  55. {
  56. $sql = "UPDATE `".TOPICS_TABLE."` SET `lock` = '1' WHERE `t_id` =$topicid;";
  57. DataBase::sql_query($sql,GENERAL,'Could not lock topic.');
  58. }
  59. function StickTopic($topicid, $mode)
  60. {
  61. $sql = "UPDATE `".TOPICS_TABLE."` SET `sticky` = '$mode' WHERE `t_id` =$topicid;";
  62. DataBase::sql_query($sql,GENERAL,'Could not stick topic.');
  63. }
  64. function UnlockTopic($topicid)
  65. {
  66. $sql = "UPDATE `".TOPICS_TABLE."` SET `lock` = '0' WHERE `t_id` =$topicid;";
  67. DataBase::sql_query($sql,GENERAL,'Could not unlock topic.');
  68. }
  69. function DeletePost($postid)
  70. {
  71. $uid = Topic::PostInformation($postid,'u_id');
  72. $tid = Topic::PostInformation($postid,'t_id');
  73. $posts = User::UserInformation($uid,'posts');
  74. $posts = $posts -1;
  75. $sql = "UPDATE `".USERS_TABLE."` SET `posts`='$posts' WHERE `u_id`='$uid'";
  76. DataBase::sql_query($sql,GENERAL,'Could not update user amout of posts');
  77. $sql2 = "DELETE FROM ".POSTS_TABLE." WHERE p_id='$postid';";
  78. DataBase::sql_query($sql2,GENERAL,'Could not delete post.');
  79. $sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id>'$postid' AND `t_id`='$tid';";
  80. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain post information.');
  81. while($item=DataBase::fetch($query))
  82. {
  83. $number = $item['tp_id'];
  84. $number = $number-1;
  85. $number2 = $item['p_id'];
  86. $sql3 = "UPDATE `".POSTS_TABLE."` SET `tp_id` = '$number' WHERE `p_id` =$number2;";
  87. DataBase::sql_query($sql3,GENERAL,'Could not update post.');
  88. }
  89. }
  90. function AcceptPost($postid)
  91. {
  92. $sql = "UPDATE `".POSTS_TABLE."` SET `moderated`='0' WHERE `p_id`='$postid'";
  93. DataBase::sql_query($sql, GENERAL, 'Could not accept post');
  94. }
  95. }
  96. ?>