Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "dhcpertekeles";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. //$conn->select_db('ping');
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14. ?>
  15.  
  16. <?php
  17. /*ini_set('error_reporting', E_ALL)*/
  18. include('dhcpdbconnect.inc');
  19. require('header.php');
  20. session_start();
  21. set_time_limit(0)
  22. ?>
  23.  
  24. if(count($_FILES["file"]['name'])>0)
  25. {
  26.  
  27. for($j=0; $j < count($_FILES["file"]['name']); $j++)
  28. {
  29. $filen = $_FILES["file"]['name']["$j"];
  30. $path = 'upload/'.$filen;
  31. if(move_uploaded_file($_FILES["file"]['tmp_name']["$j"],$path))
  32. {
  33.  
  34. $fn = fopen( utf8_encode($path),"rwb") or die("Fájl megnyitása sikertelen");
  35. $lines = file($path);
  36.  
  37. for ($i=0; $i <=32; $i++){
  38. array_shift($lines);
  39. };
  40.  
  41. for ($i=0; $i<=sizeof($lines)-1; $i++){
  42.  
  43. $cols = explode( (","), $lines[$i] );
  44.  
  45. $dateblow = explode(("/") , $cols[1]);
  46.  
  47.  
  48. $date = "20".$dateblow[2] . "-" . $dateblow[0] . "-" . $dateblow[1];
  49. /*print $date;*/
  50.  
  51. $hostnameblow = explode(("."), $cols[5]);
  52.  
  53. /*print $hostnameblow[0] ."<br>" . "sor";*/
  54.  
  55.  
  56. $result =mysqli_query($conn, "SELECT * FROM ping.users WHERE `hostname` = '".$hostnameblow[0]."'");
  57. if ($result->num_rows == 0 && $hostnameblow[0] != "")
  58.  
  59. {
  60.  
  61.  
  62. $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]."')";
  63. /*print $sql . "<br>";*/
  64. /*print $hostnameblow[0] . "<br>";*/
  65. $result =mysqli_query($conn, $sql)/* or die(mysqli_error($conn))*/;
  66.  
  67.  
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74. };
  75. fclose( $fn );
  76. unlink($path);
  77. };
  78. };
  79. print "Felvitel sikeres";
  80. print"<br><br><br><a href='dhcpedit.php'>Vissza</a>";
  81. }
  82.  
  83. /*print $sql . "<br>";*/
  84.  
  85. $result =mysqli_query($conn, $sql)
  86.  
  87. <html><head>
  88. <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