for new version visit http://www.katur.de/ This software is distributed under a Creative Commons Attribution-Noncommercial 3.0 License http://creativecommons.org/licenses/by-nc/3.0/de/ Other licences available on request! History: -------- 28-August-2009 V1.0.0 - File created 08-Oktober-2009 V1.0.1 - Minor Changes */ //configure input if (is_numeric($_GET['Limit'])){ $Limit = $_GET['Limit']; }else{ $Limit = 200; } if (is_numeric($_GET['mbkosten'])){ $mbkosten = str_replace(",", ".", $_GET['mbkosten']); }else{ $mbkosten = 0.5; //Achtung Abrechnungseinheit ist 10Kbyte } if ($_REQUEST['tarifgruppe']=="sms"){ $valuesuffix = ""; $title = "SMS-Statistik"; $verstaerkung = 100; $tarifgruppe = "sms"; }elseif ($_REQUEST['tarifgruppe']=="telefoniekosten"){ $valuesuffix = "€"; $title = "Verbindungs-Statistik"; $verstaerkung = 3; $tarifgruppe = "telefoniekosten"; }elseif ($_REQUEST['tarifgruppe']=="telefonieminuten"){ $valuesuffix = "min"; $title = "Verbindungs-Statistik"; $verstaerkung = 3; $tarifgruppe = "telefonieminuten"; }else{ //default datenauswertung $valuesuffix = " MB"; $title = "Trafficauswertung"; $verstaerkung = 3; $tarifgruppe = "datenvolumen"; } echo ''; ?> <?php echo $title." für ".$displayuser; ?>
' method='get'>
Limit: Preis pro MB: Tarifart:
"; exit; } //all files in dir $activeDir = array_reverse(scandir( $dirPath)); echo "

".$title." für ".$displayuser."

\n"; echo "\n"; echo "\t\n"; //iterate over all files aka MONTH foreach ($activeDir as $activeFile) { //if csv files found if (eregi( ".csv$", $activeFile ) !== false){ $csvContent = array_reverse(file ( $dirPath.'/'.$activeFile )); //do we have a correct type of CSV? if (eregi("^TABELLENTYP\|KONTONR\|RECHNUNGSNR", end($csvContent)) === 1){ //init inner table $detailRowHead = "\t\t\t
DateEinträgeGraphKosten
\n"; $detailRowFront = array(); $detailRowNumber = array(); $detailRowEnd = array(); $detailRowMax = 0; $activeMonthValue = 0; $activeDays = 0; echo "\t\n"; echo "\t\t\n\t\t". //empty cell on front "". //date of detail "". //text description of detail "". //Trafficdetail with graph "". "\n"; $activeDays++; }else if ($tarifgruppe == "sms" && stripos($activeCell[8], "sms") !== false ){ //sms was selected and this is a matching csv line if ("" == $activeCell[24]){ //all SMS are in detail available $activeMonthValue += 1; $detailRowFront[$activeDays] = "\t\t\t\t". //empty cell on front "". //date of detail "". //text description of detail "". //receipient of SMS "". //SMS-detail with graph "". "\n"; }else{ //all SMS are summed up $activeMonthValue += $activeCell[24]; $detailRowFront[$activeDays] = "\t\t\t\t". //empty cell on front "". //date of detail "". //text description of detail "". //SMS-detail with graph "". "\n"; } $activeDays++; }else if ($tarifgruppe == "telefoniekosten" && (stripos($activeCell[8], "verbindungen") !== false || (stripos($activeCell[8], "anrufe") !== false ))){ //euro was selected and this is a matching csv line if (0 == str_replace(",",".",$activeCell[17])){ //charges were included in a voucher, so no charge had to be paid //calculate the saved charge $activeMonthValue += str_replace(",",".",trim($activeCell[9], "()G")); $detailRowFront[$activeDays] = "\t\t\t\t". //empty cell on front "". //date and time of detail "". //duration of call "". //Type of Call (H=Homezone) "". //destination of call "". //charge of call, could be empty if flatrate "". "\n"; }else{ //normal billing of call $activeMonthValue += str_replace(",",".",$activeCell[17]); $detailRowFront[$activeDays] = "\t\t\t\t". //empty cell on front "". //date and time of detail "". //duration of call "". //Type of Call (H=Homezone) "". //destination of call "". //charge of call "". "\n"; } $activeDays++; }else if ($tarifgruppe == "telefonieminuten" && (stripos($activeCell[8], "verbindungen") !== false || (stripos($activeCell[8], "anrufe") !== false ))){ //minute calculation was selected and this is a matching csv line $activeMonthValue += strtotime("Jan 1 1970 ".$activeCell[16]." UTC")/60; $detailRowFront[$activeDays] = "\t\t\t\t". //empty cell on front "". //date and time of detail "". //Type of Call (H=Homezone) "". //destination of call "". //duration of call "". "\n"; $activeDays++; } } $detailRowFoot = "\t\t\t
"; echo substr($activeFile, 0, 7); echo ""; //content array of active file aka DAYS foreach ($csvContent as $activeLine) { $activeCell = explode ('|' , $activeLine ); if ($tarifgruppe == "datenvolumen" && stripos($activeCell[8], "internet") !== false){ //datenvolumen was selected and this is a matching csv line //Cell22 has the traffic in kb $activeMonthValue += rtrim($activeCell[22], " KB")/1000; //save month details for later $detailRowFront[$activeDays] = "\t\t\t\t
".$activeCell[13]."".$activeCell[21]."".$activeCell[22]."
".$activeCell[13]."".$activeCell[21]."".$activeCell[15]."1 SMS
".$activeCell[13]."".$activeCell[21]."".$activeCell[24]."
".$activeCell[13]." ".$activeCell[14]."Dauer: ".$activeCell[16]."".$activeCell[25]."".$activeCell[8]."; Teilnehmer: ".$activeCell[15]."".($activeCell[9]===""?0:$activeCell[9]).$valuesuffix."
".$activeCell[13]." ".$activeCell[14]."Dauer: ".$activeCell[16]."".$activeCell[25]."".$activeCell[8]."; Teilnehmer: ".$activeCell[15]."".$activeCell[17].$valuesuffix."
".$activeCell[13]." ".$activeCell[14]."".$activeCell[25]."".$activeCell[8]."; Teilnehmer: ".$activeCell[15]."".number_format(strtotime("Jan 1 1970 ".$activeCell[16]." UTC")/60, 2, ',', '.').$valuesuffix."
\n"; echo $activeDays; echo "\n"; if ($Limit < $activeMonthValue){ echo "\t\t".''.$activeMonthValue.$valuesuffix.''."\n"; echo "\t\t".''.($activeMonthValue - $Limit)* $mbkosten.'€'."\n"; }else{ echo "\t\t".''.$activeMonthValue.$valuesuffix.''."\n"; echo "\t\t".''."\n"; } echo "\t\n"; if (0 != $detailRowMax){ //detail view is available echo "\t\n"; echo "\t\t\n"; echo $detailRowHead; $i = 0; while ($detailRowFront[$i] != null){ echo $detailRowFront[$i]; echo 100*(is_numeric($detailRowNumber[$i])?$detailRowNumber[$i]:0)/$detailRowMax; echo $detailRowEnd[$i]; $i++; } echo $detailRowFoot; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; } } } } echo "\n"; ?>