Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

show today top poster without any plugin

Ads
banner
banner
banner
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#1
Member
Hello
I want to show today top poster like Lets Forum without any plugin

Heart
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#2
Support Team
Sorry not possible without plugin.

Here is a query if you decide to create one Smile

PHP Code:
$timesearch TIME_NOW 86400;
    {
        
$query $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM "
.TABLE_PREFIX."posts p
            LEFT JOIN "
.TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > 
$timesearch
            GROUP BY p.uid ORDER BY poststoday DESC
            LIMIT 1
        "
);

    } 
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#3
Member
how does mybb shows it in stat.php ?
is it possible to do it with core edit ?

(06-25-2014 09:13 PM)marcus_avrelius Wrote:  Sorry not possible without plugin.

Here is a query if you decide to create one Smile

PHP Code:
$timesearch TIME_NOW 86400;
    {
        
$query $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM "
.TABLE_PREFIX."posts p
            LEFT JOIN "
.TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > 
$timesearch
            GROUP BY p.uid ORDER BY poststoday DESC
            LIMIT 1
        "
);

    } 


would you explain more that how can I use this ?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#4
Support Team
MYBB has a query similar to the one I posted above in the stats.php file. Code file is not recommended for such a basic stuff.
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#5
Member
I put this in global.php :

Code:
// Today's top poster
$timesearch = TIME_NOW - 86400;
switch($db->type)
{
    case "pgsql":
        $query = $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM ".TABLE_PREFIX."posts p
            LEFT JOIN ".TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > $timesearch
            GROUP BY ".$db->build_fields_string("users", "u.")." ORDER BY poststoday DESC
            LIMIT 1
        ");
        break;
    default:
$query = $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM ".TABLE_PREFIX."posts p
            LEFT JOIN ".TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > $timesearch
            GROUP BY p.uid ORDER BY poststoday DESC
            LIMIT 1
        ");
}
$user = $db->fetch_array($query);
if(!$user['poststoday'])
{
    $topposter = $lang->nobody;
    $topposterposts = $lang->no_posts;
}
else
{
    if(!$user['uid'])
    {
        $topposter = $lang->guest;
    }
    else
    {
        $topposter = build_profile_link($user['username'], $user['uid']);
    }
    $topposterposts = $user['poststoday'];
}

is it correct ?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#6
Support Team
Add this to global.php

PHP Code:
$timesearch TIME_NOW 86400;
    {
        
$query $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM "
.TABLE_PREFIX."posts p
            LEFT JOIN "
.TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > 
$timesearch
            GROUP BY p.uid ORDER BY poststoday DESC
            LIMIT 1
        "
);

    }
    while (
$topposter $db->fetch_array($query)) {
        
$profile_link get_profile_link($topposter['uid']);
        
$mybb->todaytopposter[] = "<a href=&#092;"{$profile_link}&#092;">{$topposter['username']}</a>";
        
    if (!isset(
$mybb->todaytopposter))
    {
        
$mybb->todaytopposter '<span>Nobody</span>';
   } else {
      
$mybb->todaytopposter implode(', '$mybb->todaytopposter);
    } 


And use this in the template: {$mybb->todaytopposter}
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#7
Member
it doesn't work
where should I put the code exactly ?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#8
Support Team
That's why I told you is better to use a plugin. You are going to mess your forum for no reason.
I am not sure where to add it cause I am not messing with core files for no reason.

Try put it after. $plugins->run_hooks("global_start");
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#9
Member
Thanks, but it didn't work
would you give the plugin ?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#10
Support Team
PHP Code:
<?php
$plugins
->add_hook('global_start''todaytopposter');

function 
todaytopposter_info(){
    return array(
        
"name"            => "Top poster",
        
"description"    => "some description",
        
"website"        => "http://letsforum.com",
        
"author"        => "Victor Dub",
        
"authorsite"    => "http://letsforum.com",
        
"guid" => "",
        
"version" => "1.0",
        
"compatibility" => "16*"
    
);
}

function 
todaytopposter() {
    global 
$db$mybb;
    
// Put the code here
}
?>

Save as todaytopposter.php


// Put the code here = http://letsforum.com/Thread-show-today-t...94#pid8994
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#11
Member
the plugin doesn't appear in plugin list and also has hidden all the plugin
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#12
Support Team
Have you saved it as todaytopposter.php
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#13
Member
I activate it but it made error :
Warning [2] implode(): Invalid arguments passed - Line: 40 - File: D:\Xampp\htdocs\my-bb\inc\plugins\todaytopposter.php PHP 5.5.6 (WINNT)
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#14
Support Team
I have juts tested and it works did have some errors Wink

PHP Code:
<?php

// Disallow direct access to this file for security reasons DO NOT REMOVE
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook('global_start''todaytopposter');

function 
todaytopposter_info(){
    return array(
        
"name"            => "Top poster",
        
"description"    => "some description",
        
"website"        => "http://letsforum.com",
        
"author"        => "Victor Dub",
        
"authorsite"    => "http://letsforum.com",
        
"guid" => "",
        
"version" => "1.0",
        
"compatibility" => "16*"
    
);
}

function 
todaytopposter() {
    global 
$db$mybb;
   
$timesearch TIME_NOW 86400;
    {
        
$query $db->query("
            SELECT u.uid, u.username, COUNT(*) AS poststoday
            FROM "
.TABLE_PREFIX."posts p
            LEFT JOIN "
.TABLE_PREFIX."users u ON (p.uid=u.uid)
            WHERE p.dateline > 
$timesearch
            GROUP BY p.uid ORDER BY poststoday DESC
            LIMIT 1
        "
);

    }
    while (
$topposter $db->fetch_array($query)) {
        
$profile_link get_profile_link($topposter['uid']);
        
$mybb->todaytopposter[] = "<a href=&#092;"{$profile_link}&#092;">{$topposter['username']}</a>";
        
    if (!isset(
$mybb->todaytopposter))
    {
        
$mybb->todaytopposter '<span>Nobody</span>';
   } else {
      
$mybb->todaytopposter implode(', '$mybb->todaytopposter);
    }
    }
}
?>
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#15
Member
Thanks a lot marcus_avrelius
you're great
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#16
Support Team
Thanks buddy I am still learning PHP so don't expect me to write some super complex code Smile
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#17
Member
another question related to this topic
how can I make message like you for this :
Quote:Post more than (13) post/s and become Today's Best Forum Member! Make your profile standout!
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#18
Support Team
It's is a simple JavaScript that sets a cookie which expires in 24 hours. When cookie is not set you will see the message when you click on X it hides the message and sets a cookie so the next time you won't see the message. Just Google for it: hide div cookie
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#19
Member
Would you give the code ?

I want to mix it with todaytoposter like you that shows number of post that user should post
seo123 Offline referral

Posts: 427
Joined: Mar 2014
Reputation: 16

#20
Senior Member
Add:
PHP Code:
$posts $topposter['poststoday']; 

After

PHP Code:
$profile_link 

Then add {$posts} in the template. This should show the number of posts made by the user.





User(s) browsing this thread: 1 Guest(s)