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...

Natch 08-03-2004 04:32 AM

Thanks buddy :)

AndrewD 08-03-2004 04:35 AM

Those concerned about bandwidth and not about file theft might try the following patch. Edit local_links.php and find line: (about line 1900, depending on version)

PHP Code:

if ($_REQUEST['action'] == "jump") { 

About 50 lines further down find these lines
PHP Code:

if (!is_array($mimetype)) { 
// no mimetype, so assume this is a regular link
        
$hit record_hit($id$url$LINK_OK);
        eval(
print_standard_redirect('Redirecting.',0));
    } else { 

Change the
PHP Code:

if (!is_array($mimetype)) { 

to something that is always true, e.g.
PHP Code:

if (1) { 

All link/file accesses will then be handled as redirects, so I imagine this will reduce bandwidth use for files with known mimetypes coming from a remote site.

The change will have no effect for filetypes that do not have recognised filetypes, and I suspect that it will have little if any effect for files held on your own server (but I may be wrong).

However, this improvement is at the cost of potentially making visible where the files are stored and it also causes one or two changes in the way windows are opened.

Appreciate feedback. Cheers.

Natch 08-03-2004 04:40 AM

So there is no way to have leech-protection on but without the doubled bandwidth use?

AndrewD 08-03-2004 05:09 AM

Quote:

Originally Posted by Natch
So there is no way to have leech-protection on but without the doubled bandwidth use?

Not that I've found. Seems to me that you either ask the server to read the file and pass it on in a controlled way to the client (sequences of fopen/fread/fclose), or you ask the client to go away and read the file for itself (javascript or meta tag). If the server reads the file, then by definition twice the bandwidth is used. If the client reads the file, then you have to tell it which file to read.

But I may be wrong :rolleyes: and would be delighted to learn :squareeyed:

Natch 08-03-2004 11:05 AM

You should be able to cause your PHP script to redirect to a second PHP script designed just to mask the location - it would contain just a
Code:

Header: mime-type yadda yadda
statement followed by the contents of the file - if the file is local then there hsould be no bandwidth increase ... am I totally off base here ?

AndrewD 08-03-2004 11:09 AM

Quote:

Originally Posted by Natch
You should be able to cause your PHP script to redirect to a second PHP script designed just to mask the location - it would contain just a
Code:

Header: mime-type yadda yadda
statement followed by the contents of the file - if the file is local then there hsould be no bandwidth increase ... am I totally off base here ?

Yes, that's essentially what the current code does, and it works fine. The question that was raised concerns the increased bandwidth when the file to be downloaded is held on a third machine. In that case, the main server has to read the file before downloading it. Alternatively the browser can be told to launch itself and read the third party file, but in that case one cant keep the location secret.

lmongello 08-05-2004 08:24 PM

Forgive the stupid question, but I'm going crazy with this...

I want to restrict access to this page to registered members only. I tried creating a forum with a link to local_links.php using permissions in the Vb Admin, but that prevents unregistered members from seeing the list only.

I want them to see the forum (or sub-forum, etc.), but if they try and acess it, they get redirected to the "Sorry, you are not logged in or registered" page.

Hoping someone here can help!!

Thanks!!!!!

AndrewD 08-06-2004 04:25 PM

Quote:

Originally Posted by lmongello
Forgive the stupid question, but I'm going crazy with this...

I want to restrict access to this page to registered members only. I tried creating a forum with a link to local_links.php using permissions in the Vb Admin, but that prevents unregistered members from seeing the list only.

I want them to see the forum (or sub-forum, etc.), but if they try and acess it, they get redirected to the "Sorry, you are not logged in or registered" page.

Hoping someone here can help!!

Thanks!!!!!

You want all the subcategories in a category to be visible regardless of their forum protection, but to trigger a login page if someone tries to drill down into a category that is protected for member access only?

I think this will work:

Edit local_links.php
Find lines (about line 600 or so)

PHP Code:

    // Get categories at this level
    
foreach ($linkscat AS $thiscat) {
        if (
$thiscat["parentid"] == $viewcatid and !in_array($thiscat["catforum"], $limitfids)) {
            if (
$thiscat['catmoderate'] and $bbuserinfo['userid'] != $thiscat['catuserid']) continue; 

Replace by

PHP Code:

    // Get categories at this level
    
foreach ($linkscat AS $thiscat) {
        if (
$thiscat["parentid"] == $viewcatid) {
            if (
$thiscat['catmoderate'] and $bbuserinfo['userid'] != $thiscat['catuserid']) continue; 

Let me know if this is what you want, and if this should be a switch on the admin page

tteal 08-11-2004 09:22 PM

First and foremost, thank you for making this modification available! Secondly, I was wondering if I could make a recommendation?

- For each "affiliate", would it be possible to add a feature on for users to be able to post a comment on their experience? I realize that you're rating the affiliate, however, comments help out a lot to discuss what you liked/dis-liked about their service, etc.

Thanks,
Tim

Natch 08-11-2004 11:48 PM

Quote:

Originally Posted by AndrewD
Yes, that's essentially what the current code does, and it works fine. The question that was raised concerns the increased bandwidth when the file to be downloaded is held on a third machine. In that case, the main server has to read the file before downloading it. Alternatively the browser can be told to launch itself and read the third party file, but in that case one cant keep the location secret.

Thanks for clarifying - my mistake - I guess my increased bandwidth is jsut cos I'm getting more visitors ;)

Polo 08-12-2004 08:17 PM

Awesome Addon!

Clicks install

AndrewD 08-13-2004 03:31 AM

Quote:

Originally Posted by tteal
First and foremost, thank you for making this modification available! Secondly, I was wondering if I could make a recommendation?

- For each "affiliate", would it be possible to add a feature on for users to be able to post a comment on their experience? I realize that you're rating the affiliate, however, comments help out a lot to discuss what you liked/dis-liked about their service, etc.

Thanks,
Tim

I think this is an excellent idea. I'll think about how easy it is to add on without writing loads of new code - in effect we're looking for a way to tie a new VB discussion thread to a link.

darkmage 08-13-2004 01:50 PM

Quote:

Originally Posted by Natch
Thanks for clarifying - my mistake - I guess my increased bandwidth is jsut cos I'm getting more visitors ;)

I have an idea, I'm not sure if it was discussed in pages before this one but, if you use this script as a downloads page for your website, would it be possible to link to the file directly but make a entry page if coming from an outside website.

Such as if you come from google.com and you request http://forums.blah.com/local_links.php?action=jump&id=1 it would not request the file directly, but it would open up a page that you must first click the download now link before you can continue with the download. Therefore making it 100% (I think) leech proof. However right now I am using the method where users must be logged in before they can download a file.

Meltingfire 08-14-2004 12:35 PM

I love your script and have been using it for a pretty long time now! Great work!

But lately i have noticed a small problem when linking to files at SourceForge, both in v1.10 and still in v1.25 (upgraded today).

Since you link to a zip-file at sourceforge the url ends with ".zip" but when you click on the link you get to a webpage with mirrors.

So when you try to download the file you get a text file (name.zip) that contains the HTML page.

Is it possible for the links & filedatabase to be able to check if its really a zip-file and if its not then the webpage will be shown instead with the mirrors at sourceforge.

(Btw, it can be any file-formats, not only zip)

AndrewD 08-14-2004 07:22 PM

Quote:

Originally Posted by Meltingfire
I love your script and have been using it for a pretty long time now! Great work!

But lately i have noticed a small problem when linking to files at SourceForge, both in v1.10 and still in v1.25 (upgraded today).

Since you link to a zip-file at sourceforge the url ends with ".zip" but when you click on the link you get to a webpage with mirrors.

So when you try to download the file you get a text file (name.zip) that contains the HTML page.

Is it possible for the links & filedatabase to be able to check if its really a zip-file and if its not then the webpage will be shown instead with the mirrors at sourceforge.

(Btw, it can be any file-formats, not only zip)

I see what you mean. There's a signal, which is the parameter after the .zip file name at sourceforge, i.e. ?download. I'll check whether we can do anything about this.

AndrewD 08-15-2004 05:00 AM

Sourceforge provides links that have URLs looking like zip files, etc, but are treated as an instruction to redirect to the mirrors page where you actually choose the mirror you want. Perhaps other sites do the same. Versions of this hack up to 1.25 fail to spot this and give you a download which is actually the html code for the redirect.

To fix this, find the following code in local_links.php (line 1896 in version 1.25)

Code:

$dfname  = basename($urlInfo['path']);
$type        = substr(strrchr($dfname, "."), 1);

$mimetype = get_mimetype($type);

if (!is_array($mimetype)) {

Replace
Code:

if (!is_array($mimetype)) {
with
Code:

if (!is_array($mimetype) or $urlInfo['query'] != "") {
This should fix the problem. Please advise.

AndrewD 08-15-2004 05:17 AM

Quote:

Originally Posted by darkmage
I have an idea, I'm not sure if it was discussed in pages before this one but, if you use this script as a downloads page for your website, would it be possible to link to the file directly but make a entry page if coming from an outside website.

Such as if you come from google.com and you request http://forums.blah.com/local_links.php?action=jump&id=1 it would not request the file directly, but it would open up a page that you must first click the download now link before you can continue with the download. Therefore making it 100% (I think) leech proof. However right now I am using the method where users must be logged in before they can download a file.

I have another thought, which is to put a
Code:

<meta name="robots" content="index, nofollow">
tag in the links_header template. (i.e. the engine can check the page for links but must not follow those links, i.e. trigger a download). Anyone know whether search engines are reliable on this? - years ago, reports were that many did not interpret the tag. Google follows the rules, I think.

Natch 08-16-2004 12:02 AM

Good work on the continued support - this script is gaining in maturity every day :D

darkmage 08-16-2004 04:02 AM

Quote:

Originally Posted by Natch
Good work on the continued support - this script is gaining in maturity every day :D

I was wondering that since you have the categories ordered by their alphabetical order, could you tell me the line of code to change to make it so it orders the categories by their ID?

Thanks.

AndrewD 08-16-2004 06:01 AM

Quote:

Originally Posted by darkmage
I was wondering that since you have the categories ordered by their alphabetical order, could you tell me the line of code to change to make it so it orders the categories by their ID?

Thanks.

Look for the following (about 150+ lines in to local_links.php depending on version)
PHP Code:

function get_linkscat() {
    global 
$DB_site$linkscat$linkscat_set;

    if (!
$linkscat_set) {
        
$asb $DB_site->query("SELECT * FROM ".THIS_TABLE."linkscat ORDER BY catname"); 

Change catname to catid or catdate as you will.

Should this be a configuration option?

darkmage 08-16-2004 03:13 PM

Quote:

Originally Posted by AndrewD
Look for the following (about 150+ lines in to local_links.php depending on version)
PHP Code:

function get_linkscat() {
    global 
$DB_site$linkscat$linkscat_set;

    if (!
$linkscat_set) {
        
$asb $DB_site->query("SELECT * FROM ".THIS_TABLE."linkscat ORDER BY catname"); 

Change catname to catid or catdate as you will.

Should this be a configuration option?

Thank you soo much! I would say that this would be a nice little configuration option. :)

kingady 08-17-2004 01:43 PM

<a href="http://www.hl2insider.net/forums/local_links.php" target="_blank">http://www.hl2insider.net/forums/local_links.php</a>

ive set it up, im in admin area, now how do i add categories? ive tried everything to add categories/files, help ;p

AndrewD 08-17-2004 01:49 PM

Quote:

Originally Posted by kingady
http://www.hl2insider.net/forums/local_links.php

ive set it up, im in admin area, now how do i add categories? ive tried everything to add categories/files, help ;p

You use the left hand item on the Links toolbar (Links). The drop down will have an item "Add Category".

kingady 08-17-2004 01:52 PM

thanks alot mate, also this is members only access right?

AndrewD 08-17-2004 01:53 PM

Quote:

Originally Posted by kingady
thanks alot mate, also this is members only access right?

You set the permissions in the admin panel - Each action (view, add, edit, delete/link, category) has its own set of permissions

kingady 08-17-2004 01:55 PM

ooops, sorry i meant for downloading the files.

also is it possible to mask the download link for example:

download link: www.sitename.com/video/file.rar

to http://www.sitename.com/forums/local....php?getfile=3

if u understand what i mean =)

AndrewD 08-17-2004 04:27 PM

Quote:

Originally Posted by kingady
ooops, sorry i meant for downloading the files.

also is it possible to mask the download link for example:

download link: www.sitename.com/video/file.rar

to http://www.sitename.com/forums/local....php?getfile=3

if u understand what i mean =)

Access to individual links and categories is controlled by assigning them to a forum on your board. Create a standard VBulletin forum which is only visible to your members. Then, go into the links admin panel, and set the default_forumid setting to the forumid of that forum. Then, by default all your new links will be protected from non-members.

kingady 08-17-2004 09:36 PM

so the forum id is for example: http://www.hl2insider.net/forums/forumdisplay.php?f=17

17?

because i added a members only section that members can only see (forum) and i entered the forum id 27 because the ending was 27 am i correct?

becausei tried it , still didnt work

AndrewD 08-18-2004 04:00 AM

Quote:

Originally Posted by kingady
so the forum id is for example: http://www.hl2insider.net/forums/forumdisplay.php?f=17

17?

because i added a members only section that members can only see (forum) and i entered the forum id 27 because the ending was 27 am i correct?

becausei tried it , still didnt work

That's right and it should work - but you need to apply the setting also to any links/categories that you created *before* setting forumid 27 as your default. If you PM details of an admin account on your board, I'll take a quick look.

kingady 08-18-2004 01:05 PM

aye i pmed u details and minutes later i knew what u meant, im kinda slow.. lol thanks!!!!!!!!!!!!


All times are GMT. The time now is 03:19 AM.

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.03341 seconds
  • Memory Usage 1,908KB
  • 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
  • (7)bbcode_code_printable
  • (8)bbcode_php_printable
  • (21)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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