Friday, July 31, 2009

PHP Read file execution time difference

If you need to read a file into a string, you can use:

$doc = implode(file($this->attachment_file));
or
$doc = file_get_contents($this->attachment_file);

Surprisingly, the first method executes faster. I don't know why.

Wednesday, July 29, 2009

Best thing for your CentOS server

If you have a centOS server with ssh exposed on port 22, you can put in a rate limit in the iptables like this (in /etc/sysconfig/iptables):

-A RH-Firewall-1-INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --name sshattack --set
-A RH-Firewall-1-INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --name sshattack --rcheck --seconds 60 --hitcount 3 -j LOG --log-prefix "SSH RATELIMIT: "
-A RH-Firewall-1-INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --name sshattack --update --seconds 60 --hitcount 3 -j DROP

Basically after 3 failed attempts, iptables will block the hacker/robot trying to access your port 22.

Friday, July 10, 2009

CSS - :hover don't work in IE

I hate IE.

Spent a lot of time trouble shooting my my li:hover does not appear in IE6. Works in FF, Opera, Chrome, IE7.

Anyway, read this:

It points to this:
http://www.xs4all.nl/~peterned/

Now my css will not pass validation. Damn it.

Edit: Ok, went back to basics of using onmouseover and onmouseout. WTF.