if (!$db_connection->connect()) {
            die(1);
        }
    } catch (Doctrine_Connection_Exception $e) {
        die(1);
    }
}
// run from commandline
if (isset($argv) && isset($argv[0]) && basename($argv[0]) == basename(__FILE__)) {
    if ($argc >= 2) {
        list($executable, $command) = $argv;
        $executable = array_shift($argv);
        $command = array_shift($argv);
        switch ($command) {
            case 'checkdbconnection':
                checkDbConnection();
                break;
            case 'configAb':
                list($op_sig_kid, $op_enc_kid, $rp_sig_kid, $rp_enc_kid) = $argv;
                configureAb(AB_CONF_TEMPLATE, OP_AB_CONF_FILE, $op_sig_kid, $op_enc_kid, $rp_sig_kid, $rp_enc_kid);
                copy(OP_AB_CONF_FILE, RP_AB_CONF_FILE);
                break;
            case 'configDb':
                list($db_host, $db_port, $db_name, $db_user, $db_password) = $argv;
                configureDB(DB_CONF_TEMPLATE, OP_DB_CONF_FILE, $db_host, $db_port, $db_name, $db_user, $db_password);
                copy(OP_DB_CONF_FILE, RP_DB_CONF_FILE);
                if (file_exists(OP_DB_CONF_FILE)) {
                    require_once 'migration.php';
                    migrate_db();
                }
                break;
Esempio n. 2
0
function performPreinstallChecks($qubitWebRoot, $qubitDataRoot, $qubitDbType, $qubitDbName, $qubitDbUser, $qubitDbPassword, $qubitDbHost, $qubitDbPort)
{
    global $fileSystemPathToTarball;
    printStatusReportTop();
    /*
     * Set the $error variable to FALSE to keep track of whether any errors are reported by
     * the various check_x functions. If $error is false at the end of performPreinstallChecks,
     * we can procede to the installQubit().
     */
    $error = false;
    $error = checkPHPversion($error);
    $error = checkAllowUrlFopen($error);
    $error = checkXMLEnabled($error);
    $error = checkXSLEnabled($error);
    $error = checkOS($error);
    $error = checkExists($error, $qubitWebRoot, 'web root');
    $error = checkExists($error, $qubitDataRoot, 'data directory');
    $error = checkDbType($error, $qubitDbType);
    // This parameter list should work for mysql and pgsql, but not for sqlite
    $error = checkDbConnection($error, $qubitDbType, $qubitDbName, $qubitDbUser, $qubitDbPassword, $qubitDbHost, $qubitDbPort);
    /*
     * If everything is OK (i.e., no $error = true returned from the check_x functions),
     * actually install the distribution.
     */
    if ($error) {
        // Exit and report that errors reported above need to be fixed.
        print '<p>Sorry, the installer can\'t procede until all the <span class="problem">problems</span> identified below have been fixed.</p>';
        printStatusReportBottom();
    } else {
        global $distro;
        // Get the web path of this script by removing the server's web root path from $qubitWebRoot.
        $documentRootPattern = '#' . $_SERVER['DOCUMENT_ROOT'] . '#';
        $pathToWebsite = preg_replace($documentRootPattern, '', $qubitWebRoot);
        $pathToWebsite .= 'index.php';
        $urlToWebsite = '<a target="_blank" title="Opens your new ' . $distro . ' site in new browser/tab" href="http://' . $_SERVER['SERVER_NAME'] . $pathToWebsite . '/search/buildIndex">' . $distro . '</a>';
        installQubit($qubitWebRoot, $qubitDataRoot);
        printStatusReportBottom();
        print "<p>Congratulations, the installation is complete. Before you leave this page, please perform the following\n          post-installation security tasks:</p>";
        print "<ul>";
        print "<li>Remove the installation files at {$fileSystemPathToTarball}</li>";
        print "<li>Change permissions on {$qubitWebRoot} so that directory is not writable by your web server</li>";
        print "</ul>";
        print "<p>Test your new instance of the {$urlToWebsite} (with email admin@qubit-toolkit.org and password admin), and\n          if everything looks good, complete the above security tasks. <strong>It is very important that you do not forget\n          to do these things!</strong> Not doing them puts your\n          website at a high security risk.</p>";
    }
}
Esempio n. 3
0
 if (isset($_POST['ajax'])) {
     if ((int) $_POST['ajax'] == 1) {
         $method = @$_POST['method'];
         switch ($method) {
             case 'adminCred':
                 header('Content-Type: application/json');
                 $json = array();
                 $_SESSION['adminUsername'] = $_POST['adminUsername'];
                 $_SESSION['adminPassword'] = $_POST['adminPassword'];
                 $json['status'] = 'OK';
                 exit(json_encode($json));
                 break;
             case 'dbCheck':
                 header('Content-Type: application/json');
                 $json = array();
                 $result = checkDbConnection($_POST['dbHost'], $_POST['dbUsername'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbPort']);
                 if ((int) $result != 1) {
                     $json['status'] = 'ERROR';
                     $json['error'] = $result;
                 } else {
                     $_SESSION['dbHost'] = $_POST['dbHost'];
                     $_SESSION['dbUsername'] = $_POST['dbUsername'];
                     $_SESSION['dbPassword'] = $_POST['dbPassword'];
                     $_SESSION['dbName'] = $_POST['dbName'];
                     $_SESSION['dbPort'] = $_POST['dbPort'];
                     $_SESSION['mysqli'] = new mysqli($_POST['dbHost'], $_POST['dbUsername'], $_POST['dbPassword'], $_POST['dbName'], $_POST['dbPort']);
                     $json['status'] = 'OK';
                 }
                 exit(json_encode($json));
                 break;
             case 'bigdump':