Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- UserSpice 4
- An Open Source PHP User Management System
- by the UserSpice Team at http://UserSpice.com
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ?>
- <?php require_once '../users/init.php'; ?>
- <?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
- <?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
- <?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
- <?php
- if(!empty($_POST)){
- $token = $_POST['csrf'];
- if(!Token::check($token)){
- include($abs_us_root.$us_url_root.'usersc/scripts/token_error.php');
- }else {
- $fields = array(
- 'show_phone'=>Input::get('show_phone'),
- 'user_phone'=>Input::get('user_phone'),
- );
- $db->update('users',$user->data()->id,$fields);
- }
- }
- if(isset($_GET['id'])) $userID = Input::get('id');
- else $userID = $user->data()->id;
- $userQ = $db->query("SELECT * FROM profiles LEFT JOIN users ON user_id = users.id WHERE user_id = ?",array($userID));
- if ($userQ->count() > 0) {
- $thatUser = $userQ->first();
- if($user->isLoggedIn() && $user->data()->id == $userID)
- {
- $editbio = ' <small><a href="../users/edit_profile.php">Edit Bio</a></small>';
- }
- else
- {
- $editbio = '';
- }
- $ususername = ucfirst($thatUser->username)."'s Profile";
- $grav = get_gravatar(strtolower(trim($thatUser->email)));
- $useravatar = '<img src="'.$grav.'" class="img-thumbnail" alt="'.$ususername.'">';
- $usbio = html_entity_decode($thatUser->bio);
- //Uncomment out the line below to see what's available to you.
- //dump($thisUser);
- }
- else
- {
- $ususername = '404';
- $usbio = 'User not found';
- $useravatar = '';
- $editbio = ' <small><a href="/">Go to the homepage</a></small>';
- }
- ?>
- <div id="page-wrapper">
- <div class="container">
- <!-- Main jumbotron for a primary marketing message or call to action -->
- <div class="well">
- <div class="row">
- <div class="col-xs-12 col-md-2">
- <p><?php echo $useravatar;?></p>
- </div>
- <div class="col-xs-12 col-md-10">
- <h1><?php echouser($userID);?>'s Profile</h1>
- <?php echo $usbio.$editbio;?>
- <br>
- <?php
- //hide or show phone number on profile based on database prference
- if($thatUser->show_phone == 1){ ?>
- <strong>Phone: </strong><?=$thatUser->user_phone?><br>
- <?php }else{ ?>
- <strong>Phone: (hidden)</strong><br>
- <?php }
- if($user->isLoggedIn() && $user->data()->id == $userID){ ?>
- <form class="" action="" method="post">
- <label for="">Your phone number is </label>
- <select class="" name="show_phone">
- <option value="0" <?php if($thatUser->show_phone == 0){echo "selected";}?>>Not visible to the public</option>
- <option value="1" <?php if($thatUser->show_phone == 1){echo "selected";}?>>Visible to the public</option>
- </select><br>
- <label for="">Change your phone number </label>
- <input type="text" name="user_phone" value="<?=$thatUser->user_phone?>"><br>
- <input type="submit" name="submit" value="Update Information">
- <input type="hidden" name="csrf" value="<?=Token::generate();?>" />
- </form>
- <?php } ?>
- </div>
- </div>
- </div>
- <a class="btn btn-success" href="../users/view_all_users.php" role="button">All Users</a>
- </div> <!-- /container --><br />
- </div> <!-- /#page-wrapper -->
- <!-- footers -->
- <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
- <!-- Place any per-page javascript here -->
- <?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