Пример #1
0
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.
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "inventory.php";
include 'include.php';
if (!empty($_POST['name'])) {
    $name = $_POST['name'];
} else {
    die("Unit Type Not Entered");
}
$sql = "INSERT INTO unit (unit_type) VALUES ('{$name}');";
mysqli_query($con, $sql) or die("Error description: " . mysqli_error($con));
redirect2("Successfully Added Unit: {$name}", "success");
Пример #2
0
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.
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "users.php";
include 'include.php';
// Get POST variables
if (isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
} else {
    // ToDo: Better redirect system
    die("Username and/or Password not submitted");
}
// Hash Password
$hashedPassword = crypt($password);
// Admin check
$admin = isset($_POST['admin']) ? 1 : 0;
// Insert into database
$sql = "INSERT INTO `user` (`username`, `salt`, `hashed_password`, `admin`) VALUES ('{$username}', '0', '{$hashedPassword}', {$admin})";
// Execute query
mysqli_query($con, $sql) or die("Cannot execute query");
// ToDo: Output mysql error
// Redirect on successful registration
redirect2("Successfully added user: {$username}", "success");
Пример #3
0
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.
*/
$pageOptions['script'] = true;
$pageOptions['redirectTo'] = "brew.php";
include 'include.php';
if (isset($_POST['beername']) && isset($_POST['startdate']) && isset($_POST['enddate'])) {
    $beername = $_POST['beername'];
    $startdate = date("Y-m-d H:i:s", strtotime($_POST['startdate']));
    $enddate = date("Y-m-d H:i:s", strtotime($_POST['enddate']));
} else {
    redirect2("Post variables not set", "warning");
}
// Query
$sql = "INSERT INTO brew (beer_name, start_date, end_date, user) VALUES ('{$beername}', '{$startdate}', '{$enddate}', '{$loggedInUsername}');";
mysqli_query($con, $sql) or redirect2("Error description: " . mysqli_error($con), "warning");
// Execute
//mysqli_query($con, $sql) or die("Error: " . mysqli_error($con));
redirect2("{$loggedInUsername} successfully created {$beer_name} brew", "success");
//header("Location: brew.php");
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.
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "inventory.php";
include 'include.php';
if (!empty($_POST['name'])) {
    $name = $_POST['name'];
} else {
    die("Ingredient Name Not Entered");
}
$sql = "INSERT INTO ingredient (ingredient_name) VALUES ('{$name}');";
mysqli_query($con, $sql) or die("Error description: " . mysqli_error($con));
redirect2("Successfully Added Ingredient: {$name}", "success");
Пример #5
0
$pageOptionsDefaults = array("loginRequired" => true, "adminRequired" => false, "script" => false, "title" => "", "redirectTo" => "home.php");
// Set all options, that haven't already been set, to default
foreach ($pageOptionsDefaults as $entry => $defaultValue) {
    if (!isset($pageOptions[$entry])) {
        $pageOptions[$entry] = $defaultValue;
    }
}
/* HTTPS Redirect */
if (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS']) {
    $url = 'https://' . $_SERVER['HTTP_HOST'] . $SERVER['REQUEST_URI'];
    header('Location: $url');
}
/* Variables */
$fileName = basename($_SERVER['PHP_SELF']);
$loggedInUsername = isset($_SESSION['UN']) ? $_SESSION['UN'] : "";
$isAdmin = isset($_SESSION['admin']) ? $_SESSION['admin'] : 0;
$isLoggedIn = !empty($loggedInUsername);
/* Login Checking */
if ($pageOptions["loginRequired"] && !$isLoggedIn) {
    redirect("index.php");
    die;
}
/* Admin Checking */
if ($pageOptions["adminRequired"] && !$isAdmin) {
    redirect2("Error: You must be an adming to access {$fileName}", "warning");
    die;
}
/* Script Checking */
if (!$pageOptions["script"]) {
    include 'header.php';
}

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.
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "beer2.php";
include 'include.php';
// Check post variable
if (!empty($_POST['name']) && !empty($_POST['type'])) {
    $name = $_POST['name'];
    $typeId = $_POST['type'];
} else {
    redirect2("Beer name and/or type not entered", "warning");
}
// Query
$sql = "INSERT INTO beer (beer_name, beer_type_id) VALUES ('{$name}', {$typeId});";
// Execute
mysqli_query($con, $sql) or redirect2("Error description: " . mysqli_error($con), "warning");
redirect2("Successfully added beer: {$name}", "success");
Пример #7
0
				<th>Fill Date</th>
				<th>Ship Date</th>
				<th>Renter</th>
				<th>Return Date</th>
				<th>Update</th>
			</tr>
<?php 
    // Loop through all rows
    while ($row = mysqli_fetch_array($res)) {
        $rowBeerId = $row['brew_id'] ? $row['brew_id'] : false;
        $rowBeerName = "N/A";
        if ($rowBeerId != false) {
            $sql2 = "SELECT beer_name FROM brew WHERE brew_id = {$rowBeerId}";
            if ($res2 = mysqli_query($con, $sql2)) {
                $row2 = mysqli_fetch_array($res2);
                $rowBeerName = $row2['beer_name'];
            }
        }
        $rowRenter = $row['location'] ? $row['location'] : "N/A";
        $rowFillDate = $row['fill_date'] ? $row['fill_date'] : "N/A";
        $rowShipDate = $row['ship_date'] ? $row['ship_date'] : "N/A";
        $rowReturnDate = $row['return_date'] ? $row['return_date'] : "N/A";
        echo "<tr><td>{$rowBeerName}</td><td>{$rowFillDate}</td><td>{$rowShipDate}</td><td>{$rowRenter}</td><td>{$rowReturnDate}</td><td><a href='updateKeg.php?kegId={$kegId}' class='btn btn-default'>Update</a></td></tr>";
    }
} else {
    redirect2("MySQL Error: " . mysqli_error($con) . $sql, "warning");
}
?>
		</table>
	</div>
</div>
Пример #8
0
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.
*/
$pageOptions["redirectTo"] = "kegs.php";
include 'include.php';
if (isset($_POST['barcode'])) {
    $barcode = $_POST['barcode'];
} else {
    die("Barcode was not entered correctly.");
}
$sql = "INSERT INTO keg (barcode) VALUES ('{$barcode}')";
mysqli_query($con, $sql) or redirect2("Error description: " . mysqli_error($con), "warning");
$sql = "SELECT keg_id FROM keg ORDER BY keg_id DESC LIMIT 1;";
//mysqli_query($con,$sql) or die("Error description: " . mysqli_error($con));
if ($res = mysqli_query($con, $sql)) {
    $row = mysqli_fetch_array($res);
    $keg_id = $row['keg_id'];
}
$sql = "INSERT INTO brew_keg (keg_id) VALUES ('{$keg_id}');";
mysqli_query($con, $sql) or redirect2("Error description: " . mysqli_error($con), "warning");
redirect2("Successfully added new keg: {$barcode}", "success");
die;
Пример #9
0
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.
*/
$pageOptions["loginRequired"] = false;
$pageOptions["script"] = true;
include 'include.php';
// Get POST variables
$username = $_POST['username'];
$password = $_POST['password'];
// SQL query
$sql = "SELECT `hashed_password`, `admin` FROM `user` WHERE `username` = '{$username}';";
// Execute query and get password hash
if ($res = mysqli_query($con, $sql)) {
    $resArray = mysqli_fetch_array($res);
    $hashedPassword = $resArray['hashed_password'];
    $isAdmin = $resArray['admin'];
}
// If password matches
if ($hashedPassword === crypt($password, $hashedPassword)) {
    $_SESSION['UN'] = $username;
    $_SESSION['username'] = $username;
    $_SESSION['admin'] = $isAdmin;
    redirect2("Successfully logged in as {$username}", "success");
} else {
    redirect("index.php");
}
} else {
    die("Error 0 : Post options not set");
}
/* Create query based on state */
// Filling state
if ($kegState == 0) {
    $sql = "fill_date = '{$datetime}', brew_id = {$brewId}";
} else {
    if ($kegState == 1) {
        $sql = "ship_date = '{$datetime}', location = '{$location}'";
    } else {
        if ($kegState == 2) {
            $sql = "return_date = '{$datetime}'";
        } else {
            // Kill page
            die("Error 3 : Incompatible kegState");
        }
    }
}
// Construct query
$sql = "UPDATE brew_keg SET " . $sql . " WHERE row_id = {$rowId}";
// Execute query
mysqli_query($con, $sql) or die("Error 4 : Query execution failed\n<br>{$sql}");
// Add new brew_keg row
if ($kegState == 2) {
    $sql = "INSERT INTO brew_keg (keg_id) VALUES ({$kegId})";
    mysqli_query($con, $sql) or die("Error description: " . mysqli_error($con) . "<br> {$sql}");
}
// Redirect on success
redirect2("Successfully updated keg", "success");
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.
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "fermentation.php";
include 'include.php';
if (!empty($_POST['fermType'])) {
    $fermType = $_POST['fermType'];
} else {
    die("Fermentation Type Not Entered");
}
$sql = "INSERT INTO fermentation_type (type) VALUES ('{$fermType}');";
mysqli_query($con, $sql) or die("Error description: " . mysqli_error($con));
redirect2("Successfully Created Fermentation Type: {$fermType}", "success");
Пример #12
0
		$('#calendar').fullCalendar({
			theme: true,
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			editable: true,
			events: [
<?php 
// Query
$sql = "SELECT * FROM brew WHERE start_date IS NOT NULL AND end_date IS NOT NULL";
// Execute query and loop through results
if ($res = mysqli_query($con, $sql)) {
    while ($row = mysqli_fetch_array($res)) {
        $rowBeerName = $row['beer_name'];
        $rowStartDate = date("Y, n - 1, d, H, i, s", strtotime($row['start_date']));
        $rowEndDate = date("Y, n - 1, d, H, i, s", strtotime($row['end_date']));
        echo "{title: '{$rowBeerName}', start: new Date({$rowStartDate}), end: new Date({$rowEndDate})},\n";
    }
} else {
    redirect2("Error with query: {$sql}");
}
?>
			]
		});
		
	});

	</script>
	<br><br>
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "recipes.php";
include 'include.php';
// Check post variable
if (isset($_POST['beername']) && !empty($_POST['beername'])) {
    $beername = $_POST['beername'];
} else {
    die("Name of beer not entered.");
}
if (isset($_POST['ingredient']) && !empty($_POST['ingredient'])) {
    $ingredient = $_POST['ingredient'];
} else {
    die("Ingredient not entered.");
}
if (isset($_POST['unit']) && !empty($_POST['unit'])) {
    $unit = $_POST['unit'];
} else {
    die("Unit not entered.");
}
if (isset($_POST['amount']) && !empty($_POST['amount'])) {
    $amount = $_POST['amount'];
} else {
    die("Amount not entered.");
}
// Query
$sql = "INSERT INTO recipe (name, amount, ingredient_name, unit_name) VALUES ('{$beername}', '{$amount}', '{$ingredient}', '{$unit}');";
// Execute
mysqli_query($con, $sql) or die("Error: " . mysqli_error($con));
redirect2("Successfully Added an Ingredient to {$beername}", "success");
//header("Location: recipes.php");
Пример #14
0
'>
                        <input type='hidden' name='kegId' value='<?php 
            echo $kegId;
            ?>
'>
                        <input type='hidden' name='kegState' value='2'>
                        <div class="form-group">
                                <label>Return Date</label>
                                <div class='input-group date' id='datetimepicker'>
                                        <input type='text' class="form-control" name='datetime' required='yes' id='datePicker'/>
                                        <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-calendar"></span>
                                        </span>
                                </div>
                        </div>
                        <button type="submit" class="btn btn-info">Receive</button>
                </form>
        </div>
</div>
<?php 
        } else {
            redirect2("Incorrect state", "warning");
        }
    }
}
?>
<script>
$(function() {
	$("#datetimepicker").datetimepicker();
});
</script>


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.
*/
$pageOptions["script"] = true;
$pageOptions["redirectTo"] = "beerType.php";
include 'include.php';
// Check post variable
if (isset($_POST['type']) && !empty($_POST['type'])) {
    $type = $_POST['type'];
} else {
    redirect2("Type not entered", "warning");
}
// Query
$sql = "INSERT INTO beer_type (type) VALUES ('{$type}');";
// Execute
mysqli_query($con, $sql) or redirect2("Error description: " . mysqli_error($con), "warning");
redirect2("Successfully added beer type: {$type}", "success");