Example #1
0
    $valid = $xmldata->relaxNGValidate(SCHEMA_DIR . $schemaName . SCHEMA_EXT);
    //Restore the original error handler
    set_error_handler($originalHandler);
    if ($valid === false) {
        ajax_error('Schema validation failed');
    }
    //Should not see this because of the error handler
    //Retrieve the database configuration
    $dbconf = $config->Database;
    //Make sure the username is registered with this application
    $db = new Database($dbconf['host'], $dbconf['user'], $dbconf['pass'], $dbconf['name'], $dbconf['port']);
    $session = $db->searchSession($session);
    if (empty($session)) {
        ajax_error('Could not find your session id in the database.');
    }
    $db->storeForm($schemaName, $session['id'], $xmldata->saveXML());
    //Mark this data as not diff'd
    $db->storeFinalDiffState($session['subjectLabel'], 0);
    $result = array("success" => 1);
    ajax_result($result);
} catch (\Exception $e) {
    error_log('[OnlineQuestionnaire] ERROR: ' . $e->getMessage(), 0);
    ajax_error('Internal Server error. Please try again later.' . $e->getMessage());
}
/** Walks recursively through an array and trims whitespace.
 *  Compresses multiple spaces into 1
 * @param array $data
 */
function purifyArray(array &$data)
{
    foreach ($data as $key => &$value) {