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 = "The House of Oojah Deepak Chopra Audio Books"; $rss->description = "Motivational Deepak Chopra Audio Books "; $rss->link = "http://www.thehouseofoojah.com/ccp0-catshow/deepak-chopra-audio-books-cd-audiobook.html"; $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 = "Deepak Chopra Audio Books."; //optional //$image->descriptionTruncSize = 50; $image->descriptionHtmlSyndicated = true; $rss->image = $image; // added to connect to server? $mysql_link = mysql_connect ("localhost", "gregoz_khxc", "willunga") or die ('I cannot connect to the database because: ' . mysql_error()); // is this a duplicated redundant command? mysql_select_db("gregoz_khxc", $mysql_link); $res = mysql_query("SELECT * FROM ccp0_prod WHERE xcat like '%chopra%' ORDER by rand()"); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); $item->link = "http://www.thehouseofoojah.com/ccp0-prodshow/" .$data->id.".html"; // lets make a picture of the title // use default font $font_file = 'ARIALN.TTF'; $title_array = explode(" ",$data->name); $title_len = count($title_array); // set a counter $keyword_pos = 0; // blank the string $string = ""; if (strlen($data->name)>50){ // loop and plug the keywords into string while ($keyword_pos < 7) { $string = $string . $title_array[$keyword_pos] . " "; $keyword_pos = $keyword_pos +1 ; } //end while } else { $string = $data->name; } // put the new shortened anchor text of the keywords in //add the title string // $string = $data->name; //check how long the title is and pick a smaller font if required $font_size = 14; // Figure out how large the bounding image box will be based on the font size and length of the text $bbox = imageftbbox($font_size, 0, $font_file, $string); $width = abs($bbox[4] - $bbox[0]) +2; $height = abs($bbox[1] - $bbox[5]) +7; // Add 6 to height if uppercase or tall characters are used to prevent top from being cut off $im = imagecreate($width,$height); // Set color, background color, and line color // Will accept html color codes (000000) and rgb codes (0,0,0) // set background to ffffff // set default background color to white $background_color = imagecolorallocate($im, 255,255,255); // set default text color to black $color = imagecolorallocate($im, 0,0,0); // set default line color to background_color $line_color = $background_color; $draw_line = true; // Output the image imagefttext($im, $font_size, 0, 0, $height-6, $color, $font_file, $string); //header("Content-type: image/png"); //imagepng($im); imagejpeg($im, "images/" . image . $data->imgsm, 100); imagedestroy($im); // do it again for the second row if its more than 50 characters // set a counter - we have already done 9 words $keyword_pos = 7; // blank the string $string = ""; // second line is blank if we don't need it $second_line =""; if (strlen($data->name)>50){ // loop and plug the keywords into string while ($keyword_pos < 18) { $string = $string . $title_array[$keyword_pos] . " "; $keyword_pos = $keyword_pos +1 ; } //end while $font_size = 14; // Figure out how large the bounding image box will be based on the font size and length of the text $bbox = imageftbbox($font_size, 0, $font_file, $string); $width = abs($bbox[4] - $bbox[0]) +2; $height = abs($bbox[1] - $bbox[5]) +7; // Add 6 to height if uppercase or tall characters are used to prevent top from being cut off $im = imagecreate($width,$height); // Set color, background color, and line color // Will accept html color codes (000000) and rgb codes (0,0,0) // set background to ffffff // set default background color to white $background_color = imagecolorallocate($im, 255,255,255); // set default text color to black $color = imagecolorallocate($im, 0,0,0); // set default line color to background_color $line_color = $background_color; $draw_line = true; // Output the image imagefttext($im, $font_size, 0, 0, $height-6, $color, $font_file, $string); //header("Content-type: image/png"); //imagepng($im); // write the new image stick a 2 infront of it to make it different imagejpeg($im, "images/" . "2" . image . $data->imgsm, 100); // if we need a second image line then this is what the html is $second_line = "audio book audiobook
"; imagedestroy($im); } // end of >50 for seconf line of image //end image create (2nd line) // 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; } // put the shortened random tile in $item->title = $anchor_first; // increment $i = $i + 1; $item->link = "http://www.thehouseofoojah.com/ccp0-prodshow/" .$data->id.".html"; // fix description by stripping out the useless stuff $descript = trim(substr(theRealStripTags2($data->desclong),0,20000)); //then we need to strip out the commas $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); // randomise the more details anchor text $rand_choice = rand(1,7); //echo $rand_choice . "
"; //more details if ($rand_choice == 1) { $more_details = "'>more details.....
"; } elseif ($rand_choice ==2) { $more_details = "'>more information....."; } elseif ($rand_choice ==3) { $more_details = "'>more here....."; } elseif ($rand_choice ==4) { $more_details = "'>find out more....."; } elseif ($rand_choice ==5) { $more_details = "'>click here....."; } elseif ($rand_choice ==6) { $more_details = "'>more....."; } else { $more_details = "'>extra info....."; } // hyperlink the picture and take the first 600 characters plus add the image text $item->description = "audio book audiobook
" . $second_line . "
audio book audiobook
" . substr($descript,0,700) . " " ."