From 2588173192108ffc1383c5cbcc9bcea687d087f2 Mon Sep 17 00:00:00 2001 From: Goeran Heinemann Date: Fri, 6 Mar 2020 21:03:25 +0100 Subject: [PATCH] test --- fetch.php | 1 + html/index.php | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/fetch.php b/fetch.php index 700e1e4..c8498b1 100755 --- a/fetch.php +++ b/fetch.php @@ -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", "", $inhalt); $stmt->bindParam(1, $site['id']); $stmt->bindParam(2, $inhalt); $stmt->execute(); diff --git a/html/index.php b/html/index.php index 57038b9..48aee9b 100644 --- a/html/index.php +++ b/html/index.php @@ -5,7 +5,7 @@ $sql = "SELECT * FROM sites WHERE active=1"; echo ''; foreach ($pdo->query($sql) as $row){ - echo ''; + echo ''; } if (isset($_GET['source'])){ @@ -17,19 +17,42 @@ if (isset($_GET['source'])){ $data = $stmt->fetchAll(PDO::FETCH_ASSOC); echo '
'.$row['title'].''.$row['link'].'
'.$row['title'].''.$row['link'].'
'; foreach ($data as $row){ - echo ''; + echo ''; } echo '
'.$row['time'].'
'.$row['time'].'
'; }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 ''; - foreach ($data as $row){ - echo ''; + 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 '
';
+                var_dump($test);
+                echo '
'; + echo '
'.$row['place'].''.$row['amount'].'
'; + for ($i = 0; $i < count($test); $i++){ + if ($i+1 % 12 == 0){ + echo ''; + } + + echo ''; + } + echo'
'.$test[$i].'
'; + } + }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 '
'; + foreach ($data as $row){ + echo ''; + } + echo '
'.$row['place'].''.$row['amount'].'
'; } - echo ''; } } \ No newline at end of file