2018-12-02, 03:42 PM
Hi,
I want a leecher level plugin.. this plugin should work by increasing the leecher level of the user if:
But this never gets the leecher level of the user or updates it .. I think the variables $USER_POSTS, $USER_THREADS, $CURR_UID, and $USER_LEECHERLEVEL can't access the $mybb variable list and thats the problem
Any help would be appreciated.
I want a leecher level plugin.. this plugin should work by increasing the leecher level of the user if:
- the user is spamming random replies like 'asdasdf' or 'ty'
- the number of posts (replies) of the user is more than the number of threads of the user
<?php
if(!defined('IN_MYBB')) {
die('This file cannot be accessed directly.');
}
$plugins->add_hook('newreply_do_newreply_end', 'leechersystem_updatelechlevel');
$plugins->add_hook('newreply_do_newreply_end', 'leechersystem_newreplycheck');
$plugins->add_hook('index_end', 'leechersystem_fixnegativelevel');
function leechersystem_info()
{
return array(
'name' => 'LEECHER SYSTEM',
'description' => '',
'website' => 'https://mysite.com',
'author' => 'MarioLatif',
'authorsite' => 'https://mysite.com',
'version' => '1.0',
'compatibility' => '18*'
);
}
function leechersystem_activate()
{
rebuild_settings();
}
function leechersystem_deactivate()
{
rebuild_settings();
}
function leechersystem_setlechlevel($uid, $level) {
global $mybb, $db;
if( $db->query("UPDATE ".TABLE_PREFIX."users SET leecher_level='$level' WHERE uid='$uid'") === TRUE ) {
return true;
} else {
return false;
}
}
function leechersystem_updatelechlevel() {
global $mybb, $db;
$USER_POSTS = intval($mybb->user['postnum']);
$USER_THREADS = intval($mybb->user['threadnum']);
$CURR_UID = intval($mybb->user['uid']);
$USER_LEECHERLEVEL = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid=".$CURR_UID);
$USER_LEECHERLEVEL = $USER_LEECHERLEVEL->fetch_assoc();
$USER_LEECHERLEVEL = intval($USER_LEECHERLEVEL['leecher_level']);
if( $USER_POSTS >= 10 ) { // The leecher level system works only if the user have 10 posts or more!
if( ($USER_POSTS > $USER_THREADS) && ($USER_LEECHERLEVEL < 10) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 10);
}
if( ($USER_POSTS > $USER_THREADS) && ($USER_LEECHERLEVEL < 20) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 10);
}
if( ($USER_POSTS > $USER_THREADS) && ($USER_LEECHERLEVEL < 30) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 20);
}
if( ($USER_POSTS < $USER_THREADS) && ($USER_LEECHERLEVEL > 10) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL - 10);
}
if( ($USER_POSTS < $USER_THREADS) && ($USER_LEECHERLEVEL > 20) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL - 10);
}
if( ($USER_POSTS < $USER_THREADS) && ($USER_LEECHERLEVEL > 30) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL - 20);
}
}
}
function leechersystem_newreplycheck() {
global $mybb, $db;
global $pid;
$USER_POSTS = intval($mybb->user['postnum']);
$USER_THREADS = intval($mybb->user['threadnum']);
$CURR_UID = intval($mybb->user['uid']);
$USER_LEECHERLEVEL = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid=".$CURR_UID);
$USER_LEECHERLEVEL = $USER_LEECHERLEVEL->fetch_assoc();
$USER_LEECHERLEVEL = intval($USER_LEECHERLEVEL['leecher_level']);
$REPLY_ARRAY = $db->query("SELECT * FROM ".TABLE_PREFIX."posts WHERE pid=".$pid)->fetch_assoc();
if( intval($REPLY_ARRAY['replyto']) !== 0 ) {
$REPLY_CONTENT = $REPLY_ARRAY['message'];
if( is_numeric($REPLY_CONTENT) ) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 20);
}
if(strpos($REPLY_CONTENT, 'ty') !== false) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 10);
}
if(strpos($REPLY_CONTENT, 'asdf') !== false) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 10);
}
if(strpos($REPLY_CONTENT, 'asd') !== false) {
leechersystem_setlechlevel($CURR_UID, $USER_LEECHERLEVEL + 10);
}
}
}
function leechersystem_fixnegativelevel() {
global $mybb, $db;
$USER_POSTS = intval($mybb->user['postnum']);
$USER_THREADS = intval($mybb->user['threadnum']);
$CURR_UID = intval($mybb->user['uid']);
$USER_LEECHERLEVEL = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid=".$CURR_UID);
$USER_LEECHERLEVEL = $USER_LEECHERLEVEL->fetch_assoc();
$USER_LEECHERLEVEL = intval($USER_LEECHERLEVEL['leecher_level']);
if( $USER_LEECHERLEVEL < 0 ) {
leechersystem_setlechlevel($CURR_UID, 0);
}
}
But this never gets the leecher level of the user or updates it .. I think the variables $USER_POSTS, $USER_THREADS, $CURR_UID, and $USER_LEECHERLEVEL can't access the $mybb variable list and thats the problem
Any help would be appreciated.