-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Description
Description
// use fseek
<?php
set_time_limit(0);

echo "loading";
$filepath = "Video Music.txt";
$file = new SplFileObject($filepath);
$n = 0;
$lined = Array();
$data1 = Array();
$datar = "";
$file_sql = $filepath.'.sql';
// The new person to add to the file
// Write the contents to the file,
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
$link = mysqli_connect('127.0.0.1', 'wlab', 'xxxxxx', 'test', '3307');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
/* $db_selected = mysqi_select_db('torrent', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
*/
while (false !== ($char = $file->fgetc())) {
//echo "$char\n";
$n++;
$lined[] = $char;
if($char == "\n"){
$datar = implode('', $lined);
$data1 = explode("|", $datar);
if(count($data1)==2){
$sql = "INSERT INTO magnet SET mn_exid=NULL,mn_name='".addslashes($data1[1])."',mn_size=NULL,mn_seed=NULL,mn_leker=NULL,mn_magnet='".trim($data1[0])."', mn_categ='".basename($filepath)."', mn_origin='BitSnoop', mn_date='2012-02-12 00:00:00';\r\n";
// echo "\n<br />"
// file_put_contents($file_sql, $sql, FILE_APPEND | LOCK_EX);
mysqli_query($link,$sql);
}else{
echo $datar;
}
$datar = "";
$lined = Array();
}
/* if($n==5000){
exit;
} */
}
echo $n;
?>
### PHP Version
8.3.12
### Operating System
win 11