1 OR s.`listen_url` NOT LIKE 'http://%.radionomy.com:80/%' GROUP BY s.`id` ORDER BY m.`listeners` DESC;"; $res = $db->selectQuery($query)->array_data; shuffle($res); $tpl->assign_by_ref('streams', $res); $xml = $tpl->fetch('yp.xml.tpl'); // Write data $temp_filename = XML_OUTPUT.'.tmp.'. sha1(uniqid(rand(), true)); echo $temp_filename."\n"; $fp = fopen($temp_filename, 'w'); $l = fwrite($fp, $xml); fclose($fp); if ($l == strlen($xml)) { if (rename($temp_filename, XML_OUTPUT)) { echo "OK.\n"; exit(); } } echo "KO.\n"; ?>