// Construct the full URL of your Product Ad Widget request
$strUrl = "http://www.avantlink.com/product_ad_widget/paw.php?pawid=7767&pw=15437&output=html&page=" . intval($_GET['paw_page']);
// If you want your Product Ad Widget to use an internal redirect for the links instead of
// direct outbound affiliate links, uncomment the following four lines
//$paw_redirect_url = $_SERVER['PHP_SELF'];
//if ($_SERVER['QUERY_STRING'] != '') { $paw_redirect_url .= '?' . $_SERVER['QUERY_STRING']; }
//$strUrl .= "&paw_redirect_url=" . urlencode($paw_redirect_url);
//if (isset($_GET['redirect_url'])) { header("Location: " . urldecode($_GET['redirect_url'])); }
// Uncomment the next line if you want to add a rel="nofollow" attribute to your links
//$strUrl .= "&nofollow=1";
// Make the actual Product Ad Widget request
$strHtml = file_get_contents($strUrl);
// If your Product Ad Widget will contain more then one page of results you can include
// the following function call to add pagination to your display.
//
// The default is to show simple pagination links like: < Prev Next >
// If you change the boolean in the function call from true to false it will output full pagination links (eg. < Prev | 1 | 2 | 3 | Next >)
$strHtml = str_replace(““, getPawPagination($strHtml, true), $strHtml);
// Stream back the response
echo $strHtml;
function getPawPagination($strHtml, $blnSimpleStyle)
{
$strPaginationHtml = “”;
$intPaginationStart = strpos($strHtml, ““);
$intPaginationStart = ($intPaginationStart + 24);
$intLength = $intPaginationEnd – $intPaginationStart;
$strPagination = substr($strHtml, $intPaginationStart, $intLength);
$arrPagination = explode(“|”, $strPagination);
$intProductsPerPage = intval($arrPagination[0]);
$intProductCount = intval($arrPagination[1]);
$intPage = intval($arrPagination[2]);
if ($intPage == 0) { $intPage = 1; }
$strRootUrl = $_SERVER["PHP_SELF"];
$strParams = “?”;
$intParamCount = 0;
foreach ($_GET as $key => $value) {
if ($key != “paw_page”) {
if ($intParamCount == 0) { $strParams .= $key . “=” . $value; }
else { $strParams .= “&” . $key . “=” . $value; }
}
$intParamCount++;
}
if ($strParams == “?”) { $strPaginationUrl = $strRootUrl . $strParams . “paw_page=”; }
else { $strPaginationUrl = $strRootUrl . $strParams . “&paw_page=”; }
if ($intProductCount > $intProductsPerPage) {
$intTotalPages = ceil($intProductCount/$intProductsPerPage);
}
else { $intTotalPages = 0; }
if ($intTotalPages > 0) {
if ($intPage > 1) { $strPaginationHtml = “< Prev “; }
else { $strPaginationHtml = “< Prev "; }
if (!$blnSimpleStyle) {
for ($i=1; $i<=($intTotalPages); $i++)
{
if ($intPage == $i) { $strPaginationHtml .= " | " . $i . " "; }
else { $strPaginationHtml .= " | ” . $i . “ “; }
}
$strPaginationHtml .= ” | “;
}
if (($intPage + 1) <= $intTotalPages) { $strPaginationHtml .= " Next >“; }
else { $strPaginationHtml .= ” Next >”; }
}
return($strPaginationHtml);
}
?>