<?php /** * This plugin can be used to insert a graphical or text counter on your page * * History: * v0.1: initial plugin */ class NP_Counter extends NucleusPlugin { /** * Plugin data to be shown on the plugin list */ function getName() { return 'Hit Counter'; } function getAuthor() { return 'Hop Nguyen'; } function getURL() { return '<a href="http://www.mrhop.com/">http://www.mrhop.com/</a>'; } function getVersion() { return '.1'; } function getDescription() { return 'Can be called from within skins to insert a hit counter on your site by using <%Counter%>.'; } /** * On plugin install, three options are created */ function install() { // create some options $this->createOption('Count','Current Count','text','0'); $this->createOption('InstallTime','Install Time','text',date('j-n-Y')); $this->createOption('Image','Graphical Counter','yesno','no'); $this->createOption('ImageDir','Relative image directory. EA: /imagedir/','text','/media/1/'); $this->createOption('ImageExtension','Image Extension (must have period. EA: .gif, .jpg)','text','.gif'); $this->createOption('Format','How you want it to look. (Key words HITS and DATE are required)','text','<div class="Counter">HITS hits<br /> as of <br /> DATE</div>'); } function doSkinVar($skinType) { global $manager, $blog, $CONF; $current = $this->getOption(Count); $current++; $imgsrc = ""; $this->setOption(Count,$current); if ($this->getOption(Image) == "yes") { $num = strlen ($current); $i = 0; while ($i < $num) : $graphic = substr ($current, $i, 1); $imgsrc .= '<img src="'.$this->getOption(ImageDir).$graphic.$this->getOption(ImageExtension).'" border="0" alt="'.$graphic.'">'; $i++; endwhile; $emittext = ereg_replace('HITS', $imgsrc, $this->getOption(Format)); } else { $emittext = ereg_replace('HITS', $this->getOption(Count), $this->getOption(Format)); } $emittext = ereg_replace('DATE', $this->getOption(InstallTime), $emittext); echo $emittext; } } ?>