Advertisement
Faguss

UserSpice profile.php with Brandin's patch

Jul 4th, 2017
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.88 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. require_once 'init.php';
  22. require_once $abs_us_root.$us_url_root.'users/includes/header.php';
  23. require_once $abs_us_root.$us_url_root.'users/includes/navigation.php';
  24.  
  25. if (!securePage($_SERVER['PHP_SELF']))
  26.     die();
  27.  
  28. //PHP Goes Here!
  29.  
  30. if ($user->isLoggedIn())
  31.     $thisUserID = $user->data()->id;
  32. else
  33.     $thisUserID = 0;
  34.  
  35.  
  36. $userID     = Input::get('id');
  37. $name       = Input::get('name');
  38.  
  39. $ususername = '404';
  40. $usbio      = "User not found";
  41. $useravatar = "";
  42. $editbio    = " <SMALL><A HREF=\"/\">Go to the homepage</A></SMALL>";
  43.  
  44. $sql        = "SELECT * FROM profiles LEFT JOIN users ON user_id = users.id WHERE " . (empty($name) ? "user_id=" : "username LIKE ") . "?";
  45. $arg        = empty($name) ? [$userID] : [$name];
  46. $userQ      = $db->query($sql, $arg);
  47. $thatUser   = $userQ->first();
  48. $found      = !$db->error()  &&  $db->count()>0;
  49.  
  50. if ($found) {
  51.     $userID     = $thatUser->id;
  52.     $ususername = ucfirst($thatUser->username)."'s Profile";
  53.     $grav       = empty($thatUser->picture) ? get_gravatar(strtolower(trim($thatUser->email))) : $thatUser->picture;
  54.     $useravatar = '<IMG SRC="'.$grav.'" CLASS="img-thumbnail" WIDTH=130 HEIGHT=130 ALT="'.$ususername.'">';
  55.     $usbio      = html_entity_decode($thatUser->bio);
  56.     $editbio    = $thisUserID == $userID ? " <SMALL><A HREF=\"edit_profile.php\">Edit Bio</A></SMALL>" : "";
  57. }
  58.  
  59.  
  60.  
  61. echo "
  62.   <DIV ID=\"page-wrapper\">
  63.  
  64.          <DIV CLASS=\"container\">
  65.                 <!-- Main jumbotron for a primary marketing message or call to action -->
  66.                 <DIV CLASS=\"well\">
  67.                     <DIV CLASS=\"row\">
  68.                         <DIV CLASS=\"col-xs-12 col-md-2\">
  69.                             <P>{$useravatar}</P>
  70.                         </DIV>
  71.                         <DIV CLASS=\"col-xs-12 col-md-10\">
  72.  
  73.     <H2>{$ususername}</H2>
  74.     <BR />
  75.     {$usbio} {$editbio}
  76.     <BR /><BR />";
  77.    
  78. if ($found)
  79.     echo
  80.     "<SPAN STYLE=\"font-size:small; float:right\">
  81.         <B>Joined</B>: " . DateTime::createFromFormat("Y-m-d H:i:s", $thatUser->join_date)->format("Y-m-d") . " &nbsp; &nbsp;  &nbsp;
  82.         <B>Active</B>: " . DateTime::createFromFormat("Y-m-d H:i:s", $thatUser->last_login)->format("jS F (l) Y H:i") .
  83.     "</SPAN>";
  84.  
  85. echo "
  86.                     </DIV>
  87.                     </DIV>
  88.                 </DIV>";
  89.  
  90. if ($settings->messaging==1  &&  $found  &&  $thisUserID!=$userID)
  91.     echo "<BUTTON TYPE=\"button\" CLASS=\"btn btn-info\" DATA-TOGGLE=\"modal\" DATA-TARGET=\"#compose\" DATA-ID=\"{$thatUser->id};{$thatUser->username}\"><I CLASS=\"glyphicon glyphicon-plus\"></I> New Message</BUTTON> &nbsp; &nbsp; ";
  92.    
  93. if (!empty($thatUser->gpluslink))
  94.     echo "<A CLASS=\"btn btn-primary\" TARGET=\"_blank\" HREF=\"{$thatUser->gpluslink}\" ROLE=\"button\">G+ Profile</A> &nbsp; &nbsp; ";
  95. ?>
  96.  
  97.                                         <a class="btn btn-success" href="view_all_users.php" role="button">All Users</a>
  98.  
  99. <BR /><BR />
  100.  
  101.    
  102.    
  103.    
  104.    
  105.    
  106.    
  107.    
  108.    
  109. <div id="compose" class="modal fade" role="dialog">
  110.   <div class="modal-dialog">
  111.  
  112.     <!-- Modal content-->
  113.     <div class="modal-content">
  114.       <div class="modal-header">
  115.         <button type="button" class="close" data-dismiss="modal">&times;</button>
  116.         <h4 class="modal-title">New Message</h4>
  117.       </div>
  118.       <div class="modal-body">
  119. <form name="create_message" action="messages.php" method="post">
  120.  
  121.                 <select name="user_id" id="combobox" class="form-control combobox" required disabled>
  122.                 <option readonly></option>
  123.                 </select><br />
  124.               <label>Subject:</label>
  125.                 <input required size='100' class='form-control' type='text' name='msg_subject' value='' required/>
  126.                 <br /><label>Body:</label>
  127.                 <textarea rows="20" cols="80"  id="mytextarea" name="msg_body"></textarea>
  128.                 <input required type="hidden" name="csrf" value="<?=Token::generate();?>" >
  129.               </p>
  130.               <p>
  131.                   <br />
  132.       </div>
  133.       <div class="modal-footer">
  134.       <div class="btn-group">   <input type="hidden" name="csrf" value="<?=Token::generate();?>" />
  135.     <input class='btn btn-primary' type='submit' name="send_message" value='Send Message' class='submit' /></div>
  136.     </form>
  137.          <div class="btn-group"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></div>
  138.       </div>
  139.     </div>
  140.     </div>
  141.   </div>
  142.  
  143.     </div> <!-- /container -->
  144.  
  145. </div> <!-- /#page-wrapper -->
  146.  
  147. <!-- footers -->
  148. <?php require_once $abs_us_root.$us_url_root.'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
  149.  
  150.     <!-- Place any per-page javascript here -->
  151.     <script src='https://cdn.tinymce.com/4/tinymce.min.js'></script>
  152.     <script src="../usersc/js/bootstrap-combobox.js"></script>
  153.     <script src="../usersc/js/messages.php.js"></script>
  154.     <script type="text/javascript">
  155.       $(document).ready(function(){
  156.         $(".btn-info").click(function(){
  157.             var userdata = $(this).data('id');         
  158.             var userID   = userdata.substr(0, userdata.indexOf(';'));
  159.             var inputs   = document.getElementsByName("user_id");
  160.            
  161.             for (i=0, max=inputs.length; i<max; i++)
  162.                 inputs[i].value = userID;
  163.            
  164.             document.getElementById("comboboxundefined").value = userdata.substr(userdata.indexOf(';')+1);
  165.         });
  166.       });
  167.     </script>
  168.  
  169. <?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