// if you want to get fortune from local mysql server $from variable must be "mysql"
// or you can do $from="fortune.world.server.com:PORT"
// default values are below:
$from="mysql";
$mysql_host="localhost";
$mysql_user="root";
$mysql_pass="";
$mysql_db = "fortune";
// $from="213.74.172.7:7799";
if ($from != "mysql") {
$a = explode (":", $from);
$fsp = fsockopen ($a[0], $a[1]) or die ("Could not open connection...");
fputs ($fsp,"\n");
$c = fread ($fsp, 65535);
echo "
";
} else {
$mc = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die ("Cannot open mysql connection");
$numtable = mysql_list_tables($mysql_db);
srand ((double) microtime() * 1000000);
$c = mysql_num_rows($numtable);
$randval = rand(1, $c);
$d = 1;
while ($d <= $randval){
$d++;
$e = mysql_fetch_row($numtable);
}
$table=$e[0];
$q1 = mysql_query("select COUNT(*) from $table");
$qq1 = mysql_fetch_row($q1);
srand ((double) microtime() * 1000000);
$randval = rand(1, $qq1[0]);
$q2 = mysql_query ("select fortune from $table where id='$randval'");
$qq2 = mysql_fetch_row($q2);
echo "";
}
?>