Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="localhost";
- $user="root";
- $pass="loic";
- $db="infobarquee";
- $connexion=mysql_connect($host,$user,$pass) or die (mysql_error());
- mysql_select_db($db) or die (mysql_error());
- $nbconnexion = 0;
- $nbconnexiontotal= 0;
- function liste_rep($src_dir)
- {
- $dir = opendir($src_dir);
- while ($nom = readdir($dir)) {
- if ($nom != "." && $nom != "..") {
- $chemin = $src_dir . "/" . $nom;
- if (is_dir($chemin)) {
- //echo($chemin . "<br>");
- liste_rep($chemin);
- } else {
- echo("<b><br/>" . $chemin . " </b>.....");
- //echo("<ul>");
- $file = fopen("$chemin", "r");
- $nbre2 = 0;
- $nom = array();
- $ip = explode('/', $chemin);
- echo ("<br>ip : " .$ip[1]);
- $ipip = $ip[1];
- $nomfichier = str_replace(' " ','.',$ip[2]);
- echo ("<br>nom fichier : " .$nomfichier);
- $date1 = explode('-', $chemin);
- $oldname = array();
- echo ("<br> date : " . $date1[1]);
- $date = $date1[1];
- while (!feof($file)) {
- $line = fgets($file);
- $nbre = substr_count($line, "Start");
- $nbre2 = $nbre2 + $nbre;
- $array = explode('NAS-Identifier =', $line);
- if (!array_search($nom, $oldname))
- {
- $nom = $array[1];
- $oldname[] = $nom;
- $nom = $array[1];
- //echo $nom;
- }
- }
- fclose($file);
- echo ("<br/>Hotspot : " .$nom);
- echo("<br/>nb connexions : " . $nbre2 . "<br/>");
- $query="INSERT INTO `nbconexion` (`chemin`,`ip`,`nom_fichier`,`date`,`hotspot`,`nb_connexion`) VALUES('$chemin','$ipip','$nomfichier','$date','$nom','$nbre2' )";
- mysql_query($query) or die (mysql_error());
- echo $query;
- exit();
- }
- }
- }
- closedir($dir);
- $nbconnexiontotal= $nbconnexiontotal + $nbconnexion;
- echo ("<br/>".$nbconnexiontotal."<br/>");
- }
- $src_dir = ".";
- liste_rep($src_dir);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement