Browse Source

Fix the fallback functionality

pjc 5 years ago
parent
commit
0133b6aeeb
1 changed files with 7 additions and 8 deletions
  1. 7
    8
      classes/validate.class.php

+ 7
- 8
classes/validate.class.php View File

200
         $Heaviest = array_slice($Sorted, 0, 20);
200
         $Heaviest = array_slice($Sorted, 0, 20);
201
         $Matches = [];
201
         $Matches = [];
202
 
202
 
203
+        # Distill the file format
204
+        $FileTypes = $FileTypes[$Category];
205
+        $FileTypeNames = array_keys($FileTypes);
206
+
203
         foreach ($Heaviest as $Heaviest) {
207
         foreach ($Heaviest as $Heaviest) {
204
             # Collect the last 2 period-separated tokens
208
             # Collect the last 2 period-separated tokens
205
             $Extensions = array_slice(explode('.', strtolower($Heaviest[1])), -2, 2);
209
             $Extensions = array_slice(explode('.', strtolower($Heaviest[1])), -2, 2);
206
             $Matches = array_merge($Extensions);
210
             $Matches = array_merge($Extensions);
207
 
211
 
208
-            # Distill the file format
209
-            $FileTypes = $FileTypes[$Category];
210
-            $FileTypeNames = array_keys($FileTypes);
211
-
212
-            # todo: Find the smallest possible number of iterations
213
             # todo: Reduce nesting by one level
212
             # todo: Reduce nesting by one level
214
             foreach ($Matches as $Match) {
213
             foreach ($Matches as $Match) {
215
                 $Match = strtolower($Match);
214
                 $Match = strtolower($Match);
220
                     if (in_array($Match, $SearchMe[1])) {
219
                     if (in_array($Match, $SearchMe[1])) {
221
                         return $SearchMe[0];
220
                         return $SearchMe[0];
222
                         break;
221
                         break;
223
-                    } else {
224
-                        return 'Other';
225
-                    break;
226
                     }
222
                     }
227
                 }
223
                 }
224
+
225
+                # Return the last element (Other or None)
226
+                return array_key_last($FileTypes);
228
             }
227
             }
229
         }
228
         }
230
     }
229
     }

Loading…
Cancel
Save