0) { $pos2=strpos($chaineAT,chr(13),$pos); $id = substr($chaineAT,$pos+18,$pos2-$pos-18); } else { $id = "NEW!";} // ne doit pas arriver !!! // on a $id ///////////////////////////////////// // Lecture des datas... //$filename = "/var/www/ArcherTrainer/ST/".$mac; $filename = "/var/www/ArcherTrainer/AT/".$mac."/stat"; $chaine2=file_get_contents($filename); //echo $chaine2; $Date = strtotime(date("d-m-Y")); $nbT7j = 0; for ($x=0 ; $x>-7; $x-- ) { $d = date('d-m-Y', strtotime($x.' days', $Date)); $d1[abs($x)]=$d; $d2[abs($x)]=0; $pos= strpos($chaine2,$d); if ($pos>0) { // 26-08-2021,nb=132,p=91.4,tt=5.9,tm=3.8,co=85.5,r=8.4, $pos=strpos($chaine2,"nb=",$pos); $pos2=strpos($chaine2,",",$pos); $nb = substr($chaine2,$pos+3,$pos2-$pos-3); $pos=strpos($chaine2,",p=",$pos); $pos2=strpos($chaine2,",",$pos+1); $p = substr($chaine2,$pos+3,$pos2-$pos-3); $pos=strpos($chaine2,"tt=",$pos); $pos2=strpos($chaine2,",",$pos); $tt = substr($chaine2,$pos+3,$pos2-$pos-3); $d4[abs($x)]=$tt; $pos=strpos($chaine2,"tm=",$pos); $pos2=strpos($chaine2,",",$pos); $tm = substr($chaine2,$pos+3,$pos2-$pos-3); $d5[abs($x)]=$tm; $pos=strpos($chaine2,"co=",$pos); $pos2=strpos($chaine2,",",$pos); $co = substr($chaine2,$pos+3,$pos2-$pos-3); $d6[abs($x)]=$co; $pos=strpos($chaine2,"r=",$pos); $pos2=strpos($chaine2,",",$pos); $r = substr($chaine2,$pos+2,$pos2-$pos-2); $d71[abs($x)]=$r; } } ///////////////////////// Dernière scéance de tir //////////////////////////////// $Date = strtotime(date("d-m-Y")); $x=0; do { $d = date('Y-m-d', strtotime($x.' days', $Date)); $filename = "/var/www/ArcherTrainer/AT/".$mac."/".$d; $chaine2=file_get_contents($filename); $x--; } while(empty($chaine2)); $dde = $d; $pos8=0; $x=0; $tp = 0; $ttt = 0; $ttm = 0; $cott = 0; $cotm = 0; do { $pos8=strpos($chaine2,"Date=",$pos8+1); if ($pos8>0) { $pos2=strpos($chaine2,chr(10),$pos8); $Ligne=substr($chaine2,$pos8,$pos2-$pos8); $h = substr($Ligne,16,8); $d7[$x] = "(".($x+1).") ".$h; // heure en legende //echo $h; $pos=strpos($Ligne,"nb="); $pos2=strpos($Ligne,",",$pos); $nb = substr($Ligne,$pos+3,$pos2-$pos-3); $d8[$x]=$nb; $pos=strpos($Ligne,",p="); $pos2=strpos($Ligne,",",$pos+1); $p = substr($Ligne,$pos+3,$pos2-$pos-3); $d9[$x]=$p; $pos=strpos($Ligne,"tt="); $pos2=strpos($Ligne,",",$pos); $tt = substr($Ligne,$pos+3,$pos2-$pos-3); $d10[$x]=$tt; $pos=strpos($Ligne,"tm="); $pos2=strpos($Ligne,",",$pos); $tm = substr($Ligne,$pos+3,$pos2-$pos-3); $d11[$x]=$tm; $ttt += $tt; $ttm += $tm; $moytt = $ttt/($x+1); $moytm = $ttm/($x+1); $cott += abs($tt-$moytt); $cotm += abs($tm-$moytm); if ($moytt>0) {$cott2 = intval(( 1 - $cott / ($x+1) / $moytt)*100)+1;} if ($moytm>0) {$cotm2 = intval(( 1 - $cotm / ($x+1) / $moytm)*100)+1;} $co = ($cott2+$cotm2)/2; $d12[$x] = $co; $pos3=0; $pos4=1; do { $pos3 = $pos4; $pos4 = strpos($chaine2,"result=",$pos4+1); if ($pos4>$pos8) {$pos4=0;} } while ($pos4>0); $pos4 = strpos($chaine2,"result=", $pos3+1 ); $nbfleche = substr_count($chaine2, "datax", $pos3, $pos4-$pos3); // result $pos9 = strpos($chaine2,"result=",$pos8); if ($pos9>0) { $pos10 = strpos($chaine2,",",$pos9); $result = substr($chaine2,$pos9+7,$pos10-$pos9-7); if ($nbfleche>0) {$ps = intval($result / $nbfleche * 10);} $d13[$x] = $ps; } else { $d13[$x] = 0; } } if (strpos($Ligne,"result=")==0) {$x++;} } while ($pos8>0); $nbmax = $x-1; //echo $Ligne; //echo $h; // 'Précision', 'Repro', 'Score', 'Nb Flèche', 'Nb entrainement' //'data' =>[ $p , $r , $s , $nbf , $nbe ], // calcul du nombre de jour d'entrainement $Date = strtotime(date("d-m-Y")); $x=0; $nbe=0; $ttp=0; do { $d = date('Y-m-d', strtotime($x.' days', $Date)); $filename = "/var/www/ArcherTrainer/AT/".$mac."/".$d; $chaine2=file_get_contents($filename); if (!empty($chaine2)) { $nbe += 1; $nbf += substr_count($chaine2, "datax"); $d2[abs($x)]= substr_count($chaine2, "datax"); $pos=1; $tp=0; for ($i=1;$i<=$d2[abs($x)]; $i++) { $pos=strpos($chaine2,",p=",$pos+1); $pos2=strpos($chaine2,",",$pos+1); $p = substr($chaine2,$pos+3,$pos2-$pos-3); $tp += $p; } if ($d2[abs($x)]>0) {$d3[abs($x)]= $tp/$d2[abs($x)];} $ttp += $d3[abs($x)]; } $x--; } while($x>-7); $nbT7j = $nbf; // Nombre total de flèche $nbf = $nbf/400*100; if ($nbe>0) { $p = $ttp/$nbe; $r = ($d6[0]+$d6[1]+$d6[2]+$d6[3]+$d6[4]+$d6[5]+$d6[6])/$nbe; } $nbs=0; for ($i=0 ; $i<=6; $i++ ) { if ($d71[$i]>0) {$nbs++;} } if ($nbs>0) {$s = ($d71[0]+$d71[1]+$d71[2]+$d71[3]+$d71[4]+$d71[5]+$d71[6])/$nbs;} $nbe = $nbe/5*100; // donnee sur un mois $d20 ... // Lecture des datas... $filename = "/var/www/ArcherTrainer/AT/".$mac."/stat"; $chaine2=file_get_contents($filename); //echo $chaine2; $Date = strtotime(date("d-m-Y")); $x=0; for ($i=0 ; $i>-30; $i-- ) { $d = date('d-m-Y', strtotime($i.' days', $Date)); // echo "d=".$d.chr(10).chr(13); $d20[abs($x)]=$d; $d21[abs($x)]=0; $pos= strpos($chaine2,$d); if ($pos>0) { // 26-08-2021,nb=132,p=91.4,tt=5.9,tm=3.8,co=85.5,r=8.4, //echo 'x='.abs($x).chr(10).chr(13); $pos=strpos($chaine2,"nb=",$pos); $pos2=strpos($chaine2,",",$pos); $d22[abs($x)] = substr($chaine2,$pos+3,$pos2-$pos-3); // $d22 nb fleche $pos=strpos($chaine2,",p=",$pos); $pos2=strpos($chaine2,",",$pos+1); $d23[abs($x)] = substr($chaine2,$pos+3,$pos2-$pos-3); // $d23 precision $pos=strpos($chaine2,"tt=",$pos); $pos2=strpos($chaine2,",",$pos); $d24[abs($x)] = substr($chaine2,$pos+3,$pos2-$pos-3); // $d24 tt $pos=strpos($chaine2,"tm=",$pos); $pos2=strpos($chaine2,",",$pos); $d25[abs($x)] = substr($chaine2,$pos+3,$pos2-$pos-3); // $d25 tm $pos=strpos($chaine2,"co=",$pos); $pos2=strpos($chaine2,",",$pos); $d26[abs($x)] = substr($chaine2,$pos+3,$pos2-$pos-3); // $d26 repro $pos=strpos($chaine2,"r=",$pos); $pos2=strpos($chaine2,",",$pos); $d27[abs($x)] = substr($chaine2,$pos+2,$pos2-$pos-2); // $d27 resultat $x -= 1; } } $nb21 = abs($x)-1; // charts require 'chart.js-php/vendor/autoload.php'; use ChartJs\ChartJS; $datac1 = [ 'labels' => [ $d1[6], $d1[5], $d1[4], $d1[3], $d1[2], $d1[1], $d1[0] ], 'datasets' => [[ 'data' =>[$d2[6], $d2[5], $d2[4], $d2[3], $d2[2], $d2[1], $d2[0]], 'backgroundColor' => 'rgba(28,116,190,.8)', 'borderColor' => 'blue', 'label' => 'Nb Flèches' ],[ 'data' =>[$d3[6], $d3[5], $d3[4], $d3[3], $d3[2], $d3[1], $d3[0]], 'backgroundColor' => 'rgba(28,116,190,.3)', 'borderColor' => 'blue', 'label' => 'Précision (%)' ],[ 'data' =>[$d6[6], $d6[5], $d6[4], $d6[3], $d6[2], $d6[1], $d6[0]], 'backgroundColor' => '#f2b21a', 'borderColor' => '#e5801d', 'label' => 'Indice de repro' ] ] ]; $datac2 = [ 'labels' => [ $d1[6], $d1[5], $d1[4], $d1[3], $d1[2], $d1[1], $d1[0] ], 'datasets' => [[ 'data' =>[$d4[6], $d4[5], $d4[4], $d4[3], $d4[2], $d4[1], $d4[0]], 'backgroundColor' => 'rgba(28,116,190,.3)', 'borderColor' => 'blue', 'label' => 'Temps Total de tir en (s)' ],[ 'data' =>[$d5[6], $d5[5], $d5[4], $d5[3], $d5[2], $d5[1], $d5[0]], 'backgroundColor' => '#f2b21a', 'borderColor' => '#e5801d', 'label' => 'Temps de Maintien en (s)' ] ] ]; for ($x=0 ; $x<$nbmax; $x++ ) { $labels[] = $d7[$x]; $data1[] = $d9[$x]/10; $data2[] = $d10[$x]/(1000/$t); $data3[] = $d11[$x]/(1000/$t); $data4[] = $d12[$x]/10; $data5[] = $d13[$x]; } $datac3 = [ 'labels' => $labels , 'datasets' => [[ 'data' => $data1 , 'backgroundColor' => 'rgba(93,173,226,.2)', 'borderColor' => '#5dade2', 'label' => 'Indice de précision' ],[ 'data' => $data4 , 'backgroundColor' => 'rgba(88,214,141,.2)', 'borderColor' => '#58d68d', 'label' => 'Indice de repro' ],[ 'data' => $data5 , 'backgroundColor' => 'rgba(255,255,0,.2)', 'borderColor' => '#ffff00', 'label' => 'Score' ],[ 'data' => $data2 , 'backgroundColor' => 'rgba(175,122,197,.2)', 'borderColor' => '#af7ac5', 'label' => 'Temps total de tir' ],[ 'data' => $data3 , 'backgroundColor' => '#f2b21a', 'borderColor' => '#e5801d', 'label' => 'Temps de maintien' ] ] ]; $datac4 = [ 'labels' => [ '% Précision', '% Repro', '% Score', '% Nb Flèche', '% Nb entrainement' ], 'datasets' => [[ 'data' =>[ $p , $r , $s , $nbf , $nbe ], 'backgroundColor' => ['#0000FF','#0040FF','#0080FF','#00A0FF','#00C0FF' ], 'borderColor' => ['#0000FF','#0040FF','#0080FF','#00A0FF','#00C0FF' ], 'label' => 'Evaluation de l archer' ] ] ]; for ($x=$nb21 ; $x>=0; $x-- ) { $labels2[] = $d20[$x]; $data22[] = $d22[$x]; $data23[] = $d23[$x]; $data24[] = $d24[$x]*10; $data25[] = $d25[$x]*10; $data26[] = $d26[$x]; $data27[] = $d27[$x]; } $datac5 = [ 'labels' => $labels2 , 'datasets' => [[ 'data' => $data22 , 'backgroundColor' => 'rgba(93,173,226,.2)', 'borderColor' => '#5dade2', 'label' => 'Nombre de flèche' ],[ 'data' => $data23 , 'backgroundColor' => 'rgba(88,214,141,.2)', 'borderColor' => '#58d68d', 'label' => 'Précision' ],[ 'data' => $data24 , 'backgroundColor' => 'rgba(255,255,0,.2)', 'borderColor' => '#ffff00', 'label' => 'Temps total de tir x10' ],[ 'data' => $data25 , 'backgroundColor' => 'rgba(175,122,197,.2)', 'borderColor' => '#af7ac5', 'label' => 'Temps de maintien x10' ],[ 'data' => $data26 , 'backgroundColor' => 'rgba(234,128,252,.2)', 'borderColor' => '#e040fb', 'label' => 'Indice de repro' ],[ 'data' => $data27 , 'backgroundColor' => 'rgba(255,110,64,.2)', 'borderColor' => '#ff6e40', 'label' => 'Score' ] ] ]; //$options = []; $options = ['responsive' => true]; //$attributesc1 = ['id' => 'Nbfleches', 'width' => 300, 'height' => 300, 'style' => 'display:inline;']; $colors = [ ['backgroundColor' => 'rgba(28,116,190,.8)', 'borderColor' => 'blue'], ['backgroundColor' => '#f2b21a', 'borderColor' => '#e5801d'], ['backgroundColor' => ['blue', 'purple', 'red', 'black', 'brown', 'pink', 'green']] ]; /* * Create charts * */ $attributesc1['id'] = 'nbfleches'; $nbF = new ChartJS('bar', $datac1, $options, $attributesc1); //$nbF->addDataset($datasetsc1[0]); //$Line->addDataset($datasets[1]); $attributesc2['id'] = 'tt'; $TT = new ChartJS('bar', $datac2, $options, $attributesc2); //$TT->addDataset($datasetsc2[0]); //$TT->addDataset($datasetsc2[1]); $attributesc3['id'] = 'co'; $CO = new ChartJS('line', $datac3, $options, $attributesc3); $attributesc4['id'] = 'radar'; $radar = new ChartJS('polarArea', $datac4, $options, $attributesc4); $attributesc5['id'] = 'mois'; $mois = new ChartJS('line', $datac5, $options, $attributesc5); ?>
Nombre de flèches tirés durant les 7 derniers jours (Total : )
Evaluation de l'Archer en % (sur une semaine)
L'archer idéal doit avoir un cercle bleu complet !
(Critères arbitraires : 5 entrainements/semaine, 400 flèches/semaines)
Précision / Indice de repro
Temps total de tir / Temps de maintien
Dernière scéance de tir ()
Evolution sur un mois