1) return $sentence." ".nonsense($numSentences-1); return $sentence; } function nonsense_word($numWords = 1) { $lists = array("interjections", "determiners", "adjectives", "nouns", "adverbs", "verbs", "prepositions", "conjunctions", "comparatives"); foreach ($lists as $part) $wordlists[] = file(NONSENSE_PATH."$part.txt"); $word_list = ''; for ($count = 1; $count <= $numWords; $count++) { if ($count > 1) $word_list .= ' '; $list_to_use = mt_rand(0, sizeof($wordlists) - 1); $word_to_use = mt_rand(0, sizeof($wordlists[$list_to_use]) - 1); $word = $wordlists[$list_to_use][$word_to_use]; if (strpos($word, ' ')) { $word = substr_replace($word, '', strpos($word, ' ')); } $word = trim($word); $word_list .= strtolower($word); } return $word_list; } class Nonsense { function Nonsense() { $this->lists = array("interjections", "determiners", "adjectives", "nouns", "adverbs", "verbs", "prepositions", "conjunctions", "comparatives"); $this->vowels = array('a','e','i','o','u'); $this->wordlists = array(); $this->output = ''; foreach ($this->lists as $part) { $this->wordlists[$part] = file(NONSENSE_PATH."$part.txt"); } } function sentence($numSentences = 1) { $type = mt_rand(0,1); for ($i=0; $i<2; $i++) { foreach ($this->lists as $part) { ${$part}[$i] = trim($this->wordlists[$part][mt_rand(0,count($this->wordlists[$part]) - 1)]); } if ($determiners[$i] == "a") { foreach ($this->vowels as $vowel) { if (($type && ($adjectives[$i][0] == $vowel)) || (!$type && ($nouns[$i][0] == $vowel))) { $determiners[$i] = "an"; } } } } $sentence = ($type ? "$interjections[0], $determiners[0] $adjectives[0] $nouns[0] $adverbs[0] $verbs[0] $prepositions[0] $determiners[1] $adjectives[1] $nouns[1]." : "$interjections[0], $determiners[0] $nouns[0] is $comparatives[0] $adjectives[0] than $determiners[1] $adjectives[1] $nouns[1]."); if ($numSentences > 1) { $sentence .= " " . $this->sentence($numSentences-1); $this->output = $sentence; return $this->output; } return $sentence; } function word($numWords = 1) { $word_list = ''; for ($count = 1; $count <= $numWords; $count++) { if ($count > 1) { $word_list .= ' '; } $list_to_use = mt_rand(0, sizeof($this->wordlists) - 1); $word_to_use = mt_rand(0, sizeof($this->wordlists[$this->lists[$list_to_use]]) - 1); $word = $this->wordlists[$this->lists[$list_to_use]][$word_to_use]; if (strpos($word, ' ')) { $word = substr_replace($word, '', strpos($word, ' ')); } $word = trim($word); $word_list .= strtolower($word); } $this->output = $word_list; return $this->output; } } function get_included_path($file_name) { $included_files = get_included_files(); $path = ''; foreach ($included_files as $file) { if (preg_match("/({$file_name})$/", $file)) { $path = preg_replace("/({$file_name})$/", '', $file); } } return $path; } // end nonsense include("feedcreator.class.php"); $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age<1 hour $rss->syndicationURL = "http://www.TheHouseOfOojah.com/feed".$_SERVER["PHP_SELF"]; // added to connect to server? $mysql_link = mysql_connect ("localhost", "gregoz_delbase", "willunga") or die ('I cannot connect to the database because: ' . mysql_error()); // is this a duplicated redundant command? mysql_select_db("gregoz_delbase", $mysql_link); $res = mysql_query("SELECT * FROM deltable ORDER by rand() LIMIT 100"); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); // change the nouns list file // open the nouns file $_file = "nouns.txt"; $_fp = @fopen( $_file, 'w' ); // break the tages up $tags_array = explode(" ",$data->tags); // loop through the array and pull them out one by one for ($i=1; $i<=count($tags_array); $i++) { $_nouns_data= $tags_array[$i] . "\n"; @fwrite( $_fp, $_nouns_data ); } // close the file @fclose( $_fp ); //end change the nouns data //add some nonsense words $random_sentences = nonsense(3); $random_sentence2 = nonsense(1); // convert data to arrays $data_array = explode(" ",$data->description); // get the first few words of the description and save them if (strlen($data->description)>20) { $start_descript = substr($data->description,0,strpos($data->description," ",19)); } else { $start_descript = $data->description; } //combine the two arrays $big_array = $tags_array + $data_array; //shuffle it shuffle($big_array); // randomly pick out some anchor text - 5 words array has been shuffled if (count($big_array)>5) { $anchor_array = array($big_array[1],$big_array[2],$big_array[3],$big_array[4],$big_array[5],$big_array[6]); } else { $anchor_array = $big_array; } //anchor text for the link plus add the start words saved $item->title = $start_descript . " " . implode(" ",$anchor_array); //$start_descript; //. implode(" ",$anchor_array); // add the URL $item->link = $data->url; // put the mixed tags and the description together then add the unshuffled description $item->description = $data->extended . " " .$random_sentences . " " . implode(" ",$big_array) . " " . $data->description . " " . $random_sentence2; $item->source = "http://www.TheHouseOfOojah.com.au/"; $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"); ?>