Stop Software Patents

Uncategorized No Comments

Stop Software Patents

Best Video Ever - Wheee! by Jeff Gill

Humor No Comments

This is the most popular firefox flick made by Jeff Gill

Protect your FreeBSD box!

FreeBSD, PHP No Comments

I made this simple PHP script because I was tired of getting 400KB security run output emails from my FreeBSD box. It’s written in PHP because I’m not good in shell scripting.

Every minute it checks for line like this

  1. Feb  5 01:40:02 kyle sshd[939]: Failed password for root from 80.86.75.67 port 11807 ssh2

in the auth.log and grabs the IP address. If there is more than 3 failed logins from 1 IP address in one minute it is added to the firewall. I’m using the ipfw firewall.

  1. <?php
  2. // Both your server and this script must share the same timezone
  3. date_default_timezone_set('Europe/Bratislava');
  4.  
  5. // Get the last minute.
  6. // We need this because when we run this script from the cron
  7. // it starts at zero seconds and the log file will have not any entries.
  8. $lastminute = mktime(date('G'), date('i') - 1);
  9.  
  10. // Get the lines with failed logins for last minute
  11. $cmd  = '/usr/bin/more /var/log/auth.log | /usr/bin/grep "Failed password" | /usr/bin/grep "';
  12. $cmd .= date('j H:i:', $lastminute).'"';
  13. $output = shell_exec($cmd);
  14.  
  15. // Make the $output an array
  16. $output = explode("\n", $output);
  17.  
  18. // Array of IPs that you do not want to block
  19. $ignore = array('127.0.0.1');
  20.  
  21. // This array will hold IPs with failed logins
  22. $ips    = array();
  23.  
  24. // Get and count IPs
  25. foreach ($output as $line) {
  26.   $line = trim($line);
  27.   preg_match_all('/[0-9]{1,3}(\.[0-9]{1,3}){3}/', $line, $matches);
  28.  
  29.   foreach ($matches[0] as $ip) {
  30.     if (!isset($ips[$ip])) {
  31.       $ips[$ip] = 1;
  32.     } else {
  33.       $ips[$ip]++;
  34.     }
  35.   }
  36. }
  37.  
  38. // Block IPs
  39. foreach ($ips as $ip => $count) {
  40.   if ($count > 3 && !in_array($ip, $ignore)) {
  41.     $data = "/sbin/ipfw -q add 20000 deny log all from {$ip} to me";
  42.     file_put_contents('/etc/ipfw-dynamic.rules',$data, FILE_APPEND);
  43.     shell_exec($data);
  44.   }
  45. }
  46. ?>

Put this script to cron and set it to start every minute.

Google guessing drive me crazy!

Me No Comments

I decided to write another post to my blog while my last post was a long time ago. After I wrote a few words I want to check if the words are correctly typed because I am not good in English. To my surprise words that I know was correct was underlined and was suggested a correction. That correction was in Slovak! (fyi I am Slovak and live in Slovakia) I have blogger set to English. I can’t make the spellchecker work as I want. Do the spellcheck in English. I cleared all cookies, set my preferred language to English and English-US in my browser, I was restarted the browser and still no luck. As I am writing this post I recognized another strange thing. You know when you are writing a post it is automatically saved as a draft. And that is the strange thing. Not the autosave feature but the message I got when it was saved. When it is autosaved I get “Draft autosaved at 2:01 AM” but when I click “SAVE NOW” I get “Koncept bol uložený o 2:04″ (which is the same as the previous one but in Slovak). I changed everything that I found on Blogger and Google to English but country.

I will not change my country just because Google doesn’t know how to handle languages.

And I am still not sure if it will help.

When I cleared all cookies I go to www.google.com and get www.google.sk. Why?? I was not logged in to my Google account. How they know that I might want sk version which I really don’t want when I have set all to English. (Well I know that my IP address tells Google I am in Slovakia.) When I type www.google.com I want www.google.com and not the sk version! When I will want sk version I will type www.google.sk!

Till Google doesn’t learn how to read my mind I suggest Google to get me what I requested instead of what Google think that I might want!

Zend Studio 5.5 on FreeBSD 6.2

FreeBSD, PHP No Comments

In this post I’m going to write about how to run Zend Studio 5.5 on FreeBSD 6.2. FreeBSD isn’t officially supported by Zend therefore you can’t use their support.

I’m using the trial version of Zend Studio 5.5 and I think I will buy it soon. It’s the best PHP IDE that I’ve tried. Who knows the PHP better than the folks at Zend :-)

OK, let’s start…

I assume that you have correctly installed xwindows and your favorite windows manager. I’m using Xorg 7.2 and KDE 3.5.7.

First we need to download the Zend Studio from Zend. If you are not already registered on Zend website, you will have to register. Only registered users can download products from their website.

I saved it to the /home/majlo/ZendStudio-5_5_0a.tar.gz. We need to unpack it and execute.

  1. kevin# tar xzf ZendStudio-5_5_0a.tar.gz
  2. kevin# sh ZendStudio-5_5_0.bin

We get an error that this binary type is not known. This is because we don’t have installed Linux compatibility.

  1. ELF binary type „0“ not known

We need to install linux base from ports.

  1. kevin# cd /usr/ports/emulators/linux_base-fc4/
  2. kevin# make install clean

This installation will also load linux module to the kernel. To load linux module on system start add this line to /etc/rc.conf.

  1. linux_enable="YES"

Next attempt to start installation.

  1. kevin# cd /home/majlo/
  2. kevin# sh ZendStudio-5_5_0.bin

We get another error:

  1. Java HotSpot(TM) Client VM warning: Can't detect initial thread stack location – find vma failed
  2. 'SWING' UI not supported by VM. Reverting to AWT.

We need linux xorg libraries.

  1. kevin# cd /usr/ports/x11/linux-xorg-libs/
  2. kevin# make install clean

OK. Now we can successfully start the installation wizard. I will install Zend Studio into /usr/local/Zend/ZendStudio-5.5.0.

  1. kevin# cd /home/majlo/
  2. kevin# sh ZendStudio-5_5_0.bin

When the installation finish we can start Zend Studio from /usr/local/Zend/ZendStudio-5.5.0/bin/ZDE but after the “Tip of the Day…” it stop responding and after few minutes it crash. This can be resolved by modification the ZDE file.

  1. kevin# cd /usr/local/Zend/ZendStudio-5.5.0/bin/
  2. kevin# mv ZDE ZDE.bak
  3. kevin# cat ZDE.bak | sed 's/jitOnOrOff=on/jitOnOrOff=off/' > ZDE
  4. kevin# chmod 755 ZDE

Now we can successfully start and use Zend Studio on FreeBSD. (It may take a while to load.)

  1. kevin# ./ZDE

We now have running Zend Studio on FreeBSD. But I’m Slovak and I need to write Slovak national characters in Zend Studio and when I tried, it doesn’t work. After spending days searching the Internet I’ve found that the solution is really simple. Just add this line to your ~/.cshrc file and reboot.

  1. setenv LC_ALL sk_SK.ISO8859-2

We can now use Zend Studio on FreeBSD with Slovak keyboard :-)

Icons by N.Design Studio. Designed By Ben Swift. Powered by WordPress and Free WordPress Themes
Entries RSS Comments RSS Log in