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.

116 lines
4.3 KiB

  1. <?php
  2. /**
  3. * @package Dynamic Script Forum
  4. * @file includes/class_posting.php
  5. * @version 1.0.x, 30-07-2007, 16:23
  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 Post
  15. {
  16. function NewPost($tid, $post, $uid)
  17. {
  18. #read last post
  19. $last = DataBase::new_id(POSTS_TABLE);
  20. #read last post in topic
  21. $sql = "SELECT * FROM ".POSTS_TABLE." WHERE t_id='$tid' ORDER BY tp_id DESC LIMIT 1;";
  22. $query = DataBase::sql_query($sql,'GENERAL','Could not last post information.');
  23. $result = mysql_fetch_array($query);
  24. $forum = $result['f_id'];//forum id
  25. $moderate = Forum::ForumInformation($forum,'moderate');
  26. $tpid = $result['tp_id'];//post in topic id
  27. $tpid = $tpid+1;
  28. #
  29. $time = time();
  30. #add new post
  31. $sql = "INSERT INTO `".POSTS_TABLE."` VALUES ('$last','$tid', '$uid', '$post', '".$_SERVER['HTTP_USER_AGENT']."', '$time', '$tpid', '$forum','$moderate','".$_SERVER['REMOTE_ADDR']."')";
  32. $query = DataBase::sql_query($sql,'GENERAL','Could not add new post.');
  33. $result=User::UserInformation($uid,'posts');
  34. $result = $result+1;
  35. $sql="UPDATE ".TOPICS_TABLE." SET lastpost_time='$time' WHERE t_id='$tid' ";
  36. $query = DataBase::sql_query($sql,'GENERAL','Could not update user information.');
  37. $sql="UPDATE ".USERS_TABLE." SET posts='$result' WHERE u_id='$uid' ";
  38. $query = DataBase::sql_query($sql,'GENERAL','Could not update user information.');
  39. return $tpid;
  40. }
  41. function EditPost($postid, $text)
  42. {
  43. $sql = "UPDATE `".POSTS_TABLE."` SET text='$text' WHERE `p_id`='$postid';";
  44. $query = DataBase::sql_query($sql,'GENERAL','Could not edit post.');
  45. }
  46. function NewTopic($posttext, $ntopic, $forum, $uid, $sticky)
  47. {
  48. //Select last topic
  49. $moderate = Forum::ForumInformation($forum,'moderate');
  50. $time = time();
  51. $lastt=DataBase::new_id(TOPICS_TABLE);
  52. $sql = "INSERT INTO ".TOPICS_TABLE." VALUES ('$lastt', '$forum', '0', '$sticky', '$ntopic', '$uid','$time')";
  53. $query = DataBase::sql_query($sql,'GENERAL','Could not add new topic');
  54. //add post
  55. //select last post
  56. $last = DataBase::new_id(POSTS_TABLE);
  57. //add post
  58. $sql = "INSERT INTO ".POSTS_TABLE." VALUES ('$last','$lastt', '$uid', '$posttext','".$_SERVER['HTTP_USER_AGENT']."', '$time', '1', '$forum', '$moderate','".$_SERVER['REMOTE_ADDR']."');";
  59. $query = DataBase::sql_query($sql,'GENERAL','Could not add new post.');
  60. $sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid';";
  61. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
  62. $result = mysql_fetch_array($query);
  63. $result = $result['posts'];
  64. $result = $result+1;
  65. $sql = "UPDATE ".USERS_TABLE." SET posts='$result' WHERE u_id='$uid' ";
  66. $query = DataBase::sql_query($sql,'GENERAL','Could not update user information.');
  67. return $lastt;
  68. }
  69. function SmilesShow()
  70. {
  71. $text ='';
  72. $result='';
  73. $sql = "SELECT * FROM ".SMILES_TABLE."";
  74. $query = DataBase::sql_query($sql,'GENERAL','Cold not obtain smiles information.');
  75. $i = 1;
  76. while($smile = mysql_fetch_array($query))
  77. {
  78. $action = "insertSmile('".$smile['url']."','".$smile['smile']."')";
  79. $mouse = "this.style.cursor='hand';";
  80. $text = "\n".'<img src="'.$smile['url'].'" onmouseover="'.$mouse.'" onclick="'.$action.'" alt="'.$smile['smile'].'">&nbsp;'."\n";
  81. $result = $result.$text;
  82. if ($i%5==0)
  83. {
  84. $i = 1;
  85. $result=$result.'<br>';
  86. }
  87. else
  88. {
  89. $i +=1;
  90. }
  91. }
  92. return $result;
  93. }
  94. function SmilesReplace($text)
  95. {
  96. $sql = "SELECT * FROM ".SMILES_TABLE."";
  97. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain emoticons information.');
  98. $i = 1;
  99. while($result = mysql_fetch_array($query))
  100. {
  101. $smile[$i]['smile'] = $result['smile'];
  102. $smile[$i]['url'] = $result['url'];
  103. $i +=1;
  104. }
  105. $smile = (!isset($smile)) ? array() : $smile;
  106. $i = 1;
  107. for($i=1;$i<=count($smile);$i++)
  108. {
  109. $text = str_replace(' '.$smile[$i]['smile'],'<img src="'.$smile[$i]['url'].'" alt="'.$smile[$i]['smile'].'">', $text);
  110. $text = str_replace('&nbsp;'.$smile[$i]['smile'],'<img src="'.$smile[$i]['url'].'" alt="'.$smile[$i]['smile'].'">', $text);
  111. }
  112. return $text;
  113. }
  114. }
  115. ?>