First MyBB Plugin

Only a few days after I finished my PHP day of birth script, I wrote my first proper MyBB plugin. My first plugin was a Return to Top postbit button, but I'm not really counting that :P This plugin will add a message to the index of your forums if a member is awaiting activation, and you have account activation set to either email or admin activation. You can choose to turn the message on or off, specify a different title for the email/admin message, and a different message for the email/admin message. The message will display in your theme's style and is collapsible. I've wanted this for a bit but really wanted to do it myself, so once I'd furthered my understanding of the basics, I tried, and got it finished quite quickly. I had to look at how some other plugins were made, mainly to see how to setup the settings, and how to make the template changes. Anyways, I managed to create it quickly and with hardly any problems. It's now been downloaded a few times already and I've had good comments back, which is great. It was a good first plugin idea, and it turned out even better than I planned. It's available for download from the MyBB Mods site, where you can also see screenshots, and the discussion thread can be found here. I already have another idea for a plugin, which may be ready in a week or so, once I have time to get it right.

Finally learning PHP

Well, the other day, after reading the basics in books and on the net, I wrote my first little PHP script. It isn't much really, but I'm still really happy with how it's turned out. What it does, is tell you the day you were born, based on the date. So for example, 17 June 1991 (my birthday) was a Monday, and if I put that into the form, it will tell me that. Magic.

Well no it isn't magic, the main workings of it is just a mathematical formula that I was taught at college, but I thought that would be a good thing to write a script on. The script itself is relatively basic, it just takes the values from the input form, assigns them to variables, does some stuff with those, then puts it through the calculation to get a number from 0 to 6 (Sunday to Saturday). Then I wrote out a load of if, elseif and else statements to show the actual day. I also put in some statements for if you put in a day that doesn't exist, (30/31st Feb, 31st Apr, Jun, Sep, Nov), if you try and select 29th Feb in a non-leap year, and also if you try and select 29th Feb in a non-century leap year (a century year is only a leap year if divisible by 400, so 1200, 1600 and 2000 were century leap years). So, although it's quite basic, it's been a big learning curve for me, and I've learned a lot from such a small script, especially how to get information from a form, and it helped me understand ifelseif and else statements a lot more.

The script itself is at least 99% accurate. There's not many dates that won't work, and the ones that don't are either hundreds of years ago, or in 2000+. I'm not too sure why it breaks with years that are 2000+, I think the formula ends up having to divide by 0 with those years, and dividing by 0 isn't mathematically possible.

I'm probably making a big deal out of something quite pathetically small but it's the first thing I've ever written that actually works so I'm quite pleased.

You can test the most stable version, with years from 2000 onwards disallowed, here. To see the one that allows years that are 2000 onwards, see here.

Hopefully now I've started to understand this stuff more, I'll be able to do much more, much quicker.