Please note the development of this plugin has been discontinued. It is recommended you use NP_Referrer.
No documentation here. Please visit the forum.
<? // script to create log of referrers to each article // VERSION 0.32 For details please see README file included with distribution // v0.32 by http://weblog.PlasticThinking.org class NP_LinkBack extends NucleusPlugin { // name of plugin function getName() { return 'Link Back'; } // author of plugin function getAuthor() { return 'Mat Bennett'; } // an URL to the plugin website // can also be of the form mailto:foo@bar.com function getURL() { return 'http://www.matbennett.com/'; } // version of the plugin function getVersion() { return '0.31'; } // a description to be shown on the installed plugins listing function getDescription() { return 'Creates links to the last referring pages. Call with &%LinkBack(5,last)%& to show the last 5 referrers. (more options to follow)'; } function doTemplateVar(&$item,$refs2list,$show) { global $HTTP_REFERER; global $HTTP_HOST; global $itemid; $logtime = time(); $new_ref = $HTTP_REFERER; //remove unwanted referrers (add own domain to this list) google, aol, askjeeves, hotbot, yahoo, aolsearch, alltheweb, altavista, excite, web can be used too $filterlist=array("topsearcher","overture"); $parsed_ref=parse_url($new_ref); $ref_parts=explode("/", $new_ref); $ref_host=explode(".", $ref_parts[2]); // ignore referrer blockers if($ref_parts[0]!=="http:"){ $new_ref=""; } // ignore if referrer is this domain if ($ref_parts[2] == $HTTP_HOST) { $new_ref=""; } // ignore filtered domains foreach($filterlist as $key => $key2) { if(in_array($key2, $ref_host)||in_array($key2, $ref_parts)) { $new_ref=""; } } // if we still have a referrer after all that, write it to the database if ($new_ref){ // find the page title $fd = @fopen ($new_ref, "r"); if ($fd){ $ref_str = fread($fd, 200); if (eregi("<title>(.*)</title>", $ref_str, $out)) { $title = htmlspecialchars ($out[1],ENT_QUOTES); } } // set title to domain name if above does not find it if (!$title){ $title = $ref_parts[2]; } sql_query ("INSERT into nucleus_plug_lb_log (inum,ref_when,ref_url,ref_title) VALUES ('$itemid', '$logtime', '$new_ref','$title')"); $check_dom = mysql_query("SELECT * FROM nucleus_plug_lb_top WHERE ref_domain = '$ref_parts[2]'"); if (!$no_dom = mysql_num_rows($check_dom)){ sql_query ("INSERT into nucleus_plug_lb_top (ref_domain) VALUES ('$ref_parts[2]')"); } sql_query ("UPDATE nucleus_plug_lb_top SET ref_total = ref_total + 1 WHERE ref_domain = '$ref_parts[2]'"); } // start the output if (($refs2list > 0) AND ($show == 'last')){ $query = mysql_query("SELECT ref_url, ref_title from nucleus_plug_lb_log WHERE inum = '$itemid' ORDER BY ref_when DESC LIMIT 0, $refs2list"); if (mysql_num_rows($query)){ echo '<h2>Die '.$refs2list.' aktuellsten Referrers</h2><div class="commentbody">'; } while ($refs_array = mysql_fetch_array($query)){ echo "<a href=\"".$refs_array["ref_url"]."\">".$refs_array["ref_title"]."</a><br>"; } if (mysql_num_rows($query)){ echo '</div>'; } } } function install(){ // create required table sql_query ("CREATE TABLE `nucleus_plug_lb_log` ( `inum` INT(11) NOT NULL, `ref_when` INT(10) NOT NULL, `ref_url` VARCHAR(160) NOT NULL, `ref_title` VARCHAR(80) NOT NULL )"); sql_query ("CREATE TABLE `nucleus_plug_lb_top` ( `ref_domain` VARCHAR(60) NOT NULL, `ref_total` INT(10) DEFAULT '0' NOT NULL, PRIMARY KEY (`ref_domain`) )"); } function uninstall(){ // delete created tables on uninstall sql_query ("DROP TABLE `nucleus_plug_lb_log`"); sql_query ("DROP TABLE `nucleus_plug_lb_top`"); } function getTableList() { return array('nucleus_plug_lb_log', 'nucleus_plug_lb_top'); } } ?>
:: Plugins ::