/** * function to getAndStoreHexaHTML * returns FALSE on failure, TRUE otherwise */ function getAndStoreHexaHTML() { //$cachedFilename = "cachedHexas.html"; $cachedFilename = is_dir('pages') ? "pages/cachedHexas.html" : "cachedHexas.html"; // this script sets $trendsBoston, $trendsAtlanta, $trendsLA include '../cities.php'; // check if the script had any trouble or if we're out of requests // hey this might not work uhhh @todo later? if (!isset($trendsBoston) || !isset($trendsAtlanta) || !isset($trendsLA)) { //echo "trends arrays are empty, we're dead"; return FALSE; } else { $response = '<div class="content">'; $response .= '<div class="honeycombs">'; $response .= Honey($trendsBoston, "Boston", 8); $response .= Honey($trendsLA, "Los Angeles", 8); $response .= Honey($trendsAtlanta, "Atlanta", 8); $response .= "</div></div>"; } // get the absolute path to the file $fullpath = getcwd() . "/{$cachedFilename}"; // open it $handle = fopen($fullpath, "w"); // error check opening the file if (!$handle) { //echo "ERROR can't open file"; return FALSE; } // error check writing to the file if (fwrite($handle, $response) === FALSE) { //echo "ERROR file write error"; return FALSE; } // close the file and honestly, forget error checking. fclose($handle); // true means OK return TRUE; }
{ $i = 1; $tweetViewURL = "tweetLook.php"; //$tweetViewURL= "#trend"; $reply = ""; $coords = getCoordStrFromCityname($cityname); foreach ($arr as $honeycomb) { $href = "{$tweetViewURL}?q=" . urlencode($honeycomb) . "&{$coords}&rad=500"; $reply .= "<div class='comb'><span><p><a href='{$href}'>{$cityname}<br>_____<br><br> {$honeycomb}</a></p>\n</span></div>\n"; //$href="$tweetViewURL/". urlencode($honeycomb); //$reply .= "<div class='comb'><span><p><a href='$tweetViewURL/". urlencode($honeycomb)."'>$cityname<br>_____<br><br> $honeycomb</a></p>\n</span></div>\n"; if ($i === $num) { break 1; } $i++; } return $reply; } /*********** end function ***********/ /*************** main script ***************/ // @ todo this doesn't _really_ catch the errors, does it? if (!isset($trendsBoston) || !isset($trendsAtlanta) || !isset($trendsLA)) { die("<div>Out of requests! Please try again later.</div>"); } $response = '<div class="content">'; $response .= '<div class="honeycombs">'; $response .= Honey($trendsBoston, "Boston", 8); $response .= Honey($trendsLA, "Los Angeles", 8); $response .= Honey($trendsAtlanta, "Atlanta", 8); $response .= "</div></div>"; echo $response;