public function action()
 {
     if (isset($_POST["action"]["save"])) {
         // transform the users array...
         if (is_array($_POST["settings"]["server"]["users"])) {
             $transformedArray = array();
             for ($i = 0; $i < count($_POST["settings"]["server"]["users"]["firstname"]); $i++) {
                 $userArray = array("firstname" => $_POST["settings"]["server"]["users"]["firstname"][$i], "lastname" => $_POST["settings"]["server"]["users"]["lastname"][$i], "email" => $_POST["settings"]["server"]["users"]["email"][$i], "created-by" => $_POST["settings"]["server"]["users"]["created-by"][$i]);
                 // generate the authentication key
                 $passedAuthKey = $_POST["settings"]["server"]["users"]["auth-key"][$i];
                 $userArray["auth-key"] = $passedAuthKey == "" ? DIM_Server::generateAuthenticationKey($userArray) : $passedAuthKey;
                 $transformedArray[] = $userArray;
             }
             $_POST["settings"]["server"]["users"] = $transformedArray;
         }
         //ensure the mode is set in the settings
         if (!isset($_POST['settings']['mode']['mode'])) {
             $ss = $this->config->getConfiguration();
             $_POST['settings']['mode']['mode'] = $ss['mode']['mode'];
         }
         if (extension_database_integration_manager::testSettings($_POST["settings"])) {
             $logger = new DIM_Logger();
             $logger->addLogItem("Configuration Updated", "system");
             $this->config->saveConfiguration($_POST["settings"]);
             $this->pageAlert(__('Configuration Settings updated successfully.'), Alert::SUCCESS);
         } else {
             $this->pageAlert(__('One or more settings were incorrect.'), Alert::ERROR);
             $_POST['error'] = 'error';
         }
     }
 }
 public function testHandleCheckin()
 {
     $server = new DIM_Server();
     // should fail authentication
     $failRet = $server->handleRequest(array("action" => "checkin", "email" => "test", "auth-key" => "test"));
     $this->assertEquals("0:unauthed", $failRet);
     $mockAuthenticator = $this->getMock("DIM_Authenticator", array("getConfiguration"));
     $mockAuthenticator->expects($this->any())->method("getConfiguration")->will($this->returnValue(array("server" => array("users" => array(array("email" => "test", "auth-key" => "test"))))));
     $server->authenticator = $mockAuthenticator;
     $stateManager = new DIM_StateManager();
     $stateManager->checkOut();
     // should successfully check in
     $successRet = $server->handleRequest(array("action" => "checkin", "email" => "test", "auth-key" => "test"));
     $this->assertEquals("1", $successRet);
     $this->assertTrue($stateManager->isCheckedIn());
 }
<?php

/* 
	This is the server base file that contains the base processing
	and output.
	NB - as little code as possible should be here! This will be the
	root file that is called
*/
require_once dirname(__FILE__) . "/../lib/server.class.php";
$theServer = new DIM_Server();
echo $theServer->handleRequest($_REQUEST);