1
0

functions.core.user.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /* $Id: functions.core.user.php 2834 2007-04-08 12:51:00Z b4rt $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. /**
  16. * IsUser
  17. *
  18. * @param $user
  19. * @return boolean
  20. */
  21. function IsUser($user) {
  22. global $db;
  23. return ($db->GetOne("SELECT count(*) FROM tf_users WHERE user_id=".$db->qstr($user)) > 0);
  24. }
  25. /**
  26. * Is User Admin : user is Admin if level is 1 or higher
  27. *
  28. * @param $user
  29. * @return boolean
  30. */
  31. function IsAdmin($user = "") {
  32. global $cfg, $db;
  33. if ($user == "")
  34. $user = $cfg["user"];
  35. return ($db->GetOne("SELECT user_level FROM tf_users WHERE user_id=".$db->qstr($user)) >= 1);
  36. }
  37. /**
  38. * Is User SUPER Admin : user is Super Admin if level is higher than 1
  39. *
  40. * @param $user
  41. * @return boolean
  42. */
  43. function IsSuperAdmin($user = "") {
  44. global $cfg, $db;
  45. if ($user == "")
  46. $user = $cfg["user"];
  47. return ($db->GetOne("SELECT user_level FROM tf_users WHERE user_id=".$db->qstr($user)) > 1);
  48. }
  49. /**
  50. * IsOnline
  51. *
  52. * @param $user
  53. * @return boolean
  54. */
  55. function IsOnline($user) {
  56. global $cfg, $db;
  57. return ($db->GetOne("SELECT count(*) FROM tf_log WHERE user_id=" . $db->qstr($user)." AND action=".$db->qstr($cfg["constants"]["hit"])) > 0);
  58. }
  59. /**
  60. * Get Users in an array
  61. *
  62. * @return array
  63. */
  64. function GetUsers() {
  65. global $db;
  66. $user_array = array();
  67. $user_array = $db->GetCol("select user_id from tf_users order by user_id");
  68. return $user_array;
  69. }
  70. /**
  71. * Get Super Admin User ID as a String
  72. *
  73. * @return string
  74. */
  75. function GetSuperAdmin() {
  76. global $db;
  77. return $db->GetOne("select user_id from tf_users WHERE user_level=2");
  78. }
  79. ?>