Method = 'GET'; if(isset($_GET['review'])) { $review = $_GET['review']; } require \Diyl\DocRoot . '/includes/base-includes.php'; require \Diyl\DocRoot . '/partials/data-home.php'; $testimonials = new Testimonials; use \Diyl\Database\Connection as DB; use \Diyl\Database\Statement\Select as SelectStmt; use \Diyl\Database\Column; use \Diyl\Database\Table; $db = DB::get(\Diyl\Database\Cookies); $category = 'boat'; if ($db->green()) { $result = $db->query(' SELECT * FROM cookies.VinylLetteringReviews where VinylLetteringReviewID = ' . $review . ' order by VinylLetteringReviews.`DateTime` desc limit 1; '); } else { return ''; }; if ($db->green()) { $productResult = $db->query(' select count(*) as Ratings, round(sum(QualityRating)/count(8),1) as AggregateRating from cookies.VinylLetteringReviews where Category = "' . $category . '"; '); } else { return ''; }; /* Get the last two reviews for the schema */ if ($db->green()) { $reviewsResult = $db->query(' select VinylLetteringReviews.*, DATE_FORMAT(`DateTime`, "%Y-%m-%d") as Date from cookies.VinylLetteringReviews where Category = "' . $category . '" order by VinylLetteringReviewID desc limit 2; '); } else { return ''; }; while ($reviewResult = $reviewsResult->fetch_assoc()) { $reviews[] = $reviewResult; } $row = $result->fetch_assoc(); $EscapedSigned = str_replace('"', '\"', $testimonials->FormatSigned($row["Signed"])); $EscapedProductUse = str_replace('"', '\"', $row["ProductUse"]); $EscapedDescription = str_replace('"', '\"', preg_replace_callback('/^([a-z])/m', function ($matches) { return strtoupper($matches[0]);}, $row["Comments"])); $productDescription = "Custom vinyl boat lettering perfect for boats, jet skis, or any watercraft. Choose your style, color, text and special effects. Includes a 7 year warranty (Premium Vinyl) and a 100% full replacement installation guarantee."; $productName = 'Boat Lettering'; $productUrl = 'boat-lettering'; $productSku = 'boatltr'; $productMpn = 'DIYL003'; $productImage = $_SERVER['DIYL_ADDR'] . "/assets/dist/img/product/vlp-3.jpg"; $data = $productResult->fetch_assoc(); $ratings = $data["Ratings"]; $aggregateRating = $data["AggregateRating"]; if ($row["VinylLetteringReviewID"]) { $jsonStr = ' '; } else { $jsonStr = ''; } $metaDescription = $productName . ' Review from ' . $EscapedSigned . ': ' . $EscapedDescription; function getLastPunctuationPosition($str) { if (preg_match('/[!.,;?][^!.,;?]*$/', $str, $matches, PREG_OFFSET_CAPTURE)) { return $matches[0][1]; } return -1; } $position = getLastPunctuationPosition($metaDescription); if (strlen($metaDescription) > 165) { if ($position > 99 && $position < 165) { $metaDescription = substr($metaDescription, 0, $position+1); } else { $metaDescription = substr($metaDescription, 0, 165); $position = getLastPunctuationPosition($metaDescription); if ($position > 99 && $position < 165) { $metaDescription = substr($metaDescription, 0, $position+1); } else { $metaDescription = substr($metaDescription, 0, 160) . '...'; } } } $title = $productName . ' Review #' . $review . ' by ' . $EscapedSigned; if (strlen($title) > 60) { $reviewPos = strpos($title, 'Review'); $letteringPos = strpos($title, 'Lettering'); if (strlen($title) - $letteringPos < 61) { $title = substr($title, $letteringPos, 60); } else { $title = substr($title, $reviewPos, 60); } } echo $api->getResponse(new \Diyl\PathInfo('products/' . $productUrl), [ 'path' => 'resources/pages/review.html' , 'data' => [ 'metaDescription' => $metaDescription , 'title' => $title , 'canonical' => $_SERVER['DIYL_ADDR'] . '/products/' . $productUrl . '/review/' . $review . '/' , 'jsonld' => $jsonStr ] ]);