$stopwordsLang = PMF_Filter::filterInput(INPUT_GET, 'stopwords_lang', FILTER_SANITIZE_STRING);
$csrfToken = PMF_Filter::filterInput(INPUT_GET, 'csrf', FILTER_SANITIZE_STRING);
$http = new PMF_Helper_Http();
$stopwords = new PMF_Stopwords($faqConfig);
switch ($ajaxAction) {
    case 'add_instance':
        $url = PMF_Filter::filterInput(INPUT_GET, 'url', FILTER_SANITIZE_STRING);
        $instance = PMF_Filter::filterInput(INPUT_GET, 'instance', FILTER_SANITIZE_STRING);
        $comment = PMF_Filter::filterInput(INPUT_GET, 'comment', FILTER_SANITIZE_STRING);
        $email = PMF_Filter::filterInput(INPUT_GET, 'email', FILTER_VALIDATE_EMAIL);
        $admin = PMF_Filter::filterInput(INPUT_GET, 'admin', FILTER_SANITIZE_STRING);
        $password = PMF_Filter::filterInput(INPUT_GET, 'password', FILTER_SANITIZE_STRING);
        $data = array('url' => 'http://' . $url . '.' . $_SERVER['SERVER_NAME'], 'instance' => $instance, 'comment' => $comment);
        $faqInstance = new PMF_Instance($faqConfig);
        $instanceId = $faqInstance->addInstance($data);
        $faqInstanceClient = new PMF_Instance_Client($faqConfig);
        $faqInstanceClient->createClient($faqInstance);
        $urlParts = parse_url($data['url']);
        $hostname = $urlParts['host'];
        if ($faqInstanceClient->createClientFolder($hostname)) {
            $clientDir = PMF_ROOT_DIR . '/multisite/' . $hostname;
            $clientSetup = new PMF_Instance_Setup();
            $clientSetup->setRootDir($clientDir);
            $faqInstanceClient->copyConstantsFile($clientDir . '/constants.php');
            $faqInstanceClient->copyLdapConstantsFile($clientDir . '/constants_ldap.php');
            $dbSetup = array('dbServer' => $DB['server'], 'dbUser' => $DB['user'], 'dbPassword' => $DB['password'], 'dbDatabaseName' => $DB['db'], 'dbPrefix' => substr($hostname, 0, strpos($hostname, '.')), 'dbType' => $DB['type']);
            $clientSetup->createDatabaseFile($dbSetup, '');
            $faqInstanceClient->setClientUrl('http://' . $hostname);
            $faqInstanceClient->createClientTables($dbSetup['dbPrefix']);
            PMF_Db::setTablePrefix($dbSetup['dbPrefix']);
            // add admin account and rights
Ejemplo n.º 2
0
    </header>

    <div class="row">
        <div class="col-lg-12">
<?php 
if ($user->perm->checkRight($user->getUserId(), 'editinstances')) {
    $instance = new PMF_Instance($faqConfig);
    $instanceId = PMF_Filter::filterInput(INPUT_POST, 'instance_id', FILTER_VALIDATE_INT);
    // Check, if /multisite is writeable
    if (!is_writable(PMF_ROOT_DIR . DIRECTORY_SEPARATOR . 'multisite')) {
        printf('<p class="alert alert-danger">%s</p>', $PMF_LANG["ad_instance_error_notwritable"]);
    }
    // Update client instance
    if ('updateinstance' === $action && is_integer($instanceId)) {
        $system = new PMF_System();
        $clientInstance = new PMF_Instance_Client($faqConfig);
        // Collect data for database
        $data = [];
        $data['instance'] = PMF_Filter::filterInput(INPUT_POST, 'instance', FILTER_SANITIZE_STRING);
        $data['comment'] = PMF_Filter::filterInput(INPUT_POST, 'comment', FILTER_SANITIZE_STRING);
        if ($clientInstance->updateInstance($instanceId, $data)) {
            printf('<p class="alert alert-success">%s%s</p>', '<a class="close" data-dismiss="alert" href="#">&times;</a>', $PMF_LANG['ad_config_saved']);
        } else {
            printf('<p class="alert alert-danger">%s%s<br/>%s</p>', '<a class="close" data-dismiss="alert" href="#">&times;</a>', $PMF_LANG['ad_entryins_fail'], $faqConfig->getDb()->error());
        }
    }
    ?>
    <table class="table">
        <thead>
        <tr>
            <th>#</th>