コード例 #1
0
ファイル: text.php プロジェクト: Kmartynov/cms
{% endif %}

{% if (v_file_exists('application/config/database.php')) : %}
	_(t-green i-check-square-o) {{ t('База данных уже установлена') }}
	
	_ <a href="../">{{ t('Перейти к сайту') }}</a> 
	
	</div>
	{% return %}
{% endif %}


<?php 
// дефолтные значения полей
$PV['username'] = '';
$PV['password'] = v_rand_str(15);
$PV['email'] = '';
$PV['site_name'] = '';
$PV['demo'] = '1';
$PV['db_hostname'] = 'localhost';
$PV['db_username'] = '';
$PV['db_password'] = '';
$PV['db_database'] = '';
$PV['db_dbprefix'] = 'mso_';
if ($_POST) {
    // есть разница с тем что должно быть
    if ($diff = array_diff_key($_POST, $PV)) {
        echo t('Ошибочный post-запрос') . '</div>';
        return;
    }
    // сохраняем переданные значения
コード例 #2
0
ファイル: functions.php プロジェクト: Kmartynov/cms
function v_new_database($PV)
{
    $path = realpath(BASEPATH . '../') . '/';
    if (file_exists($path . 'application/config/database.php-distr')) {
        $rand = v_rand_str();
        $file = file_get_contents($path . 'application/config/database.php-distr');
        $file = str_replace('$db[\'default\'][\'hostname\'] = \'localhost\';', '$db[\'default\'][\'hostname\'] = \'' . $PV['db_hostname'] . '\';', $file);
        $file = str_replace('$db[\'default\'][\'username\'] = \'\';', '$db[\'default\'][\'username\'] = \'' . $PV['db_username'] . '\';', $file);
        $file = str_replace('$db[\'default\'][\'password\'] = \'\';', '$db[\'default\'][\'password\'] = \'' . $PV['db_password'] . '\';', $file);
        $file = str_replace('$db[\'default\'][\'database\'] = \'\';', '$db[\'default\'][\'database\'] = \'' . $PV['db_database'] . '\';', $file);
        $file = str_replace('$db[\'default\'][\'dbprefix\'] = \'mso_\';', '$db[\'default\'][\'dbprefix\'] = \'' . $PV['db_dbprefix'] . '\';', $file);
        file_put_contents($path . 'application/config/database.php', $file);
        return false;
    } else {
        return true;
    }
}