if ($action == 'ShowImageMimetex') {
    tex2image($texexp);
}
// Action: Check Slasharguments
if ($action == 'SlashArguments') {
    slasharguments($texexp);
}
// Action: Show Tex command line output
if ($action == 'ShowImageTex') {
    TexOutput($texexp, true);
    exit;
}
// Action: Show Tex command line output
if ($action == 'ShowOutputTex') {
    if (debugging()) {
        TexOutput($texexp);
    } else {
        echo "Can not output detailed information due to security concerns, please turn on debug mode first.";
    }
    exit;
}
if (!empty($action)) {
    outputText($output);
}
// nothing more to do if there was any action
if (!empty($action)) {
    exit;
}
function outputText($texexp)
{
    header("Content-type: text/html; charset=utf-8");
// Action: Show Image
if ($param->action == 'ShowImageMimetex') {
    tex2image($param->tex);
}
// Action: Check Slasharguments
if ($param->action == 'SlashArguments') {
    slasharguments($param->tex);
}
// Action: Show Tex command line output
if ($param->action == 'ShowImageTex') {
    TexOutput($param->tex, true);
    exit;
}
// Action: Show Tex command line output
if ($param->action == 'ShowOutputTex') {
    TexOutput($param->tex);
    exit;
}
if (!empty($param->action)) {
    outputText($output);
}
// nothing more to do if there was any action
if (!empty($param->action)) {
    exit;
}
function outputText($texexp)
{
    header("Content-type: text/html");
    echo "<html><body><pre>\n";
    if ($texexp) {
        $texexp = str_replace('<', '&lt;', $texexp);