AndreiMikalov

Untitled

Sep 14th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. <?php
  2. require_once("models/config.php");
  3. /*
  4. DreamCMS Version 1.0
  5. Developed by: Andrei Mikalov (Zeus)
  6.  
  7. Thanks to Adam Davis
  8. Also thanks to Mark Eriksson (m0nsta.) for coding snippets, and Jonas Laursen for extra help.
  9. */
  10.  
  11. function clean($str){ //clean a string and return it
  12. return mysql_real_escape_string(strip_tags(stripslashes($str))); //return a much cleaner string.
  13. }
  14.  
  15. function userExists($id){ //see if a user exists
  16. $id = clean($id); //remove any bad content
  17. $check = mysql_query("SELECT * FROM DreamCMS_Users WHERE `User_ID` = '$id'"); //query to get all data from user
  18. if(mysql_num_rows($check) == 0){ //the user does not exist
  19. return false;
  20. }else{
  21. return true;
  22. }
  23. }
  24.  
  25. function userRow($id, $row){ //return data from a user with their id
  26. $id = clean($id); //remove any bad content
  27. $check = mysql_query("SELECT * FROM DreamCMS_Users WHERE `User_ID` = '$id'"); //query to get all data from user
  28. if(mysql_num_rows($check) == 0){ //the user does not exist
  29. return 'An error occurred!';
  30. }else{
  31. $r = mysql_fetch_array($check); //array to get all data
  32. return $r[$row]; //return '$row' from '$r'
  33. }
  34. }
  35.  
  36. if(isset($_GET['User_ID'])){ //a user id has been set in the url
  37. $id = $_GET['User_ID']; //remove any bad content from the users id
  38. if(!userExists($id)){ //the user does not exist
  39. $title = 'User does not exist';
  40. }else{ //user exists
  41. $title = userRow($id, 'username'); //get their username
  42. }
  43. }else{
  44. $title = 'User does not exist';
  45. }
  46. ?>
  47. <?php
  48. if($in["username"]){ //check if logged in
  49. if(userExists($id)){ //the user exists
  50. echo '<h3>'.userRow($id, 'username').'\'s Profile</h3>';
  51. echo '<fieldset><legend><strong>User Details</strong></legend>
  52. <p>
  53. <label>Username</label><br>
  54. &nbsp;&nbsp;&nbsp;'.userRow($id, 'Username').'
  55. </p>
  56. <p>
  57. <label>User ID</label><br>
  58. &nbsp;&nbsp;&nbsp;'.userRow($id, 'User_ID').'
  59. </p>
  60. <p>
  61. <label>E-mail</label><br>
  62. &nbsp;&nbsp;&nbsp;'.userRow($id, 'Email').'
  63. </p>
  64. <p>
  65. <label>Rank</label><br>
  66. &nbsp;&nbsp;&nbsp;'.userRow($id, 'Group_ID').'
  67. </p>
  68. <p>
  69. <label>Join Date</label><br>
  70. &nbsp;&nbsp;&nbsp;'.userRow($id, 'SignUpDate').'
  71. </p>
  72. </fieldset>';
  73. }else{ //user does not exist
  74. echo 'This user does not exist!<br><br>&laquo; <a href="index.php">Home</a>';
  75. }
  76. }
  77. ?>
Add Comment
Please, Sign In to add comment