Esempio n. 1
0
if (isset($_REQUEST['features'])) {
    // Feature list or table.
    $set = isset($_REQUEST['cloud']) ? array('core', 'addons', 'cloud') : false;
    $set = vanillaFeatures($set);
    if (isset($_REQUEST['type'])) {
        viewFeatureList($_REQUEST['type'], $set);
    } else {
        viewFeatureTable($set);
    }
} elseif (isset($_POST['type'])) {
    if (array_key_exists($_POST['type'], $supported)) {
        // Mini-Factory for conducting exports.
        $class = ucwords($_POST['type']);
        $controller = new $class();
        if (!method_exists($controller, $method)) {
            echo "This datasource type does not support {$method}.\n";
            exit;
        }
        $controller->{$method}();
    } else {
        echo 'Invalid type specified: ' . $_POST['type'];
    }
} else {
    // Show the web UI to start an export.
    $canWrite = testWrite();
    viewForm(array('Supported' => $supported, 'CanWrite' => $canWrite));
}
// Console output should end in newline.
if (defined('CONSOLE')) {
    echo "\n";
}
Esempio n. 2
0
function main()
{
    testWrite();
    testSimpleRead();
    testStagedRead();
}
Esempio n. 3
0
/**
 * Form: Database connection info.
 */
function viewForm($data)
{
    $forums = getValue('Supported', $data, array());
    $msg = getValue('Msg', $data, '');
    $canWrite = getValue('CanWrite', $data, null);
    if ($canWrite === null) {
        $canWrite = testWrite();
    }
    if (!$canWrite) {
        $msg = 'The porter does not have write permission to write to this folder. You need to give the porter permission to create files so that it can generate the export file.' . $msg;
    }
    if (defined('CONSOLE')) {
        echo $msg . "\n";
        return;
    }
    pageHeader();
    ?>
    <div class="Info">
        Howdy, stranger! Glad to see you headed our way.
        For help,
        <a href="http://docs.vanillaforums.com/developers/importing/porter" style="text-decoration:underline;"
           target="_blank">peek at the docs</a>.
        To see what data we can grab from your platform,
        <a href="?features=1" style="text-decoration:underline;">see this table</a>.
    </div>
    <form action="<?php 
    echo $_SERVER['PHP_SELF'] . '?' . http_build_query($_GET);
    ?>
" method="post">
        <input type="hidden" name="step" value="info"/>

        <div class="Form">
            <?php 
    if ($msg != '') {
        ?>
                <div class="Messages Errors">
                    <ul>
                        <li><?php 
        echo $msg;
        ?>
</li>
                    </ul>
                </div>
            <?php 
    }
    ?>
            <ul>
                <li>
                    <label>
                        Source Forum Type
                        <select name="type" id="ForumType">
                            <?php 
    foreach ($forums as $forumClass => $forumInfo) {
        ?>
                                <option value="<?php 
        echo $forumClass;
        ?>
"<?php 
        if (getValue('type') == $forumClass) {
            echo ' selected="selected"';
        }
        ?>
><?php 
        echo $forumInfo['name'];
        ?>
</option>
                            <?php 
    }
    ?>
                        </select>
                    </label>
                </li>
                <li>
                    <label>Table Prefix <span>Most installations have a database prefix. If you&rsquo;re sure you don&rsquo;t have one, leave this blank.</span>
                        <input class="InputBox" type="text" name="prefix"
                            value="<?php 
    echo htmlspecialchars(getValue('prefix')) != '' ? htmlspecialchars(getValue('prefix')) : $forums['vanilla1']['prefix'];
    ?>
"
                            id="ForumPrefix"/>
                    </label>
                </li>
                <li>
                    <label>
                        Database Host <span>Usually "localhost".</span>
                        <input class="InputBox" type="text" name="dbhost"
                            value="<?php 
    echo htmlspecialchars(getValue('dbhost', '', 'localhost'));
    ?>
"/>
                    </label>
                </li>
                <li>
                    <label>
                        Database Name
                        <input class="InputBox" type="text" name="dbname"
                            value="<?php 
    echo htmlspecialchars(getValue('dbname'));
    ?>
"/>
                    </label>
                </li>
                <li>
                    <label>
                        Database Username
                        <input class="InputBox" type="text" name="dbuser"
                            value="<?php 
    echo htmlspecialchars(getValue('dbuser'));
    ?>
"/>
                    </label>
                </li>
                <li>
                    <label>Database Password
                        <input class="InputBox" type="password" name="dbpass" value="<?php 
    echo getValue('dbpass');
    ?>
"/>
                    </label>
                </li>
                <li>
                    <label>
                        Export Type
                        <select name="tables" id="ExportTables">
                            <option value="">All supported data</option>
                            <option value="User,Role,UserRole,Permission">Only users and roles</option>
                        </select>
                    </label>
                </li>
                <li id="FileExports">
                    <fieldset>
                        <legend>Export Options:</legend>
                        <label>
                            Avatars
                            <input type="checkbox" name="avatars" value="1">
                        </label>
                        <label>
                            Files
                            <input type="checkbox" name="files" value="1">
                        </label>

                    </fieldset>
                </li>
            </ul>
            <div class="Button">
                <input class="Button" type="submit" value="Begin Export"/>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        $('#ForumType')
            .change(function() {
                var type = $(this).val();
                switch (type) {
                    <?php 
    foreach ($forums as $forumClass => $forumInfo) {
        $exportOptions = "\$('#FileExports > fieldset, #FileExports input').prop('disabled', true);";
        $hasAvatars = !empty($forumInfo['features']['Avatars']);
        $hasAttachments = !empty($forumInfo['features']['Attachments']);
        if ($hasAvatars || $hasAttachments) {
            $exportOptions = "\$('#FileExports > fieldset').prop('disabled', false);";
            $exportOptions .= "\$('#FileExports input[name=avatars]').prop('disabled', " . ($hasAvatars ? 'false' : 'true') . ")";
            if ($hasAvatars) {
                $exportOptions .= ".parent().removeClass('disabled');";
            } else {
                $exportOptions .= ".parent().addClass('disabled');";
            }
            $exportOptions .= "\$('#FileExports input[name=files]').prop('disabled', " . ($hasAttachments ? 'false' : 'true') . ")";
            if ($hasAttachments) {
                $exportOptions .= ".parent().removeClass('disabled');";
            } else {
                $exportOptions .= ".parent().addClass('disabled');";
            }
        }
        ?>
                    case '<?php 
        echo $forumClass;
        ?>
':
                    <?php 
        echo $exportOptions;
        ?>
                        $('#ForumPrefix').val('<?php 
        echo $forumInfo['prefix'];
        ?>
');
                        break;
                    <?php 
    }
    ?>
                }
            })
            .trigger('change');
    </script>

    <?php 
    pageFooter();
}