function switchAction($action, $httpVars, $fileVars)
 {
     if ($action == "ls") {
         $this->crtPath = "";
         if (isset($httpVars["dir"]) && $httpVars["dir"] != "") {
             $this->crtPath = $httpVars["dir"];
         }
         $this->crtListingMode = isset($httpVars["mode"]) ? $httpVars["mode"] : "complete";
         $res = ListRepository($this->repository, $this->crtPath);
         //$res[IDX_STDOUT] = "";
         //header("content-type:text/xml");
         //print_r($res[IDX_STDOUT]);
         //print_r($res);
         $this->parseListing($res[IDX_STDOUT]);
         //print_r($this->listElements);
         //exit();
         AJXP_XMLWriter::header();
         // FIRST PASS FOR FOLDERS;
         foreach ($this->listElements as $element) {
             if ($element["is_file"] == "1") {
                 continue;
             }
             print "<tree ";
             foreach ($element as $attName => $attValue) {
                 print "{$attName}=\"" . $attValue . "\" ";
             }
             print "/>";
         }
         if ($this->crtListingMode != "complete") {
             foreach ($this->listElements as $element) {
                 if ($element["is_file"] == "0") {
                     continue;
                 }
                 print "<tree ";
                 foreach ($element as $attName => $attValue) {
                     print "{$attName}=\"" . $attValue . "\" ";
                 }
                 print "/>";
             }
         }
         AJXP_XMLWriter::close();
         exit(1);
     } else {
         if ($action == "log" && isset($httpVars["file"])) {
             $res = GetWebspaceLog($this->repository, $httpVars["file"]);
             //print_r($res);
             AJXP_XMLWriter::header();
             if (is_array($res)) {
                 print preg_replace("/[\r\n]/", "", str_replace('<?xml version="1.0"?>', "", $res[IDX_STDOUT]));
             }
             AJXP_XMLWriter::close();
             exit(1);
         }
     }
 }
/**
 * Executed SVN commands according to $_SESSION[IDX_ACTION].
 * Stores all execution results within $_SESSION[IDX_EXEC_RES]
 * array.
 * @param array $results A result array that should be appended by the
 * result of the command execution. A new array is returned if this
 * parameter is set to NULL.
 * @return array Array containing results of command excution.
 *
 * @since v1.0.0
 */
function &SvnExecute(&$results = NULL)
{
    if ($results == NULL) {
        $results = array();
    }
    //PrintDebugArray($_SESSION, 'Svn Executor: SESSION');
    $config = GetSelectedConfig();
    if ($config == NULL) {
        return $results;
    }
    if (isset($_SESSION[IDX_ACTION])) {
        switch ($_SESSION[IDX_ACTION]) {
            case ACTION_LIST_REPOSITORY:
                $result = ListRepository($config, "");
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_REP_LIST);
                $results[] = $result;
                break;
            case ACTION_STATUS:
                $result = GetWebspaceStatus($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_STATUS);
                $results[] = $result;
                break;
            case ACTION_LOG:
                $result = GetWebspaceLog($config, "");
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_LOG);
                $results[] = $result;
                break;
            case ACTION_INFO:
                $result = GetWebspaceInfo($config, false);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_INFO);
                $results[] = $result;
                break;
            case ACTION_UPDATE:
                $result = UpdateWebspace($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_UPDATE);
                $results[] = $result;
                break;
            case ACTION_CLEANUP:
                $result = CleanupWebspace($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_CLEANUP);
                $results[] = $result;
                break;
            case ACTION_SWITCH:
                $path = NULL;
                if (isset($_SESSION[IDX_SWITCH_PATH])) {
                    $path = $_SESSION[IDX_SWITCH_PATH];
                }
                $result = SwitchWebspace($config, $path);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_SWITCH);
                $results[] = $result;
                break;
            case ACTION_CHECKOUT:
                $result = CheckoutWebspace($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_CHECKOUT);
                $results[] = $result;
                break;
            case ACTION_SVN_HELP:
                $result[IDX_TITLE] = T(TK_RESULT_SVN_HELP_TITLE);
                $result[IDX_STDOUT] = array(T(TK_RESULT_SVN_HELP_HEADER), T(TK_RESULT_SVN_HELP_REP_SHORT), T(TK_RESULT_SVN_HELP_REP_LONG), T(TK_RESULT_SVN_HELP_WS_SHORT), T(TK_RESULT_SVN_HELP_WS_LONG));
                $results[] = $result;
                $result = GetSvnLookHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVNLOOK_HELP);
                $results[] = $result;
                $result = GetSvnHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVN_HELP);
                $results[] = $result;
                $result = GetSvnAdminHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVNADMIN_HELP);
                $results[] = $result;
                $result = GetSvnVersionHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVNADMIN_HELP);
                $results[] = $result;
                break;
            case ACTION_SVN_CMD:
                $result = array();
                $result[IDX_TITLE] = T(TK_RESULT_ERROR_CMD_NOT_EXEC);
                $result[IDX_ERROUT] = array(T(TK_RESULT_ERROR_NO_CMD));
                if (isset($_SESSION[IDX_ACTION_COMMAND]) && $_SESSION[IDX_ACTION_COMMAND] != '') {
                    $cmd = $_SESSION[IDX_ACTION_COMMAND];
                    $cmd = str_replace('%repository%', $config->GetRepositoryRoot(), $cmd);
                    $cmd = str_replace('%webspace%', $config->GetWebspaceRootDir(), $cmd);
                    $cmd = str_replace('%rep%', $config->GetRepositoryRoot(), $cmd);
                    $cmd = str_replace('%ws%', $config->GetWebspaceRootDir(), $cmd);
                    $result[IDX_ERROUT] = array(T(TK_RESULT_ERROR_NO_SVN_CMD__CMD, $cmd));
                    $rc = stripos($cmd, 'svn');
                    if ($rc !== false && $rc == 0) {
                        $result = ExecSvnCmd($cmd);
                        $result[IDX_TITLE] = T(TK_RESULT_CMD_EXEC);
                    }
                }
                $results[] = $result;
                break;
        }
    }
    return $results;
}