It is now possible to define a sitemap URL that does not return a View or even HTML. This is useful for API requests that require a specific target URL without GET parameters. It is now also possible to synchronize timestamps when creating an API session. Factory MVC loading now uses a wrapper method that reduces near-duplicate code. Version numbers of API and system version are now consistent with one another.

// If index URL cache is not configured, it is turned off by defaultif(!isset($config['index-url-cache-timeout'])){$config['index-url-cache-timeout']=0;
}

// State class is used by API and Factory created objects to keep track of request staterequire(__ROOT__.'engine'.DIRECTORY_SEPARATOR.'class.www-state.php');$state=new WWW_State($config);

// DATABASE AND SESSIONS

// This holds link to database$databaseConnection=false;

// Connecting to database, if configuration is setif(isset($config['database-name'],$config['database-type'],$config['database-host'],$config['database-username'],$config['database-password'])){// Including the required class and creating the objectrequire(__ROOT__.'engine'.DIRECTORY_SEPARATOR.'class.www-database.php');$databaseConnection=new WWW_Database($config['database-type'],$config['database-host'],$config['database-name'],$config['database-username'],$config['database-password'],((isset($config['database-errors']))?$config['database-errors']:false),((isset($config['database-persistent']))?$config['database-persistent']:false));// Passing the database to State object$state->databaseConnection=$databaseConnection;
}

// This functions file is not required, but can be used for system wide functions
// If you want to include additional libraries, do so hereif(file_exists(__ROOT__.'overrides'.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'script.php')){
require(__ROOT__.'overrides'.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'script.php');
} elseif(file_exists(__ROOT__.'resources'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'script.php')) {
require(__ROOT__.'resources'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'script.php');
}

// LOADING API AND CALLING URL SOLVING/ROUTING CONTROLLER

// API is used to process all requests and it handles caching and API validationsrequire(__ROOT__.'engine'.DIRECTORY_SEPARATOR.'class.www-api.php');$api=new WWW_API($state);

// This uses current request URI to find out which view should be loaded, by default it uses the request set by State
// API check is turned off, since index.php is considered a public gateway$view=$api->command(array('url'=>$state->data['request-true'],'www-command'=>'url-solve','www-output'=>0,'www-return-type'=>'php','www-cache-timeout'=>$config['index-url-cache-timeout'],'www-cache-load-timeout'=>$cacheLoad),false,false,true);

// CALLING DEFAULT VIEW CONTROLLER IF URL DID NOT ORDER A REDIRECTION

// If view data includes flags for redirection then the view itself will be ignoredif(!isset($view['www-temporary-redirect']) && !isset($view['www-permanent-redirect'])){

// Notifying State of View data$state->setState(array(array('view'=>$view,'language'=>((isset($view['language']))?$view['language']:'en'))));

// All the data sent by the user agent is stored in this variable$inputData=array();

// If index view cache is not configured, it is turned of by defaultif(isset($view['cache-timeout'])){$config['index-view-cache-timeout']=$view['cache-timeout'];
} elseif(!isset($config['index-view-cache-timeout'])){$config['index-view-cache-timeout']=0;
}

// API check is turned off, since index.php is considered a public gateway$api->command(array('www-command'=>((isset($view['controller']))?$view['controller']:'view').'-'.((isset($view['controller-method']))?$view['controller-method']:'load'),'www-request'=>$state->data['request-true'],'www-return-type'=>((isset($view['return-type']))?$view['return-type']:'html'),'www-cache-tags'=>((isset($view['cache-tag']))?$view['cache-tag']:''),'www-cache-timeout'=>$config['index-view-cache-timeout'],'www-cache-load-timeout'=>$cacheLoad)+$inputData,false,false,true);

}

// LOGGER

// API gathers its own log data internally and it is given to Logger to be loggedif(isset($logger)){$logger->setCustomLogData(array('category'=>'data','database-query-counter'=>(($databaseConnection)?$databaseConnection->queryCounter:0))+$api->apiLoggerData);$logger->writeLog();
}