Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2. $host="localhost";
  3.  
  4. $user="root";
  5.  
  6. $pass="loic";
  7.  
  8. $db="infobarquee";
  9. $connexion=mysql_connect($host,$user,$pass) or die (mysql_error());
  10.  
  11. mysql_select_db($db) or die (mysql_error());
  12. $nbconnexion = 0;
  13. $nbconnexiontotal= 0;
  14.  
  15. function liste_rep($src_dir)
  16.  
  17. {
  18.  
  19.  
  20. $dir = opendir($src_dir);
  21.  
  22.  
  23.  
  24. while ($nom = readdir($dir)) {
  25.  
  26. if ($nom != "." && $nom != "..") {
  27.  
  28. $chemin = $src_dir . "/" . $nom;
  29.  
  30. if (is_dir($chemin)) {
  31.  
  32. //echo($chemin . "<br>");
  33.  
  34. liste_rep($chemin);
  35.  
  36. } else {
  37.  
  38. echo("<b><br/>" . $chemin . " </b>.....");
  39. //echo("<ul>");
  40.  
  41. $file = fopen("$chemin", "r");
  42.  
  43. $nbre2 = 0;
  44.  
  45. $nom = array();
  46.  
  47. $ip = explode('/', $chemin);
  48.  
  49. echo ("<br>ip : " .$ip[1]);
  50. $ipip = $ip[1];
  51. $nomfichier = str_replace(' " ','.',$ip[2]);
  52.  
  53. echo ("<br>nom fichier : " .$nomfichier);
  54.  
  55. $date1 = explode('-', $chemin);
  56.  
  57. $oldname = array();
  58.  
  59. echo ("<br> date : " . $date1[1]);
  60. $date = $date1[1];
  61.  
  62. while (!feof($file)) {
  63.  
  64. $line = fgets($file);
  65.  
  66. $nbre = substr_count($line, "Start");
  67.  
  68. $nbre2 = $nbre2 + $nbre;
  69.  
  70. $array = explode('NAS-Identifier =', $line);
  71.  
  72. if (!array_search($nom, $oldname))
  73.  
  74. {
  75.  
  76. $nom = $array[1];
  77.  
  78. $oldname[] = $nom;
  79.  
  80. $nom = $array[1];
  81.  
  82. //echo $nom;
  83.  
  84.  
  85. }
  86.  
  87. }
  88.  
  89. fclose($file);
  90.  
  91. echo ("<br/>Hotspot : " .$nom);
  92.  
  93. echo("<br/>nb connexions : " . $nbre2 . "<br/>");
  94. $query="INSERT INTO `nbconexion` (`chemin`,`ip`,`nom_fichier`,`date`,`hotspot`,`nb_connexion`) VALUES('$chemin','$ipip','$nomfichier','$date','$nom','$nbre2' )";
  95.  
  96. mysql_query($query) or die (mysql_error());
  97. echo $query;
  98. exit();
  99. }
  100.  
  101. }
  102.  
  103. }
  104.  
  105.  
  106. closedir($dir);
  107. $nbconnexiontotal= $nbconnexiontotal + $nbconnexion;
  108.  
  109. echo ("<br/>".$nbconnexiontotal."<br/>");
  110.  
  111. }
  112.  
  113.  
  114. $src_dir = ".";
  115.  
  116.  
  117.  
  118. liste_rep($src_dir);
  119.  
  120. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement