Hi alirezaok,
I think this is redirect related.
I added this line:
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
And it ends @ http://www.aftab.ir/setcookiefirst.php I guess this is cookie-less browser detection you have implemented. So figure a way to make your php script bypass the detection? (i'm not really sure without further investigation).
You can also use (for a better understanding of what is happening):
curl_setopt($curl, CURLOPT_VERBOSE, 1);
Curlopt documentation here : http://uk3.php.net/manual/en/function.curl-setopt.php
James_h