' . "" . "Report" . "Family/Variant" . "Sigs" . "Range" . "Who" . "When" . "Filename" . ""; while ($read = readdir($dir)){ if ($read!='.' && $read!='..'){ $fileName = str_ireplace('.xls', '', $read); list( $report, $reportShard ) = getReportName($fileName); if (!$report){ continue; } list( $when, $whenShard ) = getWhen($fileName); list( $range, $rangeShard ) = getReportRange($fileName); list( $sigs, $sigsShard ) = getReportSigs($fileName); $virus = $virusShard = ""; if ( stripos($report, "Sha1") === 0 ){ $isVariant = stripos($report, "Variant"); list( $virus, $virusShard ) = getReportVirus($fileName, $isVariant); } $whenShard = str_replace('_', '', $whenShard); $reportShard = str_replace('_', '', $reportShard); $rangeShard = str_replace('_', '', $rangeShard); $sigsShard = str_replace('_', '', $sigsShard); $virusShard = str_replace('_', '', $virusShard); $file = str_replace('_', '', $fileName); $file = str_replace($whenShard, '', $file); $file = str_replace($reportShard, '', $file); $file = str_replace($rangeShard, '', $file); $file = str_replace($sigsShard, '', $file); $file = str_replace($virusShard, '', $file); $who =$file; $table .= "" . "$report" . "$virus" . "$sigs" . "$range" . "$who" . "$when" . "$read" . ""; } } $table .= ''; closedir($dir); return $table; } function getWhen($aFile){ $arrName = explode("_", $aFile); $when = ''; $seconds = $arrName[ count($arrName) - 1 ]; $minutes = $arrName[ count($arrName) - 2 ]; $hours = $arrName[ count($arrName) - 3 ]; $day = $arrName[ count($arrName) - 4 ]; $month = $arrName[ count($arrName) - 5 ]; $year = $arrName[ count($arrName) - 6 ]; $arrMonth = array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthName = $arrMonth[ (integer)$month ]; return array( "$day-$monthName-$year $hours:$minutes:$seconds", $year."_".$month."_".$day."_".$hours."_".$minutes."_".$seconds ); } function getReportName($aFile){ $report = ''; $shard = ''; $arrSearchFor = array( array( "_ReportSamplesVsSigs2_Results_", "Samples Vs Signatures" ) , array( "_ReportSha1PerFamily_Results_", "Sha1 List Per Family" ) , array( "_ReportSha1PerVariant_Results_", "Sha1 List Per Variant" ) ); for ( $i = 0; $i < count($arrSearchFor); $i++ ){ if ( stripos( $aFile, $arrSearchFor[$i][0] ) ){ $report = $arrSearchFor[$i][1]; $shard = $arrSearchFor[$i][0]; } } return array( $report, $shard ); } function getReportRange($aFile){ $range = ''; $shard = ''; $arrSearchFor = array( array( "_Today_", "Today" ) , array( "_Yesterday_", "Yesterday" ) , array( "_Last_Week_", "Last Week" ) , array( "_This_Week_", "This Week" ) , array( "_Last_Month_", "Last Month" ) , array( "_Last Month_", "Last Month" ) , array( "_This_Month_", "This Month" ) , array( "_This Month_", "This Month" ) , array( "_This_Year_", "This Year" ) , array( "_Last_Year_", "Last Year" ) , array( "_Till_Day_", "Till Day" ) ); for ( $i = 0; $i < count($arrSearchFor); $i++ ){ if ( stripos( $aFile, $arrSearchFor[$i][0] ) ){ $range = $arrSearchFor[$i][1]; $shard = $arrSearchFor[$i][0]; } } return array( $range, $shard ); } function getReportSigs($aFile){ $sig = ""; $shard = ''; $arrSearchFor = array( array( "_ALL_", "Complete" ) , array( "_FIRST_", "First" ) , array( "_PE_", "PE" ) , array( "_GEN_PE_", "PE/Gen" ) ); for ( $i = 0; $i < count($arrSearchFor); $i++ ){ if ( stripos( $aFile, $arrSearchFor[$i][0] ) ){ $sig = $arrSearchFor[$i][1]; $shard = $arrSearchFor[$i][0]; } } return array( $sig, $shard ); } function getReportVirus($aFile, $aIsVariant=false){ $arrName = explode("_", $aFile); $virus = $arrName[0] . "." . $arrName[1] . "." . $arrName[2]; if ($aIsVariant){ $virus .= "." . $arrName[3]; } $shard = $arrName[0] . "_" . $arrName[1] . "_" . $arrName[2]; if ($aIsVariant){ $shard .= "_" . $arrName[4]; } return array( $virus, $shard ); } ?>