feed_md5.phps

#!/usr/bin/php
<?
// Ok, so this script feeds a database table with all the words (separated by newlines)
// from a user-specified file, along with their md5-hash
ini_set ( "memory_limit", "600M");

mysql_connect(':/var/run/mysqld/mysqld.sock','user','pass');
mysql_select_db('md5');

#$str = file_get_contents('tokens4.txt');
$str = file_get_contents($argv[1]);

$token = strtok($str, "\n");
while($token !== false)
{
	$data = strtolower($token);
	mysql_query('insert delayed into md5 (str, md5) values ("'.mysql_real_escape_string($data).'","'.md5($data).'"),("'.mysql_real_escape_string($token).'","'.md5($token).'")') or die(mysql_error());
	$token = strtok("\n");
}
?>