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.

208 lines
6.0 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/class_user.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. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class User
  15. {
  16. function LastUser()
  17. {
  18. global $lastuser;
  19. $usr = $lastuser['nick'];
  20. $uid = $lastuser['u_id'];
  21. return '<a href="user.php?id='.$uid.'" class="fstandard">'.$usr.'</a>';
  22. }
  23. function UserInformation($uid, $inf)
  24. {
  25. $sql = "SELECT `$inf` FROM ".USERS_TABLE." WHERE u_id='$uid';";
  26. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
  27. $result = mysql_fetch_array($query);
  28. $result = $result[$inf];
  29. return $result;
  30. }
  31. function UserIdByNick($nick)
  32. {
  33. $sql = "SELECT * FROM `".USERS_TABLE."` WHERE `nick`='$nick';";
  34. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain user information.'));
  35. $result = $result['u_id'];
  36. /*if ($result=='')
  37. {
  38. message_forum('nick failed','admin_groups.php');
  39. }*/
  40. return $result;
  41. }
  42. function AddToGroup($uid, $gid)
  43. {
  44. $last= DataBase::new_id(USERS_GROUP_TABLE);
  45. $sql = "INSERT INTO `".USERS_GROUP_TABLE."` VALUES ('$last','$uid', '$gid')";
  46. DataBase::sql_query($sql,'GENERAL','Could not add user to group.');
  47. }
  48. function DeleteFromGroup($uid, $gid)
  49. {
  50. $sql = "DELETE FROM `".USERS_GROUP_TABLE."` WHERE `u_id`='$uid' AND `g_id`='$gid'";
  51. DataBase::sql_query($sql,'GENERAL','Could not delete user for group.');
  52. }
  53. function LogedAs($sid, $uid)
  54. {
  55. global $lng;
  56. global $userdata;
  57. if ($uid>0)
  58. {
  59. $nick = $userdata['nick'];
  60. return(''.$lng['youareloggedas'].' <a href="user.php?id='.$uid.'" class="fstandard"><b>'.$nick.'</b></a>');
  61. }
  62. else
  63. {
  64. return($lng['youarenotlogd']);
  65. }
  66. }
  67. function PostWithForum($posts)
  68. {
  69. $result2 = Over::TotalPosts();
  70. if($result2>0)
  71. {
  72. $result3 = ($posts/$result2*100);
  73. $result3 = round($result3,2);
  74. return($result3);
  75. }
  76. else
  77. {
  78. return(0);
  79. }
  80. }
  81. function LastRegVisit($uid, $mode)
  82. {
  83. global $lng;
  84. $result = User::UserInformation($uid,$mode);
  85. if ($result=='0')
  86. {
  87. return($lng['never']);
  88. }
  89. else
  90. {
  91. $date = date('d-m-Y, G:i',$result);
  92. return($date);
  93. }
  94. }
  95. function UserRank($rank)
  96. {
  97. global $lng;
  98. global $forum_config;
  99. switch($rank)
  100. {
  101. case '0': {$result=$lng['user']; break; }
  102. case '1': {$result='<font color="'.$forum_config['color_mod'].'"><b>'.$lng['mod'].'</b></font>'; break; }
  103. case '2': {$result='<font color="'.$forum_config['color_admin'].'"><b>'.$lng['admin'].'</b></font>'; break; }
  104. }
  105. return($result);
  106. }
  107. function RankAdminMod($uid)
  108. {
  109. if ($uid>0)
  110. {
  111. $sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid'";
  112. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user`s rank information.');
  113. $result = mysql_fetch_array($query);
  114. $rank = $result['rank'];
  115. if (($rank=='1') or ($rank=='2'))
  116. {
  117. return '1';
  118. }
  119. else
  120. {
  121. return '0';
  122. }
  123. }
  124. else
  125. {
  126. return '0';
  127. }
  128. }
  129. function UpdateProfile($uid, $gg, $email, $interests, $sig, $avatar, $allow_qr, $allow_email, $allow_gg, $skin, $lang, $limit_tpid, $limit_ftid, $limit_users, $allow_shoutbox)
  130. {
  131. $sql ="UPDATE `".USERS_TABLE."` SET
  132. `gg` = '$gg',
  133. `email` = '$email',
  134. `allow_gg` = '$allow_gg',
  135. `allow_email` = '$allow_email',
  136. `allow_qr` = '$allow_qr',
  137. `interests` = '$interests',
  138. `sig` = '$sig',
  139. `avatar` = '$avatar',
  140. `skin`='$skin',
  141. `lang`='$lang',
  142. `limit_tpid` = '$limit_tpid',
  143. `limit_ftid` = '$limit_ftid',
  144. `view_shoutbox` = '$allow_shoutbox',
  145. `limit_users` = '$limit_users'
  146. WHERE `u_id` ='$uid' LIMIT 1 ;";
  147. DataBase::sql_query($sql,'CRITICAL','Could not update user information');
  148. }
  149. function UpdateAdminPools($uid, $posts, $rank, $active, $nick)
  150. {
  151. $sql ="UPDATE `".USERS_TABLE."` SET
  152. `posts` = '$posts',
  153. `rank` = '$rank',
  154. `active` = '$active'
  155. WHERE `u_id` ='$uid' LIMIT 1 ;";
  156. DataBase::sql_query($sql,'CRITICAL','Could not update user information');
  157. }
  158. function UpdatePassword($uid, $pass)
  159. {
  160. $sql ="UPDATE `".USERS_TABLE."` SET
  161. `pass` = '$pass'
  162. WHERE `u_id` ='$uid' LIMIT 1 ;";
  163. DataBase::sql_query($sql,'CRITICAL','Could not update user information');
  164. }
  165. function CreateProfile($nick, $pass, $email, $gg, $allow_gg, $allow_email, $allow_qr, $sig, $av, $interests)
  166. {
  167. global $forum_config;
  168. $last = DataBase::new_id(USERS_TABLE);
  169. $time = time();
  170. $sql = "INSERT INTO ".USERS_TABLE." VALUES
  171. ('$last', '$nick', '$pass', '$email', '0', '$time', '0', '$gg', '$allow_gg', '$allow_email', '$allow_qr', '".$forum_config['view_shoutbox']."', '".$forum_config['defaultskin']."', '".$forum_config['defaultlang']."','".$forum_config['limit_tpid']."', '".$forum_config['limit_ftid']."', '".$forum_config['limit_users']."', '$sig', '$av', '1','0','$interests');";
  172. DataBase::sql_query($sql,'CRITICAL','Could not create new user');
  173. }
  174. function UserMsgs()
  175. {
  176. $uid = $_SESSION['uid'];
  177. if($uid>0)
  178. {
  179. $sql = "SELECT count(*) as `m_id` FROM ".PM_INBOX_TABLE." WHERE `u_id`='$uid' AND `read`='0'";
  180. $result = mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain amounts PM of User.'));
  181. $result = $result['m_id'];
  182. if ($result>0)
  183. {
  184. return '<font color="red">'.$result.'</font>';
  185. }
  186. else
  187. {
  188. return $result;
  189. }
  190. }
  191. }
  192. function UserAddWarn($uid, $value, $motive)
  193. {
  194. $sql = "INSERT INTO `".WARNINGS_TABLE."` ( `w_id` , `u_id` , `value` , `motive` ) VALUES('','$uid','$value','$motive');";
  195. DataBase::sql_query($sql,'GENERAL','Could not add new warn.');
  196. if (User::UserLevelWarns($uid)==100)
  197. {
  198. $ban_ip = '0.0.0.0';
  199. $ban_uid = $uid;
  200. $ban_motive = $lng['warns_ban'];
  201. $sql = "INSERT INTO ".BANLIST_TABLE." VALUES ('', '$ban_uid', '$ban_ip', '$ban_motive')";
  202. DataBase::sql_query($sql,'GENERAL','Could not update add ban.');
  203. }
  204. }
  205. }
  206. ?>