Most recent articles
| The joy of errors: 426 Failure writing network streamMonday, May 5, 2008, 1:00 AM
|
![]() Mail article to a friend |
Post values are writable, in addition to being readable. I've noticed a lot of code that seems to forget that you can scrub and then dump data into the POST values. Consider the following:
foreach ($_POST as $key=>$value){
$_POST[$key]=htmlentities($_POST[$key]);
}
This code takes every POSTed variable and converts it using the PHP command 'htmlentities'.
More sexy code, huh? It's actually very handy, because this allows you, especially if you combine it with a few functions, to rapidly scrub all user input. I actually embed this type of code to scrub GETs and POSTs in my MySQL connection scripts that I use as includes at the beginning of all my PHP. That way, user POSTed variables are scrubbed automatically before even being pulled into a variable that might end up in the database.
![]() Mail article to a friend |
$val2=preg_replace("/[^0-9a-zA-Z]/",'', $val1);
Tada! $val2 is now a version of $val1 with all the non-alphanumeric characters stripped. To use it for validation, all you have do is compare the two...
if($val1==$val2) $is_alphanumeric = TRUE;
Pretty sexy, huh?
![]() Mail article to a friend |
Here's a kinda back to basics for you...
$image_th = imagecreatetruecolor($th_width, $th_height);
imagecopyresampled($image_th, $src, 0, 0, 0, 0, $th_width, $th_height, $width, $height);
$color = imagecolorallocate($image_th, 255, 255, 255);
imagerectangle ($image_th, 0, 0, $th_width -1, $th_height-1, $color);
header('Content-type: image/jpeg');
imagejpeg($image_th, '', 90);
imagedestroy($image_th);
![]() Mail article to a friend |
A while back I began implementing a country-specific blacklisting system to control the amount of spam that appears on a local classifieds website I run, called PunxsyPage.com. Combined with a system that allows unregistered users to pass their ads into a human-edited system for approval, this has brought the appearance of spam on the website down to nearly zero.
I am currently working on a website called MakeABase.com, that will allow users to convert their Microsoft Excel spreadsheets into usable and repurposable databases. Of course, I figure there's gotta be some spammer interest in such a site. After all, practically any website that allows outside users to add content is an invitation for spamming.
So, I figure MakeABase is going to be my next shot at testing how well the blacklisting of countries continues to work in preventing spam.
FTR, the countries that really are pains in the ass are mostly in the Bite of Africa, including Cameroon, the Ivory Coast and Nigeria. India also is worth blacklisting, especially if you don't attract much of an English reading audience from there.
Yes, believe it or not, isolating just a handful of foreign countries and shipping all their traffic down a black hole brings spam postings on your website to an end. Makes you feel real good, right?
Anyhow, I shall report back in the future as to how effective my next experiment in xenophobia goes.
![]() Mail article to a friend |
You know, I read and read a lot of stuff on the internet bashing every service provider and hosting company out there. I just wanted to plug in my two cents about something very cool that GoDaddy does. I've known this for a while, but it came up again and I wanted to write something about, because I often delve into negativity a bit much.
This week two separate accounts, one that I own and one that I administer on someone's behalf, both had credit cards expire. GoDaddy sent multiple emails with a generous time frame for handling the incidents (cards weren't successfully billed) before any services would be terminated.
Yeah, I know they have their own reasons for being so cool about it. But, let's be honest. That doesn't stop a lot of companies from being jerks about a situation like this.
It is nice to know, even if for profit motive reasons, a company has got your back on something like this. It beats the endless reams of web pages that read some variant of "Company X sucks!" For the record, in my experience, GoDaddy does not suck.
![]() Mail article to a friend |
The other evening I was, for some inexplicable reason -- I think there was some Barrack versus Hillary stuff on -- watching the NBC Nightly News. And they were discussing that incident down in Florida with the girls who filmed their rather tame beating up of another girl and were going to put it on YouTube. And of course, the news fixated on the internet aspect of it.
Am I the only person alive who thinks this is a covert marketing ploy? That the fine folk who bring us the Nightly News are trying to smear the internet?
I think television is trying to put a hit out on the internet. Watch the cop shows now. Every police procedural on TV now runs like every third episode as some form of "Your kids will go on the internet and they will be raped and mutilated."
Now, let's start off with the easy points. First, if your kid is dumb enough to go trucking off with a stranger, it was probably going to happen even without teh internets. Second, blaming the internet as a whole is no more valid than blaming the telephones they all used to arrange this hootenanny. Third, constantly banging the drum of "the internet is evil, and it eats children, and who wants bad things to happen to children, what's wrong with you you cyber degenerate IMing social networking space aliens with no souls?!?!?!!" is an invitation to further hyperbole that makes TV look like what it already is: the medium of choice for old folks.
As to the hard points. Yes, the internet does enable some serious stupidity. But, it didn't make these kids stupid in the first place. Yes, the internet does entice idiotic behavior. But, should law enforcement be happy that the internet functions to help them?
Think about it. Prior to cheap camera phones and YouTube, the odds of LE actually coming across this kind of damning evidence was low. Nowadays, even if folks weren't deliberately taping it like these teens did, the odds are much higher that a concerned person near the incident might sneak a camera into the equation.
And understand, for as much as an open-and-shut case this is, that video is going to be the whole deal. How do you make an orderly defense against a video that proves premeditation, organization, forethought and an overt disregard for the painfully obvious fact that all of this is illegal? Without that video, the prosecutors have to go into court and make the case these teens were in a straight-headed mode when they beat this girl. With it, the prosecution merely says, "Look at the video. Who makes a video like this? This is just a softcore snuff video for teenage female shaming ritualists."
Of course they knew what they were doing. But, taking the time to organize lookouts and and film it escalates the entire argument. There is no room for misconstruing whether something got out of hand, who is lying, etc.
But, you don't hear anyone on television saying "thank you" to the internet for all that it brought to light.
Nope. The internet is evil. Look! Stupid teenagers, who prior to the internet were just languishing fields and eating grass, suddenly are stupider than ever!!!
Get it?
It's a friggin hit job by the TV industry to encourage people to think negatively about the web.
![]() Mail article to a friend |
In the last two months I have had the opportunity to build two distinct user-generated websites for small groups. If you have ever tried to get a smaller group to generate content, you know from experience that getting wide participation is like pulling teeth. But, I did find one factor that makes a huge difference in creating participation.
Cost.
The one website is completely free. And the participation is practically nil. The other site is for an organization that charges yearly dues. Those folks participate. Maybe there is something to be said for having some skin in the game.
![]() Mail article to a friend |
I have all but one of my servers already upgraded. I've gotten to be a real pro at this stuff fast. Although I still think it sucks the way GoDaddy is handling this, I've been up to the task.
According the inbox, others are having less ease with handling this than I had. I admit, I'm getting closer every day to earning my guru stripes. And the whole task is still a bit painful even if you know how to make it turn out well.
In the spirit of saving the sanity of others, I wanted offer a few tips for handling your upgrade process...
![]() Mail article to a friend |
© 2008 Pro Content and Design. All rights reserved.
Welcome!
Wonder where to start with your web design business?
This blog follows along with my efforts to build and grow a website design business, Pro Content and Design.
The goal of this blog is to fill in blanks that may be empty as you get your business rolling.
This blog, particularly the source code section, is not intended for beginners. If you are not comfortable with databases, Ajax, DOM objects and other advanced methods, I strongly suggest you go take a look over at W3 Schools before even reading -- let alone tinkering with -- any of the code here.
I hope this blog has some value to web designers as they attempt to get their businesses going.
Good luck, and happy reading.
Thank you,
John Crawford
Pro Content and Design

Coding
W3 Schools
IBM's Mastering Ajax Series
Graphic Design
Worth 1000
Stock.XCHNG
Urban Fonts
Website Software
Apache Web Server
SquirrelMail
PHP/Zend
Website Design Issues
Non-Standard Character Guide
Google Trends
Search Engine Optimization Analyzer
Business
Guy Kawasaki's Blog
Seth Godin's Blog
Freakonomics
Computers
NewEgg
My Main Website
Pro Content and Design
Websites I have built
PunxsyPage: local free classifieds website
My Webapps
TV Stations Transmitter Database
Website where I did the code, database and admin
Tour de Toona: annual bicycle race in Altoona, PA