211 lines
6.8 KiB
PHP
211 lines
6.8 KiB
PHP
|
<html>
|
||
|
<head>
|
||
|
<body>
|
||
|
|
||
|
<?php
|
||
|
|
||
|
// Session starten
|
||
|
session_start();
|
||
|
|
||
|
// Rate-Limiting - maximal 1 Anfrage alle 2 Sekunden
|
||
|
$rate_limit_seconds = 0.03;
|
||
|
if (isset($_SESSION['last_request_time'])) {
|
||
|
$time_since_last_request = time() - $_SESSION['last_request_time'];
|
||
|
|
||
|
// Wenn weniger als $rate_limit_seconds Sekunden vergangen sind, Anfrage blockieren
|
||
|
if ($time_since_last_request < $rate_limit_seconds) {
|
||
|
die("Too many request at a time - please click again on the item you want to open !");
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Den aktuellen Zeitstempel speichern
|
||
|
$_SESSION['last_request_time'] = time();
|
||
|
|
||
|
|
||
|
|
||
|
include_once 'Parsedown.php';
|
||
|
$Parsedown = new Parsedown();
|
||
|
|
||
|
$file_id = $_POST["file_id"];
|
||
|
$file_size_in_mb = $_POST["file_size_in_mb"];
|
||
|
|
||
|
|
||
|
if (str_contains($file_id, 'vide')) {
|
||
|
echo "
|
||
|
<div id='startAnnounce'>
|
||
|
<p>
|
||
|
<strong> Index </strong> <br>
|
||
|
this a index of all pl4tform archives. <br>
|
||
|
You can browse trought it by scrolling, searching, filtering. <br> <br>
|
||
|
If you are looking for a more visual way to explore the pl4tform-archive <a onclick=\"openMap('carto5');audioPlay('https://pl4tform.org/ncdata/241123_1400_jingle_slugg.wav','Bienvenue')\">click here</a> !
|
||
|
</p>
|
||
|
<div id='selectafile' onclick='closeMobileFocusItemIndex()'>select a file or filter to start browsing the archive ==></div>
|
||
|
</div>";
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
|
||
|
|
||
|
|
||
|
include 'nc-one-file-request.php';
|
||
|
|
||
|
|
||
|
$file_info = getFileInfo($file_id);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// Überprüfen, ob die Datei existiert und Daten abgerufen wurden
|
||
|
if ($file_info !== null) {
|
||
|
// Zuweisung der Werte aus dem Array in eigene Variablen
|
||
|
$file_id = $file_info['file_id'];
|
||
|
$file_name = $file_info['file_name'];
|
||
|
$file_name = htmlentities($file_name);
|
||
|
$file_size = $file_info['file_size'];
|
||
|
$mimetype_name = $file_info['mimetype_name'];
|
||
|
$file_tags = $file_info['file_tags'];
|
||
|
$file_year = $file_info['file_year'];
|
||
|
$file_month = $file_info['file_month'];
|
||
|
$file_day = $file_info['file_day'];
|
||
|
$file_hour = $file_info['file_hour'];
|
||
|
$file_minute = $file_info['file_minute'];
|
||
|
$file_title = $file_info['file_title'];
|
||
|
$file_title = htmlentities($file_title);
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
$file_path_root = '/var/www/nextcloud/data/radio_admin/files/archive/'.$file_name;
|
||
|
$file_link = 'https://pl4tform.org/ncdata/'.$file_name;
|
||
|
$file_content = file_get_contents($file_path_root);
|
||
|
$file_content = str_replace(".attachments.", "/ncdata/.attachments.", $file_content);
|
||
|
// echo $Parsedown->text($file_content);
|
||
|
|
||
|
|
||
|
|
||
|
if (str_contains($mimetype_name, 'image')) {
|
||
|
|
||
|
echo "<img class='' id='focusItemIndexImage' src='$file_link' alt='' >";
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
if (str_contains($mimetype_name, 'audio')) {
|
||
|
|
||
|
|
||
|
// $item = $SoundPlayItem;
|
||
|
include('soundfile_titleAnalyse.php');
|
||
|
|
||
|
if(str_contains($file_title, "---")) {
|
||
|
$file_title = str_replace("---", "<br>", $file_title);
|
||
|
};
|
||
|
|
||
|
|
||
|
$soundInfosFormat = "<div class='soundTitle'><h1>$file_title</h1></div> $file_day.$file_month.$file_year - $file_hour:$file_minute H<br>";
|
||
|
echo '<div class="soundDiscriptionTitle">' . $soundInfosFormat . '</div> ';
|
||
|
|
||
|
|
||
|
|
||
|
$soundPlayLink = 'https://pl4tform.org/ncdata/'.$file_name;
|
||
|
// $soundPlayLink = htmlentities($soundPlayLink);
|
||
|
echo '<button id="test1312" class="soundItemBtn soundPlayBtn" onclick=\'audioPlay("'.$soundPlayLink.'","'.$file_title.'");\'>> PLAY</button> ';
|
||
|
// echo '<button id="test1312" class="soundItemBtn soundPlayBtn" onclick=\'audioPlay("'.$file_id.'");\'>> PLAY</button> '; =====>>> try to load audio by ID but java-maridb-request and php quest ... !
|
||
|
echo '<div class="downloadLink"> <a href="'. $soundPlayLink .'" download="'. $file_name .'"><i class="fa fa-download"></i> Download .MP3 </a></div>';
|
||
|
|
||
|
|
||
|
echo '<div class="soundDiscriptionText">';
|
||
|
|
||
|
// $discriptionItemPath = $filesPath.$itemBeforeAt.'.md';
|
||
|
// include ("$discriptionItemPath");
|
||
|
|
||
|
#### discription file:
|
||
|
|
||
|
// Datenbankverbindungsdaten
|
||
|
$servername = "localhost"; // oder der Hostname deines DB-Servers
|
||
|
$username = "***"; // Dein neuer MariaDB Benutzername
|
||
|
$password = "***"; // Dein Passwort für den neuen Benutzer
|
||
|
$dbname = "nextcloud"; // Der Name deiner Nextcloud-Datenbank
|
||
|
|
||
|
// Verbindung zur MySQL-Datenbank aufbauen
|
||
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
||
|
|
||
|
// Verbindung prüfen
|
||
|
if ($conn->connect_error) {
|
||
|
die("Verbindung fehlgeschlagen: " . $conn->connect_error);
|
||
|
}
|
||
|
|
||
|
// 1. Abfrage: Alle Dateien, deren Pfad '%files/archive/%' enthält
|
||
|
$sql1_desc = "SELECT fc.fileid, fc.name AS file_name, fc.path AS file_path, fc.size, fc.mimetype
|
||
|
FROM oc_filecache AS fc
|
||
|
WHERE (fc.path LIKE '%files/archive/%" . $file_year . $file_month . $file_day . "%" . $file_hour . $file_minute . "%.md%'
|
||
|
OR fc.path LIKE '%files/archive/%" . $file_year . $file_month . $file_day . "%" . $file_hour . $file_minute . "%.txt%')
|
||
|
ORDER BY fc.name DESC";
|
||
|
|
||
|
$result1_desc = $conn->query($sql1_desc);
|
||
|
$row_desc = $result1_desc->fetch_assoc();
|
||
|
$file_id_desc = $row_desc['fileid'];
|
||
|
$file_name_desc = $row_desc['file_name'];
|
||
|
|
||
|
// echo $file_name_desc;
|
||
|
|
||
|
|
||
|
if (str_contains($file_name_desc,".md")) {
|
||
|
$file_path_root_desc = '/var/www/nextcloud/data/radio_admin/files/archive/'.$file_name_desc;
|
||
|
$file_content_desc = file_get_contents($file_path_root_desc);
|
||
|
$file_content_desc = str_replace(".attachments.", "/ncdata/.attachments.", $file_content_desc);
|
||
|
echo $Parsedown->text($file_content_desc);
|
||
|
}
|
||
|
elseif (str_contains($file_name_desc,".txt")) {
|
||
|
$file_path_root_desc = '/var/www/nextcloud/data/radio_admin/files/archive/'.$file_name_desc;
|
||
|
$file_content_desc = file_get_contents($file_path_root_desc);
|
||
|
echo $file_content_desc;
|
||
|
}
|
||
|
|
||
|
echo '</div>';
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
if (str_contains($mimetype_name, 'markdown')) {
|
||
|
|
||
|
$file_path_root = '/var/www/nextcloud/data/radio_admin/files/archive/'.$file_name;
|
||
|
$file_content = file_get_contents($file_path_root);
|
||
|
$file_content = str_replace(".attachments.", "/ncdata/.attachments.", $file_content);
|
||
|
echo $Parsedown->text($file_content);
|
||
|
|
||
|
}
|
||
|
|
||
|
if (str_contains($mimetype_name, 'text/html') or str_contains($mimetype_name, 'text/plain')) {
|
||
|
|
||
|
$file_path_root = '/var/www/nextcloud/data/radio_admin/files/archive/'.$file_name;
|
||
|
$file_content = file_get_contents($file_path_root);
|
||
|
echo $file_content;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
if (str_contains($mimetype_name, 'application/pdf')) {
|
||
|
|
||
|
echo "<h1>$file_title</h1> <a href='https://pl4tform.org/ncdata/$file_name' target='_blanck'>====>>> Open in full-screen</a> <br><br>";
|
||
|
echo "<embed class='pdfembed' src='https://pl4tform.org/ncdata/$file_name' type='application/pdf' /> ";
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
</body>
|
||
|
</head>
|
||
|
</html>
|