Archivio per Settembre 2005|pagina archivio mensile

ajax encoding pt.2: from js->escape to php->urldecode

Another brick to solve the encoding issue with ajax is settled, last week I ranted about the problem on showing data from a remote script inside a page encoded with ISO-8859-1.

This time I’ve the reverse problem, I’ve to save some data from a form to a db and then show it on another page. As usual xmlHttpRequest send data in UTF-8, so my data results always corrupted.

This time the solution is very simple, first I encode the data with javascript using the escape function then on the remote script I use the php function urldecode.

So a string like ÎÑTËRÑÅTÌÔñ�L will be escaped to %CE%D1T%CBR%D1%C5T%CC%D4%F1%C1L and then urldecoded back to ÎÑTËRÑÅTÌÔñ�L :)

ciuaz

phpCollab community forum hacked (again)

This is the 4th time that the phpCollab community forum, based on phpBB plus, was hacked.

I’ve liked a lot that forum but actually I, and the other dev team members, cannot check every single day if a new XSS o bug is discovered and if there is patch to download, we’re too busy by our payed day job to working also on something different than the phpCollab development.

With the new releases of phpBB also the update/patching process is begone long and boring with a lot of files to move, rename, update..

Now I’m thinking to switch to another OOS forum, but I don’t know what, the community doesn’t need a zillion features forum, but needs something easy to manage, to use and to restore.

Any ideas? (oh, obviously I need to import all the old messages…)

A bad way to use ajax

A friend of mine ask me about using ajax to create a small counter for his site, he wanted to update the counter every xx seconds to show how many users are visiting his site at the same time.

The idea is nice but after a 10 second thinking I’ve stopped him to implement such feature.

Why? Think about to use a small file (1kb) where you save the counter value.
Now, select as refresh time 5 seconds, every minutes a user will receive 12 refresh of the counter element (=12kb).

This isn’t a real problem for a single user but if the site has more than 100 users online? Every minutes the script will use quite 1Mb of server bandwith…

Do you see the path? If you use an ajax counter like this in a community forum with 100 different browser session, and is not rare that a user opens more than one session to read different posts, always online you’ll waste 60Mb/h => 1,4Gb day!!!

A good use of ajax should be very usefull, but a bad use will surely kill your servers…

ciuaz

utf-8 madness

As I wrote, I’m working on a stupid ajax (intranet) site but I’ve a lot of problem with charset encoding.

I’ve to publish, for legacy problem, all the intranet site using old ISO-8859-1 encoding BUT using the js XMLHttpRequest the data I receive is always UTF-8.

Unlucky I cannot use php to re-parse the data and to trasform to a latin encoding, anyone has a good idea to resolve this? Can I force another encoding on XMLHttpRequest?

Ok, I’m too tired to see the obvious… To resolve the problem I had simply forced the encoding via the php header function in the file I call remotely:

header(“Content-Type: application/x-javascript; charset=ISO-8859-1″);
echo $output;

now the browser show the right ÎÑTËRÑÅTÌÔñ�L strings :)

ciuaz

webdev days…

this is my very first (personal) post in english, please forgive my syntax, my poor dictionary (I know only a lot of tech words) and grammatical error… Btw I’ll improve it.. be sure ;)

I need some holidays, a year or two…

My head is near to explode after a full month on php, js, a very intricated and old db (that I cannot change for compatibility with an old application), some experiment on ajax and on CSS.

This one is the thing I hate more, the IE behaviour for the float things is driving me crazy… And my clients will never understand that I’M NOT A WEB DESIGNER but a developer… sigh…

ciauz

Il primo blog in italiano su WordPress.com?

Non so se Luca ha scritto qualcosa sul suo blog in italiano o se ha messo all’asta direttamente il suo account, ma altri blog in italiano non ne ho visti… :)

Che onore il primo blog di wp.com non in inglese… ma a questo punto, chi vuole essere il prossimo?

Regalerò un invito per wordpress.com alle seguenti condizioni:

  1. dovrà, tra le sue altre cose, parlare di php (e farsi aggregare dal blog del grusp)
  2. dovrà pubblicare i messaggi anche in italiano
  3. dovrà linkare downloadblog.it, fullo.net e fullo.wp.com nel suo futuro blog
  4. dovrà regalare subito l’invito omaggio che riceverà applicando 5 regole di cui una tratta dalle mie (a sua discrezione)
  5. dovrà essermi simpatico (e qui esce il vero bastardo che è in me…)

per il resto…

ciuaz