$value){ $path = realpath($dir.DIRECTORY_SEPARATOR.$value); if(!is_dir($path)) { $results[] = $path; } else if($value != "." && $value != "..") { getDirContents($path, $results); $results[] = $path; } } return $results; } $files = getDirContents('bigDB'); $fileData = function($file) { $file = fopen($file, 'r'); if (!$file) die('file does not exist or cannot be opened'); while (($line = fgets($file)) !== false) { yield $line; } fclose($file); }; $re1='([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})'; # Email Address 1 $re2='(:)'; # Any Single Character 1 foreach($files as $file) { if(filetype($file) == "file") { foreach ($fileData($file) as $line) { // $line contains current line if ($c=preg_match_all ("/".$re1.$re2."/is", $line, $matches)) { $data = explode(':', $line); if(count($data) > 2) { $i = 1; while($i <= count($data)) { $password .= $data[$i]; $i++; } } else { $password = $data[1]; } $mail = $data[0]; $db->where('username',$mail); $db->where('password',$password); $results = $db->get ('data'); if(count($results) == 0){ $insert = array("username" => $mail, "password" => $password); $id = $db->insert ('data', $insert); if($id) echo 'Entry created. Id=' . $id." username: ".$mail." password: ".$password."\n"; } else{ echo "Entry already exists!"; } } } } }