Advertisement
Guest User

Tidy code

a guest
Feb 9th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.22 KB | None | 0 0
  1.  <?php
  2.     require("connections.php");
  3.  
  4.     $id = $_SESSION['ID'];
  5.     $check_pic      = mysqli_query($con, " SELECT profile_pic FROM members WHERE ID='$username'");
  6.     $get_pic_row    = mysqli_fetch_assoc($check_pic);
  7.     $profile_pic_db = $get_pic_row['profile_pic'];
  8.  
  9.     if ($profile_pic_db == "") {
  10.         $profile_pic = "assets/img/default_pic.jpg";
  11.     } else {
  12.         $profile_pic = "userdata/profile_pics/" . $profile_pic_db;
  13.     }
  14.  
  15.     //Profile Image upload script
  16.     if ($sesID == $username) {
  17.         if (isset($_FILES['profilepic'])) {
  18.             if (((@$_FILES["profilepic"]["type"] == "image/jpeg") || (@$_FILES["profilepic"]["type"] == "image/png") || (@$_FILES["profilepic"]["type"] == "image/gif")) && (@$_FILES["profilepic"]["size"] < 3145728)) /* 1 mega byte */ {
  19.                 $chars         = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  20.                 $rand_dir_name = substr(str_shuffle($chars), 0, 15);
  21.  
  22.                 mkdir("userdata/profile_pics/$rand_dir_name");
  23.                
  24.                 if (file_exists("/userdata/profile_pics/$rand_dir_name/" . @$_FILES["profilepic"]["name"])) {
  25.                     echo @$_FILES["profilepic"]["name"] . " Already exists";
  26.                 } else {
  27.                     move_uploaded_file(@$_FILES["profilepic"]["tmp_name"], "userdata/profile_pics/$rand_dir_name/" . $_FILES["profilepic"]["name"]);
  28.  
  29.                     //echo "Uploaded and stored in: userdata/profile_pics/$rand_dir_name/".@$_FILES["profilepic"]["name"];
  30.                     $profile_pic_name  = @$_FILES["profilepic"]["name"];
  31.                     $profile_pic_query = mysqli_query($con, "UPDATE members SET profile_pic='$rand_dir_name/$profile_pic_name' WHERE ID='$username';");
  32.  
  33.                     echo "<meta http-equiv='refresh' content='0'>";
  34.                 }
  35.             } else {
  36.                 echo "<p>None or Too large pic!</p>";
  37.             }
  38.         }
  39.     }
  40. ?>
  41. <!-- <form action="" method="POST" enctype="multipart/form-data">
  42.     <input type="file" name="profilepic" id="fileupload" style="text-decoration: none; "/> <br /><br /><br /><br />
  43.     <input type="submit" name ="uploadpic" value="Upload Image" class="myButton"style="width:18.6em; height:1.2em; font-size:8px; align: left; float:left; position:left;  ">
  44. </form> -->
  45.            
  46.  
  47. <form action="" method="POST" enctype="multipart/form-data" style="float:center;">
  48.     <div class="inputWrapper" style="float:middle;" >
  49.         <input class="fileInput" type="file" name="profilepic" align="center" style="float:middle; width:150px;">
  50.     </div><br />
  51.     <img src="<?php echo $profile_pic;?>" align="center" style=" min-width:150px; max-height:150px; max-width:150px; overflow:hidden; margin:0 auto;  "><br />
  52.     <input type="submit" name="uploadpic" class="myButton" value="Upload Image" align="center" style="width:150px; height: 11px; padding: 6px;  float:middle;"><br />
  53. </form>
  54. <div class="fufbut" align="center" >
  55.     <?php $sesID = $_SESSION['ID'];
  56.         if ($username != $sesID) {
  57.             $forfollow = mysqli_query($con, "SELECT id FROM follow WHERE user_one='$sesID' AND user_two='$username'");
  58.             if (mysqli_num_rows($forfollow) == 1) {
  59.                 echo "<a  href='actions.php?action=unfollow&u=$username' class=\"myButtonnn\"><center>Unfollow</center></a>";
  60.             } else {
  61.                 echo "<a href='actions.php?action=follow&u=$username' class=\"myButtonn\" ><center>Follow</center></a>";
  62.             }  
  63.         }
  64.     ?>
  65. </div>
  66. <br />
  67. <div class="userstats">
  68.     <div class="infosection" align="center" style=" display:inline; float:center; ">
  69.         <div class="folowz" style="display: inline-block; margin-right:18px;">
  70.             <b style=" "><font size="1">Circle</font></b>
  71.             <img src="assets/img/twistfo.png" style="width:35px; height:35px; ">
  72.             <b>
  73.                 <?php
  74.                     $check_followers = mysqli_query($con, "SELECT id FROM follow WHERE user_two = '$username'");
  75.                     echo mysqli_num_rows($check_followers);
  76.                 ?>
  77.             </b>
  78.         </div>
  79.         <div class="followiz" style="display: inline-block; ">
  80.             <b style="color:white;"><font size="1">Following</font></b>
  81.             <img src="assets/img/twistfoli.png" style="width:35px; height:35px;">
  82.             <b>
  83.                 <?php
  84.                     $check_followerss = mysqli_query($con, "SELECT id FROM follow WHERE user_one = '$username'");
  85.                     echo mysqli_num_rows($check_followerss);
  86.                 ?>
  87.             </b>
  88.         </div>
  89.     </div>
  90. </div>
  91.  
  92. <!-- In use?? -->
  93. </div>
  94.  
  95. <!--HOME SECTION END-->  
  96. <div class="feedwrapper" align="middle" style="float:center; ">
  97.     <div class="postdiv" align="center" style="float:center; display:inline-block; "  >
  98.         <?php
  99.             require("connections.php");
  100.  
  101.             $firstname = $get['Firstname'];
  102.             $lastname  = $get['Lastname'];
  103.             $getposts = mysqli_query($con, "SELECT * FROM Posts WHERE Postedby = $username") or die("connecting...");
  104.  
  105.             while ($row = mysqli_fetch_assoc($getposts)) {
  106.                 $body       = $row['Postbody'];
  107.                 $date_added = $row['Postdate'];
  108.                 $added_by   = $row['Postedby'];
  109.                
  110.                 echo "<div class='Posted_by'  ><a href='$added_by'>$firstname , $lastname</a> - $date_added - <a href=\"\"><img src=\"assets/img/grøngrab.png\" style=\"width:10%; height:10%; display: inline; float:right;\" class=\"grabbutton\"></a><br /><p>&nbsp;&nbsp;$body </p></div><br />";     
  111.             }
  112. ?>          
  113.     </div>
  114. </div>
  115.  
  116. <!-- In use?? -->
  117. </div>
  118. </ul>
  119. </div>
  120. </div>
  121. </div>                           
  122. <!-- <img class="clixlogo" src="assets/img/messagepic.png" style="width:3%; height:3%; align:middle;"> <br />
  123. <img class="clixlogo" src="assets/img/settingspic.png" style="width:3%; height:3%; margin: 40px; "> -->
  124. </div>
  125. </div>
  126. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement