@@ -359,12 +359,8 @@ public static function insertFile($path, $name, $type, $accessGroupId) {
359359 // check if there is an old deletion request for the same filename
360360 $ qF = new QueryFilter (FileDelete::FILENAME , $ name , "= " );
361361 Factory::getFileDeleteFactory ()->massDeletion ([Factory::FILTER => $ qF ]);
362- if ($ fileType == DFileType::RULE ) {
363- $ file = new File (null , $ name , Util::filesize ($ path ), 1 , $ fileType , $ accessGroupId , Util::rulefileLineCount ($ path ));
364- }
365- else {
366- $ file = new File (null , $ name , Util::filesize ($ path ), 1 , $ fileType , $ accessGroupId , Util::fileLineCount ($ path ));
367- }
362+
363+ $ file = new File (null , $ name , Util::filesize ($ path ), 1 , $ fileType , $ accessGroupId );
368364 $ file = Factory::getFileFactory ()->save ($ file );
369365 if ($ file == null ) {
370366 return false ;
@@ -651,48 +647,7 @@ public static function filesize($file) {
651647
652648 return $ pos ;
653649 }
654-
655- /**
656- * This counts the number of lines in a given file
657- * @param $file string Filepath you want to get the size from
658- * @return int -1 if the file doesn't exist, else filesize
659- */
660- public static function fileLineCount ($ file ) {
661- if (!file_exists ($ file )) {
662- return -1 ;
663- }
664- // find out what a prettier solution for this would be, as opposed to setting the max execution time to an arbitrary two hours
665- ini_set ('max_execution_time ' , '7200 ' );
666- $ file = new \SplFileObject ($ file , 'r ' );
667- $ file ->seek (PHP_INT_MAX );
668-
669- return $ file ->key ();
670- }
671650
672- /**
673- * This counts the number of lines in a rule file, excluding lines starting with # and empty lines
674- * @param $file string Filepath you want to get the size from
675- * @return int -1 if the file doesn't exist, else filesize
676- */
677- public static function rulefileLineCount ($ file ) {
678- if (!file_exists ($ file )) {
679- return -1 ;
680- }
681- // find out what a prettier solution for this would be, as opposed to setting the max execution time to an arbitrary two hours
682- ini_set ('max_execution_time ' , '7200 ' );
683- $ lineCount = 0 ;
684- $ handle = fopen ($ file , "r " );
685- while (!feof ($ handle )){
686- $ line = fgets ($ handle );
687- if (!(Util::startsWith ($ line , '# ' ) or trim ($ line ) == "" )) {
688- $ lineCount = $ lineCount + 1 ;
689- }
690- }
691-
692- fclose ($ handle );
693- return $ lineCount ;
694- }
695-
696651 /**
697652 * Refreshes the page with the current url, also includes the query string.
698653 */
@@ -1393,9 +1348,7 @@ public static function arrayOfIds($array) {
13931348 }
13941349 return $ arr ;
13951350 }
1396-
1397- // new function added: fileLineCount(). This function is independent of OS.
1398- // check whether we can remove one of these functions
1351+
13991352 public static function countLines ($ tmpfile ) {
14001353 if (stripos (PHP_OS , "WIN " ) === 0 ) {
14011354 // windows line count
0 commit comments