Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 07-02-2015, 03:19 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP make thread

Hi, I've made this today:

http://spawnscape614.co.uk/forums/reportuser.php

And I'm looking to taking these inputs and then make a thread based off this information. I'll obviously validate it so that you must be logged in to see to use the form although , via the SEND button which you see what's the most basic method for this? I've seen the function on VB where you can automatically make a thread when a user reports a thread; so I only assume that it would be similar?
Reply With Quote
  #2  
Old 07-02-2015, 03:46 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

One of my products auto-creates a thread, and here is the code that actually handles creating the thread:

PHP Code:
                // Create the report thread.

                // Temporarily override the maximum characters that can be included in a post.
                
$maxchars $vbulletin->options['postmaxchars'];
                
$vbulletin->options['postmaxchars'] = 0;

                
$mthread =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
                
$reportforuminfo fetch_foruminfo($mforumid);
                
$reportthreadinfo = array();
                
$mpostip "";
                
$mallowsmilie '1';
                
$mvisible 1;
                
$showsig 1;
                
$mthread->set_info('forum',    $reportforuminfo);
                
$mthread->set_info('thread',   $reportthreadinfo);
                
$mthread->set_info('skip_floodcheck'true);
                
$mthread->setr('forumid',      $mforumid);
                
$mthread->setr('userid',       $muserid );
                
$mthread->setr('pagetext',     $report);
                if (
$vbulletin->options['markfl_report_prefixes_enabled'])
                {
                    
$mthread->set('prefixid',      'reportthread_unsolved');
                }
                
$mthread->setr('title',        $title);
                
$mthread->set('allowsmilie',   $mallowsmilie);
                
$mthread->set('visible',       $mvisible);
                
$mthread->set('ipaddress',     $mpostip);
                
$mthread->set('showsignature'$showsig);
                
$mthread->pre_save();
                if (
count($mthread->errors) < 1)
                {
                    
$threadid $mthread->save();
                    unset(
$mthread);
                    
build_thread_counters($mthread);
                }
                else 
                {
                    print 
"Error making new thread! " $mthread->errors[0] . $mthread->errors[1] . $mthread->errors[2] ;
                }
                
build_forum_counters($forumid);

                
//Restore setting for maximum characters allowed in posts.
                
$vbulletin->options['postmaxchars'] = $maxchars
Reply With Quote
  #3  
Old 07-10-2015, 11:06 AM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks! Could you help me with configure this. I've pmed you.
Reply With Quote
  #4  
Old 07-10-2015, 01:07 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I failed to mention before that you will need this line before using the data manager:

PHP Code:
require_once(DIR '/includes/functions_databuild.php'); 
Can you post all of your code so far and I may be able to give you some pointers.
Reply With Quote
  #5  
Old 07-10-2015, 02:19 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hiya

So far: (relevant part)

PHP Code:
<?php
session_start
();
$formErr "";
$username $when $where "";

            if (isset(
$_GET['submit'])) {
                if (empty(
$_GET["username"]) || empty($_GET["when"]) || empty($_GET["where"])) {
                    
$formErr "<br>You have not completed the entire form - everything must be completed! (*)";
                } else {
                    
$username $_GET["username"];
                    
$when $_GET["when"];
                    
$where $_GET["where"];
                    
//after variables retrieved for inputs:
                    
sendReport();
                }
            }
            
        function 
sendReport() {
                
$maxchars $vbulletin->options['postmaxchars']; 
                
$vbulletin->options['postmaxchars'] = 0

                
$mthread =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
                
$reportforuminfo fetch_foruminfo($mforumid); 
                
$reportthreadinfo = array(); 
                
$mpostip ""
                
$mallowsmilie '1'
                
$mvisible 1
                
$showsig 1
                
$mthread->set_info('forum',    $reportforuminfo); 
                
$mthread->set_info('thread',   $reportthreadinfo); 
                
$mthread->set_info('skip_floodcheck'true); 
                
$mthread->setr('forumid',      33); 
                
$mthread->setr('userid',       $muserid ); 
                
$mthread->setr('pagetext',     $report); 
                if (
$vbulletin->options['markfl_report_prefixes_enabled']) 
                { 
                    
$mthread->set('prefixid',      'reportthread_unsolved'); 
                } 
                
$mthread->setr('title',        $title); 
                
$mthread->set('allowsmilie',   $mallowsmilie); 
                
$mthread->set('visible',       $mvisible); 
                
$mthread->set('ipaddress',     $mpostip); 
                
$mthread->set('showsignature'$showsig); 
                
$mthread->pre_save(); 
                if (
count($mthread->errors) < 1
                { 
                    
$threadid $mthread->save(); 
                    unset(
$mthread); 
                    
build_thread_counters($mthread); 
                } 
                else  
                { 
                    print 
"Error making new thread! " $mthread->errors[0] . $mthread->errors[1] . $mthread->errors[2] ; 
                } 
                
build_forum_counters($forumid); 

                
//Restore setting for maximum characters allowed in posts. 
                
$vbulletin->options['postmaxchars'] = $maxchars;  
        }    
?>
Reply With Quote
  #6  
Old 07-10-2015, 02:35 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, aside from the file you need to require that I posted in #4, it looks to me that you will need to pass the forum and thread information to your sendReport function. Also, you will need to initialize many of the variables being used. You don't need the if block regarding the thread prefix.

It appears you get a username from the form, so you will have to query the user table to get the corresponding userid. Any data needed by the function will either have to be global or passed as parameters (which I recommend).
Reply With Quote
  #7  
Old 07-10-2015, 02:40 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
Okay, aside from the file you need to require that I posted in #4, it looks to me that you will need to pass the forum and thread information to your sendReport function. Also, you will need to initialize many of the variables being used. You don't need the if block regarding the thread prefix.

It appears you get a username from the form, so you will have to query the user table to get the corresponding userid. Any data needed by the function will either have to be global or passed as parameters (which I recommend).
The offender's username is for the "in-game" and nothing to do with the forums.
Reply With Quote
  #8  
Old 07-10-2015, 02:41 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ the user logged into the forums. I'll make it so the user must be logged in.

So what exactly is the function that sends a request to make a thread?
Reply With Quote
  #9  
Old 07-10-2015, 02:41 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay...who will be the author of the auto-created thread?
Reply With Quote
  #10  
Old 07-10-2015, 02:46 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, you can use the datamanager (as I did) or you can write directly to the "thread" table to insert a new row. In either case you still want to update the counters.
Reply With Quote
Reply

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:08 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.07139 seconds
  • Memory Usage 2,313KB
  • 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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete