rendered paste body<?php
$hostname = "localhost";
$username = "username";
$password = "password";
$dbName = "dbname";
mysql_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
mysql_select_db($dbName) or DIE("Table unavailable");
$loop=0;
$cloudarray=array();
$stopwords=array("something", "didnt", "bad", "big", "thought", "thoughts", "trying", "dont", "directly", "own", "try", "went", "wouldnt", "question", "info", "interesting", "off", "doesnt", "think", "end", "someone", "link", "bit", "place", "start", "getting", "different", "idea", "ideas", "heard", "small", "top", "set", "area", "day", "help", "long", "find", "say", "see", "year", "years", "zone", "she", "thinking", "old", "post", "even", "able", "amp", "actually", "back", "best", "change", "hey", "little", "once", "never", "lol", "two", "way", "sure", "lot", "lots", "posts", "isnt", "her", "great", "first", "few", "better", "last", "least", "one", "agree", "around", "cant", "come", "know", "new", "look", "looking", "going", "doing", "thing", "thats", "murray", "type", "list", "told", "thanks", "test", "another", "example", "take", "enough", "gday", "youve", "get", "things", "good", "need", "right", "took", "maybe", "its", "his", "my", "your", "ive", "up", "im", "beginning", "you", "did", "yep", "yup", "i", "do", "want", "far", "eg", "on", "a", "the","of","and","that","for","by","as","be","or","this","then","we","which","with","at","from","under","such","there","other","if","is","it","can","now","an","to","but","upon","where","these","when","whether","also","than","after","within","before","because","without","however","therefore","between","those","since","into","out","some","abs","about","accordingly","affecting","affected","again","against","all","almost","already","although","always","among","any","anyone","apparently","are","arise","aside","away","became","become","becomes","been","being","both","briefly","came","cannot","certain","certainly","could","etc","does","done","during","each","either","else","ever","every","following","found","further","gave","gets","give","given","giving","gone","got","had","hardly","has","have","having","here","how","itself","just","keep","kept","kg","knowledge","largely","like","made","mainly","make","many","mg","might","ml","more","most","mostly","much","must","nearly","necessarily","neither","next","none","nor","normally","not","noted","obtain","obtained","often","only","our","put","owing","particularly","past","perhaps","please","poorly","possible","possibly","potentially","predominantly","present","previously","primarily","probably","prompt","promptly","quickly","quite","rather","readily","really","recently","refs","regarding","regardless","relatively","respectively","resulted","resulting","results","said","same","seem","seen","several","shall","should","show","showed","shown","shows","significantly","similar","similarly","slightly","so","sometime","somewhat","soon","specifically","state","states","strongly","substantially","successfully","sufficiently","their","theirs","them","they","though","through","throughout","too","toward","unless","until","use","used","usefully","usefulness","using","usually","various","very","was","were","what","while","who","whose","why","widely","will","would","yet", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$sql="select `post_text` from phpbb_posts_text, phpbb_posts where phpbb_posts.post_id = phpbb_posts_text.post_id order by post_time desc limit 100";
$rs=mysql_query($sql);
$num=mysql_num_rows($rs);
if($num!=0) {
echo "<br><br>adding posts: ";
for($i=0;$i<$num;$i++) {
echo ".";
flush();
$post_text=mysql_result($rs,$i,"post_text");
$words=explode(" ",$post_text);
for($j=0;$j<sizeof($words);$j++) {
$pattern = '/[^a-zA-Z0-9 ]/';
$replacement = '';
$word=strtolower(preg_replace($pattern, $replacement, $words[$j]));
if (!in_array($word, $stopwords)) {
if(substr($word,0,5)!="quote" && strlen($word)>2 && strlen($word)<15 && strlen($word)>0) {
if (array_key_exists($word, $cloudarray)) {
$cloudarray[$word]['count']=$cloudarray[$word]['count']+1;
} else {
$cloudarray[$word]['count']=1;
}
$loop++;
echo ".";
if($loop%300==0) { echo "<br>"; }
}
}
}
}
}
echo 'tagcloud generated OK';
$loop=0;
$cloud="";
$top50=array();
arsort($cloudarray);
foreach($cloudarray as $key => $value){
$loop++;
if($loop<100) {
$top50[$key]=$cloudarray[$key]['count'];
}
}
ksort($top50);
foreach($top50 as $key => $value){
switch(TRUE) {
case ($value<8): $fontsize=10; break;
case ($value<12): $fontsize=14; break;
case ($value<15): $fontsize=15; break;
case ($value<20): $fontsize=16; break;
case ($value<25): $fontsize=17; break;
case ($value<30): $fontsize=20; break;
case ($value<35): $fontsize=22; break;
case ($value<40): $fontsize=26; break;
case ($value<50): $fontsize=30; break;
case ($value<500): $fontsize=36; break;
default: $fontsize=10; break;
}
$searchurl="http://forums.permaculture.org.au/search.php?search_keywords=$key";
#$cloud.="<a href='$searchurl'><div style='display:inline;font-size:".$fontsize."px'>$key (".$top50[$key].")</div></a> ";
$cloud.="<a target='_new' href='$searchurl'><span style='font-family:arial;font-size:".$fontsize."px'>$key</span></a> ";
}
unlink("cloud.html");
$myFile = "cloud.html";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $cloud;
fwrite($fh, $stringData);
fclose($fh);