// Check the included PDF for detailed installation instructions. // No editing required - edit jvplus-config.php instead. require("jvplus-packer.php"); function javascriptCompress($buffer) { $myPacker = new JavaScriptPacker($buffer, 'Normal', true, false); return $myPacker->pack(); } function javascriptLine($input) { $input = preg_replace("/'/", "\'", $input); // Escape slashes $lines = preg_split("/[\r\n]+/si", $input); // Separate into each line $lines = implode("", $lines); // Turn back into a string return $lines; } function javaScriptSafe($input) { $input = preg_replace("/\r?\n/si", "\\n", $input); return $input; } $shareText = ""; $shareFile = dirname(__FILE__) . "/jvplus-share.php"; if (file_exists($shareFile)) { ob_start(); include($shareFile); $shareOutput = ob_get_contents(); ob_end_clean(); $shareText = javascriptLine($shareOutput); } $cssText = ""; $cssFile = dirname(__FILE__) . "/jvplus.css"; if (file_exists($cssFile)) { $cssText = javascriptLine(file_get_contents($cssFile)); } ob_start("javascriptCompress"); header("Content-type:text/javascript"); ?> var hop; var placeholder; if (!placeholder) { placeholder = "xxxxx"; } // JVPlus settings var JVPlus = { hide : false, // Hide links? owner : "", // Default ID ratio : 0, enabled : true, setLinks : function(linkList) { if (linkList == undefined) { linkList = document.links; } for (var i=0;i 0) { // Ratio'd affiliate IDs: // Decide whether to give credit to the referrer or to the site owner JVPlus.ratio = Math.min(JVPlus.ratio, 100); JVPlus.ratio = Math.max(JVPlus.ratio, 0); var realRatio; if (JVPlus.ratio > 1) { realRatio = JVPlus.ratio / 100; } else { realRatio = JVPlus.ratio; } var rand = Math.random(); if (rand > realRatio) { hop = JVPlus.owner; } } } if (hop && hop.match(',')) { var hopList = hop.split(','); var hopIndex = Math.floor(Math.random() * hopList.length); hop = hopList[hopIndex]; } }, cloakAffiliateLink : function(linkObject) { var newURL; if (newURL = lookup(linkObject.href)) { if (JVPlus.hide) { linkObject.onclick = function() { window.location = matchLink(this); return false; }; return true; } else { if (newURL = newURL.replace(placeholder, hop)) { linkObject.href = newURL; return true; } } } return false; }, cloakNormalLink : function(linkObject) { var match; if (match = linkObject.href.match(/^(.*)#(.*)#/)) { var realLink = match[1]; var cloakedLink = '/' + match[2]; linkObject.href = cloakedLink; linkObject.onclick = function() { document.location = realLink; return false; } } }, registry : { } }; var cloak = new Object(); var claim = new Object(); var rebrand = new Object(); // Cookie functions var Cookie = { set : function(name, value, days) { // Default to a 1 year cookie if (days == undefined) { days = 365; } // Format date string var date = new Date(); date.setTime(date.getTime() + (days * 86400000)); // Set cookie name, value, and expiration date document.cookie = name + "=" + value + "; expires=" + date.toGMTString() + "; path=/"; }, get : function(name) { // Find the cookie's value in the document cookie string var results = document.cookie.match( new RegExp("(?:^|; )" + name + "=" + "(.*?)(?:$|;)") ); // Return the value if a match was found, undefined otherwise if (results && results.length > 1) return results[1]; return undefined; }, clear : function(name) { // Erase a cookie setCookie(name, "", -1); } }; document.getElementsByClassName = function(clsName){ var retVal = new Array(); var elements = document.getElementsByTagName("*"); for(var i = 0;i < elements.length;i++) { if (elements[i].className.indexOf(" ") >= 0) { var classes = elements[i].className.split(" "); for(var j = 0;j < classes.length;j++){ if(classes[j] == clsName) { retVal.push(elements[i]); } } } else if(elements[i].className == clsName) { retVal.push(elements[i]); } } return retVal; }; // Procedural code JVPlus.brand(); var shareLayer; if (shareLayer = document.getElementById("jvplus-share")) { shareLayer.innerHTML = ''; } document.write(''); function cobrand(layer, customHopLayer) { var localHop; if (hopObject = document.getElementById(customHopLayer)) { localHop = hopObject.value; } else { localHop = hop; } if (layer.length && layer.length > 0) { for (i in layer) { cobrand(layer[i]); } return; } //var updateText = layer.id + ": href = " + layer.href + ", src = " + layer.src + ", value = " + layer.value; //alert("localHop = " + localHop); // Edit the HREF attribute if this is a link if (layer.id == "localHop") { /* give up */ } else if (layer.href) { layer.href = layer.href.replace(placeholder, localHop); } // Edit the SRC attribute if this is an iframe else if (layer.src) { layer.src = layer.src.replace(placeholder, localHop); } // Edit the VALUE attribute if this is a form element else if (layer.value) { var layerID = layer.id; if (!JVPlus.registry[layerID]) { JVPlus.registry[layerID] = layer.value; } if (localHop) { layer.value = JVPlus.registry[layerID].replace(placeholder, localHop); } else { layer.value = JVPlus.registry[layerID]; } } // Otherwise, edit the innerHTML attribute if this is a text layer else if (layer.innerHTML) { var rebrandText = null; if (!rebrandText) { rebrandText = rebrand[localHop]; } if (!rebrandText) { rebrandText = getClaim(document.referrer, rebrand); } if (rebrandText) { layer.innerHTML = rebrandText; } } } function lookup(url) { for (name in cloak) { // Find out if the link matches any of our non-affiliate links //var re = new RegExp(name + "/?$"); var re = new RegExp(name); if (url.match(re)) { return cloak[name]; } } return null; } function matchLink(obj) { var realURL; if (realURL = lookup(obj.href)) { newURL = realURL.replace(placeholder, hop); return newURL; } return true; } function getParameter(parameter, url) { if (url == undefined) { url = window.location.search.substring(0); } else { url = url.substring(0); } if (url == "") { return undefined; } var results = url.match( new RegExp("(?:&|\\?)" + parameter + "=(.*?)(?:&|$)", "") ); if (results && results != null && results.length >= 1) { return unescape(results[1]); } return undefined; } function getClaim(refer, haystack) { if (haystack == undefined) { haystack = claim; } if (refer == undefined) { refer = document.referrer; } for (claimURL in haystack) { if (refer.match(claimURL)) { var affiliateID = haystack[claimURL]; return affiliateID; } } }