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 | <!DOCTYPE html> |
||
| 5 | <html> |
||
| 6 | <head> |
||
| 7 | <link href="/static/css/required.css" rel="stylesheet"> |
||
| 8 | <title>Witter: What are you doing?</title> |
||
| 9 | <script src='https://www.google.com/recaptcha/api.js' async defer></script> |
||
| 10 | <?php $user = getUserFromName($_SESSION['siteusername'], $conn); ?> |
||
| 11 | <?php $weet = getWeetFromRID($_GET['rid'], $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 | if($_SERVER['REQUEST_METHOD'] == 'POST') { |
||
| 18 | if(!isset($_SESSION['siteusername'])){ $error = "you are not logged in"; goto skipcomment; } |
||
| 19 | if(!$_POST['comment']){ $error = "your comment cannot be blank"; goto skipcomment; } |
||
| 20 | if(strlen($_POST['comment']) > 500){ $error = "your comment must be shorter than 500 characters"; goto skipcomment; } |
||
| 21 | if(!isset($_POST['g-recaptcha-response'])){ $error = "captcha validation failed"; goto skipcomment; } |
||
| 22 | if(!validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; } |
||
| 23 | |||
| 24 | $stmt = $conn->prepare("SELECT * FROM weets WHERE author = ? AND realid = ?"); |
||
| 25 | $stmt->bind_param("si", $_SESSION['siteusername'], $_GET['rid']); |
||
| 26 | $stmt->execute(); |
||
| 27 | $result = $stmt->get_result(); |
||
| 28 | if($result->num_rows === 0) { |
||
| 29 | $error = ('you dont own this blog post'); |
||
| 30 | goto skipcomment; |
||
| 31 | } |
||
| 32 | $stmt->close(); |
||
| 33 | |||
| 34 | $stmt = $conn->prepare("UPDATE weets SET contents = ? WHERE realid = ?"); |
||
| 35 | $stmt->bind_param("ss", $text, $_GET['rid']); |
||
| 36 | $text = htmlspecialchars($_POST['comment']); |
||
| 37 | $stmt->execute(); |
||
| 38 | $stmt->close(); |
||
| 39 | |||
| 40 | header("Refresh: 0"); |
||
| 41 | |||
| 42 | skipcomment: |
||
| 43 | } |
||
| 44 | ?> |
||
| 45 | <div id="content"> |
||
| 46 | <div class="wrapper"> |
||
| 47 | <div class="customtopRight"> |
||
| 48 | <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> |
||
| 49 | <table id="cols"> |
||
| 50 | <tr> |
||
| 51 | <th style="width: 33%;"> </th> |
||
| 52 | <th style="width: 33%;"> </th> |
||
| 53 | <th style="width: 33%;"> </th> |
||
| 54 | </tr> |
||
| 55 | <tr> |
||
| 56 | <td><big><big><big><b><?php echo getFollowing($_SESSION['siteusername'], $conn); ?></b></big></big></big><br><span id="blue">following</span></td> |
||
| 57 | <td><big><big><big><b><?php echo getFollowers($_SESSION['siteusername'], $conn); ?></b></big></big></big><br><span id="blue">followers</span></td> |
||
| 58 | <td><big><big><big><b><?php echo getWeets(rhandleTag($_SESSION['siteusername']), $conn); ?></b></big></big></big><br><span id="blue">weets</span></td> |
||
| 59 | </tr> |
||
| 60 | </table><br> |
||
| 61 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/followRequire.php"); ?> |
||
| 62 | <div class="altbg"> |
||
| 63 | <a href="/home.php">Home</a><br> |
||
| 64 | <a href="/pms.php">Private Messages [200]</a> |
||
| 65 | </div><br> |
||
| 66 | <div class="altbg"> |
||
| 67 | <center><a href="https://discord.gg/J5ZDsak">Join the Discord server</a></center> |
||
| 68 | </div><br> |
||
| 69 | </div> |
||
| 70 | <div class="customtopLeft"> |
||
| 71 | <big><big><big>Editing your Weet </big></big></big> <?php if(isset($error)) { echo "<small style='color: red;'>" . $error . "</small>"; } ?> <span id="textlimit">0/500</span> |
||
| 72 | <form method="post" enctype="multipart/form-data" id="submitform"> |
||
| 73 | <textarea cols="32" style="width: 534px;" id="upltx" name="comment"><?php echo $weet['contents']; ?></textarea><br> |
||
| 74 | <script src="/js/commd.js"></script> |
||
| 75 | <input style="float: right; font-size: 1.2em; margin-top: 5px; margin-right: -6px;" type="submit" value="update" class="g-recaptcha" data-sitekey="<?php echo $config['recaptcha_sitekey']; ?>" data-callback="onLogin"> |
||
| 76 | <script> |
||
| 77 | document.getElementById("upltx").onkeyup = () => { |
||
| 78 | document.getElementById("feedtext").innerHTML = document.getElementById("upltx").value.replace(/(?:\r\n|\r|\n)/g,"<br/>"); |
||
| 79 | }; |
||
| 80 | </script> |
||
| 81 | </form> |
||
| 82 | <table id="feed"> |
||
| 83 | <tr> |
||
| 84 | <th style="width: 48px;"> </th> |
||
| 85 | <th> </th> |
||
| 86 | </tr> |
||
| 87 | <tr> |
||
| 88 | <big><big><big> |
||
| 89 | <td> |
||
| 90 | <img id="pfp" src="/dynamic/pfp/<?php echo getPFPFromUser($row['author'], $conn); ?>"> |
||
| 91 | </td> |
||
| 92 | <td><a id="tag" href="/u.php?n=<?php echo handleTag($row['author']); ?>"><?php echo($row['author']); ?></a> |
||
| 93 | <?php if(returnVerifiedFromUsername($row['author'], $conn) != "") { ?> <span style="border-radius: 10px; background-color: deepskyblue; color: white; padding: 3px;"><?php echo(returnVerifiedFromUsername($row['author'], $conn)); ?></span> <?php } ?> |
||
| 94 | <div id="floatRight" class="dropdown"> |
||
| 95 | <span><img style="vertical-align: middle;" src="/static/witter-dotdotdot.png"></span> |
||
| 96 | <div class="dropdown-content"> |
||
| 97 | <a href="#<?php //echo report.php?r=$row['realid']; ?>"><img style="vertical-align: middle;" src="/static/witter-report.png"></a><br> |
||
| 98 | <?php if(isset($_SESSION['siteusername']) && $row['author'] == $_SESSION['siteusername']) { ?> |
||
| 99 | <a href="/delete.php?rid=<?php echo $row['realid']; ?>"><img style="vertical-align: middle;" src="/static/witter-trash.png"></a><br> |
||
| 100 | <a href="/edit.php?rid=<?php echo $row['realid']; ?>"><img style="vertical-align: middle;" src="/static/witter-edit.png"></a><br> |
||
| 101 | <?php } ?> |
||
| 102 | </div> |
||
| 103 | </div> |
||
| 104 | <span id="floatRight"> |
||
| 105 | <?php if(ifLiked($_SESSION['siteusername'], $row['id'], $conn) == true) { ?> |
||
|
0 ignored issues
–
show
|
|||
| 106 | <a href="/unlike.php?id=<?php echo $row['id']; ?>"><img style="vertical-align: middle;" src="/static/witter-like.png"></a> |
||
| 107 | <?php } else { ?> |
||
| 108 | <a href="/like.php?id=<?php echo $row['id']; ?>"><img style="vertical-align: middle;" src="/static/witter-liked.png"></a> |
||
| 109 | <?php } ?> |
||
| 110 | </span> |
||
| 111 | <div id="feedtext"><?php echo parseText($row['contents']); ?> </div> |
||
| 112 | <small id="grey">about <?php echo time_elapsed_string($row['date']); ?> from web |
||
| 113 | <span id="floatRight"> |
||
| 114 | <?php echo getComments($row['realid'], $conn); ?><img style="vertical-align: middle;" src="/static/witter-replies.png"> • <a href="/v.php?rid=<?php echo $row['realid']; ?>">Reply</a> • <a href="/home.php?text=https://witter.spacemy.xyz/embed/?i=<?php echo $row['realid']; ?>">Reweet</a> |
||
| 115 | </span> |
||
| 116 | </small><br> |
||
| 117 | <?php |
||
| 118 | $likes = getLikesReal($row['id'], $conn); |
||
| 119 | while($row = $likes->fetch_assoc()) { |
||
| 120 | ?> |
||
| 121 | <a href="/u.php?n=<?php echo handleTag($row['fromu']); ?>"><img style="width: 30px; height: 30px; margin-left: 2px;" id="pfp" src="/dynamic/pfp/<?php echo getPFPFromUser($row['fromu'], $conn); ?>"></a> |
||
| 122 | <?php } ?> |
||
| 123 | </td> |
||
| 124 | </big></big></big> |
||
| 125 | </tr> |
||
| 126 | </table> |
||
| 127 | </div> |
||
| 128 | <?php require($_SERVER['DOCUMENT_ROOT'] . "/static/footer.php"); ?> |
||
| 129 | </div> |
||
| 130 | </div> |
||
| 131 | </div> |
||
| 132 | </body> |
||
| 133 | </html> |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.