TUPAS is authentication service used by finnish banks. I created Zend_Service for it. See project site for code and examples.
iMagickFX – image effects for the people
August 2nd, 2010 by raspi No comments »I just started new project called iMagickFX which adds possibility to add different effects to images easily.
Like so:
$im = new iMagickFx('example.jpg');
$im->fxCropResize(100, 100)->fxReflection('white', 0.9);
$im = new iMagickFx('example.jpg');
$im->fxCropResize(100, 100)->fxRoundCorners()->fxDropShadow();
Currently it contains only four effects. Reflection, drop shadow, greyscaling and resizing but more is coming!
XoNoiD CRM development stopped
July 28th, 2010 by raspi No comments »I’ve now stopped XoNoiD CRM development completely because lack of time and feedback from testers and users. Please be free to fork it for your own CRM projects.
Subversion logs to iCalendar format
April 2nd, 2010 by raspi No comments »I wanted to know when I’ve kept my vacations so I wrote small Python script to find out.
pysvnlog2ics parses SVN XML commit log and creates iCalendar .ics file from it. This resulted in many .ics files as in work I use one repository per project and over the years this count is in hundreds today. So I wrote another script – pyicalmerge which combines those .ics files to one big .ics file. Then I just uploaded that giant .ics file to Google Calendar and now I have all my commits in my calendar and can easily see the vacation gaps.
Move PostgreSQL database
December 5th, 2009 by raspi No comments »Moving PostgreSQL database to different name is pretty hard compared to MySQL. But here’s how you do it:
$ pg_dump --no-acl --no-owner -U <username> -h <host> -Fc <database> > <dump filename> $ pg_restore -1 -c -U <username> -d <database> -h <host> --no-owner <dump filename>
$ pg_dump --no-acl --no-owner -U old -h 127.0.0.1 -Fc olddb > old.dump $ pg_restore -1 -c -U newuser -d newdb -h postgresql.lan --no-owner old.dump
Adding Windows 7 drivers directly to DVD
October 31st, 2009 by raspi 2 comments »If you’re familiar with Windows XP Service Pack slipstreaming, this is pretty similar.
I’m using Windows XP Professional for this.
Make ISO image from your Windows 7 DVD with your favorite software. I used CDBurnerXP.
Save install.wim somewhere on your hard drive from that ISO image or straight from DVD.
Download Windows Automated Installation Kit for your OS.
Start AIK Deployment Tools Command Prompt
cd <path where you saved that wim file>
Mount the WIM image with write permissions:
imagex will tell which number is which Windows edition if it’s not found. I tried it first with just number 0.
Number 4 is in this case Windows 7 Ultimate Edition 64 bit.
imagex /mountrw install.wim 4 c:\wim
add as many drivers as you like by using DISM
if dism says that files are essential for booting but drivers are unsigned, then add /forceunsigned parameter.
Here’s example for nvidia nforce drivers (Installer EXE extracted with 7-zip):
SATA/SATARAID/IDE/Ethernet/etc drivers:
cd c:\dl\15.51_nforce_win7_64bit_whql\ide\win764\ dism /image:c:\wim /add-driver /driver:. /recurse cd c:\dl\15.51_nforce_win7_64bit_whql\smbus dism /image:c:\wim /add-driver /driver:. /recurse /forceunsigned cd c:\dl\15.51_nforce_win7_64bit_whql\smu dism /image:c:\wim /add-driver /driver:. /recurse cd c:\dl\15.51_nforce_win7_64bit_whql\ethernet dism /image:c:\wim /add-driver /driver:. /recurse
..and so on for all needed drivers..
You will need to expand unexpanded driver files in some cases. Drivers are not expanded if filenames in driver directory are foo.dl_ and not foo.dll etc.
Here’s NVidia GeForce driver sample for you (Installer EXE extracted with 7-zip)
cd c:\dl\191.07_desktop_win7_winvista_64bit_international_whql mkdir c:\displaydriver expand *.* c:\displaydriver
and then
cd c:\displaydriver dism /image:c:\wim /add-driver /driver:. /recurse
Save the WIM image with new drivers:
unmount and commit (commit = save)
imagex /unmount /commit c:\wim
Add the install.wim back to the ISO image with your favorite ISO handling software. I used UltraISO.
Make sure that the DVD is bootable. Burn ISO as new DVD yet again with favorite burning software (CDBurnerXP).
Boot and enjoy your new Windows 7 with correct and working drivers.
zfComicEngine now at Launchpad
October 24th, 2009 by raspi No comments »I’ve added zfComicEngine to launchpad. It should be easy now to add new translations. Here’s the link: https://launchpad.net/zfcomicengine.
Building OpenVPN for gaming
October 13th, 2009 by raspi 2 comments »This is OpenVPN setup for gaming where VPN’s own internal network is not connected to physical LAN. It’s star shaped and OpenVPN server is running on high bandwidth connection on virtual machine or dedicated server in some ISP’s server room so that the latency is minimal to all connected gamers (ie. guy which has most upload bandwidth should do this). Every player and game server hoster connects to this server and OpenVPN handles rest of networking stuff. It’s also layer 2 (TAP) so that everyone sees mac addresses and UDP broadcasts work ok etc.
Install OpenVPN
aptitude install openvpn
Setting up OpenVPN server
/etc/openvpn/server.conf:
mode server tls-server port 1194 proto udp dev tap client-to-client ca /etc/openvpn/easy-rsa/keys/ca.crt cert /etc/openvpn/easy-rsa/keys/servername.crt key /etc/openvpn/easy-rsa/keys/servername.key dh /etc/openvpn/easy-rsa/keys/dh384.pem ifconfig-pool-persist ipp.txt server-bridge 10.10.10.1 255.255.255.0 10.10.10.128 10.10.10.250 push .route 10.10.10.1 255.255.255.0 keepalive 5 60 comp-lzo persist-key persist-tun status /var/log/openvpn-status.log log-append /var/log/openvpn.log verb 3 user nobody group nogroup #this allows more than one connection at a time from same key #good if you just want to give one "gaming" certificate to everybody #duplicate-cn
mkdir /etc/openvpn/easy-rsa cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa cd /etc/openvpn/easy-rsa
Modify “vars” file with your favorite editor
Change export KEY_SIZE=1024 to export KEY_SIZE=384. We don’t need much encryption for gaming.
Modify export KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG and KEY_EMAIL to your liking.
Save the file.
source ./vars ./clean-all ./build-ca ./build-key-server servername ./build-dh
Use
/etc/init.d/openvpn restart /etc/init.d/openvpn start /etc/init.d/openvpn stop
To start/stop/restart the OpenVPN server.
Adding clients
Replace clientX with actual username wanted.
cd /etc/openvpn/easy-rsa source ./vars ./build-key-pkcs12 clientX
copy clientX.p12 file from “keys” directory to some directory
create following clientX.ovpn file:
client dev tap proto udp #replace this with your OpenVPN server hostname/IP remote 192.168.0.123 1194 resolv-retry infinite nobind ns-cert-type server comp-lzo verb 3 pull # Replace this with your own .p12 certificate file pkcs12 clientX.p12
Send the certificate (.p12) and .ovpn file to your buddy.
Windows client configurations / troubleshooting
We used OpenVPN GUI as Windows client. Download the .ovpn and .p12 file to C:\Program Files\OpenVPN\config directory. Click connect on OpenVPN GUI’s taskbar icon and you should be connected.
To minimize problems set the OpenVPN TAP Adapter as first interface from network configuration. This required reboot for me so that Windows XP acknowledged it. Remove unnecessary stuff from TAP interface (like QoS).
WireShark is your friend. Use it to find out if games are shouting their packets to wrong network and not to VPN IP network. 99.9% of LAN games use UDP broadcast to tell about themselves so use “udp” as filter.
Ping and arp -a is also good for basic connectivity testing. Some firewalls block ping (ICMP) so be aware of that too. Other good tool is netstat and TCPView for looking in which port the game is running.
If you’re running some old games through virtual machine then set the virtual machine’s network adapter to OpenVPN’s TAP Adapter. IPX packets should go through too because TAP is layer 2 (but I didn’t test).
I also found this ForceBindIP application which will force specified application to certain network card or network card IP. Might come in handy if game is constantly picking up wrong NIC or IP network.
Sources
Minimal feedback form with ZF
October 4th, 2009 by raspi No comments »Here’s minimal feedback form example using Zend Framework 1.9.2 without MVC.
<?php
ignore_user_abort(true);
header("Content-Type: text/html; charset=utf-8")
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('magic_quotes_gpc', false);
ini_set('magic_quotes_runtime', false);
ini_set('default_charset', 'UTF-8');
ini_set('iconv.input_encoding', 'UTF-8');
ini_set('iconv.output_encoding', 'UTF-8');
ini_set('iconv.internal_encoding', 'UTF-8');
function stripinputslashes(&$input)
{
if (is_array($input))
{
foreach ($input as $key => $value)
{
switch (gettype($value))
{
default: break;
case 'string':
$input[$key] = stripinputslashes($value);
break;
} // /switch
} // /foreach
} // /if
else
{
switch (gettype($input))
{
default: break;
case 'string':
$input = stripslashes($input);
break;
} // /switch
} // /else
return true;
} // /function
if (version_compare(phpversion(), 6) === -1)
{
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() === 1)
{
array_walk_recursive($_GET, 'stripinputslashes');
array_walk_recursive($_REQUEST, 'stripinputslashes');
if (isset($_POST))
{
array_walk_recursive($_POST, 'stripinputslashes');
} // /if
} // /if
} // /if
// Add library path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(dirname(__FILE__) . '/../library'),
get_include_path(),
)));
// Enable autoloader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$view = new Zend_View();
$form = new Zend_Form();
$form->setView($view);
$form->setMethod(Zend_Form::METHOD_POST);
$form->setAction('/');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('OK');
$email = new Zend_Form_Element_Text('email');
$email->setRequired(true);
$email->setLabel('E-mail');
$email->addFilter('StringTrim');
$email->addFilter('StringToLower');
$email->addValidator('StringLength', false, array(7));
$email->addValidator(new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS, true));
$txt = new Zend_Form_Element_Textarea('text');
$txt->setRequired(true);
$txt->addFilter('StringTrim');
$txt->addValidator('StringLength', false, array(3));
// Add fields to form
$form->addElement($email);
$form->addElement($txt);
$form->addElement($submit);
if (isset($_POST) && !empty($_POST))
{
if ($form->isValid($_POST))
{
$values = $form->getValues();
$m = new Zend_Mail('UTF-8');
$m->setBodyText($values['text']);
$m->setFrom($values['email']);
$m->addTo('feedback@example.com');
$m->setSubject('Feedback');
$m->send();
header("Location: /ok.php");
}
}
// Output form to page
echo $form;
Page contains e-mail and free text field. E-mail address is checked against DNS. Form contents are send to feedback@example.com and given e-mail address is the sender. stripinputslashes kills all stupid slashes from _POST data.
Directory structure:
/home/foo/public_html/index.php (feedback form) /home/foo/public_html/ok.php /home/foo/library/Zend/ (ZF files)
ok.php contains something like “Thank you for giving feedback.”
Gozerbot and What is this file?
October 2nd, 2009 by raspi No comments »It’s been many years since I played with IRC bots. I’ve used eggdrop for something like 10+ years. Now I tried Gozerbot and coded plugin (source) to it which gets URLs from chat and then gives some information about them. It utilizes my other project – “what is this file?” which runs on top of Google App Engine. Everything is using Python.
