ImgHost/browse/index.php

57 lines
1.6 KiB
PHP

<?php
include '../config/db_config.php';
include '../config/configuration.php';
//Setting up the webpage
echo '<html>';
echo '<head>';
echo '<link rel="stylesheet" href="../config/' . $stylesheet . '">';
echo '<meta charset="UTF-8">';
echo '<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">';
echo '<title>Browse - ' . $serverName . '</title>';
echo '</head>';
echo '<body class="background">';
echo '<div class="layout" align="center">';
echo '<h1>' . $serverName . '</h1>';
$count = 0;
//Connect to MySQL
$conn = mysqli_connect($sqlServer, $sqlUsername, $sqlPassword, $dbname);
if (!$conn) {
die ("CONNECTION FAIL " . mysqli_connect_error());
} else {
}
echo '<h3>All public photos</h3>';
$browse = "SELECT * FROM $tablename WHERE isPrivate = 0";
$result = mysqli_query($conn, $browse);
//browse all code goes here
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$file = $row["imgID"] . "." . $row["fileType"];
$count++;
echo '<a href="../' . $targetDir . $file . '"><img src="../' . $targetDir . $file . '" alt="' . $row["imgID"] . '" /></a>';
if ($count == 3) { // Change this number based on how many pictures across you want on the page
echo '<br />';
}
}
} else {
echo "Shit, something broke. Try again! Maybe there's nothing here? Or if the problem persists after uploading, contact the system administrator or make a new issue on GitHub";
?>
<p>&nbsp;</p>
<a href="../">Home</a>
<?php
}
echo '<br>';
echo '<br>';
echo '<br>';
echo '<h6>' . $serverName . " - " . $serverVers . "</h6>";
echo '</body>';
echo '</html>';
?>