MyBB Community Forums

Full Version: I need help with a template configuration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was using the mod limit attachments per day but it conflicted with my forum and it needed to be uninstalled. SO I am asking is there a way to do template edits to achieve this effect? I would prefer to use the template edits as opposed to a mod anyhow..

I want to let my users have up to 5 ebooks per day. 

My Forum                               Smile  Thank you
Should look like this instead if you edit:


[Image: 2my3dhx.png]

Replace inc/plugins/ "at_limit.php" with:

<?php
/** Attachment Download Limit
 * Author: Mohammad Zangeneh @ MyBBIran.com @ Iran, updated by vintagedaddyo
**/

//I've used my new pattern!:)!

// Direct Access Disallow
if(!defined("IN_MYBB"))
die("Direct access to this file is not allowed!");
//Hooks
$plugins->add_hook("attachment_start", "at_limit_on");
$plugins->add_hook("attachment_end", "at_limit_on");
$plugins->add_hook("attachment_end", "at_limit_tb");
$plugins->add_hook("admin_formcontainer_output_row", "at_limit_acp_ug");
$plugins->add_hook("admin_user_groups_edit_commit", "at_limit_acp_ug_commit");
// Plugin Info

function at_limit_info()
{
 return array(
 
    "name"  => "Limit Attachments Downloads Per Day ",
	"description"   => "Allows You To Set A Maximum Attachments Downloads Per Day For UserGroups",
	"website"   => "www.MyBBIran.com",
	"author"   => "Mohammad Zangeneh & updated by vintagedaddyo",
	"authorsite"   => "https://community.mybb.com/user-6029.html",
	"version"    => "1.0",
	"compatibility"   => "16*,18*",
	"guid"   => "97d6cbcfb387b8a9ff08379aabd52be0"
	);
}
function at_limit_activate()
{
global $db, $cache;
	
// Add Table
$db->write_query ("CREATE TABLE `".TABLE_PREFIX."atdl` (
	  `did` smallint(8) UNSIGNED NOT NULL auto_increment,
	  `uid` bigint(30) UNSIGNED NOT NULL default '0',
	  `dateline` bigint(30) UNSIGNED NOT NULL default '0',
	  PRIMARY KEY  (`did`)
		) ENGINE=MyISAM");
		
// Add Field

	$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD attachdllimit INT(5) NOT NULL DEFAULT '5'");
	$cache->update_usergroups();

}

function at_limit_deactivate()
{
// Delete Field

global $db, $cache;
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups Drop attachdllimit");
	$cache->update_usergroups();
	
// Delete Table

if ($db->table_exists("atdl"))
$db->drop_table("atdl");
}

function at_limit_tb()
{
global $db, $attachment, $mybb;

if($attachment['thumbnail'])
{
return;
}
if(!$attachment['thumbnail'])
{
$activate = array(
'uid' => intval($mybb->user['uid']),
'dateline' => TIME_NOW,
);

$db->insert_query('atdl', $activate);
}
}


function at_limit_uid($username)
{
global $db;

$q = $db->simple_select('users', 'uid', 'username=\''.$db->escape_string($username).'\'', 1);
return $db->fetch_field ($q, 'uid');
}

function at_limit_on()
{
global $db, $mybb, $lang, $attachment;

$lang->load('at_limit');

  if ($mybb->usergroup['attachdllimit'] > 0)
  {
	$q = $db->simple_select("atdl", "COUNT(*) AS dl_num", "uid='{$mybb->user['uid']}' AND dateline >='".(TIME_NOW - (60*60*24))."'");
	$atdls = $db->fetch_field($q, 'dl_num');
	if($mybb->input['thumbnail'])
	{
	return;
	}

	if ($atdls >= $mybb->usergroup['attachdllimit'])
	{

$lang->atdl_error = $lang->sprintf($lang->atdl_error, $mybb->usergroup['attachdllimit']);
	error($lang->atdl_error);

	
	}
	
  

}
}

function at_limit_acp_ug($pluginargs)
{
global $db, $mybb, $form, $lang;

$lang->load('at_limit');

if($pluginargs['title'] == $lang->misc && $lang->misc)
{
	// add . before = for fixing the fact that it dropped all other content in misc before 
			$pluginargs['content'].= "{$lang->acp_atdl_title}<br /><small class=\"input\">{$lang->acp_atdl_desc}</small><br />".$form->generate_text_box('attachdllimit', $mybb->input['attachdllimit'], array('id' => 'attachdllimit', 'class' => 'field50'));

}
}

function at_limit_acp_ug_commit()
{
	global $mybb, $updated_group;
	$updated_group['attachdllimit'] = intval($mybb->input['attachdllimit']);
}


?>

If this is easier, here is the "Limit Attachments Downloads Per Day" (1.0)" plugin fixed:

[attachment=37666]
(2016-10-21, 07:46 PM)vintagedaddyo Wrote: [ -> ]Should look like this instead if you edit:


[Image: 2my3dhx.png]

Replace inc/plugins/ "at_limit.php" with:

<?php
/** Attachment Download Limit
 * Author: Mohammad Zangeneh @ MyBBIran.com @ Iran, updated by vintagedaddyo
**/

//I've used my new pattern!:)!

// Direct Access Disallow
if(!defined("IN_MYBB"))
die("Direct access to this file is not allowed!");
//Hooks
$plugins->add_hook("attachment_start", "at_limit_on");
$plugins->add_hook("attachment_end", "at_limit_on");
$plugins->add_hook("attachment_end", "at_limit_tb");
$plugins->add_hook("admin_formcontainer_output_row", "at_limit_acp_ug");
$plugins->add_hook("admin_user_groups_edit_commit", "at_limit_acp_ug_commit");
// Plugin Info

function at_limit_info()
{
 return array(
 
    "name"  => "Limit Attachments Downloads Per Day ",
	"description"   => "Allows You To Set A Maximum Attachments Downloads Per Day For UserGroups",
	"website"   => "www.MyBBIran.com",
	"author"   => "Mohammad Zangeneh & updated by vintagedaddyo",
	"authorsite"   => "https://community.mybb.com/user-6029.html",
	"version"    => "1.0",
	"compatibility"   => "16*,18*",
	"guid"   => "97d6cbcfb387b8a9ff08379aabd52be0"
	);
}
function at_limit_activate()
{
global $db, $cache;
	
// Add Table
$db->write_query ("CREATE TABLE `".TABLE_PREFIX."atdl` (
	  `did` smallint(8) UNSIGNED NOT NULL auto_increment,
	  `uid` bigint(30) UNSIGNED NOT NULL default '0',
	  `dateline` bigint(30) UNSIGNED NOT NULL default '0',
	  PRIMARY KEY  (`did`)
		) ENGINE=MyISAM");
		
// Add Field

	$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD attachdllimit INT(5) NOT NULL DEFAULT '5'");
	$cache->update_usergroups();

}

function at_limit_deactivate()
{
// Delete Field

global $db, $cache;
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups Drop attachdllimit");
	$cache->update_usergroups();
	
// Delete Table

if ($db->table_exists("atdl"))
$db->drop_table("atdl");
}

function at_limit_tb()
{
global $db, $attachment, $mybb;

if($attachment['thumbnail'])
{
return;
}
if(!$attachment['thumbnail'])
{
$activate = array(
'uid' => intval($mybb->user['uid']),
'dateline' => TIME_NOW,
);

$db->insert_query('atdl', $activate);
}
}


function at_limit_uid($username)
{
global $db;

$q = $db->simple_select('users', 'uid', 'username=\''.$db->escape_string($username).'\'', 1);
return $db->fetch_field ($q, 'uid');
}

function at_limit_on()
{
global $db, $mybb, $lang, $attachment;

$lang->load('at_limit');

  if ($mybb->usergroup['attachdllimit'] > 0)
  {
	$q = $db->simple_select("atdl", "COUNT(*) AS dl_num", "uid='{$mybb->user['uid']}' AND dateline >='".(TIME_NOW - (60*60*24))."'");
	$atdls = $db->fetch_field($q, 'dl_num');
	if($mybb->input['thumbnail'])
	{
	return;
	}

	if ($atdls >= $mybb->usergroup['attachdllimit'])
	{

$lang->atdl_error = $lang->sprintf($lang->atdl_error, $mybb->usergroup['attachdllimit']);
	error($lang->atdl_error);

	
	}
	
  

}
}

function at_limit_acp_ug($pluginargs)
{
global $db, $mybb, $form, $lang;

$lang->load('at_limit');

if($pluginargs['title'] == $lang->misc && $lang->misc)
{
	// add . before = for fixing the fact that it dropped all other content in misc before 
			$pluginargs['content'].= "{$lang->acp_atdl_title}<br /><small class=\"input\">{$lang->acp_atdl_desc}</small><br />".$form->generate_text_box('attachdllimit', $mybb->input['attachdllimit'], array('id' => 'attachdllimit', 'class' => 'field50'));

}
}

function at_limit_acp_ug_commit()
{
	global $mybb, $updated_group;
	$updated_group['attachdllimit'] = intval($mybb->input['attachdllimit']);
}


?>

If this is easier, here is the "Limit Attachments Downloads Per Day" (1.0)" plugin fixed:
wow it works and took all my worries away as what to do. Thank you so very much.. I love this plugin since it works for all groups. It also works with the memberlist. 

Thank you for everything you do not know how much I appreciate it! Heart