Ejemplo n.º 1
0
function upgradeConfig4000($config)
{
    $config_sts = 0;
    if (isset($GLOBALS['cfg']['db_type'])) {
        // config already upgraded
        $config_sts = 1;
    } else {
        // config  upgraded
        $config_sts = 2;
        require_once _base_ . '/config.php';
        $_SESSION['db_info']["db_host"] = $GLOBALS['dbhost'];
        $_SESSION['db_info']["db_user"] = $GLOBALS['dbuname'];
        $_SESSION['db_info']["db_pass"] = $GLOBALS['dbpass'];
        $_SESSION['db_info']["db_name"] = $GLOBALS['dbname'];
        if ($GLOBALS['uploadType'] == 'fs') {
            $_SESSION['upload_method'] = 'http';
        } else {
            $_SESSION['upload_method'] = 'ftp';
        }
        $_SESSION['ul_info']["ftp_host"] = $GLOBALS['ftphost'];
        $_SESSION['ul_info']["ftp_port"] = $GLOBALS['ftpport'];
        $_SESSION['ul_info']["ftp_user"] = $GLOBALS['ftpuser'];
        $_SESSION['ul_info']["ftp_pass"] = $GLOBALS['ftppass'];
        $_SESSION['ul_info']["ftp_path"] = $GLOBALS['ftppath'];
        $fn = _upgrader_ . '/data/config_template.php';
        // generateConfig from install/lib/lib.php
        $config = generateConfig($fn);
    }
    return array($config_sts, $config);
}
Ejemplo n.º 2
0
/**
 * Attempts to create config.inc.php
 *
 * @since 1.0
 * @package facileManager
 * @subpackage Installer
 */
function createConfig()
{
    global $fm_name, $branding_logo;
    $temp_config = generateConfig();
    $temp_file = ABSPATH . 'config.inc.php';
    if (!file_exists($temp_file) || !file_get_contents($temp_file)) {
        if (@file_put_contents($temp_file, '') === false) {
            printf('
	<div id="fm-branding">
		<img src="%s" /><span>%s</span>
	</div>
	<div id="window">
	<p>' . _('I cannot create %s so please manually create it with the following contents:') . '</p>
	<textarea rows="18">%s</textarea>
	<p>' . _('Once done, click "Install."') . '</p>
	<p class="step"><a href="?step=3" class="button click_once">' . _('Install') . '</a></p></div>', $branding_logo, _('Install'), "<code>{$temp_file}</code>", $temp_config);
        } else {
            printf('<form method="post" action="?step=3">
	<div id="fm-branding">
		<img src="%s" /><span>%s</span>
	</div>
	<div id="window">
		<table class="form-table">' . "\n", $branding_logo, _('Install'));
            $retval = @file_put_contents($temp_file, $temp_config) ? true : false;
            displayProgress(_('Creating Configuration File'), $retval);
            echo "</table>\n";
            if ($retval) {
                echo '<p>' . _("Config file has been created! Now let's create the database schema.") . '</p><p class="step"><a href="?step=3" class="button click_once">' . _('Continue') . '</a></p>';
            } else {
                echo '<p>' . _('Config file creation failed. Please try again.') . '</p><p class="step"><a href="?step=2" class="button click_once">' . _('Try Again') . '</a></p>';
            }
            echo "</div></form>\n";
        }
    }
}
Ejemplo n.º 3
0
 private function saveConfig()
 {
     // ----------- Generating config file -----------------------------
     $config = "";
     $fn = _installer_ . "/data/config_template.php";
     $config = generateConfig($fn);
     $save_fn = _base_ . "/config.php";
     $saved = FALSE;
     if (is_writeable($save_fn)) {
         $handle = fopen($save_fn, 'w');
         if (fwrite($handle, $config)) {
             $saved = TRUE;
         }
         fclose($handle);
         @chmod($save_fn, 0644);
     }
     $_SESSION["config_saved"] = $saved;
 }
Ejemplo n.º 4
0
    } elseif (is_int($value)) {
        return [$value, ' : int'];
    } elseif (is_float($value)) {
        return [$value, ' : float'];
    } elseif (is_bool($value)) {
        return [$value === true ? 'true' : 'false', ' : bool'];
    }
    return [$value, ''];
}
/**
 * @param $config
 * @param $configClass
 */
function generateConfig($config, $configClass)
{
    foreach ($config as $key => $value) {
        list($value, $returnType) = guessValue($value);
        fwrite($configClass, "\n\tpublic function get" . ucfirst($key) . "()" . $returnType . "\n\t{\n\t\treturn " . $value . ";\n\t}");
    }
    fwrite($configClass, "\n}");
    fclose($configClass);
}
$config = array_merge(require_once __DIR__ . '/../config/config.php.dist', require_once __DIR__ . '/../config/config.php');
$configClass = fopen(__DIR__ . '/../src/Config.php', 'w+');
fwrite($configClass, "<?php\ndeclare(strict_types = 1);\n\nnamespace Nucleus;\n\nclass Config\n{");
generateConfig($config, $configClass);
$testConfig = array_merge(require_once __DIR__ . '/../config/config-test.php.dist', require_once __DIR__ . '/../config/config-test.php');
$testConfigClass = fopen(__DIR__ . '/../src/TestConfig.php', 'w+');
fwrite($testConfigClass, "<?php\ndeclare(strict_types = 1);\n\nnamespace Nucleus;\n\nclass TestConfig\n{");
generateConfig($testConfig, $testConfigClass);
Ejemplo n.º 5
0
 }
 setState(false);
 setStatus("Bootstrapping database. Please wait");
 $file = file($_POST['absolute_path'] . "/bootstrap/bootstrap." . $_POST['db_type']);
 $query = implode('', $file);
 $queried = $connector->executeQuery($query);
 if ($queried == false) {
     setState(true);
     pleaseGoBack();
     echo "</span></div></div></div></body></html>";
     exit;
 }
 setState(false);
 echo "<br/>*** DATABASE SETUP IS NOW COMPLETE ***<br/><br/>";
 setStatus("Generating config.php");
 $cfgFile = generateConfig();
 echo $cfgFile;
 $filename = "config.php";
 if (!($handle = fopen($filename, 'w'))) {
     setState(true);
     echo "<strong>ERROR: Could not open config.php</strong>";
     exitConsole();
     exit;
 }
 if (fwrite($handle, $cfgFile) === FALSE) {
     setState(true);
     echo "Cannot write to file ({$filename})";
     exitConsole();
     exit;
 }
 echo "</span></div>";
Ejemplo n.º 6
0
<?php

include 'bootstrap.php';
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="config.php"');
$fn = _installer_ . "/data/config_template.php";
echo generateConfig($fn);