۱۳۹۰/۴/۱۵، ۲۰:۳۲:۰۰ عصر
سلام خواهش میکنم اگه میتونید کمک کنید
این کدهای پلاگین محدودیت تعداد پیام خصوصی هست:
و این کدهای پلاگین محدودیت ارسال موضوع:
اگر دقت کنید میبینید هردو دقیقا یکی هستند فقط جای limitpm و limitthreads در این دو تغییر کرده .
حالا سوال اینجاست چطور میشه این محدودیت را برای فایلهای پیوست هم تعریفش کرد
هر دو پلاگین هم ضمیمه شد:
این کدهای پلاگین محدودیت تعداد پیام خصوصی هست:
کد 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 در این دو تغییر کرده .
حالا سوال اینجاست چطور میشه این محدودیت را برای فایلهای پیوست هم تعریفش کرد
هر دو پلاگین هم ضمیمه شد: