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)
-   -   List latest X paid subscribers on Forum Home (https://vborg.vbsupport.ru/showthread.php?t=65254)

tamarian 05-17-2004 10:00 PM

List latest X paid subscribers on Forum Home
 
There's also a vB 3.5 version here: https://vborg.vbsupport.ru/showthrea...threadid=99049

What this hack does: This hack will list and instantly refresh (when a new subscription is made) a list of the latest X paid subscribers to your forum. It's a nice way of recognizing members who help pay the the forum bills, and encourages others to join.

Demo: http://forum.lowcarber.org

PHP edits:
1. 2 edits in index.php
2. 1 edit in includes/functions.php
3. 2 edits in includes/functions_subscriptions.php

Template edits:
1. 1 new template: thanks
2. 1 edit in FORUMHOME

Installation:

1. In index.php

Find:

PHP Code:

'FORUMHOME'

Add after:

PHP Code:

'thanks'

Find:

PHP Code:

// ### TODAY'S BIRTHDAYS 

Add before:

PHP Code:

$thanks $templatecache['thanks']; 

2. In include/functions.php

At the end of the file, just before the end/footer stuff,
Code:

/*======================================================================*\
|| ####################################################################
|| # Downloaded: Thu Apr 15th 2004
|| # CVS: $RCSfile: functions.php,v $ - $Revision: 1.967 $
|| ####################################################################
\*======================================================================*/
?>

add before:
PHP Code:

// ###################### thankyou #######################
function thankyou(){
      global 
$DB_site;

    
// This is the template for usernames
    
$thanksbit ' <a href=\"member.php?$session[sessionurl]u=$contributer[userid]\"><font color=\"#228E8E\"><b>$contributer[username]</b></font></a>';

    
$latestcontributers $DB_site->query("SELECT username, status,regdate,  subscriptionlog.userid
                FROM " 
TABLE_PREFIX "subscriptionlog AS subscriptionlog
                LEFT  JOIN " 
TABLE_PREFIX "user AS user
                USING ( userid )
                WHERE user.userid = subscriptionlog.userid
                AND STATUS = '1'
                ORDER  BY  regdate  DESC
                LIMIT 5"
);

    
$latest_str '';
    while (
$contributer $DB_site->fetch_array($latestcontributers))
    {
        eval(
"\$latest_str .= ', ' . \"$thanksbit\";");
    }
    
$latest_str substr($latest_str 2);
    
$latest_str addslashes($latest_str);
    
$DB_site->query("UPDATE " TABLE_PREFIX "template SET template=\"$latest_str\", template_un=\"$latest_str\"  WHERE title='thanks'");


Note 1: Change "LIMIT 5" to any number. By default, it will show the latest 5 paid subscribers. If you want to show the latest 3, simply change to "LIMIT 3".
Note2 The template for usernames is in the code. To change the style and colour, edit this line from the code you added to functions.php:
PHP Code:

    $thanksbit ' <a href=\"member.php?$session[sessionurl]u=$contributer[userid]\"><font color=\"#228E8E\"><b>$contributer[username]</b></font></a>'


3. In includes/functions_subscriptions.php

Find:

PHP Code:

}
      
      
// ###################### Start leavesubscription #######################
      
      
function delete_user_subscription($subscriptionid$userid

Add before (before the bracket):

PHP Code:

thankyou(); 

Find:

PHP Code:

}
      
      
// ###################### Start getsubscriptionscache #######################
      
function cache_user_subscriptions() 

Add before (before the bracket:

PHP Code:

thankyou(); 

4. Create a new template: thanks

Leave the new template empty

5. Edit the FORUMHOME template

Add $thanks where you want the list of members to appear.

For example, I use this in the stats area of FORUMHOME:

Code:

<div>Thanks latest <a href="subscriptions.php">contributing members</a>: $thanks</div>
6. First run To auto fill the list for the first time, you just need to edit an existing subscription, or just wait for the next subscription to arrive.

To auto fill it right now: Simply go to your admin control panel, click on subscriptions, view list, edit any existing subscription, for example, add 1 day to the subscription of a member, and save. You can re-edit to subtract the 1 day if you want.

ryancooper 05-18-2004 09:13 PM

This looks great! any way to make it work with vbportal?

tamarian 05-18-2004 09:42 PM

Quote:

Originally Posted by ryancooper
any way to make it work with vbportal?

I think it would be quite easy, but I've never used vbportal.

Let's see if any vbportal expert can suggest the right template edits.

jilly 05-20-2004 09:19 PM

the top of the template says Warning: Invalid argument supplied for foreach() in /web/forums/includes/functions.php on line 2871

tamarian 05-20-2004 09:53 PM

Quote:

Originally Posted by jilly
the top of the template says Warning: Invalid argument supplied for foreach() in /web/forums/includes/functions.php on line 2871

Could you post what you added to functions.php, and specify which line is 2871.

jilly 05-21-2004 12:48 AM

this is line 2871 in my functions.php


// ###################### Start bits2array #######################
// takes a bitfield and the array describing the resulting fields
function convert_bits_to_array(&$bitfield, $_FIELDNAMES)
{
$bitfield = intval($bitfield);
$arry = array();
foreach ($_FIELDNAMES AS $field => $bitvalue) {
if ($bitfield & $bitvalue)
{
$arry["$field"] = 1;
}
else

{
$arry["$field"] = 0;
}
}
return $arry;
}


and I added the thank you code right above the end of the file, here:


// ###################### thankyou #######################
function thankyou(){
global $DB_site, $stylevar, $vboptions, $vbphrase;

require_once('./global.php');

$latestcontributers = $DB_site->query("SELECT username, subscriptionlog.userid
FROM " . TABLE_PREFIX . "subscriptionlog AS subscriptionlog
LEFT JOIN " . TABLE_PREFIX . "user AS user
USING ( userid )
WHERE user.userid = subscriptionlog.userid
AND STATUS = '1'
ORDER BY regdate DESC
LIMIT 10");

$latest_str = "";
while ($contributer = $DB_site->fetch_array($latestcontributers))
{
eval ('$latest_str .= ", ' . fetch_template('thanksbit') . '";');
}
$latest_str = substr($latest_str , 2);
$latest_str = addslashes($latest_str);
$DB_site->query("UPDATE " . TABLE_PREFIX . "template SET template=\"$latest_str\", template_un=\"$latest_str\" WHERE title='thanks'");
}


/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded: 18:53, Tue Apr 27th 2004
|| # CVS: $RCSfile: functions.php,v $ - $Revision: 1.967 $
|| ################################################## ##################
\*================================================ ======================*/
?>


I couldnt post the whole file, it was too big

tamarian 05-21-2004 01:00 AM

This is strange, as that portion of the code is not related.

Try this: remove the thankyou stuff from the bottom of functions.php (and from functions_subscriptions.php), and see if this still keeps happening. It might be totally unrelated.

rookie7 05-28-2004 11:07 PM

Great hack! *install*

Bryan Ex 06-02-2004 09:44 PM

I'd really like to use this but I use a third party script for subscriptions that moves users in and out of a specified usergroup. Is there a way this could query a usergroup ID instead of the subscription logs?

tamarian 06-02-2004 10:01 PM

Quote:

Originally Posted by Bryan Ex
I'd really like to use this but I use a third party script for subscriptions that moves users in and out of a specified usergroup. Is there a way this could query a usergroup ID instead of the subscription logs?

But that won't be enough, since there would be no way to determine "last X", since there's no place to keep a record of the date the user changed usergroups by that 3rd party script.

Bryan Ex 06-02-2004 10:12 PM

You're right. I forgot that there was no date references for usergroups. I'll have to come back to this one I guess once I have some time to play around with it. I'm still trying to restore everything after upgrading to 3.0.1.

kall 06-28-2004 10:48 PM

I'm getting foreach errors also..

One question: when you say 'before the bracket', do you mean 'before the curly bracket' or 'before the round bracket?'

I currently have:
PHP Code:

 thankyou(); 
}

// ###################### Start leavesubscription #######################
function delete_user_subscription($subscriptionid$userid)


and
PHP Code:

    ");
    }

 thankyou();

}

// ###################### Start getsubscriptionscache #######################
function cache_user_subscriptions() 


tamarian 06-28-2004 11:16 PM

Kall, the "thankyou();" line should be plasced above the quoted code.

The code you posed (the first block) look fine.

If you still have problems, email me the two files and I'll take a look.

tamarian 06-29-2004 12:53 AM

For those interested, I've had a few emails back and forth with Kall, and he emailed me several of his forum files to investigate.

The conclusion is as follows:

1. The "foreach" warning is a result of another hack, in combination with this hack. The other hack is the "store cash hack". The line numbers reported in the warning is not related to this hack.

2. Despite the warning, both hacks seem to work fine, with no problems, so you can ignore it. :)

Cold Steel 07-04-2004 11:17 AM

I'm getting errors, too:

Quote:

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/global.php on line 645

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/includes/functions.php on line 2895

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/includes/functions.php on line 2895

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/includes/functions.php on line 2895



Database error in vBulletin 3.0.1:

Invalid SQL: SELECT username, subscriptionlog.userid
FROM subscriptionlog AS subscriptionlog
LEFT JOIN user AS user
USING ( userid )
WHERE user.userid = subscriptionlog.userid
AND STATUS = '1'
ORDER BY regdate DESC
LIMIT 5
mysql error: Column: 'STATUS' in where clause is ambiguous

mysql error number: 1052

Date: Sunday 04th of July 2004 07:16:12 AM
Script: http://forums.asiansinc.com/admincp/subscriptions.php
Referer: http://forums.asiansinc.com/admincp/...iptionlogid=12
Username: Webmaster
IP Address:
I'm unable to edit subscriptions.

I have the ucash/ustore hack installed, as well as the recurring paypal hack.

tamarian 07-04-2004 11:37 AM

Quote:

Originally Posted by Cold Steel
I'm getting errors, too:


I'm unable to edit subscriptions.

I have the ucash/ustore hack installed, as well as the recurring paypal hack.

The "foreach" error is not a problem, but the mysql error is a problem. I've made an update to the first post.

You just need to re-do step 2 with this code:

PHP Code:

    // ###################### thankyou #######################
    
function thankyou(){
          global 
$DB_site,  $stylevar$vboptions$vbphrase;
    
        require_once(
'./global.php');
    
        
$latestcontributers $DB_site->query("SELECT username, status, regdate,   subscriptionlog.userid
                    FROM " 
TABLE_PREFIX "subscriptionlog AS subscriptionlog
                    LEFT  JOIN " 
TABLE_PREFIX "user AS user
                    USING ( userid )
                    WHERE user.userid = subscriptionlog.userid
                    AND STATUS = '1'
                    ORDER  BY  regdate  DESC
                    LIMIT 5"
);
    
        
$latest_str "";
        while (
$contributer $DB_site->fetch_array($latestcontributers))
        {
            eval (
'$latest_str .= ", ' fetch_template('thanksbit') . '";');
        }
        
$latest_str substr($latest_str 2);
        
$latest_str addslashes($latest_str);
 
$DB_site->query("UPDATE " TABLE_PREFIX "template SET template=\"$latest_str\", template_un=\"$latest_str\" WHERE title='thanks'");
    } 


Cold Steel 07-04-2004 12:19 PM

Thanks for the prompt response. Now I'm getting this error:

Quote:

Database error in vBulletin 3.0.1:

Invalid SQL: SELECT username, status, regdate subscriptionlog.userid
FROM subscriptionlog AS subscriptionlog
LEFT JOIN user AS user
USING ( userid )
WHERE user.userid = subscriptionlog.userid
AND STATUS = '1'
ORDER BY regdate DESC
LIMIT 5
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '.userid
FROM subscriptionlog AS subscription

mysql error number: 1064

Date: Sunday 04th of July 2004 08:19:39 AM
Script: http://forums.asiansinc.com/admincp/subscriptions.php
Referer: http://forums.asiansinc.com/admincp/...iptionlogid=12
Username: Webmaster
IP Address:

assassingod 07-04-2004 12:35 PM

PHP Code:

       $latestcontributers $DB_site->query("SELECT username, status, regdate  subscriptionlog.userid 

There's a comma missing after regdate, it seems.

tamarian 07-04-2004 02:29 PM

Quote:

Originally Posted by assassingod
PHP Code:

        $latestcontributers $DB_site->query("SELECT username, status, regdate  subscriptionlog.userid 

There's a comma missing after regdate, it seems.

Ah, yes. Thanks for the catch!

tamarian 07-04-2004 02:32 PM

Quote:

Originally Posted by Cold Steel
Thanks for the prompt response. Now I'm getting this error:

I've just updated the missing comma as pointed out by assassingod. Give it another try and let me know how it goes.

assassingod 07-04-2004 02:33 PM

Quote:

Originally Posted by tamarian
Ah, yes. Thanks for the catch!

No problem:)

Cold Steel 07-04-2004 06:46 PM

Thanks assassingod and tamarian.

This is my code:

Code:

// ###################### thankyou #######################
function thankyou(){
global $DB_site, $stylevar, $vboptions, $vbphrase;
 
require_once('./global.php');
 
$latestcontributers = $DB_site->query("SELECT username, status, regdate, subscriptionlog.userid
FROM " . TABLE_PREFIX . "subscriptionlog AS subscriptionlog
LEFT JOIN " . TABLE_PREFIX . "user AS user
USING ( userid )
WHERE user.userid = subscriptionlog.userid
AND STATUS = '1'
ORDER BY regdate DESC
LIMIT 5");
 
$latest_str = "";
while ($contributer = $DB_site->fetch_array($latestcontributers))
{
eval ('$latest_str .= ", ' . fetch_template('thanksbit') . '";');
}
$latest_str = substr($latest_str , 2);
$latest_str = addslashes($latest_str);
$DB_site->query("UPDATE " . TABLE_PREFIX . "template SET template=\"$latest_str\", template_un=\"$latest_str\" WHERE title='thanks'");
}

And this is my error:

Quote:

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/global.php on line 645

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/includes/functions.php on line 2895

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/includes/functions.php on line 2895

Warning: Invalid argument supplied for foreach() in /home/asiansin/public_html/forums/includes/functions.php on line 2895

Database error in vBulletin 3.0.1:

Invalid SQL: SELECT username, status, regdate, subscriptionlog.userid
FROM subscriptionlog AS subscriptionlog
LEFT JOIN user AS user
USING ( userid )
WHERE user.userid = subscriptionlog.userid
AND STATUS = '1'
ORDER BY regdate DESC
LIMIT 5
mysql error: Column: 'status' in field list is ambiguous

mysql error number: 1052

Date: Sunday 04th of July 2004 02:44:37 PM
Script: http://forums.asiansinc.com/admincp/subscriptions.php
Referer: http://forums.asiansinc.com/admincp/...iptionlogid=12
Username: Webmaster
IP Address:

tamarian 07-04-2004 06:51 PM

Quote:

Originally Posted by Cold Steel
Thanks assassingod and tamarian.

This is my code:

And this is my error:

O.k., I've made a small change by adding subscriptionlog. prefix, even though it's not ambigious!

Give it another try (just step #2), and let's see how it goes.

Cold Steel 07-04-2004 07:04 PM

Apparently, mysql still can't get it clear:

Quote:

Invalid SQL: SELECT username, status, regdate, subscriptionlog.userid
FROM subscriptionlog AS subscriptionlog
LEFT JOIN user AS user
USING ( userid )
WHERE user.userid = subscriptionlog.userid
AND subscriptionlog.status = '1'
ORDER BY subscriptionlog.regdate DESC
LIMIT 5
mysql error: Column: 'status' in field list is ambiguous

tamarian 07-04-2004 07:24 PM

Quote:

Originally Posted by Cold Steel
Apparently, mysql still can't get it clear:

Let's try this:

PHP Code:

   // ###################### thankyou #######################
      
function thankyou(){
            global 
$DB_site,  $stylevar$vboptions$vbphrase;
      
          require_once(
'./global.php');
      
          
$latestcontributers $DB_site->query("SELECT *
                     FROM " 
TABLE_PREFIX "subscriptionlog AS subscriptionlog
                     LEFT JOIN " 
TABLE_PREFIX "user AS user
                     USING ( userid )
                     WHERE user.userid = subscriptionlog.userid
                 AND subscriptionlog.status = '1'
                     ORDER BY subscriptionlog.regdate DESC
                     LIMIT 5"
);
      
          
$latest_str "";
          while (
$contributer $DB_site->fetch_array($latestcontributers))
          {
             eval (
'$latest_str .= ", ' fetch_template('thanksbit') . '";');
          }
          
$latest_str substr($latest_str 2);
          
$latest_str addslashes($latest_str);
 
$DB_site->query("UPDATE " TABLE_PREFIX "template SET template=\"$latest_str\", template_un=\"$latest_str\" WHERE title='thanks'");
      } 


Cold Steel 07-04-2004 07:36 PM

That worked. Thanks a ton!

BTW I'm a big anti-carb person myself. :)

tamarian 07-04-2004 07:52 PM

Quote:

Originally Posted by Cold Steel
That worked. Thanks a ton!

That's great to hear. I'm just curious, what versions of PHP and MySQL do you run?

Cold Steel 07-04-2004 09:32 PM

PHP v4.3.3
MySQL v4.0.18-standard

RapCheck 07-20-2004 07:53 PM

I'm getting these errors when editing subscription users


Quote:

Warning: Invalid argument supplied for foreach() in /home/sites/site8/web/b/includes/functions.php on line 2878

Warning: Invalid argument supplied for foreach() in /home/sites/site8/web/b/includes/functions.php on line 2878

Warning: Invalid argument supplied for foreach() in /home/sites/site8/web/b/includes/functions.php on line 2878
I see others have had similar, though I have no mySQL error with it, and the everything seems to work fine updating the subscription. I don't have the store hack or cash hack installed...

I'd just like to know what it means, and if it'll affect anything on my board or subscriptions.

nice hack though, btw.

Bryan Ex 07-20-2004 08:20 PM

Did you edit functions.php with dreamweaver by chance? If so it's one of a couple of vB3 files it will mess up by changing code on you.

RapCheck 07-28-2004 07:39 AM

oops, forget to check back

No, I use edit plus

I just upgraded to 3.0.3 and reapplied the hack, and still get the 3 errors when editing subcriptions.

scottct1 10-20-2004 01:40 PM

I am also getting

Warning: Invalid argument supplied for foreach() in /home/satellit/public_html/includes/functions.php on line 2854

Warning: Invalid argument supplied for foreach() in /home/satellit/public_html/includes/functions.php on line 2854

Any ideas?

nonet 11-17-2004 03:24 AM

Has anyone been able to get this to work with vbadvanced CMPS?

mikeB 12-06-2004 10:42 PM

can someone please explain where exaclty "just before the footer stuff" is?

mikeB 12-06-2004 11:16 PM

well Im getting no errors and Im also getting no subscribers to appear heh

tamarian 12-13-2004 03:48 PM

Quote:

Originally Posted by mikeB
can someone please explain where exaclty "just before the footer stuff" is?

Meaning just before this at the bottom functions.php

Code:

/*======================================================================*\
 || ####################################################################
 || # Downloaded: Thu Apr 15th 2004
 || # CVS: $RCSfile: functions.php,v $ - $Revision: 1.967 $
 || ####################################################################
 \*======================================================================*/
 ?>


lasto 12-20-2004 09:13 PM

Quote:

Originally Posted by mikeB
well Im getting no errors and Im also getting no subscribers to appear heh

same ere - all seems to be working but nothing shows - weird

Jenta 03-10-2005 12:28 PM

Quote:

Originally Posted by lasto
same ere - all seems to be working but nothing shows - weird

Quote:

Originally Posted by mikeB
well Im getting no errors and Im also getting no subscribers to appear heh

me too, maybe not compatible with 3.0.7?

if thankyou(); is in functions_subscriptions.php u get a blank screen when after editing a subscribtion though it does actually write the change to the database

so it seems to me that the thankyou function is hanging somehow and ive double and triple checked everything

Jenta 03-11-2005 11:02 PM

ok its working now!
what happened was since its set to 5, it takes 5 subscriptions for it to kick in
at least thats what i think made it kick on

Mokster 03-13-2005 01:47 AM

nice hack, could you change it so it shows the lastest new registered users?


All times are GMT. The time now is 05:32 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.01641 seconds
  • Memory Usage 1,916KB
  • 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
  • (4)bbcode_code_printable
  • (16)bbcode_php_printable
  • (19)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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