session_start();
/* Change path info depending on your file locations */
require_once '../includes/mobile-detect.php';
$detect = new Mobile_Detect;
if ((isset($_COOKIE['app']) and ($_COOKIE['app']) == 'true') || $detect->isMobile()) {
//header('Location: /brewzeit/www/index.html#/app/brew/' . $_GET['id']);
}
include('../includes/config.php');
$beer = $_GET['id'];
$beerID = $_GET['id'];
$data = mysql_query("SELECT * FROM beers WHERE id = '$beer'");
$picData = mysql_query("SELECT picName,id,LENGTH(cheers) - LENGTH(REPLACE(cheers, ',', '')) AS popular FROM beerreel WHERE beer = '$beer' AND picName != '' ORDER BY id DESC LIMIT 1");
if (mysql_num_rows($picData) > 0) {
$picture = mysql_fetch_object($picData);
$picName = $picture->picName;
$picName = "url(https://brewzeit.com/images/thumbs_lg/" . $picName . "); background: -moz-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 15%, rgba(0, 0, 0, 1) 100%), url(https://brewzeit.com/images/thumbs_lg/" . $picName . ") no-repeat;background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(15%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 1))), url(https://brewzeit.com/images/thumbs_lg/" . $picName . ") no-repeat; background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 15%, rgba(0, 0, 0, 1) 100%), url(https://brewzeit.com/images/thumbs_lg/" . $picName . ") no-repeat; background-position: center; background-size: 100% auto;";
} else {
$picName = "#111";
}
$post = mysql_fetch_array($data);
$type = $post['type'];
$title = $post['maker'] . " " . $post['name'] . " (" . $type . ")";
$m = $post['maker'];
$n = $post['name'];
$nameURL = $post['maker'] . " " . $post['name'];
$a = array("", " ");
$a2 = array("'", ".", "&");
$replacedURL = strtolower(str_replace($a, "-", $nameURL));
$replacedURL = str_replace($a2, "", $replacedURL);
$canonical = "https://brewzeit.com/brew/" . $beerID . "/" . $replacedURL . "/";
$t = $post['maker'] . " " . $post['name'];
if (substr(strtolower($type), 0, 1) == 'a' || substr(strtolower($type), 0, 1) == 'e' || substr(strtolower($type), 0, 1) == 'i' || substr(strtolower($type), 0, 1) == 'o' || substr(strtolower($type), 0, 1) == 'u') {
$a = "an";
} else {
$a = "a";
}
$metaMaker = $post['name'] . " is " . $a . " " . $type . " by " . $post['maker'] . ". ";
if ($post['abv'] != '') {
$metaABV = "It has an ABV of " . $post['abv'] . ". ";
} else {
$metaABV = '';
}
$reviewData = mysql_query("SELECT SUM(rating),COUNT(rating) FROM beerreel WHERE beer = '$beer' AND rating != '0'");
$conData = mysql_query("SELECT * FROM beerreel WHERE beer = '$beer'");
$consumedRows = mysql_num_rows($conData);
if ($consumedRows == 1) {
$metaConsumed = "It has been consumed 1 time.";
} else {
$metaConsumed = "It has been consumed " . $consumedRows . " times.";
}
while ($reviews = mysql_fetch_array($reviewData)) {
if ($reviews['COUNT(rating)'] > 0) {
$rating = $reviews['SUM(rating)'] / $reviews['COUNT(rating)'];
$rating = round($rating, 1);
if ($reviews['COUNT(rating)'] == 1) {
$metaRating = "It has a rating of " . $rating . " out of 5 with 1 review.";
} else {
$metaRating = "It has a rating of " . $rating . " out of 5 with " . $reviews['COUNT(rating)'] . " reviews.";
}
} else {
$metaRating = '';
}
}
if ($post['grains'] != '') {
$metaMalt = " The malt bill consists of " . $post['grains'] . ". ";
}
if ($post['hops'] != '') {
$metaMalt .= "The hops used are " . $post['hops'] . ". ";
}
if ($post['yeast'] != '') {
$metaMalt .= "The yeast is " . $post['yeast'] . ". ";
}
$meta = $metaMaker . $metaABV . $metaRating . $metaMalt;
$type = $post['type'];
$nameURL = $post['maker'] . " " . $post['name'];
$a = array("", " ");
$a2 = array("'", ".", "&");
$replacedURL = strtolower(str_replace($a, "-", $nameURL));
$replacedURL = str_replace($a2, "", $replacedURL);
$ogUrl = "https://brewzeit.com/brew/" . $beerID . "/" . $replacedURL . "/";
if ($picture->picName != '') {
$ogImage = "https://brewzeit.com/images/thumbs_lg/" . $picture->picName;
} else {
$ogImage = "https://brewzeit.com/images/brewzeit-square.png";
}
include('../includes/header.php'); ?>
echo ""; ?>
echo $meta ?>
$data = mysql_query("SELECT * FROM beers WHERE id = '$beer'");
while ($post = mysql_fetch_array($data))
{
$style = $post['type'];
$style = strtolower($style);
$style = str_replace("'", "", $style);
$style = str_replace("/", "~", $style);
$style = str_replace(" ", "-", $style);
$m = $post['maker'];
$data = mysql_query("SELECT id,name FROM breweries WHERE name = \"$m\" LIMIT 1");
$b = mysql_fetch_object($data);
$brewery = $b->maker;
//$d = mysql_query("SELECT name,id FROM breweries WHERE name = \"$brewery\"");
//if(mysql_num_rows($d) > 0){
//}
//else{
//mysql_query("INSERT INTO breweries (name) VALUES (\"{$b->maker}\")");
//}
$makerN = strtolower($b->name);
$makerN = str_replace("'", "", $makerN);
$a = array(" ", ".");
$makerN = str_replace($a, "-", $makerN);
$makerURL = "/breweries/" . $b->id . "/" . $makerN . "/";
?>
echo "
";
$reviewData = mysql_query("SELECT SUM(rating),COUNT(rating) FROM beerreel WHERE beer = '$beer' AND rating != '0'");
while ($reviews = mysql_fetch_array($reviewData)) {
//echo $reviews['SUM(rating)'];
//echo $reviews['COUNT(rating)'];
//echo $rating;
if ($reviews['COUNT(rating)'] > 0) {
$rating = $reviews['SUM(rating)'] / $reviews['COUNT(rating)'];
$ratingPercent = ($reviews['SUM(rating)'] / $reviews['COUNT(rating)']) / 5 * 100;
?>
if ($reviews['COUNT(rating)'] == '1') {
echo "
" . round($rating, 2) . " out of 5 - Based on " . $reviews['COUNT(rating)'] . " review
";
} else if ($reviews['COUNT(rating)'] == '0') {
//echo "
" . round($rating,1) . " out of 5 - Based on " . $reviews['COUNT(rating)'] . " review
";
} else {
echo "
" . round($rating, 2) . " out of 5 - Based on " . $reviews['COUNT(rating)'] . " reviews
";
}
$reviewersCount = mysql_query("SELECT COUNT(author_id) FROM beerreel WHERE beer = '$beer' AND rating != '0' GROUP BY author_id");
$reviewers = mysql_num_rows($reviewersCount);
//echo "
";
?>
} else {
echo "
0 out of 50 - Based on 0 review
";
}
echo "
";
}
echo "
";
if ($post['abv'] != '') {
echo "ABV: " . $post['abv'] . " ";
}
if ($post['og'] != '') {
echo "
OG: " . $post['og'] . " ";
}
if ($post['ibu'] != '') {
echo "IBU: " . $post['ibu'] . " ";
}
echo "Style: " . $post['type'] . "
";
if ($post['description'] != '') {
echo "
Description: " . $post['description'] . "
";
}
if ($post['yeast'] != '' || $post['hops'] != '' || $post['grains'] != '') {
echo "
Ingredients:
";
if ($post['grains'] != '') {
echo "Malts: " . $post['grains'] . "
";
}
if ($post['hops'] != '') {
echo "Hops: " . $post['hops'] . "
";
}
if ($post['yeast'] != '') {
echo "Yeast: " . $post['yeast'];
}
echo "
";
}
} ?>
No one is drinking this
beer right now.
echo getBrewTotal($beer); ?>
echo getPics($beer); ?>
echo $t ?>
Reviews
include('../includes/footer.php'); ?>