Fix SEO problem in drupal (give 301 to node/xx request)

this was a problem with :

could be accessed from /node/442

Solution is to redirect all /node/[0-9]* url to the aliased one
… and is very simple in code:

includes/ :

function drupal_init_path() {
  if (!empty($_GET['q'])) {
    // add this conditional
    if(preg_match('/node\/[0-9]*$/',$_GET['q'])) {
      include "includes/";
      $newq = trim(url($_GET['q']),'/');
      if($newq!=$_GET['q']) {
    $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
  else {
    $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));

drupal_init_path() is called in bootstrap as sixth pass and find the internal path (like /node/[0-9]*)
Here I check if the request contains already a normal path, check if there is
aliased path, if so goto that path and give 301

update (16 August, 2010)
is better to use this (add conditional and goto) in custom_url_rewrite_inbound() function:
and do not touch drupal main code

see also

skype for linux 2.1 beta: 64 bit?

released skype for linux 2.1, I followed link and downloaded 64 bit version for ubuntu .. but look at package control:

Package: skype
Status: install ok installed
Priority: extra
Section: non-free/net
Installed-Size: 25096
Maintainer: Skype Technologies
Architecture: amd64
Depends: lib32stdc++6 (>= 4.1.1-21), lib32asound2 (>> 1.0.14), ia32-libs (>= 1.6), libc6-i386 (>= 2.7-1), lib32gcc1 (>= 1:4.1.1-21+ia32.libs.1.19)

Umh, a tricky way to make amd64 package …

innerHTML problem with internet explorer (supposed)

I lost some time to debug this


The problem is on Internet Explorer (all version) that refuse to load data in #target, using $.get and innerHTML(data) do not help. The problem is with no well formed html! Internet Explorer refuse to load in dom a malformed html.


will load interested html in new popup (letit open!) and wrapping with <xml></xml> document should be well formed: open with conglomerate or checking with other tool make life easy.

Email from your host you are banned (mail php security matter)

I found this in a server:

$header = "From: <".$_REQUEST['email'].">\n";

$_REQUEST[’email’] came from a form input …

Here $_REQUEST[’email’] should be, at least, stripped by all \n no matter on how you trust to js code..

$from = $_REQUEST['email'];
$from = str_replace("\n","",$from);
$header = "From: <$from>\n";

Option List jQuery plugin

A plugin for display list of item to insert.

List item are stored in input hidden comma separed, the call is simple

Some bug to fix

options are

  • target: target div to update with options
  • input: input to update with values
  • items: items list as key:value
  • optional: default to $(“<input>”).attr(“type”,”text”) … you can setup autocomplete
  • preset: an array of key preset (must be in items)
	      input: '#iptvalues',
	      items: {'0':'prova','1':'test','2':'due','3':'tre'},
	      preset: [0]


.optionlist_itemlist {
border:1px solid #000;
  background: #999;

also #optionlist_overlay is the overlay at z-index:3000

grep over ssh in emacs

M-x grep command is very useful in a number of situation, because, for example, it give you direct access to all matched file …

But there is not so intuitive how to use grep when opening file via ssh, this is the trick:

First generate a key pair and upload public part to the remote server:
(suppose remote host/user is B/b)

ssh-keygen -t rsa
ssh b@B mkdir -p .ssh
cat ~/.ssh/ | ssh b@B 'cat >> .ssh/authorized_keys'

be sure to use ssh-agent in order to use ssh-add

So you will not be asked for a password every time you ssh

Every time you want to grep in emacs:

M-x grep
Run grep (like this): ssh -t b@B 'grep -nH -e include path_to_files/*'

where path_to_file is the path relative to home in remote host

NOTE: do grep command when visiting remote home in emacs (otherwise it will not find matched files)

that’s all

SiteMap php class

2 simple class for sitemap:

simple use:

{syntaxhighlighter brush:php}
$sm = new SiteMap($root,’sitemap-1.xml’);
$http = “”;

…SiteMapIdx similar

jQuery Waiting plugin

This is a simple jQuery plugin for purpose of loading phase of an ajax request or anything else.


to stop a waiting div