Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2014, 08:53 AM
mohammad6006's Avatar
mohammad6006 mohammad6006 is offline
 
Join Date: May 2008
Location: IRAN (Tabriz)
Posts: 116
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default limit post in thread per day

this code in plugin is for limit users post in forum per day :

PHP Code:
if($vbulletin->options['chip_limitnewthreadperday_advopturn'] && trim($vbulletin->options['chip_limitnewthreadperday_advop']))
    {
        
$lines explode(PHP_EOL$vbulletin->options['chip_limitnewthreadperday_advop']);

        foreach(
$lines as $line)
        {
            list(
$forumids$limited) = explode('|'$line);
            if(
in_array($foruminfo['forumid'], array_map('intval',explode(','$forumids))))
            {

                
$check $db->query_first("
                    SELECT COUNT(threadid) as count
                    FROM "
.TABLE_PREFIX."thread 
                    WHERE dateline > " 
.$start_day"
                        AND forumid = "
.$foruminfo['forumid']."
                        AND postuserid = "
.$vbulletin->userinfo['userid']."
                "
);
                if(
$check['count'] >= intval($limited))
                {    
                    eval(
standard_error(fetch_error('chip_limitnewthreadperday_error'intval($limited), $foruminfo['title_clean'])));
                }
            }
        
        }
    } 
how can i use threadid replace forumid for limit users to post in thread replace forum?


i want restrict users to post in thread per day but this code limit post in forum per day
Reply With Quote
  #2  
Old 05-19-2014, 09:02 AM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Change query to this, maybe it works.
PHP Code:
     SELECT COUNT(postid) AS count 
     FROM 
" . TABLE_PREFIX . "post  
     WHERE dateline 
" . $start_day . " 
          
AND threadid " . $threadinfo['threadid'] . " 
          
AND userid " . $vbulletin->userinfo['userid'] . " 
Reply With Quote
  #3  
Old 05-19-2014, 09:58 AM
mohammad6006's Avatar
mohammad6006 mohammad6006 is offline
 
Join Date: May 2008
Location: IRAN (Tabriz)
Posts: 116
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mokujin View Post
Change query to this, maybe it works.
PHP Code:
     SELECT COUNT(postid) AS count 
     FROM 
" . TABLE_PREFIX . "post  
     WHERE dateline 
" . $start_day . " 
          
AND threadid " . $threadinfo['threadid'] . " 
          
AND userid " . $vbulletin->userinfo['userid'] . " 
not work

this is full code of plugin : https://vborg.vbsupport.ru/showthread.php?t=270797

PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="chip_limitnewthreadperday" active="1">
    <title>Chiplove.9xpro - Limit new thread/post per day</title>
    <description>Limit new thread/post created per day</description>
    <version>1.3</version>
    <url />
    <versioncheckurl />
    <dependencies>
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>Limit replies</title>
            <hookname>newpost_process</hookname>
            <phpcode><![CDATA[#<?
if($vbulletin->options['chip_limitnewthreadperday_turn'] 
    AND !in_array($vbulletin->userinfo['usergroupid'], explode(',', $vbulletin->options['chip_limitnewthreadperday_excludegroups']))
    AND !in_array($vbulletin->userinfo['userid'], explode(',', $vbulletin->options['chip_limitnewthreadperday_usersexcluded']))
){
    if($limted_reply = $vbulletin->options['chip_limitnewthreadperday_limitreply'])
    {
        $total = $vbulletin->db->query_first("
            SELECT COUNT(postid) AS posts 
            FROM ".TABLE_PREFIX."post
            WHERE parentid != 0 
                AND userid = ".$vbulletin->userinfo['userid']."
                AND dateline > ".mktime(0,0,0, date('n'), date('j'), date('Y'))."
                AND dateline < ".mktime(23,59,59, date('n'), date('j'), date('Y'))."
        ");
        if($total['posts'] > $limted_reply)
        {    
            $dataman->errors[] = fetch_error('chip_limitnewthreadperday_error_reply', $limted_reply);
        }
    }
}]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
            <title>Check first form</title>
            <hookname>newthread_start</hookname>
            <phpcode><![CDATA[#<?php
if($vbulletin->options['chip_limitnewthreadperday_turn'
    AND !
in_array($vbulletin->userinfo['usergroupid'], explode(','$vbulletin->options['chip_limitnewthreadperday_excludegroups']))
    AND !
in_array($vbulletin->userinfo['userid'], explode(','$vbulletin->options['chip_limitnewthreadperday_usersexcluded']))
){
    
$start_day strtotime(date('d-m-Y'));
    
    
//total
    
if($vbulletin->options['chip_limitnewthreadperday_total']){
        
//check
        
$check $db->query_first("
            SELECT COUNT(threadid) AS count 
            FROM "
.TABLE_PREFIX."thread 
            WHERE dateline > " 
.$start_day"
                AND postuserid = "
.$vbulletin->userinfo['userid']."
        "
);
        if(
$check['count'] >= $vbulletin->options['chip_limitnewthreadperday_total'])
        {    
            eval(
standard_error(fetch_error('chip_limitnewthreadperday_error'$vbulletin->options['chip_limitnewthreadperday_total'], '(all box)')));
        }
    }
    
//advance
    
if($vbulletin->options['chip_limitnewthreadperday_advopturn'] && trim($vbulletin->options['chip_limitnewthreadperday_advop']))
    {
        
$lines explode(PHP_EOL$vbulletin->options['chip_limitnewthreadperday_advop']);

        foreach(
$lines as $line)
        {
            list(
$forumids$limited) = explode('|'$line);
            if(
in_array($foruminfo['forumid'], array_map('intval',explode(','$forumids))))
            {

                
$check $db->query_first("
                    SELECT COUNT(threadid) as count
                    FROM "
.TABLE_PREFIX."thread 
                    WHERE dateline > " 
.$start_day"
                        AND forumid = "
.$foruminfo['forumid']."
                        AND postuserid = "
.$vbulletin->userinfo['userid']."
                "
);
                if(
$check['count'] >= intval($limited))
                {    
                    eval(
standard_error(fetch_error('chip_limitnewthreadperday_error'intval($limited), $foruminfo['title_clean'])));
                }
            }
        
        }
    }
    
//normal
    
if($vbulletin->options['chip_limitnewthreadperday_normal'] > 0)
    {
        
$check $db->query_first("
            SELECT COUNT(threadid) as count
            FROM "
.TABLE_PREFIX."thread 
            WHERE dateline > " 
.$start_day"
                AND forumid = "
.$foruminfo['forumid']."
                AND postuserid = "
.$vbulletin->userinfo['userid']."
        "
);
        if(
$check['count'] >= $vbulletin->options['chip_limitnewthreadperday_normal'])
        {    
            eval(
standard_error(fetch_error('chip_limitnewthreadperday_error'$vbulletin->options['chip_limitnewthreadperday_normal'], $foruminfo['title_clean'])));
        }
    }
}]]></
phpcode>
        </
plugin>
    </
plugins>
    <
phrases>
        <
phrasetype name="Error Messages" fieldname="error">
            <
phrase name="chip_limitnewthreadperday_error" date="1298051638" username="Chip Pro" version="1.0"><![CDATA[For anti spam threadyou allowed create {1threads for each day in the <b>{2}</bforum]]></phrase>
            <
phrase name="chip_limitnewthreadperday_error_reply" date="1326256560" username="Chip Pro" version="1.3"><![CDATA[For anti spam replyyou allowed create {1threads for each day ]]></phrase>
        </
phrasetype>
        <
phrasetype name="vBulletin Settings" fieldname="vbsettings">
            <
phrase name="setting_chip_limitnewthreadperday_advop_desc" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[If you want to disable this option or modified for each forumidfollow this example.<br>
<
b>Forumid1,forumid2</b>|<b>limited</b><br>
Ex:<Br>
5,6,7|3<br>
123|7]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_advop_title" date="1316795378" username="Chip Pro" version="1.2" />
            <
phrase name="setting_chip_limitnewthreadperday_advopturn_desc" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[If you enablethe below option will be active]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_advopturn_title" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Enable advanced option]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_excludegroups_desc" date="1326255796" username="Chip Pro" version="1.2"><![CDATA[If this option empty, all user groups will be affected by this modEnter any usergroup here if you want disable mod for their<br />
<
br />
NoteSeparated by comma]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_excludegroups_title" date="1326255796" username="Chip Pro" version="1.2"><![CDATA[Exclude User Groups]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_limitreply_desc" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[The number of posts (replythat member can be create per day<br /><br />
Set this value to 0 to disable this option]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_limitreply_title" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Limit replies]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_normal_desc" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Number of threads that member can create during the day for each forums <br />
Default: 
5<br /><br />
Set this value to 0 to disable this option]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_normal_title" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Limit threadforumid]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_total_desc" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Total threads member can create per day (in all forums).<br /><br />
Set this value to 0 to disable this option]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_total_title" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Total thread limited perday]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_turn_desc" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Choose "yes" if you want enable this hack]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_turn_title" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Enable or disable]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_usersexcluded_desc" date="1326255603" username="Chip Pro" version="1.2"><![CDATA[User list will not affected by this mod<br /><br />
NoteSeparated by comma]]></phrase>
            <
phrase name="setting_chip_limitnewthreadperday_usersexcluded_title" date="1326255603" username="Chip Pro" version="1.2"><![CDATA[Exclude Users]]></phrase>
            <
phrase name="settinggroup_chip_limitnewthreadperday" date="1316795378" username="Chip Pro" version="1.2"><![CDATA[Chiplove.9xpro Limit new thread/post per day]]></phrase>
        </
phrasetype>
    </
phrases>
    <
options>
        <
settinggroup name="chip_limitnewthreadperday" displayorder="65535">
            <
setting varname="chip_limitnewthreadperday_turn" displayorder="10">
                <
datatype>boolean</datatype>
                <
optioncode>yesno</optioncode>
                <
defaultvalue>1</defaultvalue>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_excludegroups" displayorder="11">
                <
datatype>free</datatype>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_total" displayorder="15">
                <
datatype>number</datatype>
                <
defaultvalue>20</defaultvalue>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_normal" displayorder="20">
                <
datatype>number</datatype>
                <
defaultvalue>5</defaultvalue>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_advopturn" displayorder="30">
                <
datatype>boolean</datatype>
                <
optioncode>yesno</optioncode>
                <
defaultvalue>0</defaultvalue>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_advop" displayorder="40">
                <
datatype>free</datatype>
                <
optioncode>textarea</optioncode>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_limitreply" displayorder="50">
                <
datatype>number</datatype>
                <
defaultvalue>100</defaultvalue>
            </
setting>
            <
setting varname="chip_limitnewthreadperday_usersexcluded" displayorder="60">
                <
datatype>free</datatype>
                <
defaultvalue>1</defaultvalue>
            </
setting>
        </
settinggroup>
    </
options>
    <
helptopics>
    </
helptopics>
    <
cronentries>
    </
cronentries>
    <
faqentries>
    </
faqentries>
</
product>

i want limit post in thread per day
this have limit thread for forum
forumid|limit
and i want :
threadid|limit
Reply With Quote
  #4  
Old 05-19-2014, 11:06 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You'd better remove all code from this thread unless you have explicit permission by the coder to publish his code.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:25 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03828 seconds
  • Memory Usage 2,340KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete