Finding the full height of a partially-hidden element

Recently I created a widget that contained a potential LARGE amount of content within it, but wanted to create a solution to have all that data accessible without being unreasonably long. My solution was to create a widget that had up/down controls, and scrolled the content inside of the widget.

The issue I ran into along the way was for a way to find the height of the entire content, not just the visible content. I ended up finding the answer after many many pages of search results:
Continue reading Finding the full height of a partially-hidden element

Creating a SQL database (and user) through SSH

This is how you create a database and corresponding user through secure shell. I am taking from the point of being connected to your server through SSH. First you log into your sql database on your server.

Note: [username], [password], [hostname] and [database-name] are all place-holders. This is where you insert your credentials without the square brackets [ ].

mysql -u[username] -p[password] -h[hostname]

Continue reading Creating a SQL database (and user) through SSH

Pharma Hack via MM Forms Community

Early last week, we experienced several injection attacks from something known as the “pharma hack” – this is a sneaky attack on your website, which alters the Search Engine results of your website’s pages. If you are using MM Forms Pro or MM Forms Community, I strongly recommend changing your site’s forms IMMEDIATELY.

The Signs

An easy way to check whether your site has been attacked is to do a quick Google search for your own site. Check to see if any of the pages that seem have anything funky – specifically Viagra, Cialis, or Propecia related.
Continue reading Pharma Hack via MM Forms Community

Extracting a Single File/Folder from a .tar Ball

It’s actually quite simple! The standard un-tarring SSH line is:

tar -xzvf your-tar-ball.tgz

You can target a specific file or folder by adding another parameter:

tar -zvxf your-tar-ball.tgz your-folder
tar -zvxf your-tar-ball.tgz your-folder/subfolder/image.jpg

Note: The process will go through the entire tarball, so be patient!

How to Get the total number of Posts in WordPress

In a recent project, I was looking to find out how many posts were in a Feedback custom post type, to display on a Dashboard widget similar to the “Right Now” Dashboard Widget that comes with WordPress.

I noticed that the only way to get a count of posts within a certain post type was using:

wp_count_posts( 'my_post_type' );

wp_count_posts() returns an object, which gives detailed information of each post status and how many posts were within that status. If you are using default post statuses, you can probably get away with this:
Continue reading How to Get the total number of Posts in WordPress

Securely Renaming a Massive Amount of Files with PHP – Part 3

Part One: Reading a folder structure recursively.
Part Two: Renaming the files (uniquely) and storing new and old file paths.
Part Three: Copy the files into a sequenced folder system.

This is the third and final part of my tutorial regarding renaming and copying files with new secure names. In the first two sections we covered:
Continue reading Securely Renaming a Massive Amount of Files with PHP – Part 3

Securely Renaming a Massive Amount of Files with PHP – Part 2

Part One: Reading a folder structure recursively.
Part Two: Renaming the files (uniquely) and storing new and old file paths.
Part Three: Copy the files into a sequenced folder system.

This tutorial is a continuation of Securely Renaming a Massive Amount of Files with PHP. In Part 1, we covered:
Continue reading Securely Renaming a Massive Amount of Files with PHP – Part 2

Securely Renaming a Massive Amount of Files with PHP – The Non-Destructive Route

A recent project scope included renaming (literally) tens of thousands of documents for security purposes – it’s not too secure having files name “November-2011-Finances.doc” hosted online.

This tutorial will explain how to use PHP locally (without a web server like XXAMP, MAMP, or WAMP). Using one of these 3 services is fine, but we decided to go the system route!

I will break this tutorial down into multiple parts:
Continue reading Securely Renaming a Massive Amount of Files with PHP – The Non-Destructive Route

Form Validation in PHP – Simplified

I was created a form earlier today, when I had to add Phone Number validation to the existing validation. This form already included email validation, but I decided to go over it as well.

Email Validation

This is a very similar validation, but there is nothing needed to customize:

function valid_email( $str )
{
    // This checks for "[email protected]"
    return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}

if( ! valid_email( $_POST['email_address'] ) {
    echo "Please enter a valid email address."
}

Phone Number Validation

Edit: Please check out my new post on phone number validation, as it has a much more efficient regular expression pattern.

Phone Number validation is fairly straight forward, but has one major issue – formatting! There are many ways of putting in a phone number, and for usability’s sake, it’s best to supp
Continue reading Form Validation in PHP – Simplified