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

SMF Package Manager Generator

Hello,
Originally I had wrote my original SMF Package Manager Generator a few years ago. It was sloppy coding, poor JavaScript and relied heavily on the server. Not my absolute best work, but was something I was proud on at the time from my efforts to dive into JavaScripting.

However, todays times are different. So with JQuery out there, I decided to take breaks from my projects for a couple hours for a few days and put forth a effort to rewrite this. Needless to say, I had the initial code wrote in only a few hours. My original script took me a few days alone. That didn’t count the package-info creator I made later which also took a while.

The new script attempts to rely all on JavaScripting via JQuery. It was a fun experience to build it this way. Although, because of JavaScript’s security measures, I couldn’t leave downloading the file outside of the server. So alas, I still have to process the actual download via the server. There is a work around with using Data URIs, however it didn’t provide the filename and sounds a bit flaky when the length of the url gets to be a bit long. I included both as a option though.

Oh and Its on github, because I see no reason to not share the code. Including the code I used to integrate it into my WordPress blog.

Read More

JQuery Week Calendar mouseover events

While working with a plugin for JQuery for week calendars. I came across a very annoying little bug. Using mouseover/out events did not seem to work correctly when hovering over the title and time. It just wouldn’t do what it should of.

Well after debugging and messing around for a while, I was able to figure out how to resolve this issue. In jquery.weekcalendar.js open up the file and locate:

After that code we want to add:

A little further down the file is:

We want to add after that:

This makes it work as I excepted it to. My thoughts here are that the inner divs are removing the mouseover events. So by attaching an event to them as well, it makes it work as well.

As a good GitHub person does, I submitted a pull request with these fixes in hopes that it gets merged into the plugin.

Read More

new Date() in javascript

It appears that the date object in javascript can have some variances. I had a bug in my code which was only affecting FireFox users on Windows machines. After some debugging time, I figured out that the date object was returning a differently formated value.

These are some examples:
FireFox on Windows 7: Wed Dec 07 2011 16:26:38 GMT-0800 (Pacific Standard Time)
IE 8 on Windows 7: Wed Dec 7 16:29:21 PST 2011
Chrome on Windows 7: Wed Dec 07 2011 16:45:45 GMT -0800 (Pacific Standard Time)
FireFox on OS X Lion: Wed Dec 07 2011 16:37:12 GMT-0800 (PST)
Opera on OS X Lion: Wed Dec 07 2011 16:37:21 GMT-0800
Safari on OS X Lion: Wed Dec 07 2011 16:44:54 GMT-0800 (PST)

It appears that the format of this is left up to the browser to decide. It would be nice if they all followed a specific format. Well it was because of the (Pacific Standard Time) not being recognized by php’s strtotime, that my code failed to work. Some helpful members on IRC brought it to my knowledge that it is up to the browser really.

I find it interesting that out of all the tests, it appears IE just takes a completely different method. While the other browsers are at least semi-similar other than the time zone string at the end. OS X at least appears to be consistent and it appears Opera may just be stripping the string parenthesis from the end.

At least there is a simple solution. Just use some regular expressions to strip off (Pacific Standard Time) and any other variation.

Read More

JQuery week calendar reoccurring events

JQuery has a nice plugin called . Very simple to use and I was able to integrate it into the database to handle pulling scheduling data. However I came across one issue. Reoccurring events.

Well after scrambling the web, I came to the conclusion that it wasn’t possible in the code by default. So away into the code I went. To say the least, my solution is nowhere near perfect nor does it allow for reoccurring events yet from different weeks or months. It was decided to take another course of action rather than trying to hack reoccurring events into the code. I just wanted to post what I had so far:

In jquery.weekcalendar.js we have this code:

Now before this and the block of code before it, I added in:

This lets me do reoccurring events for the current week. I am sure it could be greatly improved and somebody may be able to make it support multiple weeks.

In case anybody else wondered, this simply just needs a json array in the data of the weekday numbers (0-6). The key is recurring.

Read More

jQuery getting value of select with mulitple values

I have been dipping into learning jQuery. Very powerful and useful. But as I am just learning it, I am taking a learning curve to figure it out. Today I came across the need to get the values of a select that had multiple values. I needed to take the name attribute from the option as it contained a filename that I was going to use to display the image. Further more I wanted to separate those images based on their dimensions.

After some thankless google searches, I came up with code that accomplishes this task easily.

As for the HTML, I have my select box with multiple=”multiple” in it. Each option has a value attribute that I use for the database and a name attribute containing the filename. They also contain the friendly name. I then have 3 divs setup like so:

The loader lets me simply get the image loading, once it has the height and width of the image it moves it to the correct box. I keep the loader div hidden so there is no moving around showing as it does its work. Does the job for what I need it to do. Which is a simple previewer of the images being selected. I need the bigger ones to be separate as these are usually tower based images and would make a ugly looking layout otherwise.

Read More

WordPress templates on non wordpress pages

I have a couple pages such as my password generate that are non wordpress templates. However I want these to be styled as if they where from my wordpress. So after some google searches, I came up with very little information. I decided to dive into the code and came up with something that works for what I need it to do and requires little code edits to any of my pages to work.

This does also require a template edit to your wordpress templates. Sadly I couldn’t avoid this, I looked around and tried to see if I could modify the_content(), however it doesn’t look very pleasant to do so. I might in the future look into doing this. If somebody has a better solution that requires no wordpress template edits, please let me know. Back on topic, I modified page.php in my template and changed:

To this line:

Next I will just dump a file I named wp-ssi.php and explain how it works at the end.

Now for all my files I add at the very top. Of course, you need to substitute the path to match yours.

As for wp-ssi.php, I will can explain more about how that works.
(more…)

Read More

New theme

It was time for a new theme. So here it is. A bit modified from the original version I downloaded. Including some css edits and the ability to fully work with mobile devices (I only have a andriod to test though).

Interesting note on the mobile features though, both Android and iOS have a issue where they can’t use the css overflow. iOS at least lets you scroll the content, but none of them will show a scroll bar of some sort.

Read More

Highslide for Wordpress Plugin