'; $img .= '
'; if (sizeof($notes) > 0) { $img .= 'This photo has notes. Move your mouse over the photo to see them.'; } $img .= ''; $ret = array(); $ret['img'] = $img; $noteout = ''; $boxes = ''; foreach (array_keys($notes) as $notekey) { $note = $notes[$notekey]; $previewboxes .= '
'; $boxes .= '
 
'; $noteout .= '_notes[_notes.length] = \'photo_note_' . $notekey . '\';'; } $ret['notes'] = $noteout; $ret['boxes'] = $boxes; $ret['prevbox'] = $previewboxes; $ret['notekeys'] = array_keys($notes); return $ret; } /* Function that reads file from the cache if it is younger than a certain age and otherwise grabs a fresh copy of it from remote source */ function cached_file_get_contents($file, $file_mode, $cache_timeout = 3600, $cache_path = '../', $debug = false) { // $debug = true; clearstatcache(); // Clear file stats so we get an accurate file creation time for cache files if (function_exists('sha1')) // Prefer SHA1 because collision space is much larger than MD5, but MD5 will work too { $cache_filename = $cache_path . "/" . sha1($file) .".cached"; // Path to cached file } else { $cache_filename = $cache_path . "/" . md5($file) . ".cached"; // Path to cached file } if ($debug) { print "local_cache creation_time =".@filemtime($cache_filename)." actual time = ".time()." timeout = ".$timeout_seconds."\n"; } // If file exists and is young enough then do nothing because it will return file contents of cache if (( @file_exists($cache_filename) && (( @filemtime($cache_filename) + $cache_timeout) > ( time())))) { if ($debug) { print "using cached file ($cache_filename)\n"; } } else // If file doesn't exist or is too old get a fresh copy from remote source { if ($debug) { print "caching file ($file) to local ($cache_filename)\n"; } // MEME: make this also work with libcurl? i dont have that installed so i use the command line //$command_line = "/usr/bin/curl -m 120 -s $file > $cache_filename"; //exec($command_line, $foo, $num); $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $file); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); curl_close ($ch); $fh = fopen($cache_filename, 'w') or die("can't open file $cache_filename for writing"); fwrite($fh, $data); fclose($fh); } return @file_get_contents ($cache_filename); // Return the file contents from the cache } /* Function that parses the XML results from the Flickr API (based on torsten@jserver.de's makeXMLTree function found at http://www.php.net/manual/en/ref.xml.php) */ function noteMakeXMLTree($data) { $output = array(); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $data, $values, $tags); xml_parser_free($parser); $hash_stack = array(); foreach ($values as $key => $val) // Loop through all the values the XML parser gave us { switch ($val['type']) { case 'open': switch ($val['tag']) { case 'photo': // Grab photoset attributes array_push($hash_stack, $val['attributes']['id']); array_push($hash_stack, 'primary'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['primary']}\";"); array_pop($hash_stack); array_push($hash_stack, 'secret'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['secret']}\";"); array_pop($hash_stack); array_push($hash_stack, 'server'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['server']}\";"); array_pop($hash_stack); array_push($hash_stack, 'photos'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['photos']}\";"); array_pop($hash_stack); break; case 'owner': // Grab owner attributes array_push($hash_stack, 'owner'); array_push($hash_stack, 'nsid'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['nsid']}\";"); array_pop($hash_stack); array_pop($hash_stack); break; case 'notes': // Grab notes attributes array_push($hash_stack, 'notes'); break; case 'note': // an actual note array_push($hash_stack, $val['attributes']['id']); array_push($hash_stack, 'x'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['x']}\";"); array_pop($hash_stack); array_push($hash_stack, 'y'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['y']}\";"); array_pop($hash_stack); array_push($hash_stack, 'w'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['w']}\";"); array_pop($hash_stack); array_push($hash_stack, 'h'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['h']}\";"); array_pop($hash_stack); array_push($hash_stack, 'text'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['value']}\";"); array_pop($hash_stack); break; case 'user': // Grab owner attributes array_push($hash_stack, 'user'); array_push($hash_stack, 'url'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['url']}\";"); array_pop($hash_stack); array_pop($hash_stack); break; default: array_push($hash_stack, $val['tag']); break; } break; case 'close': array_pop($hash_stack); break; case 'complete': switch ($val['tag']) { case 'photo': // Grab photo attributes array_push($hash_stack, $val['attributes']['id']); array_push($hash_stack, 'secret'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['secret']}\";"); array_pop($hash_stack); array_push($hash_stack, 'server'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['server']}\";"); array_pop($hash_stack); array_push($hash_stack, 'isprimary'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['isprimary']}\";"); array_pop($hash_stack); array_push($hash_stack, 'license'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['license']}\";"); array_pop($hash_stack); array_pop($hash_stack); break; case 'owner': // Grab owner attributes array_push($hash_stack, 'owner'); array_push($hash_stack, 'nsid'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['nsid']}\";"); array_pop($hash_stack); array_pop($hash_stack); break; case 'notes': array_push($hash_stack, 'notes'); array_pop($hash_stack); break; case 'note': // an actual note array_push($hash_stack, $val['attributes']['id']); array_push($hash_stack, 'x'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['x']}\";"); array_pop($hash_stack); array_push($hash_stack, 'y'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['y']}\";"); array_pop($hash_stack); array_push($hash_stack, 'w'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['w']}\";"); array_pop($hash_stack); array_push($hash_stack, 'h'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['h']}\";"); array_pop($hash_stack); array_push($hash_stack, 'text'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['value']}\";"); array_pop($hash_stack); array_pop($hash_stack); break; case 'user': // Grab owner attributes array_push($hash_stack, 'user'); array_push($hash_stack, 'url'); eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['attributes']['url']}\";"); array_pop($hash_stack); array_pop($hash_stack); break; default: array_push($hash_stack, $val['tag']); @eval("\$output['" . implode($hash_stack, "']['") . "'] = \"{$val['value']}\";"); array_pop($hash_stack); break; } } } return $output; } // get the photo # $k = array_keys($_GET); $photoid = $k[0]; //$foo = "document.write(\" ".$photoid."\");"; print $foo; $photo = flickrphoto($photoid); // the actual work ?> var _style = ''; var _IE4=(document.all); var _notes = new Array(); // document.write(_style); document.write('
'); document.write('
class="photo_notes">
'); document.write(''); document.write('
'); document.write(''); document.write('
'); document.getElementById().style.visibility = 'hidden'; function { document.getElementById().style.visibility = 'visible'; } function { document.getElementById().style.visibility = 'visible'; }