Copyright 2013 Bazaarvoice, Inc.

Unless required by applicable law or agreed to in writing, the example code
below is provided "as is" without warranty of any kind, either express or
implied, including without limitation any implied warranties of condition,
uninterrupted use, merchantability, or fitness for a particular purpose.

-->
<div id="BVRRContainer">
<?php 
$CONFIG = array("DISPLAY_CODE" => "1234-en_us", "PRODUCT_ID" => "123456", "PRODUCT_URL" => "http://www.example.com/product/123456/?", "REVIEWS_SMARTSEO_PARAM" => "bvrrp", "SMART_SEO_PATH_PREFIX" => "/path/to/smartseo/", "CHARACTER_SET" => "ISO-8859-1");
$bvrrpValue = NULL;
if (isset($_GET[$CONFIG["REVIEWS_SMARTSEO_PARAM"]])) {
    $bvrrpValue = $_GET[$CONFIG["REVIEWS_SMARTSEO_PARAM"]];
}
$reviewsSmartSEOFileName = bvGetSourceSVIFile($bvrrpValue, $CONFIG);
if (!is_null($reviewsSmartSEOFileName)) {
    $indexableContent = bvURLTokenReplace($reviewsSmartSEOFileName, $CONFIG["PRODUCT_URL"]);
    print mb_convert_encoding($indexableContent, $CONFIG["CHARACTER_SET"], 'UTF-8');
}
function bvURLTokenReplace($filename, $url)
{
    return str_replace('{INSERT_PAGE_URI}', $url, file_get_contents($filename));
}
function bvGetSourceSVIFile($rrPage, $CONFIG)
{
    if ($rrPage) {
        $sourceFile = realpath($CONFIG["SMART_SEO_PATH_PREFIX"] . $rrPage);
        if (strpos($sourceFile, $CONFIG["SMART_SEO_PATH_PREFIX"] . $CONFIG["DISPLAY_CODE"]) == 0 && is_file($sourceFile)) {
            return $sourceFile;
        }
<!--

Copyright 2013 Bazaarvoice, Inc.

Unless required by applicable law or agreed to in writing, the example code
below is provided "as is" without warranty of any kind, either express or
implied, including without limitation any implied warranties of condition,
uninterrupted use, merchantability, or fitness for a particular purpose.

-->
<div id="BVRRContainer">
<?php 
$CONFIG = array("DISPLAY_CODE" => "1234-en_us", "PRODUCT_ID" => "123456", "SMART_SEO_PATH_PREFIX" => "/path/to/smartseo/", "CHARACTER_SET" => "ISO-8859-1");
$reviewsSmartSEOFileName = bvGetSourceSVIFile($CONFIG);
if (!is_null($reviewsSmartSEOFileName)) {
    $indexableContent = file_get_contents($reviewsSmartSEOFileName);
    print mb_convert_encoding($indexableContent, $CONFIG["CHARACTER_SET"], 'UTF-8');
}
function bvGetSourceSVIFile($CONFIG)
{
    $firstPageContent = $CONFIG["SMART_SEO_PATH_PREFIX"] . $CONFIG["DISPLAY_CODE"] . '/reviews/product/1/' . rawurlencode($CONFIG["PRODUCT_ID"]) . '.htm';
    if (is_file($firstPageContent)) {
        return $firstPageContent;
    }
    return NULL;
}
?>
</div>