I try to see what is the problem without success.
So I ran the script and printed out every command at each step to see what PHP is doing :
Query to close expired ads :
UPDATE pa_products SET approved=2,status='1261365284' WHERE enddate < 1261365284 AND isauction=0
test : if ( $timediff > 86399 )
1261365284 >86399 so run the query :
UPDATE pa_stats SET lastupdate='1261365284' WHERE id=1
Select ads that expire in 3 days:
SELECT id,user,userid,title,enddate,duration FROM pa_products WHERE enddate < 1262229284 AND status=0 AND isauction=0
Then it deals with ads that expire within 0 to 10 days.
Do you see something wrong ?