Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "dhcpertekeles";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- //$conn->select_db('ping');
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- ?>
- <?php
- /*ini_set('error_reporting', E_ALL)*/
- include('dhcpdbconnect.inc');
- require('header.php');
- session_start();
- set_time_limit(0)
- ?>
- if(count($_FILES["file"]['name'])>0)
- {
- for($j=0; $j < count($_FILES["file"]['name']); $j++)
- {
- $filen = $_FILES["file"]['name']["$j"];
- $path = 'upload/'.$filen;
- if(move_uploaded_file($_FILES["file"]['tmp_name']["$j"],$path))
- {
- $fn = fopen( utf8_encode($path),"rwb") or die("Fájl megnyitása sikertelen");
- $lines = file($path);
- for ($i=0; $i <=32; $i++){
- array_shift($lines);
- };
- for ($i=0; $i<=sizeof($lines)-1; $i++){
- $cols = explode( (","), $lines[$i] );
- $dateblow = explode(("/") , $cols[1]);
- $date = "20".$dateblow[2] . "-" . $dateblow[0] . "-" . $dateblow[1];
- /*print $date;*/
- $hostnameblow = explode(("."), $cols[5]);
- /*print $hostnameblow[0] ."<br>" . "sor";*/
- $result =mysqli_query($conn, "SELECT * FROM ping.users WHERE `hostname` = '".$hostnameblow[0]."'");
- if ($result->num_rows == 0 && $hostnameblow[0] != "")
- {
- $sql = "insert into dhcpertekeles.dhcpk (azonosito, datum, ido, leiras, ip, allomasnev, mac, felhasznalonev, tranzakcioazonosito, lekerdezese, vizsgalatido, korrelaciosaz, dhcid) values ('".$cols[0]."', '".$date."', '".$cols[2]."', '".$cols[3] ."', '".$cols[4]."', '".$hostnameblow[0]."', '".$cols[6]."', '".$cols[7]."', '".$cols[8]."', '".$cols[9]."', '".$cols[10]."', '".$cols[11]."', '".$cols[12]."')";
- /*print $sql . "<br>";*/
- /*print $hostnameblow[0] . "<br>";*/
- $result =mysqli_query($conn, $sql)/* or die(mysqli_error($conn))*/;
- }
- };
- fclose( $fn );
- unlink($path);
- };
- };
- print "Felvitel sikeres";
- print"<br><br><br><a href='dhcpedit.php'>Vissza</a>";
- }
- /*print $sql . "<br>";*/
- $result =mysqli_query($conn, $sql)
- <html><head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body></body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement