Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. <?php
  2. /*
  3. UserSpice 4
  4. An Open Source PHP User Management System
  5. by the UserSpice Team at http://UserSpice.com
  6.  
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. ?>
  21. <?php require_once '../users/init.php'; ?>
  22. <?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
  23. <?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
  24. <?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
  25. <?php
  26. if(!empty($_POST)){
  27. $token = $_POST['csrf'];
  28. if(!Token::check($token)){
  29. include($abs_us_root.$us_url_root.'usersc/scripts/token_error.php');
  30. }else {
  31. $fields = array(
  32. 'show_phone'=>Input::get('show_phone'),
  33. 'user_phone'=>Input::get('user_phone'),
  34. );
  35. $db->update('users',$user->data()->id,$fields);
  36. }
  37. }
  38. if(isset($_GET['id'])) $userID = Input::get('id');
  39. else $userID = $user->data()->id;
  40.  
  41. $userQ = $db->query("SELECT * FROM profiles LEFT JOIN users ON user_id = users.id WHERE user_id = ?",array($userID));
  42. if ($userQ->count() > 0) {
  43. $thatUser = $userQ->first();
  44.  
  45. if($user->isLoggedIn() && $user->data()->id == $userID)
  46. {
  47.  
  48. $editbio = ' <small><a href="../users/edit_profile.php">Edit Bio</a></small>';
  49. }
  50. else
  51. {
  52. $editbio = '';
  53. }
  54.  
  55. $ususername = ucfirst($thatUser->username)."'s Profile";
  56. $grav = get_gravatar(strtolower(trim($thatUser->email)));
  57. $useravatar = '<img src="'.$grav.'" class="img-thumbnail" alt="'.$ususername.'">';
  58. $usbio = html_entity_decode($thatUser->bio);
  59. //Uncomment out the line below to see what's available to you.
  60. //dump($thisUser);
  61. }
  62. else
  63. {
  64. $ususername = '404';
  65. $usbio = 'User not found';
  66. $useravatar = '';
  67. $editbio = ' <small><a href="/">Go to the homepage</a></small>';
  68. }
  69. ?>
  70. <div id="page-wrapper">
  71.  
  72. <div class="container">
  73. <!-- Main jumbotron for a primary marketing message or call to action -->
  74. <div class="well">
  75. <div class="row">
  76. <div class="col-xs-12 col-md-2">
  77. <p><?php echo $useravatar;?></p>
  78. </div>
  79. <div class="col-xs-12 col-md-10">
  80. <h1><?php echouser($userID);?>'s Profile</h1>
  81. <?php echo $usbio.$editbio;?>
  82. <br>
  83. <?php
  84. //hide or show phone number on profile based on database prference
  85. if($thatUser->show_phone == 1){ ?>
  86. <strong>Phone: </strong><?=$thatUser->user_phone?><br>
  87. <?php }else{ ?>
  88. <strong>Phone: (hidden)</strong><br>
  89. <?php }
  90. if($user->isLoggedIn() && $user->data()->id == $userID){ ?>
  91. <form class="" action="" method="post">
  92. <label for="">Your phone number is </label>
  93. <select class="" name="show_phone">
  94. <option value="0" <?php if($thatUser->show_phone == 0){echo "selected";}?>>Not visible to the public</option>
  95. <option value="1" <?php if($thatUser->show_phone == 1){echo "selected";}?>>Visible to the public</option>
  96. </select><br>
  97. <label for="">Change your phone number </label>
  98. <input type="text" name="user_phone" value="<?=$thatUser->user_phone?>"><br>
  99. <input type="submit" name="submit" value="Update Information">
  100. <input type="hidden" name="csrf" value="<?=Token::generate();?>" />
  101. </form>
  102. <?php } ?>
  103.  
  104. </div>
  105. </div>
  106. </div>
  107.  
  108. <a class="btn btn-success" href="../users/view_all_users.php" role="button">All Users</a>
  109.  
  110.  
  111. </div> <!-- /container --><br />
  112.  
  113. </div> <!-- /#page-wrapper -->
  114.  
  115. <!-- footers -->
  116. <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
  117. <!-- Place any per-page javascript here -->
  118. <?php require_once $abs_us_root.$us_url_root.'users/includes/html_footer.php'; // currently just the closing /body and /html ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement