Hacker attack detected

My site hockeysnack.com has been under hacker attack lately. Well, it is constantly under attack by bots but this time the site was targeted by a real hacker. The hacker first signed up as a regular user with the clever username ”putinn” and then he started to upload various scripts wherever he could.

Uploading php-scripts is forbidden (in code) so he tried to upload the script as other file formats. This is what he tried to upload:
shell.php.jpg
shell.php_1.jpg
shell.php.jpg
shell.php.html
shell.php.mp3

Fortunately I had already written protection against such attacks so the hacker had no luck and went somewhere else. When I found out about the attack I started to investigate it further. The attack uses the eval(base64_decode( attack vector, the same as I discovered earlier. For fun and curiosity I ran the attack code in a sandbox environment. What shoved up was a shell called n3tshell.

n3tshell

It contains so many features, like brute force ftp and sql querying etc. The image above shows the menu and a complete file browser which could edit/delete/create files.

n3tshell

This picture above shows more features. The attacker can execute all commands that are available for the user running the web server process. He could also upload files and do much more. It is a very powerful tool if the hacker manages to get the script running on the server.

The conclusion is to take ”submit/upload” threat very seriously. Everything that a user could submit to your site has to be checked for EVERY POSSIBLE attack vector.

Segmentation fault: 11 (core dumped) in php on Freebsd

Oh, I finally got time for some coding and server updates. Sadly but interestering I got this strange error after updating php5 (/usr/ports/lang/php5) to the latest in the Freebsd ports tree.

The error:
/usr/local> php -v
PHP Fatal error: PHP Startup: apc_shm_create: shmget(0, 31457280, 914) failed: Cannot allocate memory. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment. in Unknown on line 0
PHP Fatal error: PHP Startup: apc_shm_attach: shmat failed: in Unknown on line 0
Segmentation fault: 11 (core dumped)

The first problem was the ”PHP Fatal error” lines that has something to do with APC cache. This was solved by:
/usr/ports/www/pecl-APC> make config
Then I unticked the "IPC Enable IPC shm memory support (default: mmap)" line. Don't really know what it does....
/usr/ports/www/pecl-APC> make deinstall
/usr/ports/www/pecl-APC> make clean
/usr/ports/www/pecl-APC> make install clean

The second problem was the ”Segmentation fault: 11 (core dumped)” line which caused a core dump each time php ran (a php.core file is produced). This was a bit strange. To investigate why it crashes I used gdb on the core file. A core file contains the in-memory state of the program at the time it crashes.

/usr/local/lib/php> gdb /usr/local/bin/php php.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols found)...
Core was generated by `php'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcrypt.so.4...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypt.so.4
Reading symbols from /usr/local/lib/libpcre.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libpcre.so.0
Reading symbols from /lib/libm.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /usr/local/lib/libxml2.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libxml2.so.5
Reading symbols from /lib/libz.so.4...(no debugging symbols found)...done.
Loaded symbols for /lib/libz.so.4
Reading symbols from /usr/local/lib/libiconv.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libiconv.so.3
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /usr/local/lib/php/libs/curl.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/curl.so
Reading symbols from /usr/local/lib/libcurl.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libcurl.so.6
Reading symbols from /usr/lib/libssl.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libssl.so.5
Reading symbols from /lib/libcrypto.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypto.so.5
Reading symbols from /usr/local/lib/php/libs/iconv.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/iconv.so
Reading symbols from /usr/local/lib/php/libs/json.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/json.so
Reading symbols from /usr/local/lib/php/libs/exif.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/exif.so
Reading symbols from /usr/local/lib/php/libs/ftp.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/ftp.so
Reading symbols from /usr/local/lib/php/libs/openssl.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/openssl.so
Reading symbols from /usr/local/lib/php/libs/hash.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/hash.so
Reading symbols from /usr/local/lib/php/libs/bz2.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/bz2.so
Reading symbols from /usr/lib/libbz2.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libbz2.so.3
Reading symbols from /usr/local/lib/php/libs/mysql.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/mysql.so
Reading symbols from /usr/local/lib/php/libs/tokenizer.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/tokenizer.so
Reading symbols from /usr/local/lib/php/libs/simplexml.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/simplexml.so
Reading symbols from /usr/local/lib/php/libs/xml.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/xml.so
Reading symbols from /usr/local/lib/php/libs/posix.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/posix.so
Reading symbols from /usr/local/lib/php/libs/dom.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/dom.so
Reading symbols from /usr/local/lib/php/libs/gd.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/gd.so
Reading symbols from /usr/local/lib/libt1.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libt1.so.5
Reading symbols from /usr/local/lib/libfreetype.so.9...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libfreetype.so.9
Reading symbols from /usr/local/lib/libX11.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libX11.so.6
Reading symbols from /usr/local/lib/libXpm.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libXpm.so.4
Reading symbols from /usr/local/lib/libpng.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libpng.so.6
Reading symbols from /usr/local/lib/libjpeg.so.11...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libjpeg.so.11
Reading symbols from /usr/local/lib/libxcb.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libxcb.so.2
Reading symbols from /usr/lib/librpcsvc.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/librpcsvc.so.4
Reading symbols from /usr/local/lib/libXau.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libXau.so.6
Reading symbols from /usr/local/lib/libXdmcp.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libXdmcp.so.6
Reading symbols from /usr/local/lib/libpthread-stubs.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libpthread-stubs.so.0
Reading symbols from /usr/local/lib/php/libs/xmlreader.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/xmlreader.so
Reading symbols from /usr/local/lib/php/libs/xmlwriter.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/xmlwriter.so
Reading symbols from /usr/local/lib/php/libs/sockets.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/sockets.so
Reading symbols from /usr/local/lib/php/libs/zlib.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/zlib.so
Reading symbols from /usr/local/lib/php/libs/session.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/session.so
Reading symbols from /usr/local/lib/php/libs/soap.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/soap.so
Reading symbols from /usr/local/lib/php/libs/xsl.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/xsl.so
Reading symbols from /usr/local/lib/libexslt.so.8...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libexslt.so.8
Reading symbols from /usr/local/lib/libxslt.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libxslt.so.2
Reading symbols from /usr/local/lib/libgcrypt.so.17...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libgcrypt.so.17
Reading symbols from /usr/local/lib/libgpg-error.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libgpg-error.so.0
Reading symbols from /usr/local/lib/libintl.so.9...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libintl.so.9
Reading symbols from /usr/local/lib/php/libs/sqlite.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/sqlite.so
Reading symbols from /usr/local/lib/php/libs/pdo.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/pdo.so
Reading symbols from /usr/local/lib/php/libs/pdo_sqlite.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/pdo_sqlite.so
Reading symbols from /usr/local/lib/libsqlite3.so.8...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libsqlite3.so.8
Reading symbols from /lib/libthr.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /usr/local/lib/php/libs/xmlrpc.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/xmlrpc.so
Reading symbols from /usr/local/lib/php/libs/ctype.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/ctype.so
Reading symbols from /usr/local/lib/php/libs/fileinfo.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/fileinfo.so
Reading symbols from /usr/local/lib/php/libs/filter.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/filter.so
Reading symbols from /usr/local/lib/php/libs/imap.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/php/libs/imap.so
Reading symbols from /usr/local/lib/libc-client4.so.9...done.
Loaded symbols for /usr/local/lib/libc-client4.so.9
Reading symbols from /usr/lib/libpam.so.4...done.
Loaded symbols for /usr/lib/libpam.so.4
Reading symbols from /usr/local/lib/php/libs/mbstring.so...done.
Loaded symbols for /usr/local/lib/php/libs/mbstring.so
Reading symbols from /usr/local/lib/libonig.so.1...done.
Loaded symbols for /usr/local/lib/libonig.so.1
Reading symbols from /usr/local/lib/php/libs/sqlite3.so...done.
Loaded symbols for /usr/local/lib/php/libs/sqlite3.so
Reading symbols from /usr/local/lib/php/libs/zip.so...done.
Loaded symbols for /usr/local/lib/php/libs/zip.so
Reading symbols from /usr/local/lib/php/libs/apc.so...done.
Loaded symbols for /usr/local/lib/php/libs/apc.so
Reading symbols from /usr/lib/librt.so.1...done.
Loaded symbols for /usr/lib/librt.so.1
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 0x0000000805de1f5d in apc_sma_init () from /usr/local/lib/php/libs/apc.so
[New Thread 0x801533120 (LWP 100263)]

Ok, I smell some fish here. Then i checked the ”stack backtrace” with bt.

(gdb) bt
#0 0x0000000804c7c8c0 in ?? ()
#1 0x00000008042e1bc4 in xsltUnregisterExtModuleFunction () from /usr/local/lib/libxslt.so.2
#2 0x00000008040adc97 in zm_shutdown_xsl () from /usr/local/lib/php/libs/xsl.so
#3 0x000000000055e2cf in module_destructor ()
#4 0x000000000056597a in zend_hash_apply_deleter ()
#5 0x0000000000565be8 in zend_hash_graceful_reverse_destroy ()
#6 0x00000000005596f7 in zend_shutdown ()
#7 0x00000000005045f5 in php_module_shutdown ()
#8 0x00000000005e505f in main ()
#9 0x00000000004189e5 in _start ()
#10 0x0000000800786000 in ?? ()

The problem was clearly related to one of my php-extensions /usr/local/lib/php/libs/xsl.so. Then I tried not to use this extension by uncomment it in /usr/local/etc/php/extensions.ini. However I got similiar error in another extension by doing that. There must be some other error that hasn’t with my extensions to do…

With some google fu I found this post which explains the problem. Some extensions are threaded while php5 isn’t by default. To make php threaded you have to configure it to be so. That’s fairly easy in Freebsd.

/usr/ports/lang/php5/make config
Tick the "LINKTHR Link thread lib (for threaded extensions)" option.
/usr/ports/lang/php5/make deinstall
/usr/ports/lang/php5/make clean
/usr/ports/lang/php5/make install clean

Then i restarted my apache server, typed ”php -m” and everything looked fine, not one single strange error message. Yieeehaa!!

Goodbye php eAccelerator and welcome APC

Goodbye eaccelerator, your decision to remove the functionality that I use in eAccelerator 0.9.6 is a dead end for me. I am lucky that I wrote my software to check if ”eaccelerator_put” functions exists on runtime, otherwise my website would have been down by now after updating from 0.9.3.

The release info says it all:
”The theme of this release is: back to basics! All non-essential functionality has been removed from eAccelerator. The key and content cache and the session functions have been removed. ”

The theme of this release is a killer for me. I have used eAccelerator for many years with great success but now its time to move on. I am now looking for other php cache systems and I also have to rewrite my code. It is not that much work but it has to be done, sadly. I hope there is something good or better then eAccelerator waiting for me in the FreeBSd ports-tree…

… and I found the prefect solution for me in Alternative PHP Cache – APC. It is going to be included (by default?) in PHP6 so I think it is the best choice for me and others. The most important functionality for me right now is apc_add or apc_store which should be the equivalent of eaccelerator_put. Great!

How to install APC in FreeBSD
cd /usr/ports/www/pecl-APC
make install clean

And remember to uncomment eaccelerator from php.ini.

Sluta använda Internet Explorer 6

Något som börjar bli uppmärksammat i webbvärlden är kampanjen mot Microsofts webbläsare IE6 (Internet Explorer 6). Läs mer på http://ie6.forteller.net. Denna webbläsare har nu varit med i 8 långsamma år och hållit tillbaka webbens utveckling sedan första dagen. Jag kan bara instämma i detta och kommer att göra allt i min makt för att få folk att sluta använda webbläsaren från helvetet.

Jag har gjort en egen lösning för detta i php+css+html som gör att mina sidor ser ut enligt screenshoten nedan. Tanken är att imitera actionbaren som finns i IE6 och be användaren att uppdatera sin webbläsare om denne kör IE6. Lösningen är en blandning av flera andra lösningar.

Screenshot
sluta-anvanda-ie6

php
// Vilken webbläsare kör användaren
$browser = substr($_SERVER[‘HTTP_USER_AGENT’], 25, 8);

// Kolla om IE6
$ie6 = ($browser == "MSIE 6.0");

// Om IE6, visa actionbar
if(!$ie6) { include "actionbar.html"; }

CSS
div.activebar
{
position: absolute;
background-color: #ffffe1;
border-bottom: 1px solid #c8c8c8;
margin:0;
padding:0;
width:100%;
}

div.activebarText
{
font-family: sans-serif;
font-size: 12px;
margin-left: 6px;
margin-top: 4px;
height: 100%;
}

actionbar.html
<div class="activebar">
<div class="activebarText" align="center">
Din webbläsare är gammal och osäker! För att få ut det mesta av vår webbsida så rekommenderar vi att ni <a href="http://www.microsoft.com/ie" target="_blank">uppgraderar</a> den.
Pröva även andra populära webbläsare som <a href="http://www.mozilla.com/sv-SE/" target="_blank">Firefox</a>, <a href="http://www.opera.com/" target="_blank">Opera</a>, <a href="http://www.google.com/chrome/" target="_blank">Chrome</a> eller <a href="http://www.apple.com/se/safari/" target="_blank">Safari</a>.
</div>
</div>

Convert youtube-links in text to embedded flash player

If you have a forum, cms or whatever and the users contribute with youtube-links in their posts. You probably convert the urls to a-href links at display time, like this:

simple-link

If the posted link is a youtube-link, are you converting it the same way? Why should you! A cooler way is to convert the link to a embedded youtube-video, like this:

parseyoutubeurls

I have written a small php-function that converts youtube-links (like: http://www.youtube.com/watch?v=XELJ9_Fy0ag) in text to embedded videos. Download it, give it a try and feel free to modify it to suit your needs. Feedback is appreciated.

Download parseYoutubeUrls

function parseYoutubeUrls($text, $width = -1, $height = -1)
{
// defaults
if($width == -1) { $width = 425; }
if($height == -1) { $height = round((344/425) * $width); }

// get all urls in text
$regexp = "/<a\s+.*?href=[\"\']?([^\"\' >]*)[\"\']?[^>]*>(.*)<\/a>/i";
if(preg_match_all($regexp, $text, $matches, PREG_SET_ORDER))
{
// check each url
foreach($matches as $match)
{
// replace all youtube urls with embedded flash player
if(preg_match_all("/www.youtube.com/",$match[1],$hit))
{
$parsedUrl = parse_url($match[1]);
parse_str($parsedUrl["query"], $query);
$videoId = ($query['v']);
$replace = '<p><object width="'.$width.'" height="'.$height.'"><param name="movie" value="http://www.youtube.com/v/'.$videoId.'&hl=sv&fs=1&rel=0"> </param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$videoId.'&hl=sv&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$width.'" height="'.$height.'"></embed></object></p>';
$text = str_replace($match[0],$replace, $text);
}
}
}
return $text;
}

Hemsida till Ludvig Nordström sällskapet

Jag har nyligen hjälp en kompis med att bygga en hemsida åt Ludvig Nordström sällskapet. Så kika på den!

ludvig1

Eftersom jag är ett stort fan av att använda WordPress (php) som CMS till enklare webbsidor åt föreningar/mindre företag så blev det givetvis den tekniska lösningen. Som vanligt blev det lite hackande i form av att mixtra med teman samt plugins/tillägg men det var ganska enkla fixar som behövde göras. Samtidigt var det kul att se alla bra nyheter i WordPress 2.8. Det är riktigt imponerande att följa WP’s utveckling.

Tutorial – Sending email from WordPress using Google Gmail

This tutorial covers how you easily can modify your WordPress installation to send email with a Google Gmail account instead of sending through your webserver. Only ONE file needs to be modified. You also need to have a working WP-installation and a Gmail-account.

Step 1
Open the file ”wp-includes/class-phpmailer.php” (which is the class that sends email in WordPress) in your favourite text-editor.

Step 2
Find and modify the following properties.

var $Mailer = ‘smtp’;
var $Host = ‘smtp.gmail.com’;
var $Port = 465;
var $SMTPAuth = true;
var $Username = ‘your_username@gmail.com’;
var $Password = ‘your_gmail_password’;

Step 3
Find the the method ”IsMail” (in the same file) and comment out one row of code like this:

function IsMail() {
//$this->Mailer = ‘mail’;
}

All steps complete!

This should work with all WordPress versions that uses a version of the phpMailer-class that is Gmail compatible.

Tested in WordPress v 2.7

LOOK HERE
I don’t use this method any longer because I don’t want to touch the core-files of wordpress. It is a bad habit to do so, because they get overwritten each time you update wordpress. There is a plugin called XPertMailer that can send email through gmail. Use that one instead!

Uppgraderar från WordPress 2.3 till 2.7

Då jag skapade bloggen så var det första gången jag testade WordPress och den aktuella versionen var då 2.3. Sedan dess så har det runnit mycket vatten under broarna och WordPress är nu uppe i version 2.7. Det var alltså på tiden att uppdatera den här installationen till ”latest”. Att uppgradera WordPress visade sig vara väldigt enkelt och förvånansvärt smidigt bara man följer instruktionerna. Efter några minuter var både databas och programfiler uppdaterade. Då jag installerat programvaran och sedan loggar in på administrations-sidorna så möts man av en total remake av gränssnittet. Men som tidigare så är det väldigt enkelt att hitta saker och ting. En rolig detalj var att WP påpekade att det finns en svensk version av WP 2.7 som jag kunde installera. Några knapptryckningar senare så installerades WP på svenska automatiskt utan att jag behövde lämna webbsidan. Mycket imponerande!

Saker som imponerar på mig:
* Automatisk uppdatering och installation av plugins.
* Automatisk uppdatering av själva WordPress ”core”
* Det nya GUI:t. Snyggare, enklare och bättre.
* Enkel och smidig uppgradering och installation.
* Widgets för sidopanelen som ändras via wp-admin

Nu tänker jag installera ett nytt tema och anpassa sajten för denna. Så sidan kan se lite tokig ut ett tag och vissa länkar kan vara döda innan jag fått till det.

Summering:
Wordpress 2.7 är en riktigt bra version om man jämför med 2.3 som jag körde tidigare. Man har kommit riktigt långt såväl användarmässigt som systemmässigt. WordPress är riktigt imponerande både som blogg-verktyg och CMS. Det finns ingen tvekan längre, jag kommer nu definitivt att använda WordPress som mitt primära CMS-system.

Elitserien på Facebook

Igår kväll så roade jag mig med att tillverka min första Facebook-applikation. Efter att ha följt instruktionerna på http://developers.facebook.com/ så tog det inte lång tid innan jag hade en applikation up and running.

För att göra något vettigt så gjorde jag en applikation som hämtar upp den senaste elitserietabellen på HockeySnack. Denna kan sedan användarna lägga till på sin egen profil.

För att installera Elitserien på din profil så går du till adressen http://apps.facebook.com/elitserien/ och följer instruktionerna. Om du gillar applikationen så får du gärna sprida den till dina hockeypolare.

Exempel på bilden nedan:

Facebook app

Eftersom det inte är särskilt svårt att göra en Facebook applikation så var det här troligen inte den sista som jag tillverkar. Om man lyckas göra en bra svensk applikation så tror jag att man kan få en väldigt stor spridning med tanke på användarantalet på FB.

Elitserien på Facebook

Unix timestamp in C#, Java and php

For some strange reason the Dotnet framework has no conversion between a unix timestamp and a DateTime. Or has it? Why is it so when the framework has billions of other stuff that you never use. This functionality is actually something you would normally use in a system that communicates with the outside world.

This webpage has a solution
Another page about the same stuff

In my current project I am trying to convert a Java Calendar object to a C# DateTime through JNI (Java Native Interface). I have no perfect solution at this moment but I will try to use a unix timestamp though I am losing some precision.

Java has direct conversion from Calendar to Date (which is a representation of a unix timestamp). Bravo! :-)

php has lots of functions (like timetostr, time) to create and convert unix timestamps.