Wednesday, November 30, 2005

venkman for Firefox 1.5

I just installed Firefox 1.5 and tried to update my venkman.. *shocking* it's not working!!
Without Venkman i can't work properly.. i need it, i want it, o baby, o baby...

Well i found a link in the comments of the mozilla.org page of venkman:
http://getahead.ltd.uk/ajax/venkman

Now get it ;-)

Sunday, November 27, 2005

ssh problem solved

I actually can't belive it yet.. i solved my ssh problem which was givin me some sleepless nights since april this year.

I have a debian sarge running with a chroot environment (debian etch). In etch i was not able to get ssh running after an update. It was always saying: Server was not able to allocate pty...

Now i found my mistake.. somehow the mount option was deleted and so it was never able to activate the pts..

Here is what was missing:
mount -t devpts devpts /chroot/dev/pts

Where chroot is the Directory to your chroot System. Maybe there are also some people having problems with this..

Tuesday, November 22, 2005

PHP5 reading XML using DOM

Working with XML Files in php5 you definetly want to work with DOM. Using DOM is very easy, but unfortunately the documentation is not complete and there are one or two things missing, which stop your work for several hours.

We use XML for multiple languages on websites, so our content is in the XML File written in XHTML.
If you use XML Files for different Languages like for example german, you need specific characters. This made us some troubles, but in the end it's more than easy.

First you have to tell the xml File which language you are using in the "xml" header through using encoding. For Example a german File looks like this:
<?xml version="1.0" encoding="iso-8859-1">
Next if you are using HTML Entities like or ü you have to define a DOCTYPE. Since we used XHTML Entities we used a dtd from w3.org:
<!DOCTYPE shiva SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
Now we get to the PHP Part:
Loading a XML File using DOM is very easy. First you have to create a new DOMDocument Object and then load the File:
$oXML = new DOMDocument();
$oXML->load(Filename with Path);
Now if you have a external DOCTYPE like we did, you have to enable a Variable or it will not work before the ->load(..) Function:
$oXML->resolveExternals = true;
This enables to read external DOCTYPE Files.
Remember: If you are just using a couple of Entities, it's quicker to just put them directly in the File or create your own File with just the entities you need and link to that File. There were some comments on php.net that enabling that Variable will slow down the load Procedure for some time.

Now the load Procedure will not send you any more Warning Messages and possible an Exception, but you will still miss the HTML Entities in your Object.
Instead of Hello World which should look like that: Hello World, you will get a HelloWorld. You are still missing the Final Variable:
$oXML->substituteEntities = true;
With that you will get your Hello World and all other Entities your DOCTYPE defines.

Addition:
We had the additional Problem that we used htmlentities in the text like "&amp;" .. but we needed it also in php this way and using a doctype from w3c converted our entity into &, so we wrote our own Doctype File where we made a little hack so we could use htmlentities.

To use "&uuml ;" for ü we wrote into the dtd File the following:
<!ENTITY uuml "&amp;uuml ;">

Thursday, November 17, 2005

Civilization 4

Playing Civilization since Civ 2, i had to buy the new version. Civ 3 did not have any multiplayer posibilities so i just played it once or twice. But with Civ 4 they have really made a multiplayer Gamers Dream come true. Not even the Hot Seat Function is a ingenious old fashion Idea, which nowadays is very rare, but also the Email and LAN Game Possibilities are good.

And they really made a good Job with the LAN Option. In CallToPower2 we always had Problems at some time where we had to save and all had to load it again becouse the LAN mode was collapsing from time to time. But in Civ 4 we had no Problems at all.. even when somebody touched the Windows Key in Error... no Problem. That's a big THANKYOU!

The new Animations are also quite nice as the Idea not having one scout, but a scout unit. That shows how much work they put on it. The new Startmusic is great and also generating a new World when you start a new game.

What i am not able to understand is the diplomatic part. I am searching for threats and so on, but can not find anything. There is also no trade part as in CallToPower, where you built camels and trucks to ship goods through the continents.

And what they completely fucked up are spies. All they can do is show you were all Units of a country are or you can sabotage the current production of a city. Wow.. really.. where the hell are the features like steel technology?
Why isn't there an option to spread false information somewhere? Why can't i start a demostration in a foreign city so they begin a revolution and join me?

I really would like to spread false information to foreign countries so they start a war against each other and i just help one of them.... that's what i am missing... more possible options on spies and foreign affairs.

In war when you are winning, you can not force a surrender so they join you, no way, you have to fight until the last man.

And one more thing about the Mulitplayer Mode: In Singleplayer you get a Window with a Video when producing a Worldwonder, but in Multiplayer there is nothing like that. I miss an option for that.

Last but not least i want to talk about Religions. I think it is good to have the Religions now, but why do i have to invent them all to get throught to the end of technology? Why can't i just find one and be like that for the rest of the game, if i wish it?

I think Civilization 4 is a great game when it comes to Grafix, stabilitiy, Mulitplayer. But they have to work more on the diplomatic and spy part again. Hopefully a new addon will make some adjustments there.

Monday, November 07, 2005

squid error maybe solved

I might have solved my squid error Problem today. It seems like i just reached the memory limit of the host, but i would have supposed to get an php error instead.. or an apache error.. but nothing at all is not ok.

I found the calculation you need for imagecreatetruecolor at: http://www.boutell.com/gd/faq.html

Of course, opening truly huge images can cause real memory problems, if several are open at once. 8,000 pixels times 8,000 pixels times four bytes for truecolor equals a walloping 256 megabytes.


So you need 4 bytes per pixel and that meant 26MB just for the source image.. and i have about 32 MB to work with ;-(

Firefox ignores http-equiv Attribute in Meta Tag?

I just solved a bug which was keeping me busy the last hours. A Form for multilingual input went crazy in IE since it always mixed up the special characters.
The funny thing was, Firefox had no Problems with it at all.. so i tested different charsets, but IE never showed any change in reaction and i almost went beserk until i found an error in typing of the meta tag:

<meta equiv="type" content="text/html; charset=iso-8859-1">

You see the failure in http-equiv, which should say Content-Type. IE is very particular here, but Firefox seems to ignore it, since it reacted to all my changes perfectly...

For those who want's to see the right meta tag, here it is:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Friday, November 04, 2005

squid error while Uploading Image with PHP

I have a very strange problem with Squid on a host provided by a company in vienna. While triing to upload an Image with HTTP Post (normal Form Element with input File) i get a

Zero Sized Reply

ErrorMessage from Squid. The Problem only occures only when using Images greather than 1MB.

At first we checked the Parameters for php and apache (post_max_size,..) but they were set at least at 16MB... So this is not the source of our problems.

I have to clarify one thing: The Image normally would be uploaded, resized and then saved. Becouse of the Problems i changed the upload to first upload the image to a temporary File and then work with it, same Problem, but the File has been uploaded before the Error occured.

That made me a little curious and i checked the code where the Error exactly happen to be...
Another little Info is required here:
  • First i upload the File, which works fine.
  • Then i create an object from that image, which happens to be in jpeg Format, so i use imagecreatefromjpeg.
  • After that i have some code for resizing the image and
  • then i create a new Image Object by using imagecreatetruecolor with the calculated Size and copy the image into that new Object
  • At last the Object is saved as a File.
Well i used some var_dumps and exits and found the point where everything stopped working.. imagecreatetruecolor.

Odd, i though, and tried to create a Image with a less size... worked perfectly. Then i aligned the size step by step to the one calculated... and at about 300x200 there was the end.

Ok, this meant for me: The Function has not enough Memory to acquire for the Image.. The Provider also worked on the Problem on their site and they have another Problem: It works Perfectly on their site... why is it working when they are triing and when i try it not?
They asked me to outsource the code to a single file for testing, which i did. I tested it myself first and wow, everything is working...

Now i thought: That's it, here it ends, i am completely at the end of my knowledge and went home for some sleep ;-)

The next day i thought over it again and found the reason.. i used a couple of classes for the System, which i did not use on the outsourced File. This classes also needed some Memory which now they don't, so i have more memory for the Upload.
The quickest test was to change the end Resolution to 800x600, which worked on the server at my work fine, but not on the other host. (Got Ya!)

I simplified the outsourced code, killed the calculation code (since the end Size is 800x600) and so on until i just had the basic part. While working on that i found out if i don't call session_start() at the end of the file, the Code also stopps at the same position, but no error Message was called... (no Zero Sized Reply)...

Now we are still searching for that error.