darknet-lantern/www/header.php
2025-05-10 16:24:14 +02:00

211 lines
7.4 KiB
PHP

<?php
function DisplayCSVNEW($csvfile, $query, $sensitive) {
$resultcount=0;
$row = 1;
$rowcount=0;
echo "<center><table>\n\n"; //begin html table formatting
if (($handle = fopen($csvfile, "r")) !== FALSE) {
$oldcatname="";
while (($data = fgetcsv($handle, 1000, ",",'"','\\')) !== FALSE) {
//PREVENT ALL MALICIOUS PHP PAYLOADS FROM BEING EXECUTED FROM CSV FILES!
for ($i = 0; $i < count($data); $i++) {
$data[$i] = htmlspecialchars($data[$i]);
$data[$i] = preg_replace("/[^a-zA-Z0-9:\/.\ -✔️❌]/", "", $data[$i]);
}
$row++;
$num = count($data);
//echo "<p>" . $data[1] . "</p>";
//echo "<p> $num fields in line $row: <br /></p>\n";
//echo $row;
if ( $row == "2") {
echo "<tr><td>Category</td> <td>Name</td> <td>Description</td> <td>Score</td> <td></td></tr>";
}else{
if (str_contains(strtolower($data[5]), strtolower($query)) or str_contains(strtolower($data[3]), strtolower($query)) or str_contains(strtolower($data[2]), strtolower($query)) or str_contains(strtolower($data[1]), strtolower($query))) {
$resultcount++;
for ($c=0; $c < $num; $c++) { // iterate over each row
if ($data[7] == 0.0){
continue;
}else{
echo "<tr>"; // begin html table row for that Category
// if the row is the first one (name url status score) only display (Name Status Score):
// display the contents of a csv row
if ( $c == "1" ){
//add http if its not already done in the URL
if (!preg_match("~^(?:f|ht)tps?://~i", $data[3])) {
$urllink = "http://" . $data[3];
}else{
$urllink = $data[3];
}
//if ((($sensitive == 1) and ($data[4] == "✔️")) or (($sensitive == 0) and ($data[4] != "✔️")) ){
// ONLY display links if (sensitive equals to 1 and sensitiveCOLUMN equals to V) OR (sensitive equals to 0 and sensitiveCOLUMN is NOT equal to V)
if (($data[4] != "YES") or (($sensitive == 1) and ($data[4] == "YES"))){
$rowcount++;
if (strtolower($oldcatname) != strtolower($data[1])){
//echo "<td><tr></tr><tr></tr><tr></tr></td>"; // skip a row if new category
//echo "<td><tr></tr><tr></tr><tr></tr></td>"; // skip a row if new category
echo '<td class="category"><p><h4>' . $data[1] . ' </h4></p></td>'; // display the category as its the first row with this new category
$oldcatname=$data[1];
}else{
echo "<td><p>" . ' </p></td>'; // category is already displayed so skip it (empty cell in category column)
}
echo '<td class="linktitle"><p class="linktitle">' ; // begin the table cell of link title
if(str_contains(strtolower($data[1]),'monero' )){
echo '<a class="xmr" href="'; // begin a href
}elseif(str_contains(strtolower($data[1]),'simplex' )){
echo '<a class="sxc" href="'; // begin a href
}elseif($data[4] == "YES"){
echo '<a class="sensitivelink" href="'; // begin a href
}else{
echo '<a href="'; // begin a href
}
//echo $data[3] . '"> '; // display the link
echo htmlspecialchars_decode($urllink ) . '"> '; // display the link
echo $data[2] . ' </a></p></td><td class="description">'; // display the link title and close the a href and first cell, open the second cell
echo $data[5] . " </td><td>"; // OPTIONAL: display the description column
echo $data[7] . " </td><td>"; // display the score and close the second cell, open the third cell
if($data[6] == "YES"){
echo "✔️" ;
}else{
echo "" ;
}
echo " </td> \n"; // display the status and close the third cell
}
//if ($c == 2){
//}
}
}
}
}
echo "</tr>"; // end html table row
}}
echo "\n</table></center>";
fclose($handle);
}
echo "<center><p>" . $rowcount . " Result(s) found.</p></center>";
}
// strtolower({key}) -> logo = /img/{value}
$logomap = array(
"archive" => "archive.webp",
"collaboration" => "collaboration.webp",
"communities" => "community.webp",
"community" => "community.webp",
"exchanges" => "haveno.webp",
"fediverse" => "fediverse.webp",
"forum" => "dread.webp",
"forums" => "dread.webp",
"indexes" => "index.webp",
"infos and indexes" => "info.webp",
"libraries" => "library.webp",
"mail" => "clawsmail.webp",
"markets" => "market.webp",
"monero node" => "monero.webp",
"news" => "news.webp",
"password generator" => "passwordgen.webp",
"pastebins" => "pastebins.webp",
"privacy front-ends" => "opensource.webp",
"radios" => "radio.webp",
"sms" => "sms.webp",
"search engine" => "searxng.svg",
"simplex chatrooms" => "simplex.webp",
"social" => "social.webp",
"tools" => "tools.webp",
"torrents" => "torrents.webp",
"translation" => "translation.webp",
"vpns" => "openvpn.webp",
"vps" => "linux.webp",
);
$classmap = array(
"monero node" => "xmr",
"simplex chatrooms" => "sxc",
);
function DisplayCategories($instancename, $path) {
global $logomap, $classmap;
$resultcount = 0;
$row = 1;
//echo $instancename;
//$csvfilenames = "verified.csv unverified.csv";
$csvfilenames = "verified.csv";
$csvfilenames = explode(' ', $csvfilenames);
foreach ($csvfilenames as $csvfilename) {
//echo $csvfilename;
$csvfile = $path . $csvfilename;
//echo $csvfile;
//echo "test";
echo "<center><table>\n\n"; //begin html table formatting
if (($handle = fopen($csvfile, "r")) !== FALSE) {
$oldcatname = "";
while (($data = fgetcsv($handle, 1000, ",",'"','\\')) !== FALSE) {
$num = count($data);
$row++;
if ( $row == "2") {
echo '<p> ';
continue;
}
//PREVENT ALL MALICIOUS PHP PAYLOADS FROM BEING EXECUTED FROM CSV FILES!
for ($i = 0; $i < count($data); $i++) {
$data[$i] = htmlspecialchars($data[$i]);
$data[$i] = preg_replace("/[^a-zA-Z0-9:\/.\ -]/", "", $data[$i]);
}
$resultcount++;
if (strtolower($oldcatname) != strtolower($data[1])){
echo '<a class="cata ' . ($classmap[strtolower($data[1])] ?? '') . '" href="index.php?query=' . $data[1] . '">' . '<img class="caticon" src="img/' . ($logomap[strtolower($data[1])] ?? 'empty.png') . '"></img>'. $data[1] . '</a> ';
$oldcatname = strtolower($data[1]);
}
}
echo '<a class="cata sensitivelink" href="index.php?query=.&sensitive=1"><img class="caticon" src="img/showall.webp"></img>Display All Links</a></p>';
fclose($handle);
}
}
}
$min_length = 1;
$max_length = 32;
$instance= $_SERVER['SERVER_NAME'];
$participantpath="participants/" . $instance . '/';
$verifiedcsvpath="participants/" . $instance . '/verified.csv';
$unverifiedcsvpath="participants/" . $instance . '/unverified.csv';
DisplayCategories($instance, $participantpath);
?>
</br>
<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>