forked from claell/BackupBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevice.php
More file actions
28 lines (23 loc) · 723 Bytes
/
device.php
File metadata and controls
28 lines (23 loc) · 723 Bytes
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
<?php
$con = mysqli_connect("localhost","root","root","ping_backupbox_se");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$lines = file("list.csv");
foreach($lines as $line) {
$parts = explode("\t",$line);
if(count($parts) == 1) {
$lastVendor = $id = substr($line, 0, 4);
}
if(count($parts) == 2) {
$id = substr($line, 1, 5);
$name = substr($line, 6);
mysqli_query($con,'INSERT INTO devices (id, vendor, name) VALUES ("'.$id.'","'.$lastVendor.'", "'.$name.'")');
echo('INSERT INTO devices (id, vendor, name) VALUES ("'.$id.'","'.$lastVendor.'", "'.$name.'")<br />');
}
//echo(count($parts)."<br />");
}
mysqli_close($con);
?>