Writing a simple mod

Discussion forum for MOD Writers regarding MOD Development.
Locked
DarkDepths
Registered User
Posts: 8
Joined: Fri Feb 10, 2012 8:17 pm

Writing a simple mod

Post by DarkDepths » Fri Feb 10, 2012 9:21 pm

Hi guys. I'm trying to write a mod to do a pretty simple task. However, I've never written a PhpBB mod before, and I can't find any good tutorials/documentation about how to even start the process. I should note, however, that though I've never written a mod for PhpBB, I do have a fair bit of experience with PHP and have written plugins for Wordpress and other software.

So, I've written a script that migrated all my Wordpress users over to PhpBB. However, Wordpress doesn't store IP addresses, so I now have about 900 members all with an IP address of 0.0.0.0. I want to remedy this so that (a) I can use the ban-by-ip feature and (b) so that I don't have to worry about other members of the staff accidentally banning half the forum members!

My thoughts on how to do it are pretty simple: On login, check if the logged IP address is 0.0.0.0. If it is, then set it to be the users current IP address, and move on as normal.

I found some documentation about the DBAL and how I can use the update function to make changes to entries in the table, but I can't figure out how a Mod is actually put together.

So, are there any clear samples of a "bare bones" mod that I can look at?

Also, how can I have my function triggered when the user logs in? I'm used to Wordpress' hook system, so that's where I looked in phpbb, but I'm not entirely sure that's the right course.

Thank-you very much!

femu
Registered User
Posts: 1070
Joined: Tue Sep 27, 2005 10:03 am

Re: Writing a simple mod

Post by femu » Sat Feb 11, 2012 4:24 am

I think a good start is this page. I used that too, when I started to mod by myself ;-) It really describes very easy on how the different basic functions work in phpBB3.
Regards, femu
_____________________________________________
[My development page] - [My normal homepage (German only)]

DarkDepths
Registered User
Posts: 8
Joined: Fri Feb 10, 2012 8:17 pm

Re: Writing a simple mod

Post by DarkDepths » Mon Feb 13, 2012 5:00 am

Hi, and thanks for your response. I've read that page, and though it is helpful in some ways, I'm still confused. Perhaps I'm missing something fairly obvious, or I'm trying to do something that phpbb doesn't make particularly easy? My problem, essentially, is how to "hooK" custom functions to various actions. For example, how can I run a piece of code whenever someone logs in, or whenever someone makes a new post?

Thank you again!

BlueCollar
Registered User
Posts: 67
Joined: Sun Dec 05, 2010 11:54 pm

Re: Writing a simple mod

Post by BlueCollar » Wed Feb 15, 2012 6:50 pm

I'm a coding newbie but I'll try to help you out. Check out 'root/includes/functions.php'

Around line 2945 is some code for 'Generate login box or verify password'. Perhaps this can help you out.

Not sure how much you know about phpBB but the best way I can explain it is that inside the phpBB files is just one snippet of code for each action performed on the board. When a MOD or any function needs a user to log in, that MOD calls the phpBB login function. So if you are looking to make some code that executes after every login, you will want to find the login function and add your code in after it. That way when anyone logs in, your code will execute directly after the login, every time.

Once you have altered the php files, if your desired code requires visual representation, you will likely need to alter the html and css files according to the style of your board. This can be found in

root/styles/prosilver/template/login_body.html
root/styles/prosilver/template/login_forum.html

I hope this helps answer your question. I wish I could help you more but I'm really new to this as well.

DarkDepths
Registered User
Posts: 8
Joined: Fri Feb 10, 2012 8:17 pm

Re: Writing a simple mod

Post by DarkDepths » Thu Feb 16, 2012 12:02 am

OK. So basically, I actually have to modify the core files? After installing a couple of mods, I sort of discovered that to be the case, but I'd like to make sure that is the recommended(/only) way of doing it.

Thank you.

User avatar
Elias
Registered User
Posts: 4625
Joined: Sat Feb 25, 2006 4:31 pm
Location: In the Water!
Name: Elias

Re: Writing a simple mod

Post by Elias » Thu Feb 16, 2012 1:07 am

Have a read at the Introduction to Writing MODs page.

Thanks
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|

BlueCollar
Registered User
Posts: 67
Joined: Sun Dec 05, 2010 11:54 pm

Re: Writing a simple mod

Post by BlueCollar » Thu Feb 16, 2012 1:58 am

Yes, almost all MODs alter or work with the core files. Often this might compromise your board's security from threats, so make sure you know what you are doing or you get help.

User avatar
Elias
Registered User
Posts: 4625
Joined: Sat Feb 25, 2006 4:31 pm
Location: In the Water!
Name: Elias

Re: Writing a simple mod

Post by Elias » Thu Feb 16, 2012 3:45 am

BlueCollar wrote:so make sure you know what you are doing or you get help.
Well he's at the right place to get the help he needs! ;)
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|

DarkDepths
Registered User
Posts: 8
Joined: Fri Feb 10, 2012 8:17 pm

Re: Writing a simple mod

Post by DarkDepths » Thu Feb 16, 2012 8:28 am

Thanks guys. I'm fairly experienced with PHP, but most of the work I've done has been on my own projects, or making plugins for WordPress and some other web software. The thing is, all of them provided some kind of "hook" system, so that you could just register a function with the hook you need, and then it would be executed when the software ran the hook. I just sort of assumed phpBB did something similar. I guess it doesn't primarily for performance reasons?

Thanks again!

User avatar
Elias
Registered User
Posts: 4625
Joined: Sat Feb 25, 2006 4:31 pm
Location: In the Water!
Name: Elias

Re: Writing a simple mod

Post by Elias » Thu Feb 16, 2012 3:57 pm

If i am not mistaken, the Hook System will be implemented in phpBB 3.1.

Thanks
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|

User avatar
Steve
Registered User
Posts: 993
Joined: Tue Apr 07, 2009 7:48 pm
Location: UK ,up north!!
Name: Steven Clark

Re: Writing a simple mod

Post by Steve » Thu Feb 16, 2012 5:45 pm

Hook system can be used in the latest the latest phpBB3 version read here
phpBB is fun!! :)
Topic/Post Reactions|phpBB Vehicle Showroom + Market Place + Tracks + 1/4 Mile | Calendar
All coming back for testing soon. (dated 6/11/2019)

Locked

Return to “[3.0.x] MOD Writers Discussion”