copy car from string to newstring if tag > 0 => don't copy. Found one or more '<' and need to search '>'. If we found 3 '<' need to find all the 3 '>' */ /* I am C programmer. walk in a string is natural for me and more efficient */ for ($i=0; $i < $tam; $i++){ // If I found one '<', $tag++ and continue whithout copy if ($string{$i} == '<'){ $tag++; continue; } // if I found '>', decrease $tag and continue if ($string{$i} == '>'){ if ($tag){ $tag--; } /* $tag never be negative. If string is "test>" (error, of course) $tag will stop in 0 */ continue; } // if $tag is 0, can copy if ($tag == 0){ $newstring .= $string{$i}; // simple copy, only one car } } return $newstring; } include("feedcreator.class.php"); $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age<1 hour $rss->title = "Audio Books"; $rss->description = "Learn with Audio "; $rss->link = "http://www.thehouseofoojah.com/audiobooks"; $rss->syndicationURL = "http://www.thehouseofoojah.com/feed".$_SERVER["PHP_SELF"]; $image = new FeedImage(); $image->title = "The House of Oojah logo"; $image->url = "http://www.thehouseofoojah.com/skins/freepostover100/media/oojahNew.jpg"; $image->link = "http://www.TheHouseOfOojah.com"; $image->description = "Learn with your Ears ."; //optional //$image->descriptionTruncSize = 50; $image->descriptionHtmlSyndicated = true; $rss->image = $image; // connect to server $mysql_link = mysql_connect ("localhost", "gregoz_khxc", "willunga") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db("gregoz_khxc", $mysql_link); // pick only 1 item $res = mysql_query("SELECT * FROM ccp0_prod WHERE xcat like '%carnegie%' ORDER by rand() Limit 1"); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); $item->title = $data->name; $item->link = "http://www.thehouseofoojah.com/ccp0-prodshow/" .$data->id.".html"; // clean up the title so it looks better jumbled $clean_title = $data->name; // strip hyphens $clean_title = str_replace("-"," ",$clean_title); // strip "to" makes the jumbled title look bad $clean_title = str_replace(" to "," ",$clean_title); // strip "2" makes the jumbled title look bad $clean_title = str_replace("2","",$clean_title); // strip "8" makes the jumbled title look bad $clean_title = str_replace("8","",$clean_title); // strip "5" makes the jumbled title look bad $clean_title = str_replace("5","",$clean_title); // strip "1" makes the jumbled title look bad $clean_title = str_replace("1","",$clean_title); // strip "3" makes the jumbled title look bad $clean_title = str_replace("3","",$clean_title); // strip "4" makes the jumbled title look bad $clean_title = str_replace("4","",$clean_title); // strip "6" makes the jumbled title look bad $clean_title = str_replace("6","",$clean_title); // strip "7" makes the jumbled title look bad $clean_title = str_replace("7","",$clean_title); // strip "9" makes the jumbled title look bad $clean_title = str_replace("9","",$clean_title); // strip "$" makes the jumbled title look bad $clean_title = str_replace("$","",$clean_title); // strip "the" makes the jumbled title look bad $clean_title = str_replace(" the "," ",$clean_title); // strip "The" makes the jumbled title look bad $clean_title = str_replace(" The "," ",$clean_title); // strip "The" makes the jumbled title look bad $clean_title = str_replace("The "," ",$clean_title); // strip "The" makes the jumbled title look bad $clean_title = str_replace(" The ","",$clean_title); // strip "a" makes the jumbled title look bad $clean_title = str_replace(" a "," ",$clean_title); // strip "." makes the jumbled title look bad $clean_title = str_replace("."," ",$clean_title); // strip "the" makes the jumbled title look bad $clean_title = str_replace(" the ","",$clean_title); // strip "of" makes the jumbled title look bad $clean_title = str_replace(" of "," ",$clean_title); // strip "," makes the jumbled title look bad $clean_title = str_replace(",","",$clean_title); // strip "in" makes the jumbled title look bad $clean_title = str_replace(" in "," ",$clean_title); // strip "and" makes the jumbled title look bad $clean_title = str_replace(" and "," ",$clean_title); // strip "your" makes the jumbled title look bad $clean_title = str_replace(" your "," ",$clean_title); // strip "9" makes the jumbled title look bad $clean_title = str_replace("9","",$clean_title); // strip "Your" makes the jumbled title look bad $clean_title = str_replace(" Your "," ",$clean_title); // strip "plus" makes the jumbled title look bad $clean_title = str_replace(" plus "," ",$clean_title); // strip "You" makes the jumbled title look bad $clean_title = str_replace(" You "," ",$clean_title); // strip "Dr" makes the jumbled title look bad $clean_title = str_replace(" Dr "," ",$clean_title); // strip "for" makes the jumbled title look bad $clean_title = str_replace(" for "," ",$clean_title); // strip "&" makes the jumbled title look bad $clean_title = str_replace(" & "," ",$clean_title); // strip "It" makes the jumbled title look bad $clean_title = str_replace(" It ","",$clean_title); // strip "it" makes the jumbled title look bad $clean_title = str_replace(" it ","",$clean_title); // strip "it" makes the jumbled title look bad $clean_title = str_replace("0","",$clean_title); // strip "it" makes the jumbled title look bad $clean_title = str_replace("0","",$clean_title); // strip "Now!" makes the jumbled title look bad $clean_title = str_replace(" Now! ","",$clean_title); // strip "In" makes the jumbled title look bad $clean_title = str_replace(" In ","",$clean_title); // strip "it" makes the jumbled title look bad $clean_title = str_replace("0","",$clean_title); // strip "it" makes the jumbled title look bad $clean_title = str_replace("0","",$clean_title); // strip ":" makes the jumbled title look bad $clean_title = str_replace(":","",$clean_title); // strip "+" makes the jumbled title look bad $clean_title = str_replace("+","",$clean_title); //change the anchor text so that it is a random length $anchor_text = explode(" ",$clean_title); //shuffle it shuffle($anchor_text); // find the length array $anchor_len = count($anchor_text); //get a random num within the length of the array $ran_length = rand(1,$anchor_len); $keyword_pos = 0; $anchor_first =""; // fix odd blanks? if ($anchor_text[0]==""){ // push ran_length up 1 $ran_length = $ran_length + 1; } // put the new shortened anchor text of the keywords in while ( $keyword_pos < $ran_length) { $anchor_first = $anchor_first . " " . $anchor_text[$keyword_pos]; $keyword_pos = $keyword_pos+1; } // anchor text done - now we need to clean up description // fix description by stripping out the useless stuff $descript = trim(substr(theRealStripTags2($data->desclong),0,20000)); //then we need to strip out the commas because we are producing a csv file $descript = str_replace(","," ",$descript); // strip blanks tabs $descript = str_replace(" "," ",$descript); // strip blanks amp $descript = str_replace("&"," ",$descript); //strip new lines $descript = str_replace("\n"," ",$descript); // strip carriage returns $descript = str_replace("\r"," ",$descript); // strip double blanks to single - step 1 $descript = str_replace(" "," ",$descript); // strip double blanks to single - step 2 $descript = str_replace(" "," ",$descript); // strip double blanks to single - step 3 $descript = str_replace(" "," ",$descript); // strip double blanks to single - step 4 $descript = str_replace(" "," ",$descript); // strip double blanks to single - step 5 $descript = str_replace(" "," ",$descript); // strip double blanks to single - step 6 $descript = str_replace(" "," ",$descript); // strip double blanks to single - step 7 $descript = str_replace(" "," ",$descript); // strip brand new audio book? $descript = str_ireplace("Brand New Audio Book"," ",$descript); // strip brand new audiobook? $descript = str_ireplace("Brand New AudioBook"," ",$descript); // break up and truncate the description so we can embed the link in the middle $descript_array = explode(" ",$descript); // find the length array $descript_len = count($descript_array); // lets put the random anchor text at a random position in the text $new_description =""; $keyword_pos = 0; $ran_length = rand(1,250); // put the first part of the description in first while ( $keyword_pos < $ran_length) { $new_description = $new_description . " " . $descript_array[$keyword_pos]; $keyword_pos = $keyword_pos+1; } // now add our anchor text $new_description = $new_description . " " ."" . $anchor_first . ""; // now the rest of the description while ( $keyword_pos < $descript_len) { $new_description = $new_description . " " . $descript_array[$keyword_pos]; // lets see if we are above 250 words and we have a full stop if ($keyword_pos >250) { break; //lets exit } // end check for full stop above 250 $keyword_pos = $keyword_pos+1; } // end of description // don't hyperlink the picture - in fact don't have a picture $item->description = $new_description ; // make it the current time plus a bit $item->date = time() + 200; $item->source = "http://www.thehouseofoojah.com/audiobooks"; $item->author = "The House of Oojah"; $rss->addItem($item); } // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), // MBOX, OPML, ATOM, ATOM0.3, HTML, JS echo $rss->saveFeed("RSS2.0"); ?>