How to create custom tags in drupal(Like wordpress)

Leave a comment

Create a vocabulary with ‘tags’ checkbox checked(Terms are created by users when submitting posts by typing a comma separated list.).

And Follow this link-


Mongodb Querying

Leave a comment

With this post i want to explain some of my experiences with Mongodb and php mongo driver.

  • searching a  collection of Mongodb with a word we can use the code like this
$search = new MongoRegex(“/”.$str.”/i”);
$cursor = $collection->find(array(“Campo” => $search))
($str is the string for search,collection is the reference to db collection,Campo is the field to search)
(i will add more  later)

Syndication rules

Leave a comment


I have noticed that, beside Planet (and Universe) Gentoo and Linux-Planet — both of which I asked for my blog to be syndacated on, there are a number of other websites that seem to fetch and use my own posts, fetched from the atom feeds.

Some of these are community websites, other are “hubs” that supposedly focus content for users; quite a few though seem to be scams and websites that simply take others’ posts and snap a bunch of AdSense units over them. While I could go as far as pushing for DMCA violation for those – as often CC-BY-NC-ND is not respected – I’d rather not, and especially I’d rather go with technical solutions of some kind.

What I would like to do is to have different feeds depending on who’s requesting them; so have a “pure” feed, with the original unmangled content from Typo for the syndications I allow explicitly (with host-based detection is even better), one Flattr-enabled feed to provide to feed readers and Google, and one, eventually, with AdSense units to shove down the abusive websites.

Now, for the moment I set up the two most-subscribed feeds on Google’s FeedBurner; I’d still ask you to keep using my blog’s host URLs though, as that might not be a definitive solution; if I can find some software to deal with this, or even write a Typo plugin to handle this for me, I’ll drop FeedBurner again; I’m just not happy to have to outsource feeds handling for my own blog. I’ll call this an experiment. If you happen to subscribe to the FeedBurner feeds, don’t worry, I’ll make sure to keep them updated, and hopefully without mangling content if I do handle that on my side.

Now, the important information on this post relates to the “rules” for syndicating my content, so that it is clear whether you’ll get the Ad-encumbered feed or not. Obviously if I asked to be syndicated, as is the case for Planet Gentoo and Linux Planet, then you’ll get the absolutely clear feed: no ads, no flattr buttons, nothing else. If the website has no content, a lot of ads, and even worse no indication of where the content truly comes from, I’m going to consider technical means to hinder the syndication, such as pushing ads on the feed myself, or removing the content, or adding a footer making the author and the terms of the content’s license explicit.

For the rest of the websites, I’m generally not going to bother; if you’re a decent news aggregator, and don’t have advertisement as main content on your site, and you abide to the content’s license giving proper attribution rather than showing off my content as your own, I’ve got no problem. I’ll be happy if you were to flattr me and I might decide to push a Flattr button on the content pushed on.. if you wish to avoid that, you’re free to contact me and we can work out the details.. in general I have no objection to that as long as your aggregation software is decent enough to cache responses using If-None-Match and If-Modified-Since, and to use deflated (compressed) content transfer.

custom cck check box and default values and label

Leave a comment

For making cck check box field with label and default value,tricky way is there.You must pass ‘Allowed values list:’ as a key value pair separated with ‘|’.



Then it shows proper label when editing the story.

File upload with session codepage 65001

Leave a comment

The problems with session.codepage=65001 and MidB(asp,vbscript)

MID is intended for use with languages that use the single-byte character set (SBCS), whereas MIDB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

o MID always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.

o MIDB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language.

So when you use file uploading with the following code you need to set up session.code page to 1252 and after uploading reset it with your defaults.
The code i  have used for test(default setting of session.codepage is 65001)
<form method=”POST” enctype=”multipart/form-data” action=”testupload.asp?id=0″>
<font size=”2″>
File :
<input type=”file” name=”file” size=”20″><br>
<input type=”submit” name=”Enter” value=”Upload –>”>

L’unica particolarità di questo modulo (form) è come passare i dati inseriti (enctype=”multipart/form-data”).

Il file upload.asp

<%@ Language= VBScript %>
if request.querystring(“id”)<>”” then
‘for avoid byte counting problems we need to set up session.code page to english .
‘MidB counts double-byte character as 2 when you have enabled the
‘editing of a language that supports DBCS and then set it as the default language
‘for avoiding this probelm please set code page 1252 when use file upload and reset the utf-8 code page to rest
Session.CodePage = 1252
response.write “————–“
‘ Imposta il tempo max di esecuzione dello script (espresso in millisecondi)
Server.ScriptTimeout = 100000

Response.Buffer = TRUE

‘impostazioni variabili
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Set UploadRequest = CreateObject(“Scripting.Dictionary”)
BuildUploadRequest RequestBin

‘individua il tipo di file che si cerca di fare l upload
contentType = UploadRequest.Item(“file”).Item(“ContentType”)

‘intero percorso del file
filepathname = UploadRequest.Item(“file”).Item(“FileName”)

‘****************************** CONTROLLI IMMAGINE

‘controllo tipo immagine
tipo = Right(filepathname,Len(filepathname)-InstrRev(filepathname,”.”))

‘cambiare la scrita zip e gz qui sotto per inserire la sigla di un altro tipo di file
‘Se si vuole permettere l’upload di qualsiasi tipo di file cancellare o commentare
‘le successive 4 linee di codice e l’ultimo END IF della pagina upload.asp
‘If tipo <> “zip” AND tipo <> “gz” then
‘Response.Write (“Errore Upload.
‘Non è possibile fare upload di un file .” & tipo)

‘ calcolo del peso della immagine
‘imposta qui, il peso max.
‘9000 vuol dire 9 Kb circa
‘IF byteCount > 9000 THEN
‘Response.Write (“Errore Upload.
‘File troppo grande!”)

‘*********************************** NOME FINALE DEL FILE e UPLOAD
nomefile = Right(filepathname,Len(filepathname)-InstrRev(filepathname,”\”))

‘in questa variabile viene salvato il nome del file che sarà del tipo 2311235.gif
filename = nomefile

value = UploadRequest.Item(“file”).Item(“Value”)
Set ScriptObject = Server.CreateObject(“Scripting.FileSystemObject”)
pathEnd = Len(Server.mappath(Request.ServerVariables(“PATH_INFO”)))-14

‘da questa riga di codice si specifica l’indirizzo relativo dove sarà inserito il file
response.write Server.mappath(“../../immagini”) & “/”&filename
Set MyFile = ScriptObject.CreateTextFile(Server.mappath(“../../immagini”) & “/”&filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))


‘End If
‘End If
end if

Questo script in poche parole effettua un controllo sul tipo e il peso del file di cui si vuole fare l’upload.
Questo script va inserito tra gli HEAD della nostra pagina web, altrimenti non funzionerà.
Questo codice inoltre preleva il nome del file (senza url) e lo memorizza dentro la cartella impostata.
Per funziona, questo script necessita anche della seguente riga di codice da inserire tra i tag BODY: <!–include file=”esegui.asp”–>

La pagina esegui.asp

Questa pagina contiene codice che NON DEVE essere modificato.
Basta copiarlo e incollarlo così come è.


‘********************** NON MODIFICARE
‘è il cuore dello script
‘senza questo file non viene effettuato l upload
Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString(“–“)))
Dim UploadControl
Set UploadControl = CreateObject(“Scripting.Dictionary”)
Pos = InstrB(BoundaryPos,RequestBin,getByteString(“Content-Disposition”))
Pos = InstrB(Pos,RequestBin,getByteString(“name=”))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString(“filename=”))
PosBound = InstrB(PosEnd,RequestBin,boundary)
If PosFile<>0 AND (PosFile) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add “FileName”, FileName
Pos = InstrB(PosEnd,RequestBin,getByteString(“Content-Type:”))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add “ContentType”,ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add “Value” , Value
UploadRequest.Add name, UploadControl
End Sub
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
End Function

Function getString(StringBin)
getString =””
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
End Function

Compare It

Leave a comment

A worried woman went to her gynecologist and said:

Leave a comment

One of my friend send me this Email.I think It is a good one for every one to read.Please take only the right thinking .don’t be negative

A worried woman went to her gynecologist and said:
‘Doctor, I have a serious problem and desperately need your help! My baby is not even 1 yr. old and I’m pregnant again. I don’t want kids so close together.’

So the doctor said: ‘Ok and what do you want me to do?’

She said: ‘I want you to end my pregnancy, and I’m counting on your help with this.’

The doctor thought for a little, and after some silence he said to the lady: ‘I think I have a better solution for your problem. It’s less dangerous for you too.’

She smiled, thinking that the doctor was going to accept her request.

Then he continued: ‘You see, in order for you not to have to take care of 2 babies at the same time, let’s kill the one in your arms. This way, you could rest some before the other one is born. If we’re going to kill one of them, it doesn’t matter which one it is. There would be no risk for your body if you chose the one in your arms.

The lady was horrified and said: ‘No doctor! How terrible! It’s a crime to kill a child!

‘I agree’, the doctor replied. ‘But you seemed to be ok with it, so I thought maybe that was the best solution. The doctor smiled, realizing that he had made his point.

He convinced the mom that there is no difference in killing a child that’s already been born and one that’s still in the womb. The crime is the same!

Older Entries Newer Entries