string */ $strfile_header_array[char] = "\n$strfile_header_array[char]"; /* Add \n to beginning on seperation char. */ mt_srand((double) microtime() * 1000000); /* Seed the random number generator. */ $fortunefile_seek = mt_rand(1,$strfile_header_array[ulong2])*4; /* How much farther to seek? */ fseek($FORTUNE_DAT_FH,($fortunefile_seek+20)); /* Seeking... */ $fortunefile_offset_hex = fread($FORTUNE_DAT_FH,4); /* Find the offset. */ $fortunefile_offset = unpack('Noffset',$fortunefile_offset_hex); /* Convert to decimal */ fclose($FORTUNE_DAT_FH); /* Don't need the data file anymore. */ fseek($FORTUNE_FH,$fortunefile_offset[offset]); /* Seek to the fortune */ $fortunefile_unparsed_fortune = fread($FORTUNE_FH,$strfile_header_array[ulong3]); /* Read up to the length of longest string. */ fclose($FORTUNE_FH); /* Don't need the fortune file open anymore. */ $fortunefile_parsed_fortune = explode($strfile_header_array[char],$fortunefile_unparsed_fortune); /* Split it at the seperation character. */ trim($fortunefile_parsed_fortune[0]); /* Remove \r if read on a Windows box. */ return($fortunefile_parsed_fortune[0]); } ?>