Merge pull request 'issue 83: submission status is centered in the middle on submission' (#84) from SovereigntyIsNotFreedom/darknet-lantern:main into main

Reviewed-on: http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern/pulls/84
Reviewed-by: Doctor Dev <doctor_dev@noreply.localhost>, @Nihilist
This commit is contained in:
Doctor Dev 2025-06-11 10:33:26 +02:00
commit e60f7f7e78
4 changed files with 40 additions and 27 deletions

View file

@ -203,8 +203,6 @@ function DisplayCategories($instancename, $path) {
?> ?>
</br> </br>
<h1><a href="http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern"><img src="img/lantern project large.png" class="projectbanner"></a></h1> <h1><a href="http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern"><img src="img/lantern project large.png" class="projectbanner"></a></h1>
<p><u>Update Frequency:</u> every 3 hours</p> </br> <p><u>Update Frequency:</u> every 3 hours</p> </br>

View file

@ -23,6 +23,7 @@
<div class="width-class"> <div class="width-class">
<?php <?php
require("header.php"); require("header.php");
$min_length = 1; $min_length = 1;
$max_length = 32; $max_length = 32;
@ -31,12 +32,12 @@ require("header.php");
$verifiedcsvpath="participants/" . $instance . '/verified.csv'; $verifiedcsvpath="participants/" . $instance . '/verified.csv';
$unverifiedcsvpath="participants/" . $instance . '/unverified.csv'; $unverifiedcsvpath="participants/" . $instance . '/unverified.csv';
// check if the verified and unverified csv files have links in them or not: // check if the verified and unverified csv files have links in them or not:
$lines_uv = count(file($unverifiedcsvpath)); $lines_uv = count(file($unverifiedcsvpath));
$lines_v = count(file($verifiedcsvpath)); $lines_v = count(file($verifiedcsvpath));
//echo "<p>CSV LINES: " . $lines_uv . " " . $lines_v . "</p>"; //echo "<p>CSV LINES: " . $lines_uv . " " . $lines_v . "</p>";
?> ?>
<form action="index.php" method="GET"> <form action="index.php" method="GET">
<input type="text" name="query" /> <input type="text" name="query" />
<input type="submit" value="Search" /> </br> <input type="submit" value="Search" /> </br>
@ -99,6 +100,7 @@ require("header.php");
?> ?>
</div> </div>
<center><a href="submit.php">Submit a new link</a></center> <center><a href="submit.php">Submit a new link</a></center>
<?php <?php

View file

@ -325,3 +325,10 @@ img{
}*/ }*/
.submission-status-success{
color: green;
}
.submission-status-error{
color: red;
}

View file

@ -1,9 +1,11 @@
<?php <?php
session_start(); session_start();
$submission_message = null; // Initialize the variable
$status_class = null;
if (isset($_POST['submit'])){ if (isset($_POST['submit'])){
// Link checks // Link checks
$link = str_replace(['<','>'],'', $_POST['link']); $link = str_replace(['<','>'],'', $_POST['link']);
// Clear user input // Clear user input
$link = htmlspecialchars($link); $link = htmlspecialchars($link);
$name = htmlspecialchars($_POST['name']); $name = htmlspecialchars($_POST['name']);
$description = htmlspecialchars($_POST['description']); $description = htmlspecialchars($_POST['description']);
@ -12,33 +14,36 @@ if (isset($_POST['submit'])){
$captcha = htmlspecialchars($_POST['captcha']); $captcha = htmlspecialchars($_POST['captcha']);
// Captcha Auth check // Captcha Auth check
if ($captcha != htmlspecialchars($_SESSION['secure'])){ if ($captcha != htmlspecialchars($_SESSION['secure'])){
echo "Captcha Failed"; $submission_message = "Error: Captcha Failed";
}else{ } else {
if (empty($link) or empty($name) or empty($description)){ if (empty($link) or empty($name) or empty($description)){
echo "All of the fields must not be empty"; $submission_message = "Error: All of the fields must not be empty";
}else{ } else {
if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){
echo "Don't excede the limit"; $submission_message = "Error: Don't exceed the limit";
}else{ } else {
// Open the file once before the loop // Open the file once before the loop
$file = fopen("../submissions/submission.csv", "a"); $file = fopen("../submissions/submission.csv", "a");
if ($file !== false) { if ($file !== false) {
// Create an array with the inputs to write as a single row // Create an array with the inputs to write as a single row
$row = [$link, $name,$description,$category,$sensitive]; $row = [$link, $name,$description,$category,$sensitive];
// Write the row to the CSV file // Write the row to the CSV file
fputcsv($file, $row, ',', '"'); fputcsv($file, $row, ',', '"');
// Close the file after writing // Close the file after writing
fclose($file); fclose($file);
} else { } else {
// Handle error opening the file // Handle error opening the file
error_log("Error opening the file."); error_log("Error opening the file.");
} }
echo "Link Successfully Submitted";
} if ($submission_message === null) { // Only set success message if no error occurred
$submission_message = "Link Successfully Submitted";
}
}
} }
} }
} }
@ -68,6 +73,7 @@ if (isset($_POST['submit'])){
<html> <html>
<?php include("header.php");?> <?php include("header.php");?>
<div class="width-class"> <div class="width-class">
<h3 class="<?php echo str_contains($submission_message, 'Error') ? 'submission-status-error' : 'submission-status-success' ?>"> <?php echo $submission_message ?> </h3>
<center> <center>
<h1>Character Limits</h1> <h1>Character Limits</h1>
<p>Link should be 354</p> <p>Link should be 354</p>
@ -90,7 +96,7 @@ if (isset($_POST['submit'])){
<label style="color:white">Captcha</label> <label style="color:white">Captcha</label>
<div> <div>
<img src="generate.php"> <img src="generate.php">
<input type="text" name="captcha"> <input required type="text" name="captcha">
<input type="submit" value="submit" name="submit" /> <input type="submit" value="submit" name="submit" />
</div> </div>
</form> </form>