هاست لینوکس

آخرین بسته‌ی MyBB: نسخه‌ی 1.8.27 MyBB منتشر شد


امتیاز موضوع:
  • 0 رأی - میانگین امتیازات: 0
  • 1
  • 2
  • 3
  • 4
  • 5
درخواست کمک در مورد ساخت پلاگین محدودیت تعداد دانلود برای کاربر
#1
سلام خواهش میکنم اگه میتونید کمک کنید

این کدهای پلاگین محدودیت تعداد پیام خصوصی هست:

کد php:
<?php
/**
 * Limit number of PMs
 * Copyright 2010 Starpaul20
 */

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Tell MyBB when to run the hooks
$plugins->add_hook('private_send_do_send''limitpm_run');
$plugins->add_hook('private_send_start''limitpm_run');
$plugins->add_hook('admin_formcontainer_output_row''limitpm_usergroup_permission');
$plugins->add_hook('admin_user_groups_edit_commit''limitpm_usergroup_permission_commit');

// The information that shows up on the plugin manager
function limitpm_info()
{
    return array(
        
"name"            => "Limit number of PMs",
        
"description"    => "Allows you to limit the number of Private Messages that a user in a usergroup can send in a day.",
        
"website"        => "http://galaxiesrealm.com/index.php",
        
"author"        => "Starpaul20",
        
"authorsite"    => "http://galaxiesrealm.com/index.php",
        
"version"        => "2.0.2",
        
"guid"            => "c13b1bac7595d16c854a60918453499a",
        
"compatibility" => "14*,16*"
    
);
}

// This function runs when the plugin is activated.
function limitpm_activate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxpmsday INT(3) NOT NULL DEFAULT '10'");

    
$cache->update_usergroups();
}

// This function runs when the plugin is deactivated.
function limitpm_deactivate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxpmsday");

    
$cache->update_usergroups();
}

function 
limitpm_run()
{
    global 
$mybb$db$lang;
    
$lang->load("limitpm");

    
// Check group limits
    
if($mybb->usergroup['maxpmsday'] > 0)
    {
        
$query $db->simple_select("privatemessages""COUNT(*) AS sent_count""fromid='{$mybb->user['uid']}' AND folder != 2 AND dateline >= '".(TIME_NOW - (60*60*24))."'");
        
$sent_count $db->fetch_field($query"sent_count");
        if(
$sent_count >= $mybb->usergroup['maxpmsday'])
        {
            
$lang->error_max_pms_day $lang->sprintf($lang->error_max_pms_day$mybb->usergroup['maxpmsday']);
            
error($lang->error_max_pms_day);
        }
    }
}

// Admin CP permission control
function limitpm_usergroup_permission($above)
{
    global 
$mybb$lang$form;
    
$lang->load("limitpm");

    if(
$above['title'] == $lang->private_messaging && $lang->private_messaging)
    {
        
$above['content'] .= "<div class=\"group_settings_bit\">{$lang->maxpmday}:<br /><small>{$lang->maxpmday_desc}</small><br /></div>".$form->generate_text_box('maxpmsday'$mybb->input['maxpmsday'], array('id' => 'maxpmsday''class' => 'field50'));
    }
}

function 
limitpm_usergroup_permission_commit()
{
    global 
$mybb$updated_group;
    
$updated_group['maxpmsday'] = intval($mybb->input['maxpmsday']);
}

?>
و این کدهای پلاگین محدودیت ارسال موضوع:

کد php:
<?php
/**
 * Limit number of Threads
 * Copyright 2010 Starpaul20
 */

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Tell MyBB when to run the hooks
$plugins->add_hook('newthread_start''limitthreads_run');
$plugins->add_hook('newthread_do_newthread_start''limitthreads_run');
$plugins->add_hook('admin_formcontainer_output_row''limitthreads_usergroup_permission');
$plugins->add_hook('admin_user_groups_edit_commit''limitthreads_usergroup_permission_commit');

// The information that shows up on the plugin manager
function limitthreads_info()
{
    return array(
        
"name"            => "Limit number of Threads",
        
"description"    => "Allows you to limit the number of threads that a user in a usergroup can post in a day.",
        
"website"        => "http://galaxiesrealm.com/index.php",
        
"author"        => "Starpaul20",
        
"authorsite"    => "http://galaxiesrealm.com/index.php",
        
"version"        => "2.0.1",
        
"guid"            => "5691f550ad5ec10de6fd86ab2f6590c4",
        
"compatibility" => "14*,16*"
    
);
}

// This function runs when the plugin is activated.
function limitthreads_activate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxthreadsday INT(3) NOT NULL DEFAULT '10'");

    
$cache->update_usergroups();
}

// This function runs when the plugin is deactivated.
function limitthreads_deactivate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxthreadsday");

    
$cache->update_usergroups();
}

function 
limitthreads_run()
{
    global 
$mybb$db$lang;
    
$lang->load("limitthreads");

    
// Check group limits
    
if($mybb->usergroup['maxthreadsday'] > 0)
    {
        
$query $db->simple_select("threads""COUNT(*) AS thread_count""uid='{$mybb->user['uid']}' AND dateline >='".(TIME_NOW - (60*60*24))."'");
        
$thread_count $db->fetch_field($query"thread_count");
        if(
$thread_count >= $mybb->usergroup['maxthreadsday'])
        {
            
$lang->error_max_threads_day $lang->sprintf($lang->error_max_threads_day$mybb->usergroup['maxthreadsday']);
            
error($lang->error_max_threads_day);
        }
    }
}

// Admin CP permission control
function limitthreads_usergroup_permission($above)
{
    global 
$mybb$lang$form;
    
$lang->load("limitthreads");

    if(
$above['title'] == $lang->posting_rating_options && $lang->posting_rating_options)
    {
        
$above['content'] .= "<div class=\"group_settings_bit\">{$lang->maxthreadsday}:<br /><small>{$lang->maxthreadsday_desc}</small><br /></div>".$form->generate_text_box('maxthreadsday'$mybb->input['maxthreadsday'], array('id' => 'maxthreadsday''class' => 'field50'));
    }
}

function 
limitthreads_usergroup_permission_commit()
{
    global 
$mybb$updated_group;
    
$updated_group['maxthreadsday'] = intval($mybb->input['maxthreadsday']);
}

?>

اگر دقت کنید میبینید هردو دقیقا یکی هستند فقط جای limitpm و limitthreads در این دو تغییر کرده .

حالا سوال اینجاست چطور میشه این محدودیت را برای فایلهای پیوست هم تعریفش کرد Cool

هر دو پلاگین هم ضمیمه شد:



فایل‌(های) پیوست شده
.zip   Limit Threads.zip (اندازه: 3.4 KB / تعداد دفعات دریافت: 3)
.zip   Limit PMs.zip (اندازه: 3.39 KB / تعداد دفعات دریافت: 1)
پاسخ
 سپاس شده توسطM48D1 (۱۳۹۰/۴/۱۵، ۲۰:۴۴:۱۴ عصر) ، Mohammad.T (۱۳۹۱/۳/۲۳، ۰۶:۵۶:۴۰ صبح)


پیام‌های داخل این موضوع
درخواست کمک در مورد ساخت پلاگین محدودیت تعداد دانلود برای کاربر - توسط Farhoodi - ۱۳۹۰/۴/۱۵، ۲۰:۳۲:۰۰ عصر

موضوع‌های مشابه…
موضوع نویسنده پاسخ بازدید آخرین ارسال
  دانلود فایل پیوست برای تعداد پست بالاتر از 10تا raminr63 6 2,674 ۱۳۹۱/۳/۲۳، ۱۴:۵۹:۳۲ عصر
آخرین ارسال: Mohammad-Za
  در پی راهکاری برای مخفی کردن گزینه‌های postbit، مثل «تعداد تشکرها»، توسط خود کاربر؟ h.d.n 2 1,914 ۱۳۹۱/۱/۳، ۱۳:۲۰:۴۸ عصر
آخرین ارسال: h.d.n
  کم کردن تعداد دفعاتی که کاربر میتواندتلاش کند برای ورود به سایت only-only 8 4,706 ۱۳۹۰/۹/۸، ۱۲:۴۵:۳۵ عصر
آخرین ارسال: Doodoo
  پلاگین محدودیت تعداد پ.خ ارسالی در روز Webmaster 3 3,281 ۱۳۸۸/۹/۳، ۰۰:۱۸:۲۰ صبح
آخرین ارسال: Pars

پرش به انجمن:


کاربرانِ درحال بازدید از این موضوع: 1 مهمان