Jump to content

oz11

Members
  • Posts

    169
  • Joined

  • Last visited

Everything posted by oz11

  1. I use PDO so not sure if this is a good idea. Anyway, maybe it won't hurt? if (str_contains($_GET['q'], 'SELECT')) { exit(); } if (str_contains($_GET['q'], 'UPDATE')) { exit(); } if (str_contains($_GET['q'], 'DELETE')) { exit(); } if (str_contains($_GET['q'], '||')) { exit(); } if (str_contains($_GET['q'], 'WHERE')) { exit(); } if (str_contains($_GET['q'], 'SLEEP')) { exit(); } if (str_contains($_GET['q'], 'DROP')) { exit(); } if (str_contains($_GET['q'], 'FROM users')) { exit(); } if (str_contains($_GET['q'], 'FROM links')) { exit(); } if (str_contains($_GET['q'], '1=1')) { exit(); } if (str_contains($_GET['q'], '1 = 1')) { exit(); } Pontless?
  2. Code in all it's glory. I will leave it here.. <?php if ($_GET["nsfw_options"] == "true") { $sfw = 1; setcookie("nsfw", "true"); $_COOKIE["nsfw"] = "true"; } if ($_GET["nsfw_options"] == "false") { $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } if (!isset($_COOKIE["nsfw"])) { $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } ?> NSFW Filter: <?php if ($_COOKIE["nsfw"] == "true") { ?> <select name="nsfw_options" id="nsfw_options"> <option disabled selected value> -- select -- </option> <option value="false">Disable</option> <option value="true">Enable</option> </select> <small>[Currently enabled]</small> <?php } elseif ($_COOKIE["nsfw"] == "false") { ?> <select name="nsfw_options" id="nsfw_options"> <option disabled selected value> -- select -- </option> <option value="true">Enable</option> <option value="false">Disable</option> </select> <small>[Currently disabled]</small> <?php } else { ?> <select name="nsfw_options" id="nsfw_options"> <option disabled selected value> -- select -- </option> <option value="true">Enable</option> <option value="false">Disable</option> </select> <small>[Currently enabled]</small> <?php } ?> Messy but ok. or a change of markup. (v2).. <?php if ($_GET["nsfw_options"] == "true") { $sfw = 1; setcookie("nsfw", "true"); $_COOKIE["nsfw"] = "true"; } if ($_GET["nsfw_options"] == "false") { $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } if (!isset($_COOKIE["nsfw"])) { $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } ?> NSFW Filter: <?php if ($_COOKIE["nsfw"] == "true") { ?> <select name="nsfw_options" id="nsfw_options"> <option disabled selected value>[Currently enabled]</option> <option value="false">Disable</option> <option value="true">Enable</option> </select> <?php } elseif ($_COOKIE["nsfw"] == "false") { ?> <select name="nsfw_options" id="nsfw_options"> <option disabled selected value>[Currently disabled]</option> <option value="true">Enable</option> <option value="false">Disable</option> </select> <?php } else { ?> <select name="nsfw_options" id="nsfw_options"> <option disabled selected value>[Currently disabled]</option> <option value="true">Enable</option> <option value="false">Disable</option> </select> <?php } ?>
  3. Ah. forgot to clean my cookies. Seems to work okay. Thanks for being here guys, helps alot!
  4. <?php if($_GET['nsfw_options'] == "true"){ $sfw = 1; setcookie("nsfw", "true"); $_COOKIE["nsfw"] = "true"; } if($_GET['nsfw_options'] == "false"){ $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } if(!isset( $_COOKIE["nsfw"])){ $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } ?> NSFW Filter: <?php if($_COOKIE["nsfw"] == "true"){ ?> <select name="nsfw_options" id="nsfw_options"> <option value="true">Enable</option> <option value="false">Disable</option> </select> Enabled <?php } elseif($_COOKIE["nsfw"] == "false") { ?> <select name="nsfw_options" id="nsfw_options"> <option value="true">Enable</option> <option value="false">Disable</option> </select> Disabled <?php } else { ?> <select name="nsfw_options" id="nsfw_options"> <option value="true">Enable</option> <option value="false">Disable</option> </select> Disabled <?php } ?> I meddled around with it but when navigating from the page and back again it goes from enabled to disabled. Helpz.
  5. Thanks. Is there a workaround? Ps: Glad you said that, I thought I was ging mad (again).
  6. <?php if($_GET['sfw'] == "true"){ $sfw = 1; setcookie("nsfw", "true"); $_COOKIE["nsfw"] = "true"; } if($_GET['sfw'] == "false"){ $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } if(!isset( $_COOKIE["nsfw"])){ $sfw = 0; setcookie("nsfw", "false"); $_COOKIE["nsfw"] = "false"; } ?> <?php if($_COOKIE["nsfw"] == "true"){ ?> <input type="checkbox" id="sfw" name="sfw" value="false" checked="checked">Filter NSFW? <?php } elseif($_COOKIE["nsfw"] == "false") { ?> <input type="checkbox" id="sfw" name="sfw" value="true" >Filter NSFW? <?php } else { ?> <input type="checkbox" id="sfw" name="sfw" value="true" >Filter NSFW? <?php } What am I doing wrong freaks? Can you spot anything? Ta. ps: it turns on and off but not on again.. Edit: i mean it turns on bt not off
  7. oz11

    "New posts"

    Ooops. Fixed .,Thanks guys again!
  8. oz11

    "New posts"

    Ended up doing this which worked... //$day = date('Y-m-d', $row['date']); $day = date('Y-m-d', strtotime($row['date'])); if($day < date('Y-m-d', strtotime('-2 weeks'))){ } ELSE { echo "<img src='ttps://i.imgur.com/0rlIlUD.gif'>"; } abit of a workaround but ok for me. Thanks guys!
  9. oz11

    "New posts"

    Still shows on the reverse but not the other way round hmm. (showing on all the old ones but not the new ones)
  10. oz11

    "New posts"

    Still not fixed it . You would think flipping it would work as it sorta did before, but opposite. all t he ones that shouldn't be "new" were new and all the other actual "new" posts were not showing.. weird. Never come across anything like it.
  11. oz11

    "New posts"

    oops. its abit longer "2022-11-22 16:03:32" (take two)
  12. oz11

    "New posts"

    The date of the post, eg (a real example) of "2022-11-22" update : "2022-11-22 16:03:32" not just "2022-11-22"
  13. I wrote this.. $now = strtotime('now'); $now = date('Y-m-d', $now); $day = date('Y-m-d', strtotime($row['date'] . ' + 2 weeks')); if($day < $now){ echo "<img src='https://i.imgur.com/0rlIlUD.gif'>"; } It should show a "new" gif image on new posts.. however, they only show on posts that are not new. I tried flipping the "<" to ">" but doesn't work.... not sure what to do. So simple but get can't grasp the conditional . Help Internet freaks.
  14. Hey, I'm having trouble here... how do i modify this code so that the following element is displayed ahead of each "word" in the output..[see bellow]. Also is there a way to count the number of times the occurrences take place (1,2,3 etc). Help. $str = "Yogurt (Milk), Strawberries (11%), Sugar, Water, Stabilisers: Pectins, Guar Gum, Flavourings, Acidity Regulator: Citric Acid, Yogurt (Milk), Peach (9%), Sugar, Water, Apricot (3%), Stabilisers: Pectins, Guar Gum, Acidity Regulator: Citric Acid, Flavourings"; $new_str = array_unique(array_map('trim', explode(',', $str))); $string = implode(',', $new_str); echo $string;
  15. Fixed code: <?php include 'config.php'; $stmt = $pdo->prepare("SELECT count(*) FROM news WHERE reference=?"); $stmt->execute([$_GET['ref']]); $check_exist = $stmt->fetchColumn(); if($check_exist == 0){ echo "error not found"; exit(); } $user_ip=$_SERVER['REMOTE_ADDR']; $stmt = $pdo->prepare("SELECT count(*) FROM outgoing_count WHERE IP = ? AND news_reff = ?"); $stmt->execute([$user_ip, $_GET['ref']]); $count = $stmt->fetchColumn(); if($count == 0){ $sql = "INSERT INTO outgoing_count (IP, news_reff) VALUES (?,?)"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_ip, $_GET['ref']]); $stmt = $pdo->prepare("SELECT count(*) FROM outgoing_count WHERE news_reff = ?"); $stmt->execute([ $_GET['ref']]); $count2 = $stmt->fetchColumn(); echo "Redirect. This page has been viewed ".$count2."times"; } else { $stmt = $pdo->prepare("SELECT count(*) FROM outgoing_count WHERE news_reff = ?"); $stmt->execute([$_GET['ref']]); $count3 = $stmt->fetchColumn(); echo "Redirect. This page has been viewed ".$count3."times"; //header('Location: http://google.com'); } ?> .. just needed time.
  16. Updated the code a bit... still doesn't work.. <?php include 'config.php'; $stmt = $pdo->prepare("SELECT count(*) FROM news WHERE reference=?"); $stmt->execute([$_GET['ref']]); $check_exist = $stmt->fetchColumn(); if($check_exist == 0){ echo "error not found"; exit(); } $user_ip=$_SERVER['REMOTE_ADDR']; $stmt = $pdo->prepare("SELECT count(*) FROM outgoing_count WHERE IP = ? AND news_reff = ?"); $stmt->execute([$user_ip, $_GET['ref']]); $count = $stmt->fetchColumn(); if($count == 0){ $sql = "INSERT INTO outgoing_count (IP, news_reff) VALUES (?,?)"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_ip, $_GET['ref']]); } else { echo "Redirect. This page has been viewed ".$count."times"; //header('Location: http://google.com'); } ?>
  17. Well.. basically just wrote this. But want it to be forwarded to a page if it's complete... However, it only loads the final conditional if the page is refreshed a second time.. Help, please. Code: <?php include 'config.php'; $user_ip=$_SERVER['REMOTE_ADDR']; $news_ref = $_GET['ref']; $stmt = $pdo->prepare("SELECT count(*) FROM outgoing_count WHERE IP = ? AND news_reff = ?"); $stmt->execute([$user_ip, $news_ref ]); $count = $stmt->fetchColumn(); if($count == 0){ $sql = "INSERT INTO outgoing_count (IP, news_reff) VALUES (?,?)"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_ip, $news_ref ]); } else { $stmt = $pdo->prepare("SELECT count(*) FROM news WHERE reference=?"); $stmt->execute([$_GET['ref']]); $check_exist = $stmt->fetchColumn(); if($check_exist == 0){ echo "404 Error: not found"; } else { echo "Redirect. This page has been viewed ".$count."times"; // <--- ONLY SHOWS ON SECOND REFRESH..??... //header('Location: http://google.com'); } } ?>
  18. I found this... https://www.rgraph.net/canvas/reference/todataurl.html#:~:text=The toDataURL function returns a,save it to a file. which looks great. Don't know how to amend them together yet, both the codes.. help..? Could someone splice them for me.. ? This also looks handy: $dataURL = $_POST["imageDataURL"]; $dataURL = str_replace('data:image/png;base64,', '', $dataURL); $dataURL = str_replace(' ', '+', $dataURL); $image = base64_decode($dataURL); $filename = 'newImage.png'; file_put_contents('path/to/' . $filename, $image); But how do the pieces fit together..?
  19. How would I go about using the script bellow to save the updated image to serverside using PHP <html> <script type="text/javascript"> var canvas, ctx, flag = false, prevX = 0, currX = 0, prevY = 0, currY = 0, dot_flag = false; var x = "black", y = 2; var saveTimer; function onSaveTimer() { save(); } function init() { canvas = document.getElementById('can'); ctx = canvas.getContext("2d"); w = canvas.width; h = canvas.height; canvas.addEventListener("mousemove", function (e) { findxy('move', e) }, false); canvas.addEventListener("mousedown", function (e) { findxy('down', e) }, false); canvas.addEventListener("mouseup", function (e) { findxy('up', e) }, false); canvas.addEventListener("mouseout", function (e) { findxy('out', e) }, false); saveTimer = setInterval(onSaveTimer, 3000); } function color(obj) { switch (obj.id) { case "black": x = "black"; break; case "white": x = "white"; break; } if (x == "white") y = 14; else y = 2; } function draw() { ctx.beginPath(); ctx.moveTo(prevX, prevY); ctx.lineTo(currX, currY); ctx.strokeStyle = x; ctx.lineWidth = y; ctx.stroke(); ctx.closePath(); } function erase() { var m = confirm("Want to clear"); if (m) { ctx.clearRect(0, 0, w, h); document.getElementById("canvasimg").style.display = "none"; } } function save() { document.getElementById("canvasimg").style.border = "2px solid"; var dataURL = canvas.toDataURL(); if (dataURL) { document.getElementById("canvasimg").src = dataURL; document.getElementById("canvasimg").style.display = "inline"; return true; // will POST form to the server } return false; // will not POST to server } function findxy(res, e) { if (res == 'down') { prevX = currX; prevY = currY; currX = e.clientX - canvas.offsetLeft; currY = e.clientY - canvas.offsetTop; flag = true; dot_flag = true; if (dot_flag) { ctx.beginPath(); ctx.fillStyle = x; ctx.fillRect(currX, currY, 2, 2); ctx.closePath(); dot_flag = false; } } if (res == 'up' || res == "out") { flag = false; } if (res == 'move') { if (flag) { prevX = currX; prevY = currY; currX = e.clientX - canvas.offsetLeft; currY = e.clientY - canvas.offsetTop; draw(); } } } </script> <body onload="init()"> <canvas id="can" width="500px" height="150px" style="position:absolute;border:2px solid;"></canvas> <div style="position:relative;top:30px;left:520px;">Eraser</div> <div style="position:relative;top:40px;left:520px;width:15px;height:15px;background:white;border:2px solid;" id="white" onclick="color(this)"></div> <div style="position:relative;top:70px;left:520px;width:15px;height:15px;background:black;border:2px solid;" id="black" onclick="color(this)"></div> <div style="position:relative;top:30px;left:520px;">Pen</div> <form method="POST" action="" onsubmit="save"> <img id="canvasimg" style="position:relative;top:10%;left:600px;" style="display:none;"> </form> <!--<input type="button" value="save" id="btn" size="30" onclick="save()" style="position:fixed;top:170px;left:10px;">--> <!-- <input type="button" value="clear" id="clr" size="23" onclick="erase()" style="position:fixed;top:170px;left:60px;">--> </body> </html> I was thinking something along the lines of POST in PHP..?.. no?.. Screenie for illustration:
  20. Nope. It's just a querk of the DB. The table name is actually known as "cooment_anon" correctly.
  21. Basically a boolean value in the DB says if the anonymous checkbox has been set to be checked by default. A typo of comment_anon, but stuck with it lol.
  22. Remo Removing the echo statements still doest work. In honesty it should still assign the values even if I did echo them as well.
  23. Update: oops was using ... } elseif($anon_comment == "2" ) { ..instead of == 0. Tho still does not work on the second box (from line 151). Still a problem. Not showing anything in fact, using the conditional.
  24. By not working i mean that the code is not functioning on one of the examples while on the other it is. The code is very similar and don't see why it shouldn't work on both... help me.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.