function shipworks()
{
    // using output buffering to get around headers that magento is setting after we've started output
    ob_start();
    header("Content-Type: text/xml;charset=utf-8");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    // HTTP/1.1
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    // HTTP/1.0
    header("Pragma: no-cache");
    // Open the XML output and root
    writeXmlDeclaration();
    writeStartTag("ShipWorks", array("moduleVersion" => SHIPWORKS_MODULE_VERSION, "schemaVersion" => SHIPWORKS_SCHEMA_VERSION));
    // If the admin module is installed, we make use of it
    if (checkAdminLogin()) {
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
        switch (strtolower($action)) {
            case 'getmodule':
                Action_GetModule();
                break;
            case 'getstore':
                Action_GetStore();
                break;
            case 'getcount':
                Action_GetCount();
                break;
            case 'getorders':
                Action_GetOrders();
                break;
            case 'getstatuscodes':
                Action_GetStatusCodes();
                break;
            case 'updateorder':
                Action_UpdateOrder();
                break;
            case 'updatestatus':
                Action_UpdateStatus();
                break;
            case 'updateshipment':
                Action_UpdateShipment();
                break;
            default:
                outputError(20, "'{$action}' is not supported.");
        }
    }
    // Close the output
    writeCloseTag("ShipWorks");
    // end output
    ob_end_flush();
}
function outputError($code, $error)
{
    writeStartTag("Error");
    writeElement("Code", $code);
    writeElement("Description", $error);
    writeCloseTag("Error");
}
$secure = false;
try {
    if (isset($_SERVER['HTTPS'])) {
        $secure = $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == '1';
    }
} catch (Exception $e) {
}
// Open the XML output and root
writeXmlDeclaration();
writeStartTag("ShipWorks", array("moduleVersion" => $moduleVersion, "schemaVersion" => $schemaVersion));
try {
    // start the mage engine
    Mage::app($storeCode);
} catch (Mage_Core_Model_Store_Exception $e) {
    outputError(100, "Invalid Store Code.");
    writeCloseTag("ShipWorks");
    exit;
}
// Enforse SSL
if (!$secure && REQUIRE_SECURE) {
    outputError(10, 'A secure (https://) connection is required.');
} else {
    // If the admin module is installed, we make use of it
    if (checkAdminLogin()) {