MyBB Central

Full Version: Creating my own NEWTHREAD page... need some quick infos
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys

I'm building a Buy and Sell website off MyBB forum platform and to make this website function the way I like it I'm gona need to do modifications.... I am well versed w/ PHP and "ok" in CSS, but I would like it if ya'll can give quick answers to some questions i have.. I can probably figure this out myself but it sure would save me a lot of time if you guys can point things out.


To keep my forum organized, I need to make sure users follow the format I want them to, specially since I'll be creating my own SEARCH pages that will return filtered results based on things such as the title having the "Buying" or "Selling" word in the title..

So to do this, I wanted to make my own NEW THREAD interface, with additional fields that will look like:
Title (input Box)
Buying/Selling? (check box)
Price of item (input box)
Picture (upload box)
Description (full text box)

These new fields will simply be formatted into the "standard" input expected by the forum software.. where for example:

If Author types " Washing machine, 3 months used" and ticks the check box "Selling" .. the data will be submitted as POST TITLE VARIABLE
"Selling: Washing machine, 3 months used"

I initially planned to modify myBB's "newthread.php" file to check for FORUM ID and IF forum ID is one of the buy and sell forums, modify the look of the NEW THREAD page accordingly.. but I realized that this is more complicated, and it's gona be hell to maintain things when upgrading...(Correct me if im wrong)

So I decided why not MAKE my own simple NEW THREAD page and insert the values via SQL directly..

So.. w/ that said.. I wanted to know:
1) What are the TABLES i need to update when adding threads? by glancing at the tables i'd assume the following:

mybb_threads - the basic thread details
mybb_posts - the actual post data
mybb_threadsubscriptions - for setting subscriptions for the author

what else?
(is there a simple documentation on mybb's table structure?)

2) How do I check validation of logged in user? What session / cookie variables does MyBB use? What are the values in the session do i need to extract and put into the tables?

3) How are the User passwords encrypted in mybb? is it a simple MD5?



also, in general, is this approach of mine practical? Would there be a better way to get to my goal? I basically need to make sure that thread starters follow a format such as:

Subject: FS: 1 month old washing machine
Message:
Price: $300
Warranty: Shop warranty @ best buy, 1 year
Condition: 2nd hand


...and ofcourse, when the author tries to EDIT the post, I wish there was a way to "maintain" things like this structure. im thinking my own editpost page as well
Sounds like you need to start writing a plugin.

Probably best to work from scratch imho.
Yeah i was thinking the same too.. but i dont think i have time to study the plugin system and develop it.. i just wanted to get it working how i need it too...

i might result to manually playing w/ the codes by simple php hacks Sad

anyway can ya'll answer some of my questions please so i can get started right away?
Most of your questions seem better suited directly at the Mybb support site.

Quote:3) How are the User passwords encrypted in mybb? is it a simple MD5?

Salted and hashed. Check the functions of mybb. (inc/functions.php)

Again...this is going to be simpler as a plugin no matter how you slice it.
(Apr 03, 2009, 12:08 AM)labrocca Wrote: [ -> ]Most of your questions seem better suited directly at the Mybb support site.

Quote:3) How are the User passwords encrypted in mybb? is it a simple MD5?

Salted and hashed. Check the functions of mybb. (inc/functions.php)

Again...this is going to be simpler as a plugin no matter how you slice it.


hi labrocca
thanks for the inputs..

w/ regards to this being better as a plugin.. i dont see how i can do it . i read up on the plugin system. i've to admin it's pretty darn neat, but..

it seems my mod options are only limitted to where the plugin_hooks are..

for example, w/ the newthread page (one of many pages I have to manually modify), i need to put, in between the subject and the message field my own fields:

[Image: 1125y4m.jpg]


there's no way a plugin hook can do that except if the template was modified during plugin activation..

furthermore, what i need to do w/ those extra variables is to "combine" them w/ the standard myBB variables of subject and message, in a formatting that i need..

to make all these things come together properly i would need to edit:
function_posts.php
newthread.php
showthread.php
edithread.php
and so on.. and where i need to edit those files the plugin_hooks can not get to...

for example.. in the showthread.php file, line 58

Quote:$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
//TEA: Modify Thread Subject according to my design!
$thread_subject = $thread['subject'];

//set value substitutes first
$fs_sub = "<img src='http://www.ozcastles.com.au/pics/for_sale.gif'>";
$lf_sub = "<img src='http://letsgobuffalo.com/_borders/search4.gif'>";
$ft_sub = "<img src='http://jalbum.net/images/icons/handshake.gif'>";
$fr_sub = "<img src='http://www.carolinatix.org/resources/images/eventthumbs/Rent-50.gif'>";

//evaluate subject
$sub_prefix =substr($thread['subject'],0,3);

switch ($sub_prefix){
case "FS:":
$thread_subject = str_replace("FS:",$fs_sub,$thread_subject);
break;

case "LF:":
$thread_subject = str_replace("LF:",$lf_sub,$thread_subject);
break;

case "FT:":
$thread_subject = str_replace("FT:",$ft_sub,$thread_subject);
break;

case "FR:":
$thread_subject = str_replace("FR:",$fr_sub,$thread_subject);
break;

default:
$thread_subject = "INVALID SUBJECT HEADER: " . $thread_subject;
}
$thread['subject'] = $thread_subject;

see my needed modification? there's no way to do that via plugin system...

so i didnt think plugin is the way to go on this one because im modifying the core too much in the first place...

I could still be wrong though.. what do you think?

regards
TJ
Quote:there's no way a plugin hook can do that except if the template was modified during plugin activation..

Many plugins do just that.

Trust me you can do what you are doing with a plugin. The problem with all these core file changes you are making is that any upgrade will be a problem. Not so if you use hooks.

You may struggle at first figuring out good methods but long-term it will be well worth it. You will have a better understanding of the mybb plugin system for future development.
(Apr 16, 2009, 08:54 PM)labrocca Wrote: [ -> ]
Quote:there's no way a plugin hook can do that except if the template was modified during plugin activation..

Many plugins do just that.

Trust me you can do what you are doing with a plugin. The problem with all these core file changes you are making is that any upgrade will be a problem. Not so if you use hooks.

You may struggle at first figuring out good methods but long-term it will be well worth it. You will have a better understanding of the mybb plugin system for future development.

hmm.. perhaps i need be enlightened some more hehe.

I thought, by my read, plugins work hand in hand w/ pluginhooks and "some" core modifications necessary.. problem as I see w/ my project i think would require more core mod..

for example.. in the newthread page i have added new input fields.. meaning I need to get those custom variables into the myBB routines during form submission.. here's how I fugured 'd do it..


in newthread.php somwhere around
line 600++
added my comma to the last official array
added my additional variables


PHP Code:
// If we're preving a post then generate the preview.
    
if($mybb->input['previewpost'])
    {
        
// Set up posthandler.
        
require_once MYBB_ROOT."inc/datahandlers/post.php";
        
$posthandler = new PostDataHandler("insert");
        
$posthandler->action "thread";
    
        
// Set the thread data that came from the input to the $thread array.
        
$new_thread = array(
            
"fid" => $forum['fid'],
            
"subject" => $mybb->input['subject'],
            
"icon" => $mybb->input['icon'],
            
"uid" => $uid,
            
"username" => $username,
            
"message" => $mybb->input['message'],
            
"ipaddress" => get_ip(),
            
"posthash" => $mybb->input['posthash'], //added my comma here
            
            /*
            TEA:// extra vars for preview of deals type threads
            */
            
"deal_type" => $_POST['deal_type'],
            
"item_price" => $_POST['item_price'],
            
"item_image" => $_POST['item_image']
            

        ); 


and after that , somewhere , i concatenated the custom variables into the message variable ... no additional tables or columns setup, just using the message column to store my special variables.. i figured this way i need not mess w/ the sql queries..

how do you propose i achieve this in a PLUGIN way?