fixed the template files + added checks if your verified and unverifiedcsv files are empty

This commit is contained in:
root 2025-01-26 18:01:31 +01:00
parent e76297de64
commit b478a64614
29 changed files with 66 additions and 202 deletions

View file

@ -14,6 +14,18 @@
<?php
require("header.php");
$min_length = 1;
$max_length = 32;
$instance= $_SERVER['SERVER_NAME'];
$participantpath="participants/" . $instance . '/';
$verifiedcsvpath="participants/" . $instance . '/verified.csv';
$unverifiedcsvpath="participants/" . $instance . '/unverified.csv';
// check if the verified and unverified csv files have links in them or not:
$lines_uv = count(file($unverifiedcsvpath));
$lines_v = count(file($verifiedcsvpath));
//echo "<p>CSV LINES: " . $lines_uv . " " . $lines_v . "</p>";
?>
<form action="index.php" method="GET">
@ -35,18 +47,16 @@ require("header.php");
$query = $_GET['query'];
// gets value sent over search form
$min_length = 1;
$max_length = 32;
$instance= $_SERVER['SERVER_NAME'];
$participantpath="participants/" . $instance . '/';
$verifiedcsvpath="participants/" . $instance . '/verified.csv';
$unverifiedcsvpath="participants/" . $instance . '/unverified.csv';
if(strlen($query) >= $min_length and strlen($query) <= $max_length){ // if query length is more or equal minimum length then
$query = htmlspecialchars($query);
// removes the risky characters
// there needs to be regex checking, only allow [a-zA-Z0-9.:/]
$query=preg_replace("/[^a-zA-Z0-9:\/.\ ]/", "", $query);
echo "<p>Search results for " . $query . " :</p>";
echo nl2br("\n");
@ -54,12 +64,20 @@ require("header.php");
//echo $verifiedcsvpath;
//echo nl2br("\n");
//echo $unverifiedcsvpath;
echo '<div class="verified"><h3>Verified Links</h3></br></div>';
echo nl2br("\n");
DisplayCSVNEW($verifiedcsvpath,$query,$sensitive);
echo '</br></br></br><div class="unverified"><h3>Unverified Links</h3></br></div>';
echo nl2br("\n");
DisplayCSVNEW($unverifiedcsvpath,$query,$sensitive);
if ($lines_v >= 2){
echo '<div class="verified"><h3>Verified Links</h3></br></div>';
echo nl2br("\n");
DisplayCSVNEW($verifiedcsvpath,$query,$sensitive);
}else{
echo "<p>Your verified.csv file is empty, check the documentation to know how to add links into it.</p>";
}
if ($lines_uv >= 2){
echo '</br></br></br><div class="unverified"><h3>Unverified Links</h3></br></div>';
echo nl2br("\n");
DisplayCSVNEW($unverifiedcsvpath,$query,$sensitive);
}else{
echo "<p>Your unverified.csv file is empty, please check the documentation to know how to add links into it.</p>";
}
// display the results of verified.csv
// only display the results of verified.csv that matches with the search term
// display the results of unverified.csv