1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#! /usr/bin/php
<?php
//created by Antonio Gallo (tonicucoz@yahoo.com) and P. J. McDermott
// this script is in the Public Domain
include("connect.php");
include("functions.php");
//insert the PCI vendors
$ids_fp = fopen('pci.ids', 'r');
while (($line = fgets($ids_fp)) !== false) {
if (preg_match('/^([0-9a-f]{4})\s+(.*)\s*$/',
$line, $matches) == 1) {
$vendorid = $matches[1];
$full_name = sanitizeDb(decode_soft($matches[2]));
$clean_name = sanitizeDb(decode($matches[2]));
// echo "$vendorid $full_name $clean_name".PHP_EOL;
$query = "INSERT INTO vendors (bus,vendorid,clean_name,full_name) VALUES ('pci','$vendorid','$clean_name','$full_name');";
DB::$instance->query($query);
}
}
fclose($ids_fp);
//insert the USB vendors
$ids_fp = fopen('usb.ids', 'r');
while (($line = fgets($ids_fp)) !== false) {
if (preg_match('/^([0-9a-f]{4})\s+(.*)\s*$/',
$line, $matches) == 1) {
$vendorid = $matches[1];
$full_name = sanitizeDb(decode_soft($matches[2]));
$clean_name = sanitizeDb(decode($matches[2]));
// echo "$vendorid $full_name $clean_name".PHP_EOL;
$query = "INSERT INTO vendors (bus,vendorid,clean_name,full_name) VALUES ('usb','$vendorid','$clean_name','$full_name');";
DB::$instance->query($query);
}
}
fclose($ids_fp);
|