This is the code I use for batch importing. It takes a .txt file, parses it and inserts info into my MYSQL DB.
It needs to be rewritten (I just ripped it off one of my scripts), it'll create undeletable files on your server depending on server setting, its a bit clunky 'cause it doesn't use regexp... and you need an HTML with a form that takes files with BROWSE, but I'm about to hit the sack .. so I'll just post it.
PHP Code:
$batchlinksdir = "mysql/batchfiles"; // directory where the .txt file's uploaded.
upload_file("batchlinks", $batchlinksdir);
$batchfilename = $_FILES['batchlinks']['name'];
$file = fopen("../batch/$batchfilename", "r");
while($fileline = fscanf($file, "%[a-zA-Z0-9@&=;_:./ '!?-]\n")) {
list($myline) = $fileline;
$myline = substr($myline, strpos($myline, "http:"), strlen($myline));
list($url) = sscanf($myline, "http://%[a-zA-Z0-9@&=_,:./!?-][ |\n]");
if($url=='') echo "EMPTY STRING<BR>";
else {
$url = "http://" .$url;
echo "PARSED URL: " .$url ."<BR>";
/*_ First, check if the url already's in the database __*/
$query = "SELECT * FROM hosted_gallery WHERE url=\"$url\"";
$result = mysql_query($query) or mysql_error();
if(mysql_num_rows($result)>0) echo "URL: [$url]::DUPLICATE ENTRY<BR>";
else {
$query = "INSERT INTO hosted_gallery (url,site_id,description,title, url_type_id, static,content_type,niche_id,disable, thumb, date_added,dvd_id) VALUES ('$url','$site_id',\"$description\",\"$title\", '$url_type_id', '$static','$content_type','$niche_id', '$disable', '$thumbname', '$date_added', '$dvd_id')";
$result = mysql_query($query) or error_msg($query ." modify-gallery.php::batch<BR>");
}
}
}
fclose($file);
exit;
}