$file_name='C:/Radio Toolbox/logs/' .$m .'_' .$d. '_' .$y. '_rtb_log.txt'; //директория хранениея логов Radio Toolbox с выборкой нужной даты $r=fopen($file_name,'r'); $text=fread($r,filesize($file_name)); fclose($r); $massiv=explode("\r\n", $text); foreach ($massiv as $txt) { $h = substr($txt,12,2); $h=$h*1; $temp=explode(" ", $txt); $l[$h]=$l[$h]+$temp[1]; $s[$h]=$s[$h]+1; } $txtout='<?php'."\r\n"; for ($i=0; $i<=23; $i++) { $txtout=$txtout. '$ls[]=' .$l[$i]. '; $kz[]=' .$s[$i]. ";\r\n"; } $txtout=$txtout.'?>'; //запись в файл $fp = fopen ("C:/listens/".$y.$m.$d.".dat", "w"); fwrite($fp,$txtout); fclose($fp); ?>
<?php $ls[]=165; $kz[]=120; <sciped> $ls[]=360; $kz[]=120; ?>
<?php $kratnost=5; //кратность графика $font="ariblk.ttf"; //имя шрифта $dir='C:/*.dat'; //путь к файлам БД =) $y=$_GET['y']; $m=$_GET['m']; $d=$_GET['d']; $in=$_GET['in']; $t=$_GET['t']; if ($y<2009) {$y=date("Y",time()-86500);} if ($y>2038) {$y=date("Y",time()-86500);} if ($m<1) {$m=date("m",time()-86500);} if ($m>12) {$m=date("m",time()-86500);} if ($d<1) {$d=date("d",time()-86500);} if ($d>31) {$d=date("d",time()-86500);} if ($in==0) {$in=1;} if ($in<0) {$in=1;} if ($in>3) {$in=1;} if ($t<1) {$t=1;} if ($t>3) {$t=1;} if ($t==1 && $in>2) {$in=2;} if ($t==2 && $in<2) {$in=2;} if ($t==3 && $in<3) {$in=3;} $d=substr("0000" .$d,-2,2); $m=substr("0000" .$m,-2,2); if ($in==1) { $d1=$y.$m.$d; $d2=$y.$m.$d; } if ($in==2) { $d1=$y.$m."01"; $d2=$y.$m."31"; } if ($in==3) { $d1=$y."0101"; $d2=$y."1231"; } $d1=$d1*1; $d2=$d2*1; if ($t<0) {$t=1;} if ($t>3) {$t=1;} $mass=glob($dir); $x=0; $td=0; $pem=0; $nachalo=mktime(0,0,0,substr($d1,4,2),substr($d1,6,2),substr($d1,0,4)); //обработка БД согласно вводным foreach ($mass as $filename){ $locfile= substr($filename,-12,8); $locfile=$locfile*1; if ($locfile >=$d1 && $locfile <=$d2) { $tm=1*substr($filename,-8,2); if ($pem==0) {$pem=1;$pm=$tm;} if ($t==3 && $pm<>$tm) { $pm=$tm; $l[$td]=array_sum($ls); $s[$td]=array_sum($kz); $ls=''; $kz=''; $td=$td+1; } include($filename); if ($t==2) { $l[$td]=array_sum($ls); $s[$td]=array_sum($kz); $ls=''; $kz=''; $td=$td+1; } } } if ($t==1) { $name="hours"; $l=$ls; $s=$kz; } if ($t==2) { $name="days"; } if ($t==3) { $name="months"; if ($t==3) { $l[$td]=array_sum($ls); $s[$td]=array_sum($kz); } } $k=sizeof($l); $vivod=0; if (array_sum($l)==0) {$vivod=2;} if ($k==0) {$vivod=1;} $vis=0; for ($i=0;$i<$k;$i++){ $r=$l[$i]/$s[$i]; if ($vis<$r) {$vis=$r;} } $vt=250; $vis=$kratnost*ceil($vis/$kratnost); if ($t==1 && $in==2) {$vt=300;} if ($t==2 && $in==3) {$vt=300;} //генерация графика header("Content-type: image/png"); $image = imageCreate(800, $vt); $colorback = imageColorAllocate($image, 0, 0, 0); $color1 = imageColorAllocate($image, 211, 211, 211); $color2 = imageColorAllocate($image, 250, 250, 220); imageFilledRectangle($image, 0, 0, 99, 99, $colorback); imageLine($image,30,10,30, 240,$color2); $max=$k; if ($vivod==0) { if ($t==1 && $in==1) {$max=23;} if ($t==1 && $in==2) {$max=24*(date("t",$nachalo)-1);} if ($t==2 && $in==2) {$max=date("t",$nachalo)-1;} if ($t==2 && $in==3) {$max=365;} if ($t==3 && $in==3) {$max=11;} $sh=750/($max+1); $vd=round($vis); $st=0; if ($vis==0) {$rp=20;$st=1;} if ($vis<>0) { $rp=200*$st/$vis; while ($rp<10) { $st=$st+$kratnost; $rp=200*$st/$vis; } } $i=0; while ($i<=$vd) { $v=200*$i/$vis; $bbox=imagettfbbox(6, 0, $font, $i); imageLine($image,20,229-$v,780, 229-$v,$color2); imagettftext ($image, 6, 0, 30-$bbox[2]-3, 229-$v-2, $color2, $font,$i); $i=$i+$st; } for ($i=0;$i<$k;$i++){ $r=$l[$i]/$s[$i]; $v=200*$r/$vis; $nc=$i+1; if ($t==1) {$nc=$i;} imageFilledRectangle($image, 31+$sh*$i, 229-$v, 29+$sh*($i+1), 229, $color1); $bbox=imagettfbbox(6, 0, $font, $i); } $st=1;$oo=1;$u=0; if ($t==1 && $in==2) {$st=24;$oo=0;$u=-90;} if ($t==2 && $in==3) {$st=30;$oo=0;$u=-90;} $rp=750*$st/$max; while ($rp<10) { $st=$st+1; $rp=200*$sh; } $i=0; while ($i<=$max) { $v=750*$i/$max; $io=$i; if ($t<>1) {$io=$i+1;} if ($t==1 && $in==2) {$io=date("d-M",$nachalo+3600*$i);} if ($t==2 && $in==3) {$io=date("M",$nachalo+24*3600*$i);} if ($t==3) {$io=date("M",$nachalo+31*24*3600*$i);} if ($i<>0) {imagettftext ($image, 6, $u, 31+$sh+$sh*$i-$sh/2-$bbox[2]/2, 240-$bbox[3]/2, $color2, $font,$io);} if ($i==0 && $oo==1) {imagettftext ($image, 6, $u, 31+$sh+$sh*$i-$sh/2-$bbox[2]/2, 240-$bbox[3]/2, $color2, $font,$io);} $i=$i+$st; } } if ($vivod==1) {imagettftext ($image, 20, 0, 175, 150, $color1, $font,"NOT DATA IN STORAGE");} if ($vivod==2) {imagettftext ($image, 20, 0, 260, 150, $color1, $font,"Not Listens");} $dati=substr($d1,0,4).":".substr($d1,4,2).":".substr($d1,6,2)."-".substr($d2,0,4).":".substr($d2,4,2).":".substr($d2,6,2)." (" . date("T",$nachalo). ")"; if ($d1==$d2) {$dati=substr($d1,0,4).":".substr($d1,4,2).":".substr($d1,6,2)." (" . date("T",$nachalo). ")";} imagettftext ($image, 8, 0, 40, 10, $color2, $font,$dati); imagettftext ($image, 6, 0, 760, 10, $color2, $font,'V.2.9'); imagettftext ($image, 6, 0, 2, 247, $color2, $font,$name); imageInterlace($image, 1); imagepng($image); ?>
<?php $ls[]=0; $kz[]=120; <sciped> $ls[]=0; $kz[]=120; ?>