public function testInternals()
 {
     $this->assertTrue(WeatherMapEditor::rangeOverlaps(array(1, 5), array(4, 7)));
     $this->assertTrue(WeatherMapEditor::rangeOverlaps(array(4, 7), array(1, 5)));
     $this->assertFalse(WeatherMapEditor::rangeOverlaps(array(1, 5), array(6, 7)));
     $this->assertEquals(array(5, 10), WeatherMapEditor::findCommonRange(array(1, 10), array(5, 20)));
     $this->assertEquals(array(4, 5), WeatherMapEditor::findCommonRange(array(1, 5), array(4, 7)));
     $this->assertEquals(array(4, 5), WeatherMapEditor::findCommonRange(array(4, 7), array(1, 5)));
     $this->assertEquals("", WeatherMapEditor::simplifyOffset(0, 0));
     $this->assertEquals("1:2", WeatherMapEditor::simplifyOffset(1, 2));
     $this->assertEquals("E95", WeatherMapEditor::simplifyOffset(1, 0));
     $this->assertEquals("W95", WeatherMapEditor::simplifyOffset(-3, 0));
     $this->assertEquals("N95", WeatherMapEditor::simplifyOffset(0, -5));
     $this->assertEquals("S95", WeatherMapEditor::simplifyOffset(0, 9));
 }
 function main($request, $from_plugin = false)
 {
     $mapname = "";
     $action = "";
     if (isset($request['action'])) {
         $action = strtolower(trim($request['action']));
     }
     if (isset($request['mapname'])) {
         $mapname = $request['mapname'];
         if ($action == "newmap" || $action == "newmap_copy") {
             $mapname .= ".conf";
         }
         // If there's something funny with the config filename, just stop.
         if ($mapname != wmeSanitizeConfigFile($mapname)) {
             exit;
         }
         $this->mapfile = $this->mapDirectory . "/" . $mapname;
         $this->mapname = $mapname;
     }
     if ($mapname == '') {
         $this->showStartPage();
     } else {
         if ($this->validateRequest($action, $request)) {
             $editor = new WeatherMapEditor();
             $this->setEmbedded($from_plugin);
             if (!isset($this->commands[$action]['late_load'])) {
                 $editor->loadConfig($this->mapfile);
             }
             $result = $this->dispatchRequest($action, $request, $editor);
             if (!isset($this->commands[$action]['no_save'])) {
                 $editor->saveConfig();
             }
             if ($result !== false) {
                 $this->showMainPage($editor);
             }
         } else {
             print "FAIL";
         }
     }
 }