. $ownerresult['lastname'], $subject); $subject = str_replace("", $ownerresult['firstname'] . " " . $ownerresult['lastname'], $subject); $subject = str_replace("", $pricetext, $subject); $subject = str_replace("", $typetext, $subject); $subject = str_replace("", $typetext, $subject); $subject = str_replace("", $customertext, $subject); $subject = str_replace("", $returninstructions, $subject); $emailtext = str_replace("", $row['title'], $emailtext); $emailtext = str_replace("<ownerusername>", $ownerresult['username'], $emailtext); $emailtext = str_replace("<orderid>", $row['rentid'], $emailtext); $emailtext = str_replace("<isbn>", $isbn, $emailtext); $emailtext = str_replace("<cancelreason>", $row['reason'], $emailtext); $emailtext = str_replace("<title>", $row['title'], $emailtext); $emailtext = str_replace("<sku>", $row['sku'], $emailtext); $emailtext = str_replace("<trackinglink>", $link, $emailtext); $emailtext = str_replace("<trackinginfo>", $trackinginfo, $emailtext); $emailtext = str_replace("<address>", $address, $emailtext); $emailtext = str_replace("<shippinglabel>", $row['shippinglabel'], $emailtext); $emailtext = str_replace("<owner>", $ownerresult['firstname'] . " " . $ownerresult['lastname'], $emailtext); $emailtext = str_replace("<ownername>", $ownerresult['firstname'] . " " . $ownerresult['lastname'], $emailtext); $emailtext = str_replace("<pricetext>", $pricetext, $emailtext); $emailtext = str_replace("<ordertype>", $typetext, $emailtext); $emailtext = str_replace("<typetext>", $typetext, $emailtext); $emailtext = str_replace("<customer>", $customertext, $emailtext); $emailtext = str_replace("<returninstructions>", $returninstructions, $emailtext); $emailtext = str_replace("**shippinglabel**", $row['shippinglabel'], $emailtext); $returnvalues = array("{$subject}", "{$emailtext}"); return $returnvalues; } // end replacetags /** * Goes to the DT API and retrieves the book information for a particular * isbn and prepends it to the description * * @param isbn : 12 character isbn value used to identify book * @description : string description we are prepending book information to */ function getbookinfo($isbn, $description) { $apitracking = '&request=' . urlencode($_SERVER['REQUEST_URI']) . '&ip=' . urlencode($_SERVER['REMOTE_ADDR']); // $dtapiurl = "https://www.directtextbook.com/xml.php?key=ece0658aef4f327784f231746e6c433d{$apitracking}&rentalsonly=y&ean={$isbn}"; $useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 FLIPSY'; $curlhandler = curl_init($dtapiurl); curl_setopt($curlhandler, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); curl_setopt($curlhandler, CURLOPT_DNS_CACHE_TIMEOUT, 21600); // 6 hours curl_setopt($curlhandler, CURLOPT_HEADER, 1); curl_setopt($curlhandler, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curlhandler, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlhandler, CURLOPT_TIMEOUT, 5); curl_setopt($curlhandler, CURLOPT_CONNECTTIMEOUT, 4); curl_setopt($curlhandler, CURLOPT_USERAGENT, $agent); $dtcontent = curl_exec($curlhandler); $_curlerror = curl_error($curlhandler); curl_close($curlhandler); // get the content from the api $dtcontent = utf8_encode($dtcontent); // scrape out each of the pieces from the API that we can get $apititle = scrape($dtcontent, '<title>', ''); $author = scrape($dtcontent, '', ''); $edition = scrape($dtcontent, '', ''); $format = scrape($dtcontent, '', ''); $publisher = scrape($dtcontent, "",""); $isbn9 = scrape($dtcontent, "",""); $ean = scrape($dtcontent, "",""); $release = scrape($dtcontent, "",""); if (trim($apititle) != "") $apititle = "Title: " . $apititle . "
"; if (trim($author) != "") $author = "Author: " . $author . "
"; if (trim($edition) != "") $edition = "Edition: " . $edition . "
"; if (trim($publisher) != "") $publisher = "Publisher: " . $publisher . "
"; if (trim($format) != "") $format = "Format: " . $format . "
"; if (trim($isbn9) != "") $isbn9 = "ISBN: " . $isbn9 . "
"; if (trim($ean) != "") $ean = "ISBN 13: " . $ean . "
"; if (trim($release) != "") $release = "Release: " . $release . "
"; // make our description out of what we have available from the api $description = "{$apititle}{$author}{$edition}{$format}{$publisher}{$isbn9}{$ean}{$release}
{$description}"; // return our resulting description return $description; } /** * Goes to the DT API and retrieves the book information for a particular * isbn and prepends it to the description * * @param isbn : 12 character isbn value used to identify book * @description : string description we are prepending book information to */ function getiteminfo($isbn) { $apitracking = '&request=' . urlencode($_SERVER['REQUEST_URI']) . '&ip=' . urlencode($_SERVER['REMOTE_ADDR']); // $dtapiurl = "https://www.directtextbook.com/xml.php?key=ece0658aef4f327784f231746e6c433d{$apitracking}&rentalsonly=y&ean={$isbn}"; $useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US