Commit c810fe94 authored by Daniel Messer's avatar Daniel Messer

Content, slides, and admin functions added.

parent 56d3549e
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -10,10 +10,12 @@ The software itself is aimed at running as a standalone system on a Raspberry Pi
#### Special Thanks
Signbrary utilizes the [Javascript Date Picker](https://github.com/chrishulbert/datepicker) by [Chris Hulbert](http://www.splinter.com.au/). Thank you, Chris!
Signbrary utilizes:
---
The [Javascript Date Picker](https://github.com/chrishulbert/datepicker) by [Chris Hulbert](http://www.splinter.com.au/).
[The 4 Col Portfolio](https://github.com/BlackrockDigital/startbootstrap-4-col-portfolio) Bootstrap template from BlackrockDigital.
---
**Signbrary is currently under active development. Some features are not yet available.**
<?php require('login.php');?>
<!DOCTYPE html>
<html>
<head>
<title>Signbrary - Add Content</title>
<link rel="stylesheet" type="text/css" href="../css/datepicker.css" />
<link rel="stylesheet" type="text/css" href="../css/layout.css" />
<script type="text/javascript" src="../js/datepicker.js"></script>
<script type="text/javascript" src="../js/timepicker.js"></script>
<script type="text/javascript" src="../js/w3.js"></script>
</head>
<body>
<div id="pagewidth">
<div id="header"><h1>Signbrary &ndash; Digital Signage. Digital Content.</h1></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Add Content</h1>
<p>Accepted formats include: Mobi, ePUB, PDF, MP3, MP4</p>
<p style = "color:#ff0000;">All fields are required.</p>
<hr>
<form action="../content-add.php" method="post" enctype="multipart/form-data" id="addcontent">
Title:<br />
<input type="text" name="cont_title" placeholder="Ex: Dubliners" /><br /><br />
Author:<br />
<input type="text" name="cont_author" placeholder="Ex: James Joyce" /><br /><br />
Format<br />
<input type="radio" name="format" value="mobi" checked="checked">Mobi eBook<br />
<input type="radio" name="format" value="ePub">ePub eBook<br />
<input type="radio" name="format" value="PDF">PDF file<br />
<input type="radio" name="format" value="MP3">MP3 audio<br />
<input type="radio" name="format" value="ePub">MP4 video<br /><br />
Genre<br />
<?php
include '../creds.php';
$result = mysqli_query($conn,"SELECT Description from genre order by Description");
echo "<select name='genre'>";
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['Description'] . "'>" . $row['Description'] . "</option>";
}
echo "</select><br /><br />";
?>
Brief Summary (Max 250 characters)<br />
<textarea rows="3" cols="80" maxlength="250" name="bsum" form="addcontent"></textarea><br /><br />
Full Summary<br />
<textarea rows="8" cols="80" name="fsum" form="addcontent"></textarea><br /><br />
Set content to Active/Inactive<br />
<input type="radio" name="activecontent" value="active" checked="checked">Active<br />
<input type="radio" name="activecontent" value="inactive">Inactive<br /><br />
Select content for upload (Max size = 20 MB):
<input type="file" name="fileToUpload" id="fileToUpload"><br /><br />
Select cover image for upload (Max size = 10 MB):
<input type="file" name="coverToUpload" id="coverToUpload"><br /><br />
<input type="submit" value="Add Content" name="submit">
</form>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="admin-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<?php require('login.php');?>
<!DOCTYPE html>
<html>
<head>
<title>Signbrary - Add Slide</title>
<link rel="stylesheet" type="text/css" href="../css/datepicker.css" />
<link rel="stylesheet" type="text/css" href="../css/layout.css" />
<script type="text/javascript" src="../js/datepicker.js"></script>
<script type="text/javascript" src="../js/timepicker.js"></script>
<script type="text/javascript" src="../js/w3.js"></script>
</head>
<body>
<div id="pagewidth">
<div id="header"><h1>Signbrary &ndash; Digital Signage. Digital Content.</h1></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Add Slide</h1>
<p>Accepted formats include: JPG, JPEG, PNG, GIF, MP4</p>
<p style = "color:#ff0000;">All fields are required.</p>
<hr>
<form action="../slide-add.php" method="post" enctype="multipart/form-data">
Image Title:<br />
<input type="text" name="img_title" placeholder="Name your slide" /><br /><br />
Start Date / Time:<br />
<input id="start_dt" name="start_dt" class='datepicker' size='11' title='D-MMM-YYYY' placeholder="Use date picker ->" />
<input id="start_tm" name="start_tm" class='timepicker' size='5' title='HH:MM' placeholder="HH:MM" /><br /><br />
End Date / Time:<br />
<input id="end_dt" name="end_dt" class='datepicker' size='11' title='D-MMM-YYYY' placeholder="Use date picker ->" />
<input id="end_tm" name="end_tm" class='timepicker' size='5' title='HH:MM' placeholder="HH:MM" /><br /><br />
Set Slide to Active/Inactive<br />
<input type="radio" name="activeslide" value="active" checked="checked">Active<br />
<input type="radio" name="activeslide" value="inactive">Inactive<br /><br />
Select media for upload (Max size = 10 MB):
<input type="file" name="fileToUpload" id="fileToUpload"><br /><br />
<input type="submit" value="Add Slide" name="submit">
</form>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="admin-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<html>
<head>
<h2 style="color:#fff;">Navigation</h2>
<hr>
<ul>
<h3 style="color:#fff; font-variant:small-caps;">Slides</h3>
<li><a href="addslide.php">Add Slide</a></li>
<li><a href="slide-manage.php">Manage Slides</a></li>
<h3 style="color:#fff; font-variant:small-caps;">Content</h3>
<li><a href="addcontent.php">Add Content</a></li>
<li><a href="content-manage.php">Manage Content</a></li>
<li><a href="genre-manage.php">Manage Genres</li>
</ul>
<?php require('login.php');?>
<?php
include 'creds.php';
$deleteid = htmlspecialchars($_GET["id"]);
// Updating the database
$result = mysqli_query($conn,"SELECT DownloadFile, Cover FROM content WHERE ContentID = '$deleteid'");
while($row = mysqli_fetch_array($result))
{
$filedelete = $row['DownloadFile'];
$coverdelete = $row['Cover'];
}
unlink($filedelete);
unlink($coverdelete);
mysqli_query($conn,"DELETE FROM content WHERE ContentID = '$deleteid'");
// Close database connection
mysqli_close($conn);
header("Location: content-manage.php");
?>
<?php require('login.php');?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Content</title>
<link rel="stylesheet" type="text/css" href="css/datepicker.css" />
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<script type="text/javascript" src="js/w3.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
<script type="text/javascript" src="js/timepicker.js"></script>
</head>
<body>
<div id="pagewidth">
<div id="header"><h2>Signbrary &ndash; Digital Signage. Digital Content.</h2></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Edit Content</h1>
<p style = "color:#ff0000;">All fields are required.</p>
<hr>
<?php
$editid = htmlspecialchars($_GET["id"]);
include 'creds.php';
$result = mysqli_query($conn,"SELECT * from content WHERE ContentID = '$editid'");
$getgenre = mysqli_query($conn,"SELECT Description from genre order by Description");
while($row = mysqli_fetch_array($result))
{
?>
<form action="content-update.php" method="post" enctype="multipart/form-data" id="updatecontent">
Item ID:<br />
<input type="text" name="ItemID" value="<?php echo(htmlspecialchars($row['ItemID'])); ?>" /><br /><br />
Title:<br />
<input type="text" name="cont_title" value="<?php echo(htmlspecialchars($row['Title'])); ?>" /><br /><br />
Author:<br />
<input type="text" name="cont_author" value="<?php echo(htmlspecialchars($row['Author'])); ?>" /><br /><br />
Format:<br />
<input type="radio" name="format" value="mobi" checked="checked">Mobi eBook<br />
<input type="radio" name="format" value="ePub">ePub eBook<br />
<input type="radio" name="format" value="PDF">PDF file<br />
<input type="radio" name="format" value="MP3">MP3 audio<br />
<input type="radio" name="format" value="ePub">MP4 video<br /><br />
Brief Summary (Max 250 characters)<br />
<textarea rows="3" cols="80" maxlength="250" name="bSum" form="updatecontent"><?php echo(htmlspecialchars($row['SummaryBrief'])); ?></textarea><br /><br />
Full Summary<br />
<textarea rows="8" cols="80" name="fSum" form="updatecontent"><?php echo(htmlspecialchars($row['SummaryFull'])); ?></textarea><br /><br />
Set Content to Active/Inactive<br />
<input type="radio" name="activecontent" value="active" checked="checked">Active<br />
<input type="radio" name="activecontent" value="inactive">Inactive<br /><br />
Cover:<br />
<?php
echo '<img src="'.($row['Cover']).'" width="150"><br /><br />';
?>
Genre:<br />
<?php
echo "<select name='genre'>";
while ($row = mysqli_fetch_array($getgenre)) {
echo "<option value='" . $row['Description'] . "'>" . $row['Description'] . "</option>";
}
echo "</select><br /><br />"; ?>
Select content for upload (Max size = 20 MB):
<input type="file" name="fileToUpload" id="fileToUpload"><br /><br />
Select cover image for upload (Max size = 10 MB):
<input type="file" name="coverToUpload" id="coverToUpload"><br /><br />
<input type="hidden" name="editID" value="<?php echo $editid; ?>" />
<input type="submit" value="Edit Content" name="submit">
</form>
<?php
}
?>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="admin-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<?php require('login.php');?>
<html>
<head>
<title>Signbrary - Manage Content</title>
<link rel="stylesheet" type="text/css" href="../css/datepicker.css" />
<link rel="stylesheet" type="text/css" href="../css/layout.css" />
<script type="text/javascript" src="../js/datepicker.js"></script>
<script type="text/javascript" src="../js/timepicker.js"></script>
<script type="text/javascript" src="../js/w3.js"></script>
<style>
#slides {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 90%;
}
#slides td, #slides th {
border: 1px solid #ddd;
padding: 8px;
}
#slides tr:nth-child(even){background-color: #f2f2f2;}
#slides tr:hover {background-color: #ddd;}
#slides th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0000ff;
color: white;
}
</style>
</head>
<body>
<div id="pagewidth">
<div id="header"><h2>Signbrary &ndash; Digital Signage. Digital Content.</h2></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Manage Content</h1>
<?php include '../creds.php';?>
<table id="slides">
<tr>
<th><strong>Item ID</strong></th>
<th><strong>Title</strong></th>
<th><strong>Author</strong></th>
<th><strong>Format</strong></th>
<th><strong>Genre</strong></th>
<th><strong>Brief Summary</strong></th>
<th><strong>Full Summary</strong></th>
<th><strong>Cover</strong></th>
<th><strong>Active</strong></th>
<th><strong>Downloads</strong></th>
<th><strong>Edit</strong></th>
<th><strong>Delete</strong></th>
</tr>
<?php
$result = mysqli_query($conn,"SELECT * FROM content ORDER BY Title");
while($row = mysqli_fetch_array($result))
{
$row_contentID = $row['ContentID'];
$row_id = $row['ItemID'];
$row_title = $row['Title'];
$row_author = $row['Author'];
$row_format = $row['Format'];
$row_genre = $row['Genre'];
$row_bsum = $row['SummaryBrief'];
$row_fsum = $row['SummaryFull'];
$row_cover = $row['Cover'];
$row_active = $row['Active'];
$row_downloads = $row['Downloads'];
echo '<tr>';
echo '<td>' . $row_id . '</td>';
echo '<td>' . $row_title . '</td>';
echo '<td>' . $row_author . '</td>';
echo '<td>' . $row_format . '</td>';
echo '<td>' . $row_genre . '</td>';
echo '<td>' . $row_bsum . '</td>';
echo '<td>' . $row_fsum . '</td>';
echo '<td><img src="../' . $row_cover . '" width="100"</td>';
echo '<td><a href="content-toggleactive.php?id=' . $row_contentID . '">'.$row_active.'</a></td>';
echo '<td>' . $row_downloads . '</td>';
echo '<td><a href="content-edit.php?id=' . $row_contentID . '">Edit</a></td>';
echo '<td><a href="content-delete.php?id=' . $row_contentID . '" onclick="return confirm(\'Are you sure you want to delete this content?\');">Delete</a></td>';
echo '</tr>';
}
mysqli_close($conn);
?>
</table>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="admin-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<?php require('login.php');?>
<?php
include '../creds.php';
$toggleid = htmlspecialchars($_GET["id"]);
// Updating the database
$result = mysqli_query($conn,"SELECT Active FROM content WHERE ContentID = '$toggleid'");
while($row = mysqli_fetch_array($result))
{
$active = $row['Active'];
if($active != "active") {
mysqli_query($conn,"UPDATE content SET Active = 'active' WHERE ContentID = '$toggleid'");
} else {
mysqli_query($conn,"UPDATE content SET Active = 'inactive' WHERE ContentID = '$toggleid'");
}
}
// Close database connection
mysqli_close($conn);
header("Location: content-manage.php");
?>
<?php require('login.php');?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<script type="text/javascript" src="js/w3.js"></script>
</head>
<body>
<div id="pagewidth">
<div id="header"><h1>Signbrary &ndash; Digital Signage. Digital Content.</h1></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Genre Added</h1>
<?php
include '../creds.php';
$genre_add = $_POST["genre"];
// Updating the database
mysqli_query($conn,"INSERT INTO genre VALUES (NULL,'$genre_add')");
// Close database connection
mysqli_close($conn);
header('Location: genre-manage.php');
?>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="side-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<?php require('login.php');?>
<?php
include 'creds.php';
$deleteid = htmlspecialchars($_GET["id"]);
// Updating the database
mysqli_query($conn,"DELETE FROM genre WHERE GenreID = '$deleteid'");
// Close database connection
mysqli_close($conn);
header("Location: genre-manage.php"); // Slide deleted - return to management
?>
<?php require('login.php');?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Genre</title>
<link rel="stylesheet" type="text/css" href="../css/layout.css" />
<script type="text/javascript" src="../js/w3.js"></script>
</head>
<body>
<div id="pagewidth">
<div id="header"><h2>Signbrary &ndash; Digital Signage. Digital Content.</h2></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Edit Genre</h1>
<p style = "color:#ff0000;">All fields are required.</p>
<hr>
<?php
$editid = htmlspecialchars($_GET["id"]);
include '../creds.php';
$result = mysqli_query($conn,"SELECT * from genre WHERE GenreID = '$editid'");
while($row = mysqli_fetch_array($result))
{
?>
<form action="genre-update.php" method="post" enctype="multipart/form-data">
Genre Description:<br />
<input type="text" name="genre" value="<?php echo(htmlspecialchars($row['Description'])); ?>" /><br /><br />
<input type="hidden" name="GenreID" value="<?php echo $editid; ?>" />
<input type="submit" value="Edit Genre" name="submit">
</form>
<?php
}
?>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="admin-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<?php require('login.php');?>
<html>
<head>
<title>Signbrary - Manage Genres</title>
<link rel="stylesheet" type="text/css" href="../css/datepicker.css" />
<link rel="stylesheet" type="text/css" href="../css/layout.css" />
<script type="text/javascript" src="../js/w3.js"></script>
<style>
#slides {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 90%;
}
#slides td, #slides th {
border: 1px solid #ddd;
padding: 8px;
}
#slides tr:nth-child(even){background-color: #f2f2f2;}
#slides tr:hover {background-color: #ddd;}
#slides th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0000ff;
color: white;
}
</style>
</head>
<body>
<div id="pagewidth">
<div id="header"><h2>Signbrary &ndash; Digital Signage. Digital Content.</h2></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Manage Genres</h1>
<?php include '../creds.php';?>
<table id="slides">
<tr>
<th><strong>Genre</strong></th>
<th><strong>Edit</strong></th>
<th><strong>Delete</strong></th>
</tr>
<?php
$result = mysqli_query($conn,"SELECT * FROM genre ORDER BY Description");
while($row = mysqli_fetch_array($result))
{
$row_genreid = $row['GenreID'];
$row_genre = $row['Description'];
echo '<tr>';
echo '<td>' . $row_genre . '</td>';
echo '<td><a href="genre-edit.php?id=' . $row_genreid . '">Edit</a></td>';
echo '<td><a href="genre-delete.php?id=' . $row_genreid . '" onclick="return confirm(\'Are you sure you want to delete this genre?\');">Delete</a></td>';
echo '</tr>';
}
mysqli_close($conn);
?>
</table>
<hr><br />
<form action="genre-add.php" method="post" enctype="multipart/form-data" id="addgenre">
Add a New Genre:<br />
<input type="text" name="genre" placeholder="Ex: Science Fiction" />
<input type="submit" value="Add Genre" name="submit">
</form>
</div> <!-- End maincol -->
<div id="leftcol">
<p w3-include-html="admin-nav.html"></p>
<script>
w3.includeHTML();
</script>
</div> <!-- End leftcol -->
</div> <!-- End wrapper -->
</div> <!-- End pagewidth -->
</body>
</html>
<?php require('login.php');?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/layout.css" />
<script type="text/javascript" src="../js/w3.js"></script>
</head>
<body>
<div id="pagewidth">
<div id="header"><h1>Signbrary &ndash; Digital Signage. Digital Content.</h1></div>
<div id="wrapper" class="clearfix">
<div id="maincol"><h1>Genre Edit Complete</h1>
<?php