I have moved over to using vBa CMPS - here is my new module for tha tportal to show the last month's most popular links:
Link to original posting of this module on vBa homepage
My members requested a different count of the hits - one that "reset" every month to show the current most popular links, not just the All time most popular links...
So I did it.
Replace your current hotlinks.php / install a hotlinks.php module with the following contents:
Code:
<?
// ######################## USER-EDITABLE VAR ############################
// If you want to use the standard VBulletin database table prefix, comment out
// the following line and uncomment the line after it
define('THIS_TABLE', 'local_');
// define ('THIS_TABLE', TABLE_PREFIX);
//
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_misc.php');
global $DB_site, $vboptions, $forumcache;
$limit = "3"; // default number of HotLinks to display in case not set in database
$links_permissions = array();
$links_defaults = array();
$asb = $DB_site->query("SELECT * FROM ".THIS_TABLE."linksadmin");
while ($admin_settings = $DB_site->fetch_array($asb)) {
if (substr($admin_settings["settingname"],0,3) == "can") {
$array = preg_split("/[\s,]+/", $admin_settings["setting"]);
$links_permissions[$admin_settings["settingname"]] = iif(in_array($bbuserinfo[usergroupid], $array), 1, 0);
} else {
$links_defaults[$admin_settings["settingname"]] = $admin_settings["setting"];
}
}
if (isset($links_permissions[can_see_protected_links_on_portal])) {
$cansee = $links_permissions[can_see_protected_links_on_portal];
} else {
$cansee = 0;
}
$thismonth = vbdate("n")-1;
$thisyear = vbdate("Y");
$lastmonth = vbmktime("6","0","0",$thismonth,"1",$thisyear);
$filter = "WHERE link.linkmoderate = 0 AND ldown.usertime > $lastmonth ";
if (!$cansee) {
$limitfids = array(0);
$forumperms = array();
foreach ($forumcache AS $forum) {
$forumperms["$forum[forumid]"] = fetch_permissions($forum['forumid']);
if (!($forumperms["$forum[forumid]"] & CANVIEW) || !($forumperms["$forum[forumid]"] & CANVIEWOTHERS)) {
$limitfids[] = $forum['forumid'];
}
}
$filter .= 'AND link.linkforum NOT IN ('.implode(',', $limitfids).') ';
}
if (isset($links_defaults[categories_seen_on_portal])) {
$catsee = $links_defaults[categories_seen_on_portal];
} else {
$catsee = '';
}
if ($catsee != '') $filter .= 'AND ltoc.catid IN ('.$catsee.')';
if (isset($links_defaults[links_seen_on_portal])) {
$linksee = $links_defaults[links_seen_on_portal];
} else {
$linksee = $limit;
}
$hotquery = "
SELECT DISTINCT link.linkid AS linkid, link.linkname AS linkname, link.linkdesc AS linkdesc,
COUNT(ldown.usertime) AS linkhits, link.linkstatus AS linkstatus,
ltoc.catid AS linkcatid, link.linkhits AS olinkhits
FROM ".THIS_TABLE."linkslink AS link
LEFT JOIN ".THIS_TABLE."linksdownloads AS ldown
ON link.linkid = ldown.linkid
LEFT JOIN ".THIS_TABLE."linksltoc AS ltoc
ON link.linkid = ltoc.linkid
$filter
GROUP BY olinkhits ORDER BY linkhits DESC
LIMIT $linksee
";
$hotties = $DB_site->query($hotquery);
while ($myrow=$DB_site->fetch_array($hotties)) {
$linkid = $myrow["linkid"];
$linkname = parse_bbcode2($myrow["linkname"], 1, 1, 1, 1);
$linkdesc = parse_bbcode2($myrow["linkdesc"], 1, 1, 1, 1);
$linkhits = $myrow["olinkhits"];
$monthhits = $myrow["linkhits"];
$linkstatus = $myrow["linkstatus"];
if ($linkstatus > 1) { // filesize, convert to KB
$linkstatus = intval (round($linkstatus / 1024));
}
eval('$hotlinksbits .= "' . fetch_template('adv_portal_hotlinksbits') . '";');
$nhits++;
}
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_hotlinks') . '";');
?>
Enjoy!