darknet-lantern/www/submit.php
2025-04-13 19:05:59 +01:00

101 lines
3.9 KiB
PHP

<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
session_start();
if (isset($_POST['submit'])){
// Clear user input
$link = htmlspecialchars($_POST['link']);
$name = htmlspecialchars($_POST['name']);
$description = htmlspecialchars($_POST['description']);
$sensitive = htmlspecialchars($_POST['sensitive']);
$category = htmlspecialchars($_POST['category']);
$captcha = htmlspecialchars($_POST['captcha']);
// Captcha Auth check
if ($captcha != htmlspecialchars($_SESSION['secure'])){
echo "Captcha Failed";
}else{
if (empty($link) or empty($name) or empty($description)){
echo "All of the fields must not be empty";
}else{
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";
}else{
// Open the file once before the loop
$file = fopen("../submissions/submission.csv", "a");
if ($file !== false) {
// Create an array with the inputs to write as a single row
$row = [$link, $name,$description,$category,$sensitive];
// Write the row to the CSV file
fputcsv($file, $row, ',', '"');
// Close the file after writing
fclose($file);
} else {
// Handle error opening the file
errorlog("Error opening the file.");
}
header("Location: index.php");
}
}
}
}
?>
<!DOCTYPE html>
<head>
<title>Darknet Lantern</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="twitter:card" content="summary" />
<meta name="description" content="Darknet Lantern is a minimalistic Peer to Peer Decentralised Search Engine for the Darknet, that got officially released on>
<meta property="og:site_name" content="Darknet Lantern" />
<meta property="og:title" content="Darknet Lantern" />
<meta property="og:type" content="website" />
<!-- // Now displays the url of the instance -->
<meta property="og:url" content="<?php echo htmlspecialchars($_SERVER['SERVER_NAME']); ?>" />
<!-- // Default images for previews -->
<meta property="og:image:url" content="<?php echo htmlspecialchars($_SERVER['SERVER_NAME']) . "/img/logo-large.png"; ?>" />
<meta property="og:locale" content="en_US" />
<!-- // This tells search engines which URL should be considered the original source when multiple URLs contain the same content. -->
<link rel="canonical" href="<?php echo htmlspecialchars($_SERVER['SERVER_NAME']); ?>" />
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" href="/img/logo-favicon.png">
</head>
<html>
<?php include("header.php");?>
<div class="width-class">
<center>
<h1>Character Limits</h1>
<p>Link should be 354</p>
<p>Name should be 64</p>
<p>Description should be 256</p>
<p>Category should be 64</p>
<p>Sensitive should be 1</p>
</center>
<form action="submit.php" method="POST">
<label style="color:white">Link</label>
<input required class="input-class" type="text" name="link" placeholder="http://link.com/onion">
<label style="color:white">Name</label>
<input required class="input-class" type="text" name="name">
<label style="color:white">Description</label>
<input required class="input-class" type="text" name="description">
<label style="color:white">Category</label>
<input required class="input-class" type="text" name="category">
<label style="color:white">Sensitive</label>
<input required class="input-class" type="text" name="sensitive" placeholder="y/n">
<label style="color:white">Captcha</label>
<div>
<img src="generate.php">
<input type="text" name="captcha">
<input type="submit" value="submit" name="submit" />
</div>
</form>
</div>
</html>