This commit is contained in:
Göran Heinemann 2020-03-06 21:03:25 +01:00
parent 276706afeb
commit 2588173192
2 changed files with 35 additions and 11 deletions

View File

@ -10,6 +10,7 @@ foreach ($sites as $site){
$inhalt = file_get_contents($site['link']);
$sql = "INSERT INTO `scans`(`site`, `content`) VALUES (?, ?)";
$stmt = $pdo->prepare($sql);
$inhalt = str_replace("\n", "<!---break--->", $inhalt);
$stmt->bindParam(1, $site['id']);
$stmt->bindParam(2, $inhalt);
$stmt->execute();

View File

@ -5,7 +5,7 @@ $sql = "SELECT * FROM sites WHERE active=1";
echo '<table>';
foreach ($pdo->query($sql) as $row){
echo '<tr><td><a href="index.php?source='.$row['id'].'">'.$row['title'].'</a></td><td>'.$row['link'].'</td></tr>';
echo '<tr><td><a href="index.php?source='.$row['id'].'&type='.$row['type'].'">'.$row['title'].'</a></td><td>'.$row['link'].'</td></tr>';
}
if (isset($_GET['source'])){
@ -17,19 +17,42 @@ if (isset($_GET['source'])){
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '<table>';
foreach ($data as $row){
echo '<tr><td><a href="index.php?source='.$_GET['source'].'&time='.$row['id'].'">'.$row['time'].'</a></td></tr>';
echo '<tr><td><a href="index.php?source='.$_GET['source'].'&time='.$row['id'].'&type='.$_GET['type'].'">'.$row['time'].'</a></td></tr>';
}
echo '</table>';
}else{
$sql = "SELECT * FROM data WHERE scan=?";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(1, $_GET['time']);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '<table>';
foreach ($data as $row){
echo '<tr><td>'.$row['place'].'</td><td>'.$row['amount'].'</td></tr>';
if (isset($_GET['type'])){
if ($_GET['type'] == 'csv'){
$sql = "SELECT content FROM scans WHERE id=?";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(1, $_GET['time']);
$stmt->execute();
$csv = $stmt->fetchAll(PDO::FETCH_ASSOC)[0]['content'];
$test = str_getcsv($csv, ",", "\"", "\\");
echo '<pre>';
var_dump($test);
echo '</pre>';
echo '<table>';
for ($i = 0; $i < count($test); $i++){
if ($i+1 % 12 == 0){
echo '</tr><tr>';
}
echo '<td>'.$test[$i].'</td>';
}
echo'<table>';
}
}else{
$sql = "SELECT * FROM data WHERE scan=?";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(1, $_GET['time']);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo '<table>';
foreach ($data as $row){
echo '<tr><td>'.$row['place'].'</td><td>'.$row['amount'].'</td></tr>';
}
echo '</table>';
}
echo '</table>';
}
}