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; } function badwords($old_string) { $title_excl = $old_string; $title_excl = str_replace('delete',"",$title_excl); $title_excl = str_replace('1=1',"",$title_excl); $title_excl = str_replace("=","",$title_excl); $title_excl = str_replace("search"," ",$title_excl); $title_excl = str_replace("*","",$title_excl); $title_excl = str_replace("alter","",$title_excl); $title_excl = str_replace("table","",$title_excl); $title_excl = str_replace("commit","",$title_excl); $title_excl = str_replace("load","",$title_excl); $title_excl = str_replace("desc","",$title_excl); $title_excl = str_replace("ignore","",$title_excl); $title_excl = str_replace("insert","",$title_excl); $title_excl = str_replace("lock"," ",$title_excl); $title_excl = str_replace("path","",$title_excl); $title_excl = str_replace("select","",$title_excl); // get rid of anything weird left //$title_excl = preg_replace("/[^A-Za-z0-9\s\s+\.\-\,]/","",$title_excl); // strip line returms carriage returns $new_string = $title_excl; return $new_string; } include("feedcreator.class.php"); $rss = new UniversalFeedCreator(); $rss->title = "The House of Oojah"; $rss->description = "AudioBooks "; $rss->link = "https://www.thehouseofoojah.com"; $rss->syndicationURL = "httsp://www.thehouseofoojah.com/feed".$_SERVER["PHP_SELF"]; $image = new FeedImage(); $image->title = "The House of Oojah logo"; $image->url = "https://www.thehouseofoojah.com/skins/freepostover100/media/oojahNew.jpg"; $image->link = "https://www.TheHouseOfOojah.com"; $image->description = "AudioBooks"; //optional //$image->descriptionTruncSize = 50; $image->descriptionHtmlSyndicated = true; $rss->image = $image; // pass value via url $search = $_GET['search']; $maxnumber= $_GET['max']; $search = badwords($search); $maxnumber = badwords($maxnumber); if ($maxnumber < 1){ $maxnumber=30; } // switch between duplicate spun databases if (rand(1,2)>1){ $mysql_link = mysql_connect ("localhost", "thehouseofoojah", "da5sgKbZc4uP") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db("copy1", $mysql_link); }else{// copy 2 database $mysql_link = mysql_connect ("localhost", "thehouseofoojah", "da5sgKbZc4uP") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db("copy2", $mysql_link); } $res = mysql_query("SELECT * FROM ccp0_prod WHERE xcat like '%" . $search . "%' ORDER by rand() LIMIT " . $maxnumber .""); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); $item->link = "https://www.thehouseofoojah.com/Item/" .$data->id; // 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); // randomise alt image text $alt_words2=$alt_image_text[rand(0,25)]; $alt_words1=$alt_image_text[rand(0,25)]; $alt_words3=$alt_image_text[rand(0,25)]; // if we need a second image line then this is what the html is $second_line = "" . $alt_words3 . "
"; 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); //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 =""; // 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; } // Add random anchor text 25% of the time // 50% put the shortened random tile in //%25 remove over optimised words // if only after 2 or less feeds then just strip bad words (blog posts for example) // plus sometimes just add the anchor text of the url "http://www.thehouseofoojah.com/ccp0-prodshow/" .$data->id.".html" if($maxnumber > 2){ $anchor_choice = rand(1,6); }else{ $anchor_choice=6; // feed less than 2 strip over optimised words } if($anchor_choice<3){ $item->title = $anchor_first; // 50% normal feed }elseif($anchor_choice==3){ $item->title = $anchor_words[rand(0,31)]; }elseif($anchor_choice==4){ $item->title = $anchor_words[rand(0,31)]; }elseif($anchor_choice==5){ $item->title = "https://www.thehouseofoojah.com/Item/" .$data->id; }else{ $item->title = str_ireplace($over_opt_words," ",$anchor_first); // remove over optimised words } // increment $i = $i + 1; $item->link = "https://www.thehouseofoojah.com/Item/" .$data->id; // 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,29); //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 = "'>additional info....."; } elseif ($rand_choice ==5) { $more_details = "'>considerably more details"; } elseif ($rand_choice ==6) { $more_details = "'>details"; } elseif ($rand_choice ==7) { $more_details = "'>full details"; } elseif ($rand_choice ==8) { $more_details = "'>further data"; } elseif ($rand_choice ==9) { $more_details = "'>here"; } elseif ($rand_choice ==10) { $more_details = "'>information"; } elseif ($rand_choice ==11) { $more_details = "'>more advice"; } elseif ($rand_choice ==12) { $more_details = "'>more data"; } elseif ($rand_choice ==13) { $more_details = "'>more info"; } elseif ($rand_choice ==14) { $more_details = "'>more tips"; } elseif ($rand_choice ==15) { $more_details = "'>much more info"; } elseif ($rand_choice ==16) { $more_details = "'>find out more....."; } elseif ($rand_choice ==17) { $more_details = "'>click here"; } elseif ($rand_choice ==18) { $more_details = "'>click"; } elseif ($rand_choice ==19) { $more_details = "'>link here"; } elseif ($rand_choice ==20) { $more_details = "'>click on"; } elseif ($rand_choice ==21) { $more_details = "'>click the link"; } elseif ($rand_choice ==22) { $more_details = "'>click to go"; } elseif ($rand_choice ==23) { $more_details = "'>come here"; } elseif ($rand_choice ==24) { $more_details = "'>extra"; } elseif ($rand_choice ==25) { $more_details = "'>extra info"; } elseif ($rand_choice ==26) { $more_details = "'>lots more"; } elseif ($rand_choice ==27) { $more_details = "'>related info"; } elseif ($rand_choice ==28) { $more_details = "'>click here....."; } elseif ($rand_choice ==29) { $more_details = "'>more....."; } else { $more_details = "'>extra info....."; } //Randomise the length of descrition // make a better sub description $wrapped_descript = wordwrap($descript,100); //find out how many lines in the description $array_descript = explode("\n", $wrapped_descript); $lines_descrip = count($array_descript)-1; // depending on number of lines is how we will determine the substr if ($lines_descrip<3 ){ // do nothing display the description as is }elseif($lines_descrip<5){ // get the description after line 1 $descript=substr($wrapped_descript,0,strpos($wrapped_descript, "\n")); }elseif($lines_descrip<18){ //randomise the start line $line_count=rand(1,5); //between 2nd and 5th line array $end_count=$line_count+12; //lets have 12 lines $descript_bits = ""; while($line_count<$end_count){ // max five lines // create a description with the lines after line 2 $descript_bits = $descript_bits . " " . str_replace("\n","",$array_descript[$line_count]); $line_count=$line_count+1; $descript = $descript_bits; } }else{ //randomise the start line $line_count=rand(1,5); //between 2nd and 5th line array $end_count=$line_count+9; //lets have 12 lines $descript_bits = ""; while($line_count<$end_count){ // max five lines // create a description with the lines after line 2 $descript_bits = $descript_bits . " " . str_replace("\n","",$array_descript[$line_count]); $line_count=$line_count+1; } // now do 3 more lines from later in the text $line_count = rand(10,$lines_descrip); $end_count=$line_count+3; while($line_count<$end_count){ // max five lines // create a description with the lines after line 2 $descript_bits = $descript_bits . " " . str_replace("\n","",$array_descript[$line_count]); $line_count=$line_count+1; $descript = $descript_bits; } }// end better desc // hyperlink the picture and take the first 600 characters plus add the image text $item->description = "" . $alt_words1 . "
" . $second_line . "" . $alt_words2 . "
" . $descript . " " ."