A unf. social network done poorly.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

375 lines
12KB

  1. <?php
  2. ini_set('display_errors', '1');
  3. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/session.php');
  4. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/config.php');
  5. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/user-data.php');
  6. if(isset($_SESSION['Authenticated']) && $_SESSION['Authenticated']){
  7. if($_SESSION['Expires'] < time()){
  8. // Log out here.
  9. exit();
  10. header("Location: logout.php");
  11. }
  12. $_SESSION['Expires'] = time() + 86400; // if logged in, set to 24 hours.
  13. //header("Location: Dashboard.php");
  14. }else{
  15. header("Location: index.php");
  16. }
  17. // Here is the profile grabbing shit. >.>
  18. $profile_id = (!empty($_GET['id'])) ? $_GET['id'] : false;
  19. if($profile_id){
  20. $connection = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName);
  21. $profile_id = mysqli_real_escape_string($connection, $profile_id);
  22. $data = mysqli_query($connection, "SELECT * FROM users WHERE id='$profile_id'");
  23. if($data){
  24. $row = mysqli_fetch_array($data, MYSQLI_NUM);
  25. $profile_First_Name = $row[3];
  26. $profile_Last_Name = $row[4];
  27. $profile_birthdate = $row[5];
  28. $profile_country = $row[6];
  29. $profile_state = $row[7];
  30. $profile_town = $row[8];
  31. $profile_signup = $row[9];
  32. $profile_bio = $row[10];
  33. $profile_image_ext = $row[11];
  34. $profile_isOnline = $row[13];
  35. }else{
  36. echo "The data didn't go through";
  37. }
  38. if(mysqli_num_rows($data) > 0){
  39. } else{
  40. header("Location: index.php");
  41. }
  42. }else{
  43. header("Location: dashboard.php");
  44. }
  45. ?>
  46. <!DOCTYPE html>
  47. <html lang="en">
  48. <head>
  49. <meta charset="utf-8">
  50. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  51. <meta name="viewport" content="width=device-width, initial-scale=1">
  52. <title>SocialTune | <?php echo 'profile'; ?></title>
  53. <!--// bootstrap //-->
  54. <link href="css/bootstrap.css" rel="stylesheet">
  55. <link href="css/specialFX.css" rel="stylesheet">
  56. <script type="text/javascript"
  57. src="socialtune-chat/client/js/jquery-1.11.0.js">
  58. </script>
  59. <script type="text/javascript"
  60. src="socialtune-chat/client/js/md5.js">
  61. </script>
  62. <script type="text/javascript"
  63. src="socialtune-chat/client/js/store.js">
  64. </script>
  65. <script type="text/javascript"
  66. src="socialtune-chat/client/js/cookies.js">
  67. </script>
  68. <script type="text/javascript"
  69. src="socialtune-chat/client/js/dateformat.js">
  70. </script>
  71. <script type="text/javascript"
  72. src="socialtune-chat/client/js/im.js">
  73. </script>
  74. <script type="text/javascript">
  75. $(function(){
  76. if (!cookies.get('sessionid')) {
  77. cookies.set('sessionid', uid(40));
  78. }
  79. var u =
  80. window.location.href.split('/');
  81. var p = 8000; // Node.js port
  82. u = u[0]+'//'+u[2]+':'+p;
  83. var im = AjaxIM.init({pollServer: u,
  84. theme: 'themes/default'});
  85. });
  86. </script>
  87. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  88. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  89. <!--[if lt IE 9]>
  90. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  91. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  92. <![endif]-->
  93. <style>
  94. html,
  95. body{
  96. height: 100%;
  97. }
  98. #wrap{
  99. min-height: 100%;
  100. height: auto !important;
  101. height: 100%
  102. margin: 0 auto -60px;
  103. }
  104. #push,
  105. #footer{
  106. height: 60px;
  107. }
  108. @media(max-width: 767px){
  109. #footer{
  110. margin-left: -20px;
  111. margin-right: -20px;
  112. padding-left: 20px;
  113. padding-right: 20px;
  114. }
  115. }
  116. </style>
  117. </head>
  118. <body>
  119. <div id="wrap">
  120. <!--// Navigation //-->
  121. <nav class="navbar navbar-default navbar-fixed-top">
  122. <div class="container">
  123. <div class="navbar-header">
  124. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  125. <span class="sr-only">Toggle Navigation</span>
  126. <span class="icon-bar"></span>
  127. <span class="icon-bar"></span>
  128. <span class="icon-bar"></span>
  129. </button>
  130. <a class="navbar-brand" href="#">Social.Tune</a>
  131. </div>
  132. <div id="navbar" class="navbar-collapse collapse">
  133. <ul class="nav navbar-nav">
  134. <li><a href="dashboard.php">Home</a></li>
  135. <?php if($pending_notification == 1){
  136. echo '<li><span class="relative_blink"><span class="notification_blink"><span class="online_blink">New</span></span></span><a href="notifications.php">Notifications</a></li>';
  137. }else{ echo '<li><a href="notifications.php">Notifications</a><li>'; } // HOLY SHIT THIS IS A CLUSTERFUCK OF BAD. ~~ Ashton
  138. ?> <li class="active"><?php echo'<a href="profile.php?id='.$user_id.'">View Profile</a>'; ?></li>
  139. <li><a href="edit-profile.php">Edit Profile</a></li>
  140. <li><?php echo '<a href="friends.php?id='.$user_id.'">Friends</a></li>'; ?>
  141. <li><a href="about.php">About</a></li>
  142. <li><a href="logout.php">Log out</a></li>
  143. </ul>
  144. </div>
  145. </div>
  146. </nav>
  147. <!--// Content //-->
  148. <div class="container">
  149. <div class="jumbotron">
  150. <div class="row">
  151. <div class="col-md-8">
  152. <br />
  153. <?php echo '<img src="user-images/'.$profile_image_ext.'" style="width: 150px; height: 150px; float: left; margin: 1em 1em 1em 1em;">'; ?>
  154. <?php
  155. // grabs age.
  156. $profile_age = date_diff(date_create($profile_birthdate), date_create('now'))->y;
  157. if($profile_isOnline == 1){echo '<sup><span class="online_blink_bg"><span class="online_blink">Online</span></span></sup>';}else{echo '<sup><span class="offline_blink_bg"><span class="offline_blink">Offline</span></span></sup>';}
  158. echo '<b> '.$profile_First_Name.' '.$profile_Last_Name.'</b><br />';
  159. echo 'Age: <b>'.$profile_age.'</b><br />';
  160. echo 'Town: ';
  161. if($profile_town == false){echo '[unlisted]<br />';}else{echo $profile_town.'<br />';}
  162. echo 'State: ';
  163. if($profile_state == false){echo '[unlisted]<br />'; }else{echo $profile_state.'<br />'; }
  164. echo 'Country: ';
  165. if($profile_country == false){echo '[unlisted]<br />'; }else{echo $profile_country.'<br />'; }
  166. ?>
  167. <?php echo '<u>bio</u>:<br />';
  168. echo '<p>'.$profile_bio.'</p>';
  169. ?>
  170. <br>
  171. <u><h3>Garbled Transmission:</h3></u>
  172. <?php
  173. /* Ok.. This is the status stuff. :| */
  174. $status_query = "SELECT * FROM status WHERE poster_id='$profile_id' ORDER BY post_date DESC";
  175. $get_status = mysqli_query($connection, $status_query);
  176. while($status_row = mysqli_fetch_array($get_status, MYSQLI_NUM)){
  177. $status_id = $status_row[0];
  178. $status_owner = $status_row[1];
  179. $status_date = $status_row[2];
  180. $status_body = $status_row[3];
  181. $status_user_data = "SELECT * FROM users WHERE id='$status_owner'"; // ORDER BY isn't working?
  182. $get_status_user_data = mysqli_query($connection, $status_user_data);
  183. while($status_user = mysqli_fetch_array($get_status_user_data, MYSQLI_NUM)){
  184. $status_owner_name = $status_user[3].' '.$status_user[4];
  185. $status_owner_picture = $status_user[11];
  186. }
  187. echo '<table class="table table-bordered"><tr>';
  188. echo '<tbody><img style="width: 30px; height:30px;" src="user-images/'.$status_owner_picture.'">'.$status_owner_name.'
  189. <sub style="float:right;margin-top:15px;"><sub>'.$status_date.'</sub></sub></tbody></tr>';
  190. echo '<tr><td>'.$status_body.'</td></tr></table>';
  191. }
  192. ?>
  193. </table>
  194. </div>
  195. <div class="col-md-4">
  196. <center><h3><?php echo '<a href="friends.php?id='.$profile_id.'">Friends List</a>'; ?></h3></center>
  197. <?php
  198. $connection = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName);
  199. $isPending = 0;
  200. $query = "SELECT * FROM friends WHERE user_two='$profile_id' AND pending='$isPending' OR user_one='$profile_id' AND pending='$isPending' LIMIT 6";
  201. $get_friends = mysqli_query($connection, $query);
  202. $counter = 0;
  203. $data = mysqli_query($connection, $query);
  204. if(mysqli_num_rows($data) > 0){ // Checks if they have friends.
  205. while($row = mysqli_fetch_array($get_friends, MYSQLI_NUM)){
  206. $friend_A = $row[1];
  207. $friend_B = $row[2];
  208. if($friend_A == $profile_id){
  209. // use friend_B.
  210. $friend_search = "SELECT * FROM users WHERE id='$friend_B'";
  211. $get_friend_info = mysqli_query($connection, $friend_search);
  212. while($friend_info = mysqli_fetch_array($get_friend_info)){
  213. $friend_info_id = $friend_info[0];
  214. $friend_info_name = $friend_info[3].' '.$friend_info[4];
  215. $friend_info_img = $friend_info[11];
  216. $friend_info_online = $friend_info[13];
  217. }
  218. }else{
  219. // use friend_A.
  220. $friend_search = "SELECT * FROM users WHERE id='$friend_A'";
  221. $get_friend_info = mysqli_query($connection, $friend_search);
  222. while($friend_info = mysqli_fetch_array($get_friend_info)){
  223. $friend_info_id = $friend_info[0];
  224. $friend_info_name = $friend_info[3].' '.$friend_info[4];
  225. $friend_info_img = $friend_info[11];
  226. $friend_info_online = $friend_info[13];
  227. }
  228. }
  229. if($counter == 0 || $counter == 3){ echo '<div class="col-md-6">';}
  230. echo'<table class="table table-bordered"><tr><td><a href="profile.php?id='.$friend_info_id.'"><img style="width:100px; height:100px;" src="user-images/'.$friend_info_img.'">';
  231. if($friend_info_online == 1){
  232. echo '<sup><span class="online_blink_bg"><span class="online_blink">Online</span></span></sup></a></td></tr>';
  233. }else{
  234. echo'<sup><span class="offline_blink_bg"><span class="offline_blink">Offline</span></span></sup></a></td></tr>';
  235. }
  236. echo '<tr><td><a style="font-size: 10px;" href="profile.php?id='.$friend_info_id.'">'.$friend_info_name.'</a></td></tr>';
  237. if($counter == 2 || $counter == 5){
  238. echo '</table></div>';
  239. }
  240. $counter = $counter + 1;
  241. }
  242. }else{
  243. // no friends lol...
  244. }
  245. ?>
  246. </table>
  247. </div>
  248. </div>
  249. <div class="row">
  250. <div class="col-md-12">
  251. &nbsp;
  252. </div>
  253. </div>
  254. <div class="row">
  255. <div class="col-md-12">
  256. <?php
  257. if(mysqli_num_rows($data) > 0){ // Checks if they have friends.
  258. if($profile_id == $user_id){
  259. // nothing.
  260. }else{
  261. //$isFriend = "SELECT * FROM friends WHERE user_two='$profile_id' AND pending='$isPending' OR user_one='$profile_id' AND pending='$isPending'";
  262. if($friend_A == $user_id || $friend_B == $user_id){
  263. echo '
  264. <form method="POST" action="friend_request.php">
  265. <div class="form-group">
  266. <input type="hidden" name="profile_id" id="profile_id" value="'.$profile_id.'">
  267. <input type="hidden" name="remove" id="remove" value="True">
  268. </div>
  269. <button type="submit" class="btn btn-primary">Delete Friends</button>
  270. </form>
  271. ';
  272. }else{
  273. echo '
  274. <form method="POST" action="friend_request.php">
  275. <div class="form-group">
  276. <input type="hidden" name="profile_id" id="profile_id" value="'.$profile_id.'">
  277. </div>
  278. <button type="submit" class="btn btn-primary">Add Friend</button>
  279. </form>
  280. ';
  281. }
  282. }
  283. }else{
  284. echo '
  285. <form method="POST" action="friend_request.php">
  286. <div class="form-group">
  287. <input type="hidden" name="profile_id" id="profile_id" value="'.$profile_id.'">
  288. </div>
  289. <button type="submit" class="btn btn-primary">Add Friend</button>
  290. </form>
  291. ';
  292. }
  293. ?>
  294. </div>
  295. </div>
  296. </div>
  297. </div>
  298. <div class="container">
  299. <div class="jumbotron">
  300. <div id="push"></div>
  301. </div>
  302. </div>
  303. </div> <!--## ending wrap ##-->
  304. <!--// Footer //-->
  305. <div id="footer">
  306. <div class="container">
  307. <div class="row">
  308. <div class="col-md-4">
  309. <p style="font-size: 12px;">Social.Tune &copy; 2015</p>
  310. </div>
  311. <div class="col-md-8">
  312. <p class="text-right" style="font-size: 12px;">
  313. | <a href="">English</a> | <a href="">汉语</a> | <a href="">日本語</a> |
  314. <a href="">français</a> |<br /> | <a href="">Social-Tune</a> |
  315. <a href="">About Us</a> |<a href="">Contact Us</a> | <a href="">Careers</a> |
  316. <a href="">Privacy</a> | <a href="">License</a> | <a href="">Help</a> |
  317. </p>
  318. </div>
  319. </div>
  320. </div>
  321. </div>
  322. </div>
  323. </body>
  324. </html>