Tags: Real Estate
"; $mytag_close1 = ""; $taglen1 = 13; $mytag_open2 = ""; $mytag_close2 = ""; $taglen2 = 14; $mytag_open3 = ""; $mytag_close3 = ""; $taglen3 = 16; $mytag_open4 = ""; $mytag_close4 = ""; $taglen4 = 13; $wordstoshow = "22"; $wordender = ""; function word_limit($string, $length = 20, $ellipsis = "..."){ return (count($words = explode(' ', $string)) > $length) ? implode(' ', array_slice($words, 0, $length)) . $ellipsis : $string; } $cat_array = file("tempcats.txt"); foreach($cat_array as $cat){ $folder = trim($cat)."/"; $postedin = str_replace("_", " ", $folder); $postedin = ucwords(str_replace("/", "", $postedin)); $fileCount = 0; if($handle = opendir($folder)) { $total_array = array(); while(false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != ".htaccess" && $file != "index.html") { $filename = $file; $fp = fopen($folder.$filename, "r"); $contents = fread($fp, filesize($folder.$filename)); $pos1 = strpos($contents,$mytag_open1); //list tags to look for $pos2 = strpos($contents,$mytag_close1); $str_length1 = $pos2 - $pos1; $pos3 = strpos($contents,$mytag_open2); //image tags to look for $pos4 = strpos($contents,$mytag_close2); $str_length2 = $pos4 - $pos3; $pos5 = strpos($contents,$mytag_open3); //content tags to look for $pos6 = strpos($contents,$mytag_close3); $str_length3 = $pos6 - $pos5; $pos7 = strpos($contents,$mytag_open4); //date tags to look for $pos8 = strpos($contents,$mytag_close4); $str_length4 = $pos8 - $pos7; $date = substr($contents,$pos7+$taglen4,$str_length4-$taglen4); // offsets for tag3 length $date = str_replace("", "", $date); //remove end comment tags $total_array[$fileCount]['date'] = $date; $title = substr($contents,$pos1+$taglen1,$str_length1-$taglen1); // offsets for tag1 length $total_array[$fileCount]['title'] = $title; $image = substr($contents,$pos3+$taglen2,$str_length2-$taglen2); // offsets for tag2 length $total_array[$fileCount]['image'] = $image; $description = substr($contents,$pos5+$taglen3,$str_length3-$taglen3); // offsets for tag3 length $total_array[$fileCount]['description'] = $description; $total_array[$fileCount]['file'] = $file; // $total_array[]['date'] // $total_array[]['title'] // $total_array[]['image'] // $total_array[]['description'] // $total_array[]['file'] fclose($fp); $file_array[] = $file; $fileCount++; } } } closedir($handle); sort($total_array); //sort by newest date $iterator = 0; while($file_array[$iterator] && $iterator < 1) { $file = substr($file_array[$iterator], 0, (strlen($file_array[$iterator]))); $total_array[$iterator]['title'] = str_replace("
", "", $total_array[$iterator]['title']); //title link fixes $total_array[$iterator]['title'] = str_replace("
", "", $total_array[$iterator]['title']); $total_array[$iterator]['title'] = str_replace("", "", $total_array[$iterator]['title']); $total_array[$iterator]['image'] = str_replace("md_", "tb_", $total_array[$iterator]['image']); //image fixes $total_array[$iterator]['image'] = str_replace("bg_", "tb_", $total_array[$iterator]['image']); $total_array[$iterator]['image'] = str_replace("
", "", $total_array[$iterator]['image']);
$total_array[$iterator]['description'] = str_replace("
", "", $total_array[$iterator]['description']); //article content fixes [we don't want to see this stuff]
$total_array[$iterator]['description'] = str_replace("
", "", $total_array[$iterator]['description']);
$total_array[$iterator]['description'] = str_replace("About the Author", "", $total_array[$iterator]['description']);
$popupfix = str_replace("
", "", $total_array[$iterator]['title']); $popupfix = str_replace("
", "", $popupfix); $popupfix = str_replace("", "", $popupfix); $popupfix = str_replace("", "", $popupfix); //display link content echo '';
echo '
| ';
echo '';
echo ''.$total_array[$iterator]['title'].''; //show title links
echo ' '; echo word_limit($total_array[$iterator]['description'],$wordstoshow,$wordender); //show a few lines from articles $timestring = $total_array[$iterator]['date']; $timestring = strtotime($timestring); $gooddate = date('F jS Y', $timestring); echo ' '.$postedin.' | '.$gooddate.' '; echo ' |
'; $iterator++; } unset($file_array); unset($total_array); } ?>