the-real-sumsome /
witter
| 1 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/config.inc.php"); ?> |
||
| 2 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/conn.php"); ?> |
||
| 3 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/lib/profile.php"); ?> |
||
| 4 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/lib/manage.php"); ?> |
||
| 5 | <!DOCTYPE html> |
||
| 6 | <html> |
||
| 7 | <head> |
||
| 8 | <link href="/static/css/required.css" rel="stylesheet"> |
||
| 9 | <title>Witter: What are you doing?</title> |
||
| 10 | <script src='https://www.google.com/recaptcha/api.js' async defer></script> |
||
| 11 | <?php $user = getUserFromName($_SESSION['siteusername'], $conn); ?> |
||
| 12 | <script>function onLogin(token){ document.getElementById('submitform').submit(); }</script> |
||
| 13 | </head> |
||
| 14 | <body id="front"> |
||
| 15 | <div id="container"> |
||
| 16 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/header.php"); |
||
| 17 | $stmt = $conn->prepare("SELECT banstatus FROM users WHERE username = ?"); |
||
| 18 | $stmt->bind_param("s", $username); |
||
| 19 | $stmt->execute(); |
||
| 20 | $result = $stmt->get_result(); |
||
| 21 | $row = $result->fetch_assoc(); |
||
| 22 | if($row['banstatus'] == 'suspended'){ $_SESSION['errorMsg'] = "you're suspended"; } |
||
| 23 | if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['bioset']) { |
||
| 24 | updateUserBio($_SESSION['siteusername'], $_POST['bio'], $conn); |
||
| 25 | header("Location: index.php"); |
||
| 26 | } else if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['bgset']) { |
||
| 27 | if (filter_var($_POST['bg'], FILTER_VALIDATE_URL) == FALSE) { |
||
| 28 | $_SESSION['errorMsg'] = 'Invalid URL'; |
||
| 29 | goto skip; |
||
| 30 | } |
||
| 31 | $ext = substr($_POST['bg'], -4); |
||
| 32 | $ext = preg_replace("/\s+/", "", $ext); |
||
| 33 | $ext = str_replace(" ", "", $ext); |
||
| 34 | if($ext == ".png " || $ext == ".gif " || $ext == ".jpg ") { |
||
| 35 | $_SESSION['errorMsg'] = 'URL does not end with .png, .gif, or .jpg'; |
||
| 36 | goto skip; |
||
| 37 | } |
||
| 38 | updateUserBG($_SESSION['siteusername'], $_POST['bg'], $conn); |
||
| 39 | skip: |
||
| 40 | } else if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['pfpset']) { |
||
| 41 | ini_set('display_errors', 1); |
||
| 42 | ini_set('display_startup_errors', 1); |
||
| 43 | error_reporting(E_ALL); |
||
| 44 | |||
| 45 | //This is terribly awful and i will probably put this in a function soon |
||
| 46 | $target_dir = "../dynamic/pfp/"; |
||
| 47 | $imageFileType = strtolower(pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_EXTENSION)); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 48 | $target_name = md5_file($_FILES["fileToUpload"]["tmp_name"]) . "." . $imageFileType; |
||
| 49 | |||
| 50 | $target_file = $target_dir . $target_name; |
||
| 51 | |||
| 52 | $uploadOk = true; |
||
| 53 | $movedFile = false; |
||
| 54 | |||
| 55 | if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
||
| 56 | && $imageFileType != "gif" ) { |
||
| 57 | $fileerror = 'unsupported file type. must be jpg, png, jpeg, or gif'; |
||
| 58 | $uploadOk = false; |
||
| 59 | } |
||
| 60 | |||
| 61 | if (file_exists($target_file)) { |
||
| 62 | $movedFile = true; |
||
| 63 | } else { |
||
| 64 | $movedFile = move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file); |
||
| 65 | } |
||
| 66 | |||
| 67 | if ($uploadOk) { |
||
| 68 | if ($movedFile) { |
||
| 69 | $stmt = $conn->prepare("UPDATE users SET pfp = ? WHERE `users`.`username` = ?;"); |
||
| 70 | $stmt->bind_param("ss", $target_name, $_SESSION['siteusername']); |
||
| 71 | $stmt->execute(); |
||
| 72 | $stmt->close(); |
||
| 73 | header("Location: index.php"); |
||
| 74 | } else { |
||
| 75 | $fileerror = 'fatal error'; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | ?> |
||
| 80 | <div id="content"> |
||
| 81 | <div class="wrapper"> |
||
| 82 | <div class="customtopRight"> |
||
| 83 | <img id="pfp" style="vertical-align: middle;" src="/dynamic/pfp/<?php echo $user['pfp']; ?>"> <b><big><big><?php echo $_SESSION['siteusername']; ?></big></big></b><br> |
||
| 84 | <table id="cols"> |
||
| 85 | <tr> |
||
| 86 | <th style="width: 33%;"> </th> |
||
| 87 | <th style="width: 33%;"> </th> |
||
| 88 | <th style="width: 33%;"> </th> |
||
| 89 | </tr> |
||
| 90 | <tr> |
||
| 91 | <td><big><big><big><b><?php echo getFollowing($_SESSION['siteusername'], $conn); ?></b></big></big></big><br><span id="blue">following</span></td> |
||
| 92 | <td><big><big><big><b><?php echo getFollowers($_SESSION['siteusername'], $conn); ?></b></big></big></big><br><span id="blue">followers</span></td> |
||
| 93 | <td><big><big><big><b><?php echo getWeets(rhandleTag($_SESSION['siteusername']), $conn); ?></b></big></big></big><br><span id="blue">tweets</span></td> |
||
| 94 | </tr> |
||
| 95 | </table><br> |
||
| 96 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/followRequire.php"); ?> |
||
| 97 | <div class="altbg"> |
||
| 98 | <a href="/home.php">Home</a><br> |
||
| 99 | <a href="/pms.php">Private Messages [200]</a> |
||
| 100 | </div><br> |
||
| 101 | <div class="altbg"> |
||
| 102 | <center><a href="https://discord.gg/J5ZDsak">Join the Discord server</a></center> |
||
| 103 | </div><br> |
||
| 104 | </div> |
||
| 105 | <div class="customtopLeft"> |
||
| 106 | <form method="post" enctype="multipart/form-data"> |
||
| 107 | <b>Profile Picture</b><br> |
||
| 108 | <input type="file" name="fileToUpload" id="fileToUpload"> |
||
| 109 | <input type="submit" value="Upload Image" name="pfpset"> |
||
| 110 | </form><br> |
||
| 111 | <form method="post" enctype="multipart/form-data"> |
||
| 112 | <b>Bio</b><br> |
||
| 113 | <textarea cols="56" id="biomd" placeholder="Bio" name="bio"><?php echo $user['bio'];?></textarea><br> |
||
| 114 | <input name="bioset" type="submit" value="Set"> |
||
| 115 | </form><br> |
||
| 116 | <form method="post" enctype="multipart/form-data"> |
||
| 117 | <b>Background URL</b><br><?php if(isset($_SESSION['errorMsg'])) { echo "<div style='padding: 5px; border: 5px solid green;'><h4 id='noMargin'>" . $_SESSION['errorMsg']; unset($_SESSION['errorMsg']); echo "</h4></div><br>"; }?> |
||
| 118 | <input size="50" type="text" value="<?php echo $user['bg'];?> " placeholder="Background Image" name="bg"> <input name="bgset" type="submit" value="Set"> |
||
| 119 | </form><br> |
||
| 120 | </div> |
||
| 121 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/footer.php"); ?> |
||
| 122 | </div> |
||
| 123 | </div> |
||
| 124 | </div> |
||
| 125 | </body> |
||
| 126 | </html> |
||
| 127 |