Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
Prev Previous Post   Next Post Next
  #3  
Old 11-20-2014, 10:16 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is what I use in my mods to make the post, build the thread counters, and if chosen, update the posters post count..

PHP Code:
if ($vbulletin->options['ozzmodz_welcome_thread_active'] AND $vbulletin->options['ozzmodz_welcome_thread_auto_post_email_verify'] == 0)
{
                
        
// Some Declarations
        
global $vbphrase;

        
$postmessage = array(
            
'pagetext1' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_one'],
            
'pagetext2' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_two'],
            
'pagetext3' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_three'],
            
'pagetext4' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_four'],
            
'pagetext5' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_five'],
            
'pagetext6' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_six'],
            
'pagetext7' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_seven'],
            
'pagetext8' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_eight'],
            
'pagetext9' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_nine'],
            
'pagetext10' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_post_ten']
        ); 
        
$rand_text array_rand($postmessage);

        
$title = array(
            
'title1' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_one'],
            
'title2' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_two'],
            
'title3' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_three'],
            
'title4' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_four'],
            
'title5' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_five'],
            
'title6' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_six'],
            
'title7' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_seven'],
            
'title8' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_eight'],
            
'title9' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_nine'],
            
'title10' => $vbulletin->options['ozzmodz_welcome_thread_auto_post_title_ten']
        ); 
        
$rand_title array_rand($title);                                        

        
// Needed Classes
        
require_once(DIR .'/includes/class_dm.php');
        require_once(
DIR .'/includes/class_dm_threadpost.php');
        require_once(
DIR '/includes/functions_databuild.php');
        
$threaddm datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
            
        
$userdata $vbulletin->db->query_first("
            SELECT u.username,u.userid
            FROM " 
TABLE_PREFIX "useractivation AS ua
            LEFT JOIN " 
TABLE_PREFIX "user AS u USING (userid) 
            WHERE ua.activationid = '" 
$vbulletin->db->escape_string($vbulletin->GPC['i']) . "'       
        "
);
        
        
$useridnumber $vbulletin->db->query_first("
            SELECT userid
            FROM " 
TABLE_PREFIX "useractivation
            WHERE activationid = '" 
$vbulletin->db->escape_string($vbulletin->GPC['i']) . "'
            
        "
);           

        
// Some Variables
        //Registered Name
        
$username htmlspecialchars_uni($userdata['username']);
        
//Registered Userid for DBTECH's AUT Mod
        
$mentionuserid $useridnumber['userid'];
        
//Post Icons
        
$posticons_get explode(","$vbulletin->options['ozzmodz_welcome_thread_auto_post_post_icon']);
        
$posticons $posticons_get[array_rand($posticons_get)];
        
//Forum ID To Post To
        
$forumid $vbulletin->options['ozzmodz_welcome_thread_auto_post_forumid'];
        
//Posters ID
        
$postuserid $vbulletin->options['ozzmodz_welcome_thread_auto_post_userid'];
        
//Posters ID?
        
$userid $vbulletin->options['ozzmodz_welcome_thread_auto_post_userid'];
        
//Posters Username
        
$usernames $db->query_first("
            SELECT username 
            FROM " 
TABLE_PREFIX "user 
            WHERE userid = " 
intval($userid));
        
$username2 $usernames['username'] ? $usernames['username'] : 'Guest';
        
//Site Title
        
$bbtitle $vbulletin->options['bbtitle'];
        
//Site URL
        
$url $vbulletin->options['bburl'];
                
$userid2 $useridnumber['userid'];

$vboptions $vbulletin->options;
$bbuserinfo $vbulletin->userinfo;

        
//Post Content
        
$pagetext str_replace(array('$username''$url''$bbtitle''$mentionuserid'), array($username$url$bbtitle$mentionuserid), $postmessage);    
        
//Post Title
        
$title str_replace(array('$username''$url''$bbtitle'), array($username$url$bbtitle), $title);
        
//Allow Smiles (No Option)
        
$allowsmilie '1';
        
//Show Signature (No Option)
        
$showsignature '1';
        
//Moderated (No Option)
        
$visible '1';
        
//Open To Replies
        
$open $vbulletin->options['ozzmodz_welcome_thread_auto_post_close_thread'];
        
//Sticky Thread
        
$sticky $vbulletin->options['ozzmodz_welcome_thread_auto_post_sticky'];
        
//Thread ID To Post To
        
$threadid $vbulletin->options['ozzmodz_welcome_thread_auto_post_thread'];
        
//Thread Counters To Build
        
$threadids $vbulletin->options['ozzmodz_welcome_thread_auto_post_thread'];
        
$ipaddress '000.000.000';

        if (
$vbulletin->options['ozzmodz_welcome_thread_auto_post_how'] AND $userdata['username'] !='')
        {
            
$threaddm datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
            
// Write Into Post Table
            
$threaddm->do_set('forumid'$forumid);
            
$threaddm->do_set('postuserid'$postuserid);
                        
$threaddm->do_set('ipaddress'$ipaddress);
            
$threaddm->do_set('userid'$userid);
            
$threaddm->do_set('title'$title[$rand_title]);
            
$threaddm->do_set('pagetext'$pagetext[$rand_text]);
            
$threaddm->do_set('username'$username2);
            
$threaddm->do_set('open'$open);
            
$threaddm->do_set('sticky'$sticky);
            
$threaddm->do_set('iconid'$posticons);
            
$threaddm->do_set('allowsmilie'$allowsmilie);
            
$threaddm->do_set('showsignature'$showsignature);
            
$threaddm->do_set('visible'$visible);
            
$threaddm->pre_save();
            
            if(
count($threaddm->errors) < 1)
            {
                
$threadid $threaddm->save();
                unset(
$threaddm);
                
build_thread_counters($threaddm);
            }
    
             
build_forum_counters($forumid);
        }
        else
        {
            
$threaddm datamanager_init('Post'$vbulletinERRTYPE_ARRAY'threadpost');
            
// Post As A Reply To A Post
            //$threaddm->do_set('forumid', $forumid);
            
$threaddm->do_set('threadid'$threadid);
                        
$threaddm->do_set('ipaddress'$ipaddress);
            
$threaddm->do_set('parentid'$parentid);
            
$threaddm->do_set('userid'$userid);
            
$threaddm->do_set('title'$title[$rand_title]);
            
$threaddm->do_set('pagetext'$pagetext[$rand_text]);
            
$threaddm->do_set('username'$username2);
            
//$threaddm->do_set('open', $open);
            
$threaddm->do_set('iconid'$posticons);
            
$threaddm->do_set('allowsmilie'$allowsmilie);
            
$threaddm->do_set('showsignature'$showsignature);
            
$threaddm->do_set('visible'$visible);
            
$threaddm->pre_save();
            
            if(
count($threaddm->errors) < 1)
            {
                
$threadid $threaddm->save();
                unset(
$threaddm);
                
build_thread_counters($threadids);
                
            
build_forum_counters($forumid);    
            }
        }         

        
// Update Post Count For Poster
        
if ($vbulletin->options['ozzmodz_welcome_thread_auto_post_count_posts'])
        {
            
$posts $vbulletin->db->query_first("
                SELECT posts
                 FROM " 
TABLE_PREFIX "user
                  WHERE userid = "
.$vbulletin->options['ozzmodz_welcome_thread_auto_post_userid']."
               "
);
    
             
$newpostcount $posts['posts'] + 1;
    
             
$vbulletin->db->free_result($posts);
    
             
$vbulletin->db->query_write("
                 UPDATE " 
TABLE_PREFIX "user
                 SET posts = "
.$newpostcount."
                  WHERE userid = "
.$vbulletin->options['ozzmodz_welcome_thread_auto_post_userid']."
               "
);
        }

Reply With Quote
 

Thread Tools
Display Modes

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 05:15 AM.


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.06036 seconds
  • Memory Usage 2,759KB
  • Queries Executed 12 (?)
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
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • 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_threaded
  • showthread_threaded_construct_link
  • 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