Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Licznerski</title>
  8. </head>
  9. <body>
  10. <br>
  11. <?php
  12. // Polaczenie z baza
  13. $dbhost="serwer1976179.home.pl"; $dbuser="31577296_uslugi"; $dbpassword="Okulary123/"; $dbname="31577296_uslugi";
  14. $polaczenie = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname);
  15. if (!$polaczenie) {
  16. echo "Błąd połączenia z MySQL." . PHP_EOL;
  17. echo "Errno: " . mysqli_connect_errno() . PHP_EOL;
  18. echo "Error: " . mysqli_connect_error() . PHP_EOL;
  19. exit;
  20. }
  21.  
  22. // Wczytanie rekordow
  23. $domeny = mysqli_query($polaczenie, "SELECT * FROM domeny") or die ("Błąd zapytania do bazy: $dbname");
  24. $pracownicy = mysqli_query($polaczenie, "SELECT * FROM Pracownicy") or die ("Błąd zapytania do bazy: $dbname");
  25.  
  26. ?>
  27. <form action="dodaj.php" method="post">
  28. Adres strony:
  29. <input type="text" name="adres">
  30. <br/><br/>
  31. Numer portu:
  32. <input type="text" name="port">
  33. <br><br>
  34. <select name="pracownicy">
  35. <?php
  36. // Wyswietlenie pracownikow w liscie rozwijanej
  37. while ($wiersz = mysqli_fetch_array ($pracownicy))
  38. {
  39. print "<option value=\"$wiersz[1]\">$wiersz[1]</option>";
  40. }
  41. ?>
  42. </select>
  43. <input type="submit" value="Dodaj adres">
  44. </form>
  45. <br/>
  46. <?php
  47. // Wyswietlenie tabeli
  48. print "<TABLE CELLPADDING=5 BORDER=1>";
  49. print "<TR><TD>idt</TD><TD>Nazwa</TD><TD>Pracuje</TD><TD>Port</TD><TD>Pracownicy</TD></TR>\n";
  50.  
  51. while ($wiersz = mysqli_fetch_array ($domeny)) {
  52. $idt = $wiersz[0];
  53. $nazwa = $wiersz[1];
  54. $numer_portu = $wiersz[2];
  55. $pracownik = $wiersz[3];
  56. $host = $nazwa;
  57. $port = '80';
  58.  
  59. $fp = @fsockopen($host, $port, $errno, $errstr, 30);
  60.  
  61. if ($fp && $numer_portu == 80){
  62. print "<TR><TD>$idt</TD><TD>$nazwa</TD><TD>Ok</TD><TD>$numer_portu</TD><TD>$pracownik</td></TR>\n";
  63. }
  64. else {
  65. print "<TR><TD>$idt</TD><TD>$nazwa</TD><TD>Awaria</TD><TD>$numer_portu</TD><td>$pracownik</td></TR>\n";
  66. }
  67. }
  68.  
  69. print "</TABLE>";
  70. mysqli_close($polaczenie);
  71. ?>
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement