20 || ((filemtime($cache_file) + $cache_time - $time[1]) + $cache_time_rnd < 0) || (filemtime(__FILE__) > filemtime($cache_file)) ) { $c = curl_init($api_url); curl_setopt($c, CURLOPT_RETURNTRANSFER,1); curl_setopt($c, CURLOPT_USERPWD,"$user:$pass"); curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($c, CURLOPT_TIMEOUT, 4); curl_setopt($c, CURLOPT_USERAGENT, "del.icio.us WordPress Plugin v1.3 http://linuxbrit.co.uk/"); $response = curl_exec($c); $info = curl_getinfo($c); $_curl_error_code = $info['http_code']; curl_close($c); if ($_curl_error_code == 200) { $_fpwrite = fopen($cache_file_tmp, 'w'); if($_fpwrite) { # parse the XML, then write out includable html to the cache file. if (!($xml_parser = xml_parser_create())) die("Couldn't create parser."); xml_set_element_handler($xml_parser, "_delicious_startelem", "_delicious_endelem"); fputs($_fpwrite, "\n"); xml_parser_free($xml_parser); fclose($_fpwrite); # be atomic rename($cache_file_tmp, $cache_file); } } } if ((file_exists($cache_file)) && filesize($cache_file) > 20) { include($cache_file); } elseif ($_curl_error_code) { echo ""; } else { echo ""; } } function _delicious_startelem ($parser,$name,$attrib) { global $_fpwrite; global $_del_user; switch ($name) { case $name=="POST" : { $href = htmlspecialchars($attrib["HREF"]); $desc = htmlspecialchars($attrib["DESCRIPTION"]); $extended = htmlspecialchars($attrib["EXTENDED"]); $tag = htmlspecialchars($attrib["TAG"]); $time = htmlspecialchars($attrib["TIME"]); $time = preg_replace("/[TZ]/", " ", $time); $line = "
  • \n"; $line .= " $desc\n"; if ($_display_extended && $extended && $extended != $desc) { $line .= "

    $extended

    \n"; } if ($_display_tags) { $line .= " \n"; } $line .= "
  • \n"; fputs($_fpwrite, $line); break; } } } function _delicious_endelem ($parser,$name){ } ?>