I installed yet another install of phpMyAdmin, and every time I forget how to configure it to force SSL. All phpMyAdmin installs should do this (use SSL). You never want to login without SSL unless you’re on a secured network.

2 ways to force SSL with phpMyAdmin

1) Using Apache .htaccess (this can also be put in the httpd.conf if you don’t use .htaccess files):

1
2
3
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/directory(.*)$ https://%{HTTP_HOST}/directory$1 [L,R]

Note: I don’t like this way but I this is a way some people do it.

2) Using phpMyAdmin’s config.inc.php file:

1
2
// place this at the bottom somewhere
$cfg['ForceSSL'] = true;


CONTINUE READING


This is amazing. Somebody finally put this together:

http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers

Bookmark it because you’re going to need it if you’re a web developer. It’s helped me. Well, it hasn’t yet but I’m sure it will. And that’s also why I’m blogging about it. I want to remember it and I want it somewhere I’ll be sure to find it.


Been out of the game a little while, my apologies. I know there isn’t much I can do to make it up to you (my fans); however, I’ll give you this in hopes of trying to win you back.

Format phone function using PHP:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function format_phone($country, $phone) {
$function = 'format_phone_' . $country;
if(function_exists($function)) {
return $function($phone);
}
return $phone;
}

function format_phone_us($phone) {
// note: making sure we have something
if(!isset($phone{3})) { return ''; }
// note: strip out everything but numbers
$phone = preg_replace("/[^0-9]/", "", $phone);
$length = strlen($phone);
switch($length) {
case 7:
return preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone);
break;
case 10:
return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $phone);
break;
case 11:
return preg_replace("/([0-9{1})([0-9]{3})([0-9]{3})([0-9]{4})/", "$1($2) $3-$4", $phone);
break;
default:
return $phone;
break;
}
}

// usage
$phone = '111 111 1111';
$phone = format_phone('us', $phone);
echo $phone;


CONTINUE READING


I still see on a lot of sites the copyright date being outdated. Shoot, it was even outdated on mine. How embarrassing. Easy fix though. Something I do at work all the time, but since I’m not getting paid for this site, it wasn’t done.

Now, let’s forget the past and move onto the future.

The solution (in PHP):

1
2
3
4
function copyright_year($year = '2009', $sep = '-') {
$current_year = date('Y');
return ($year == $current_year) ? $year : $year . $sep . $current_year;
}

OR, for those that need more lines (I do too. I like to be able to READ my code):

[cc lang="php"]
function copyright_year($year = ’2009′, $sep = ‘-’) {


CONTINUE READING