Monthly Archives: January 2012

SMF $user_info in as a class

I wrote up this method while writing my Pastebin. It was an experiment mostly to not have to use as many globals in my main code. I think it turned out nice and easy. Knowing that SMF 3.0 will use OOP does not help as this is the least likely way this would be implanted in the code. At least this can act as a bridge at that time to the new code.

I should explain the _() method. I set this up so I could do a Singleton. It also allows me to use it in a sorta static method by doing “userInfo::_()->id;”. Nice quick and easy.

I could of wrote this like my smcFunc class, but choose otherwise on the fact I wanted to use it as a object rather than a static method. A setup like that should be possible, but I didn’t test that.

I never tested but I don’t think accessing multiple dimensional parts of the $user_info will work. Things like $user_info[‘group’][1] most likely won’t work here. I should add support to drill down into the array, but will save that for a later day.

Read More

Pastebin rewrote

I have taken my original code I wrote for my SMF powered pastebin and rewrote this script. This was a massive rewrite from the original code and hopefully it works out well for anyone else who is looking into using it.

I wrote it so it should be plugable with different databases, user information and templating engines. The design was mostly to implant it into my mixed environment of SMF and WordPress, but also to make it robust so it could be used in other ways.

The source of the code is up on GitHub at https://github.com/jdarwood007/pastebin

Read More

SMF in WordPress

For some reason, while using WordPress and including SMF’s SSI.php, it would not detect my logged in SMF session. Baffled and almost thinking this was a SMF bug of some sorts, I began to debug this process.

Well it turns out it is sorta a SMF old PHP support issue, but the problem lies in WordPress. This is the function in WordPress wp-includes/load.php

The problem here, is that they add magic quotes to the cookie. Not quite sure why they are even doing this. But it broke adding SMF. The part in SMF which failed because of this is in SMFs Sources/Load.php in the loadUserSettings function

Because of old PHP support in SMF, its trying to combat a cookie security issue that existed below PHP 4.3.9. Now I don’t use that version, but I rather not strip out the code. The preg match was failing because it was not finding that valid string in the cookie. Since all the double quotes where escaped with a slash \.

For my code, I called in Settings.php from SMF and then did a stripslashes on the cookie. Then I included SSI.php, with the results I expected of it finding my active SMF session.

I should note because SMF uses a lot of global variables, that I had to globalize all of those before hand. I just borrowed the globals from SSI.php and put them into that scripts function.

Read More

Password Generator is open source

I have rewrote my Password Generator script and after doing so, I have enabled it so you can see the source of this code. Simply click the link on the right side when viewing that page and the entire source code will be revealed.
Developers are welcome to reuse any part of the code as long as credit is given where appropriate. Although this script may be over the top for normal password generation, I developed it to create truly random passwords.

Read More

Highslide for Wordpress Plugin