vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Links and Files Database (https://vborg.vbsupport.ru/showthread.php?t=60403)

Natch 07-21-2004 10:41 AM

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!

digicreations 07-21-2004 12:01 PM

is there anyway to get this nice system to handle ftp protocol for public ftp's?

AndrewD 07-26-2004 04:08 AM

Quote:

Originally Posted by digicreations
is there anyway to get this nice system to handle ftp protocol for public ftp's?

I think this will be possible - the php routine the hack uses can handle FTP exactly as HTTP. Next version.

AndrewD 07-26-2004 04:10 AM

Quote:

Originally Posted by vonedaddy
I installed an it works great. Thanks... ONE QUICK QUESTION... Where in the templates is the forum jump?? I would like to remove the forums jump drop down menu.

See it here : http://hereyah.com/forums/local_links.php?action=links

Sorry for the delay - vacation time :). It's in the links_header template

AndrewD 07-26-2004 04:11 AM

Quote:

Originally Posted by EnriqueHavoc
Hi Andrew thanks for this awesome script.

*note- Im using 1.22 because my php/mysql is not up to date so i apologize if this has been address in 1.25

Question: How can I alternate the linkbit TD colors for each link and category displayed?

Ive tried editing the linkbit using if conditions with $linkid and it works but when the links are sorted, it throws off the alternating sequence. How can I edit the templates so that the links/categories will always alternate color regardless of how they are sorted?

I'll deal with this in the next version. Thanks.

EnriqueHavoc 07-29-2004 07:54 PM

Thanks very much.. hope you had a good vacation!

Another question:

When linking to an external file, it appears the file is using twice the bandwidth I would expect.. First when its pulled from the external host, and then again when it goes through local_links on my host... is this by design?

AndrewD 08-02-2004 04:29 AM

Quote:

Originally Posted by EnriqueHavoc
Thanks very much.. hope you had a good vacation!

Another question:

When linking to an external file, it appears the file is using twice the bandwidth I would expect.. First when its pulled from the external host, and then again when it goes through local_links on my host... is this by design?

That's probably right, as each file is read by the server and then re-written to the client. It's by design as part of the "anti leech" process. It is easy to change if necessary, but bandwidth is less of a concern for our site than theft.

On your earlier question, it's straightfoward to have alternating "alt1" and "alt2" bands in the link and category displays. A few lines of code (in get_linklistbit, etc) keep a variable in even/odd sequence, and the link and category templates have to be modified to use that variable when setting the style.

Natch 08-02-2004 05:33 AM

Could you post the modification (or add it as an option) to provide the anti-leech facade but without the passthru (if possible)?

SandsUSA 08-02-2004 01:21 PM

Quote:

Originally Posted by Natch
Could you post the modification (or add it as an option) to provide the anti-leech facade but without the passthru (if possible)?

Yes, I'd be interested in reducing my bandwidth also.....

AndrewD 08-02-2004 07:06 PM

Quote:

Originally Posted by Natch
Could you post the modification (or add it as an option) to provide the anti-leech facade but without the passthru (if possible)?

Will do. Give me a few days to check the side effects...


All times are GMT. The time now is 06:29 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02038 seconds
  • Memory Usage 1,764KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (4)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete