Suggested fixes are applied

This commit is contained in:
SovereigntyIsNotFreedom 2025-04-13 19:05:59 +01:00
parent 4837034ec3
commit e21455540e
4 changed files with 39 additions and 34 deletions

View file

@ -182,7 +182,7 @@ Maintenance:
0) Exit
""")
option = input("Select an option? (0-10): ").strip()
option = input("Select an option? (0-11): ").strip()
try:
option = int(option)
except ValueError:
@ -1199,8 +1199,6 @@ Maintenance:
break
case 11:
category = "EXTERNAL USER"
sensitive = "YES"
try:
print_colors("1) Move entries to verified 2) Move entries from submission to unverified 3) Delete from submission file 0) exit")
option = int(input("Enter an option: "))
@ -1214,9 +1212,11 @@ Maintenance:
print_colors(submission_df)
indx = int(input("Which index do you want to add? "))
link = submission_df.iloc[indx]['link']
name = submission_df.iloc[indx]['name']
desc = submission_df.iloc[indx]['desc']
link = submission_df.iloc[indx]['link'].strip()
name = submission_df.iloc[indx]['name'].strip()
desc = submission_df.iloc[indx]['desc'].strip()
category = submission_df.iloc[indx]['category'].strip()
sensitive = "YES" if submission_df.iloc[indx]['sensitive'].strip() == 'y' else "NO"
new_row = pd.DataFrame({'Instance': [instance], 'Category': [category], 'Name':[name],'URL':[link],'Sensitive':[sensitive],'Description':[desc],'Status':['YES'],'Score':['100']})
@ -1229,9 +1229,11 @@ Maintenance:
print_colors(submission_df)
indx = int(input("Which index do you want to add? "))
link = submission_df.iloc[indx]['link']
name = submission_df.iloc[indx]['name']
desc = submission_df.iloc[indx]['desc']
link = submission_df.iloc[indx]['link'].strip()
name = submission_df.iloc[indx]['name'].strip()
desc = submission_df.iloc[indx]['desc'].strip()
category = submission_df.iloc[indx]['category'].strip()
sensitive = "YES" if submission_df.iloc[indx]['sensitive'].strip() == 'y' else "NO"
new_row = pd.DataFrame({'Instance': [instance], 'Category': [category], 'Name':[name],'URL':[link],'Sensitive':[sensitive],'Description':[desc],'Status':['YES'],'Score':['100']})
@ -1250,8 +1252,8 @@ Maintenance:
case 0:
break
except:
print_colors('Try again',is_error=True)
except Exception as e:
print_colors(f'Try again {e}',is_error=True)
break
break
case 0:

View file

@ -1,2 +1,3 @@
,link,name,desc
0,daskd.com,myname,dasjklj
link,name,desc,category,sensitive
,,
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion,"Nihilist Git repo","GIt repo","Git Repo",n

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -1,18 +1,3 @@
<?php
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
?>
<!DOCTYPE html>
<html>
<head>

View file

@ -1,4 +1,8 @@
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
session_start();
if (isset($_POST['submit'])){
@ -6,6 +10,8 @@ if (isset($_POST['submit'])){
$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'])){
@ -14,18 +20,16 @@ if (isset($_POST['submit'])){
if (empty($link) or empty($name) or empty($description)){
echo "All of the fields must not be empty";
}else{
// Clearing unusual characters in all the fields
$clear_link = str_replace(['@','*','(',') ',';','#'],'',$link);
$clear_name = str_replace(['@','.',',','(',')','#',';'],'',$name);
$clear_description = str_replace(['@',';'], '', $description);
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 = [$clear_link, $clear_name,$clear_description];
$row = [$link, $name,$description,$category,$sensitive];
// Write the row to the CSV file
fputcsv($file, $row, ',', '"');
@ -39,6 +43,7 @@ if (isset($_POST['submit'])){
header("Location: index.php");
}
}
}
}
?>
@ -66,6 +71,14 @@ if (isset($_POST['submit'])){
<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">
@ -73,6 +86,10 @@ if (isset($_POST['submit'])){
<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">