<commit_before><?php
class Vps_Controller_Action_Cli_ImportController extends Vps_Controller_Action_Cli_Abstract
{
    public function indexAction()
    {
        $ownConfig = Vps_Registry::get('config');

        $config = Vps_Config_Web::getInstance($this->_getParam('server'));
        if (!$config->server || !$config->server->host) {
            throw new Vps_ClientException("kein server konfiguriert");
        }
        $this->_sshHost = $config->server->user.'@'.$config->server->host;
        $this->_sshDir = $config->server->dir;

        if ($ownConfig->server->host == $config->server->host) {
            $cmd = "cd {$config->server->dir} && php bootstrap.php import get-update-revision";
        } else if (file_exists('/usr/local/bin/sshvps')) {
            $cmd = "sudo -u vps sshvps $this->_sshHost $this->_sshDir import get-update-revision";
        } else {
            $cmd = "ssh $this->_sshHost ".escapeshellarg("cd $this->_sshDir && php bootstrap.php import get-update-revision");
        }
        if ($this->_getParam('debug')) echo $cmd."\n";
        exec($cmd, $onlineRevision, $ret);
        if ($ret != 0) throw new Vps_ClientException();
        $onlineRevision = implode('', $onlineRevision);

        if (!$onlineRevision) {
            throw new Vps_ClientException("Can't get onlineRevision");
        }

        try {
            Vps_Registry::get('db');
        } catch (Zend_Db_Adapter_Exception $e) {
            $dbConfig = Vps_Registry::get('dao')->getDbConfig();
            $dbConfig['dbname'] = 'test';
            $db = Zend_Db::factory('PDO_MYSQL', $dbConfig);
            $databases = array();
            foreach ($db->query("SHOW DATABASES")->fetchAll() as $r) {
                $databases[] = $r['Database'];
            }

            $dbConfig = Vps_Registry::get('dao')->getDbConfig();
            if (!in_array($dbConfig['dbname'], $databases)) {
                echo "Datenbank {$dbConfig['dbname']} nicht vorhanden, versuche sie zu erstellen...\n";
                $db->query("CREATE DATABASE {$dbConfig['dbname']}");
                echo "OK\n";
            }
        }

        if (Vps_Registry::get('config')->application->id != 'service') {
            $this->_copyServiceUsers();
        }

        if ($config->uploads && $ownConfig->uploads) {
            echo "kopiere uploads...\n";
            if ($ownConfig->server->host == $config->server->host) {
                if ($ownConfig->uploads == $config->uploads) {
                    throw new Vps_ClientException("Uplodas-Pfade für beide Server sind gleich!");
                }
                $cmd = "rsync --progress --delete --times --exclude=cache/ --recursive {$config->uploads} {$ownConfig->uploads}";
                if ($this->_getParam('debug')) echo "$cmd\n";
                $this->_systemCheckRet($cmd);
            } else if (file_exists('/usr/local/bin/sshvps')) {
                $this->_systemSshVps('copy-uploads '.$ownConfig->uploads.'/', $config->uploads);
            } else {
                $cmd = "rsync --progress --delete --times --exclude=cache/ --recursive {$this->_sshHost}:{$config->uploads} {$ownConfig->uploads}";
                if ($this->_getParam('debug')) echo "$cmd\n";
                $this->_systemCheckRet($cmd);
            }
        }

        if ($config->server->import && $config->server->import->dirs) {
            foreach ($config->server->import->dirs as $dir) {
                echo "importing $dir...\n";
                $ig = simplexml_load_string(`svn propget --recursive --xml svn:ignore $dir`);<commit_msg>korrekte ordner, ansonsten wird ein unterordner erstellt<commit_after><?php
class Vps_Controller_Action_Cli_ImportController extends Vps_Controller_Action_Cli_Abstract
{
    public function indexAction()
    {
        $ownConfig = Vps_Registry::get('config');

        $config = Vps_Config_Web::getInstance($this->_getParam('server'));
        if (!$config->server || !$config->server->host) {
            throw new Vps_ClientException("kein server konfiguriert");
        }
        $this->_sshHost = $config->server->user.'@'.$config->server->host;
        $this->_sshDir = $config->server->dir;

        if ($ownConfig->server->host == $config->server->host) {
            $cmd = "cd {$config->server->dir} && php bootstrap.php import get-update-revision";
        } else if (file_exists('/usr/local/bin/sshvps')) {
            $cmd = "sudo -u vps sshvps $this->_sshHost $this->_sshDir import get-update-revision";
        } else {
            $cmd = "ssh $this->_sshHost ".escapeshellarg("cd $this->_sshDir && php bootstrap.php import get-update-revision");
        }
        if ($this->_getParam('debug')) echo $cmd."\n";
        exec($cmd, $onlineRevision, $ret);
        if ($ret != 0) throw new Vps_ClientException();
        $onlineRevision = implode('', $onlineRevision);

        if (!$onlineRevision) {
            throw new Vps_ClientException("Can't get onlineRevision");
        }

        try {
            Vps_Registry::get('db');
        } catch (Zend_Db_Adapter_Exception $e) {
            $dbConfig = Vps_Registry::get('dao')->getDbConfig();
            $dbConfig['dbname'] = 'test';
            $db = Zend_Db::factory('PDO_MYSQL', $dbConfig);
            $databases = array();
            foreach ($db->query("SHOW DATABASES")->fetchAll() as $r) {
                $databases[] = $r['Database'];
            }

            $dbConfig = Vps_Registry::get('dao')->getDbConfig();
            if (!in_array($dbConfig['dbname'], $databases)) {
                echo "Datenbank {$dbConfig['dbname']} nicht vorhanden, versuche sie zu erstellen...\n";
                $db->query("CREATE DATABASE {$dbConfig['dbname']}");
                echo "OK\n";
            }
        }

        if (Vps_Registry::get('config')->application->id != 'service') {
            $this->_copyServiceUsers();
        }

        if ($config->uploads && $ownConfig->uploads) {
            echo "kopiere uploads...\n";
            if ($ownConfig->server->host == $config->server->host) {
                if ($ownConfig->uploads == $config->uploads) {
                    throw new Vps_ClientException("Uplodas-Pfade für beide Server sind gleich!");
                }
                $cmd = "rsync --progress --delete --times --exclude=cache/ --recursive {$config->uploads}/ {$ownConfig->uploads}/";
                if ($this->_getParam('debug')) echo "$cmd\n";
                $this->_systemCheckRet($cmd);
            } else if (file_exists('/usr/local/bin/sshvps')) {
                $this->_systemSshVps('copy-uploads '.$ownConfig->uploads.'/', $config->uploads);
            } else {
                $cmd = "rsync --progress --delete --times --exclude=cache/ --recursive {$this->_sshHost}:{$config->uploads}/ {$ownConfig->uploads}/";
                if ($this->_getParam('debug')) echo "$cmd\n";
                $this->_systemCheckRet($cmd);
            }
        }

        if ($config->server->import && $config->server->import->dirs) {
            foreach ($config->server->import->dirs as $dir) {
                echo "importing $dir...\n";
                $ig = simplexml_load_string(`svn propget --recursive --xml svn:ignore $dir`);
{'fraction_non_alphanumeric': 0.17274871652560012, 'fraction_numerical': 0.0002775079783543777, 'mean_word_length': 2.219294327824922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6123327', 'n_tokens_mistral': 2185, 'n_tokens_neox': 2057, 'n_words': 395}