当前位置: 首页>>代码示例>>PHP>>正文


PHP create_config_file函数代码示例

本文整理汇总了PHP中create_config_file函数的典型用法代码示例。如果您正苦于以下问题:PHP create_config_file函数的具体用法?PHP create_config_file怎么用?PHP create_config_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_config_file函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_chat_check_installed

/**
 * bp_chat_check_installed()
 *
 * Checks to see if the DB tables exist or if you are running an old version
 * of the component. If it matches, it will run the installation function.
 */
function bp_chat_check_installed()
{
    global $wpdb, $bp;
    if (!$bp->loggedin_user->is_site_admin) {
        return false;
    }
    /***
     * If you call your admin functionality here, it will only be loaded when the user is in the
     * wp-admin area, not on every page load.
     */
    /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    if (get_site_option('bp-chat-db-version') < BP_CHAT_DB_VERSION) {
        bp_chat_install();
    }
    create_config_file();
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:22,代码来源:bp-chat.php

示例2: check_rename_priv

$rename_priv = check_rename_priv();
$disabled = '';
if ($dir_checking['result'] === 'ERROR' || !empty($template_checking) || !empty($rename_priv) || !function_exists('mysql_connect')) {
    data_back('安装目录的某些权限不够');
}
$db_host = isset($_POST['dbhost']) ? trim($_POST['dbhost']) : '';
$db_port = isset($_POST['db_port']) ? trim($_POST['db_port']) : '';
$db_user = isset($_POST['dbuser']) ? trim($_POST['dbuser']) : '';
$db_pass = isset($_POST['dbpass']) ? trim($_POST['dbpass']) : '';
$db_name = isset($_POST['dbname']) ? trim($_POST['dbname']) : '';
$prefix = isset($_POST['db_prefix']) ? trim($_POST['db_prefix']) : 'ecs_';
$timezone = isset($_POST['timezone']) ? trim($_POST['timezone']) : 'Asia/Shanghai';
if (empty($db_host) || empty($db_user) || empty($db_pass) || empty($db_name)) {
    data_back('缺少必要的参数');
}
$result = create_config_file($db_host, $db_port, $db_user, $db_pass, $db_name, $prefix, $timezone);
if ($result === false) {
    data_back('构建配置文件失败');
}
$result = create_database($db_host, $db_port, $db_user, $db_pass, $db_name);
if ($result === false) {
    data_back('创建数据库失败');
}
$system_lang = isset($_POST['system_lang']) ? $_POST['system_lang'] : 'zh_cn';
if (file_exists(ROOT_PATH . 'install/data/data_' . $system_lang . '.sql')) {
    $data_path = ROOT_PATH . 'install/data/data_' . $system_lang . '.sql';
} else {
    $data_path = ROOT_PATH . 'install/data/data_zh_cn.sql';
}
$sql_files = array(ROOT_PATH . 'install/data/structure.sql', $data_path);
$result = install_data($sql_files);
开发者ID:BGCX262,项目名称:zuyii-svn-to-git,代码行数:31,代码来源:auto_index.php

示例3: oc_install

function oc_install()
{
    $dbhost = Params::getParam('dbhost');
    $dbname = Params::getParam('dbname');
    $username = Params::getParam('username');
    $password = Params::getParam('password', false, false);
    $tableprefix = Params::getParam('tableprefix');
    $createdb = false;
    if ($tableprefix == '') {
        $tableprefix = 'oc_';
    }
    if (Params::getParam('createdb') != '') {
        $createdb = true;
    }
    if ($createdb) {
        $adminuser = Params::getParam('admin_username');
        $adminpwd = Params::getParam('admin_password', false, false);
        $master_conn = new DBConnectionClass($dbhost, $adminuser, $adminpwd, '');
        $error_num = $master_conn->getErrorConnectionLevel();
        if ($error_num > 0) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
            }
            switch ($error_num) {
                case 1049:
                    return array('error' => __('The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges'));
                    break;
                case 1045:
                    return array('error' => __('Cannot connect to the database. Check if the user has privileges.'));
                    break;
                case 1044:
                    return array('error' => __('Cannot connect to the database. Check if the username and password are correct.'));
                    break;
                case 2005:
                    return array('error' => __('Cannot resolve MySQL host. Check if the host is correct.'));
                    break;
                default:
                    return array('error' => sprintf(__('Cannot connect to the database. Error number: %s')), $error_num);
                    break;
            }
        }
        $m_db = $master_conn->getOsclassDb();
        $comm = new DBCommandClass($m_db);
        $comm->query(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname));
        $error_num = $comm->getErrorLevel();
        if ($error_num > 0) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__('Cannot create the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
            }
            if (in_array($error_num, array(1006, 1044, 1045))) {
                return array('error' => __('Cannot create the database. Check if the admin username and password are correct.'));
            }
            return array('error' => sprintf(__('Cannot create the database. Error number: %s'), $error_num));
        }
        unset($conn);
        unset($comm);
        unset($master_conn);
    }
    $conn = new DBConnectionClass($dbhost, $username, $password, $dbname);
    $error_num = $conn->getErrorConnectionLevel();
    if ($error_num == 0) {
        $error_num = $conn->getErrorLevel();
    }
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1049:
                return array('error' => __('The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges'));
                break;
            case 1045:
                return array('error' => __('Cannot connect to the database. Check if the user has privileges.'));
                break;
            case 1044:
                return array('error' => __('Cannot connect to the database. Check if the username and password are correct.'));
                break;
            case 2005:
                return array('error' => __('Cannot resolve MySQL host. Check if the host is correct.'));
                break;
            default:
                return array('error' => sprintf(__('Cannot connect to the database. Error number: %s'), $error_num));
                break;
        }
    }
    if (file_exists(ABS_PATH . 'config.php')) {
        if (!is_writable(ABS_PATH . 'config.php')) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__('Cannot write in config.php file. Check if the file is writable.'), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __('Cannot write in config.php file. Check if the file is writable.'));
        }
        create_config_file($dbname, $username, $password, $dbhost, $tableprefix);
    } else {
        if (!file_exists(ABS_PATH . 'config-sample.php')) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__("config-sample.php doesn't exist. Check if you have everything well decompressed."), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __("config-sample.php doesn't exist. Check if you have everything well decompressed."));
        }
//.........这里部分代码省略.........
开发者ID:randomecho,项目名称:OSClass,代码行数:101,代码来源:install-functions.php

示例4: oc_install

function oc_install()
{
    $dbhost = trim($_POST['dbhost']);
    $dbname = trim($_POST['dbname']);
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);
    if (empty($_POST['tableprefix'])) {
        $tableprefix = 'oc_';
    } else {
        $tableprefix = trim($_POST['tableprefix']);
    }
    if (isset($_POST['createdb'])) {
        $createdb = true;
    } else {
        $createdb = false;
    }
    if ($createdb) {
        $adminuser = trim($_POST['admin_username']);
        $adminpwd = trim($_POST['admin_password']);
        $master_conn = getConnection($dbhost, $adminuser, $adminpwd, 'mysql', DEBUG_LEVEL);
        $master_conn->osc_dbExec(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname));
        $error_num = $master_conn->get_errno();
        if ($error_num > 0) {
            if ($error_num == 1006 || $error_num == 1044 || $error_num == 1045) {
                return array('error' => 'Cannot create the database. Check if the admin username and password are correct.');
            }
            return array('error' => 'Cannot create the database. Error number: ' . $error_num . '.');
        }
    }
    $conn = getConnection($dbhost, $username, $password, $dbname, DEBUG_LEVEL);
    $error_num = $conn->get_errno();
    if ($error_num > 0) {
        if ($error_num == 1049) {
            return array('error' => 'The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges');
        }
        if ($error_num == 1045) {
            return array('error' => 'Cannot connect to the database. Check if the user has privileges.');
        }
        if ($error_num == 1044) {
            return array('error' => 'Cannot connect to the database. Check if the username and password are correct.');
        }
        return array('error' => 'Cannot connect to database. Error number: ' . $error_num . '.');
    }
    if (file_exists(ABS_PATH . 'config.php')) {
        if (!is_writable(ABS_PATH . 'config.php')) {
            return array('error' => 'Cannot write in config.php file. Check if the file is writable.');
        }
        create_config_file($dbname, $username, $password, $dbhost, $tableprefix);
    } else {
        if (!file_exists(ABS_PATH . 'config-sample.php')) {
            return array('error' => 'It doesn\'t exist config-sample.php. Check if you have everything well decompressed.');
        }
        if (!is_writable(ABS_PATH)) {
            return array('error' => 'Can\'t copy config-sample.php. Check if the root directory is writable.');
        }
        copy_config_file($dbname, $username, $password, $dbhost, $tableprefix);
    }
    require_once ABS_PATH . 'config.php';
    $sql = file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/struct.sql');
    $conn->osc_dbImportSQL($sql);
    $error_num = $conn->get_errno();
    if ($error_num > 0) {
        if ($error_num == 1050) {
            return array('error' => 'There are tables with the same name in the database. Change the table prefix or the database and try again.');
        }
        return array('error' => 'Cannot create the database structure. Error number: ' . $error_num . '.');
    }
    require_once LIB_PATH . 'osclass/locales.php';
    require_once LIB_PATH . 'osclass/model/OSCLocale.php';
    $localeManager = OSCLocale::newInstance();
    $locales = osc_listLocales();
    foreach ($locales as $locale) {
        $values = array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 'b_enabled' => $locale['code'] == 'en_US' ? 1 : 0, 'b_enabled_bo' => 1);
        if (isset($locale['stop_words'])) {
            $values['s_stop_words'] = $locale['stop_words'];
        }
        $localeManager->insert($values);
    }
    $required_files = array('basic_data.sql', 'categories.sql', 'pages.sql');
    $sql = '';
    foreach ($required_files as $file) {
        if (!file_exists(ABS_PATH . 'oc-includes/osclass/installer/' . $file)) {
            return array('error' => 'the file ' . $file . ' doesn\'t exist in data folder');
        } else {
            $sql .= file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/' . $file);
        }
    }
    $conn->osc_dbImportSQL($sql, '');
    $error_num = $conn->get_errno();
    if ($error_num > 0) {
        if ($error_num == 1471) {
            return array('error' => 'Cannot insert basic configuration. This user has no privileges to \'INSERT\' into the database.');
        }
        return array('error' => 'Cannot insert basic configuration. Error number: ' . $error_num . '.');
    }
    return false;
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:97,代码来源:install-functions.php

示例5: make_safe

     exit;
 } else {
     $dbname = make_safe($_POST['dbname']);
     $dbuser = make_safe($_POST['dbuser']);
     $dbpass = make_safe($_POST['dbpass']);
     $dbhost = make_safe($_POST['dbhost']);
     $email = make_safe($_POST['email']);
     $pass = make_safe($_POST['pass']);
     $pass1 = make_safe($_POST['pass1']);
     /* Check if passwords matches */
     if (strcmp($pass, $pass1) != 0) {
         $err = "Passwords do not match";
         show_first_time_form($dbname, $dbuser, $dbpass, $dbhost, $email, $pass, $err);
         exit;
     } else {
         create_config_file($dbname, $dbuser, $dbpass, $dbhost, $email, $pass);
         sql_con();
         $query = "DROP TABLE IF EXISTS `login`";
         $result = mysql_query($query) or die(mysql_error());
         $query = "CREATE TABLE `login` (\n\t\t\t\t`Name` varchar(40) NOT NULL,\n\t\t\t\t`User` varchar(20) NOT NULL,\n\t\t\t\t`password` varchar(50) NOT NULL,\n\t\t\t\t`Email` varchar(50) NOT NULL,\n\t\t\t\t`Gender` varchar(20) NOT NULL,\n\t\t\t\t`admin` int(11) DEFAULT NULL,\n\t\t\t\t`status` int(11) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY (`User`)\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1";
         $result = mysql_query($query) or die(mysql_error());
         $query = "DROP TABLE IF EXISTS `week_report`";
         $result = mysql_query($query) or die(mysql_error());
         $query = "CREATE TABLE `week_report` (\n\t\t\t\t`Project` varchar(30) DEFAULT NULL,\n\t\t\t\t`Task` varchar(200) NOT NULL,\n\t\t\t\t`Percent` int(3) NOT NULL,\n\t\t\t\t`Week` varchar(20) DEFAULT NULL,\n\t\t\t\t`User` varchar(20) NOT NULL,\n\t\t\t\t`team` varchar(20) DEFAULT NULL,\n\t\t\t\tKEY `User` (`User`),\n\t\t\t\tCONSTRAINT `week_report_ibfk_1`\n\t\t\t\tFOREIGN KEY (`User`) REFERENCES `login` (`User`)\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1";
         $result = mysql_query($query) or die(mysql_error());
         $query = "DROP TABLE IF EXISTS `teams`";
         $result = mysql_query($query) or die(mysql_error());
         $query = "CREATE TABLE `teams` (\n\t\t\t  `team_name` varchar(20) NOT NULL DEFAULT '',\n\t\t\t  `location` varchar(20) DEFAULT NULL,\n\t\t\t  PRIMARY KEY (`team_name`)\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1";
         $result = mysql_query($query) or die(mysql_error());
         $query = "DROP TABLE IF EXISTS `team`";
         $result = mysql_query($query) or die(mysql_error());
开发者ID:yogeshpowar,项目名称:fwrt,代码行数:31,代码来源:index.php

示例6: foreach

if (isset($_POST['form_sent']) && $_POST['form_sent'] == 'eps_config') {
    foreach ($_POST as $k => $v) {
        $field = preg_replace('#^req_#i', '', $k);
        eval('$updates["' . $field . '"] = eps_linebreak(trim($_POST["' . $k . '"]));');
    }
    while (list($key, $input) = @each($updates)) {
        // Only update values that have changed
        if (array_key_exists($key, $eps_config) && $eps_config[$key] != $input) {
            if ($input != '' || is_int($input)) {
                $changes = array('value' => $input);
            } else {
                $changes = array('value' => NULL);
            }
            $epsclass->db->vupdate(TBL_CONFIG, $changes, $key, 'name');
        }
    }
    create_config_file();
    redirect('index.php?eps=admin', $eps_lang['Redirect_admin']);
    return;
}
$smarty->assign('page_title', $eps_lang['Page_admin']);
$smarty->assign('error_show', !empty($errors) ? gen_alert($errors) : '');
$smarty->assign('form_tag', auto_gen_form('index.php?eps=admin', 'admin', true));
$smarty->assign('styles', get_stuff('style'));
$smarty->assign('languages', get_stuff('language'));
$smarty->assign('yesno_radios', array(1 => $eps_lang['Yes'], 0 => $eps_lang['No']));
foreach ($eps_config as $k => $v) {
    eval('$smarty->assign("' . $k . '", (isset($updates["' . $k . '"])) ? $updates["' . $k . '"] : $eps_config["' . $k . '"]);');
}
unset($updates);
$smarty->display('admin/admin.tpl');
开发者ID:nqv,项目名称:eposys,代码行数:31,代码来源:admin.php

示例7: do_install

function do_install($form)
{
    $form = array_map('stripslashes', $form);
    $form = array_map('trim', $form);
    // First check the requirements
    $errors = check_requirements();
    if (sizeof($errors) > 0) {
        echo "\t" . '<p class="errors">' . plog_tr('Plogger cannot be installed until the following problems are resolved') . ':</p>';
        echo "\n\n\t\t" . '<ul class="info">';
        foreach ($errors as $error) {
            echo "\n\t\t\t" . '<li class="margin-5">' . $error . '</li>';
        }
        echo "\n\t\t" . '</ul>';
        echo "\n\n\t" . '<form method="get" action="' . $_SERVER['REQUEST_URI'] . '">
		<p><input class="submit" type="submit" value="' . plog_tr('Try again') . '" /></p>
	</form>' . "\n";
        return false;
    }
    $ok = false;
    $errors = array();
    // If we've already defined the database information, pass the values and skip them on the form
    if (defined('PLOGGER_DB_HOST')) {
        $mysql = check_mysql(PLOGGER_DB_HOST, PLOGGER_DB_USER, PLOGGER_DB_PW, PLOGGER_DB_NAME);
        if (!empty($mysql)) {
            $mysql_fail = true;
        } else {
            unset($_SESSION['plogger_config']);
        }
        // Set the form values equal to config values if already set
        if (empty($form['db_host'])) {
            $form['db_host'] = PLOGGER_DB_HOST;
        }
        if (empty($form['db_user'])) {
            $form['db_user'] = PLOGGER_DB_USER;
        }
        if (empty($form['db_pass'])) {
            $form['db_pass'] = PLOGGER_DB_PW;
        }
        if (empty($form['db_name'])) {
            $form['db_name'] = PLOGGER_DB_NAME;
        }
    }
    if (isset($form['action']) && $form['action'] == 'install') {
        if (!defined('PLOGGER_DB_HOST') || isset($mysql_fail)) {
            $mysql_form_check = check_mysql_form($form);
            if (!empty($mysql_form_check)) {
                $errors = array_merge($errors, $mysql_form_check);
            }
        }
        if (empty($form['gallery_name'])) {
            $errors[] = plog_tr('Please enter the name for your gallery.');
        }
        if (empty($form['admin_email'])) {
            $errors[] = plog_tr('Please enter your email address.');
        }
        if (empty($form['admin_username'])) {
            $errors[] = plog_tr('Please enter a username.');
        }
        if (empty($form['admin_password'])) {
            $errors[] = plog_tr('Please enter a password.');
        }
        if ($form['admin_password'] != $form['admin_password_confirm']) {
            $errors[] = plog_tr('Your passwords do not match. Please try again.');
        }
        if (is_safe_mode()) {
            // If safe_mode enabled, check the FTP information form inputs
            $ftp_form_check = check_ftp_form($form);
            $form = $ftp_form_check['form'];
            if (!empty($ftp_form_check['form']['errors'])) {
                $errors = array_merge($errors, $ftp_form_check['form']['errors']);
            }
        }
        if (empty($errors)) {
            $mysql_errors = check_mysql($form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name']);
            if (is_safe_mode()) {
                $ftp_errors = check_ftp($form['ftp_host'], $form['ftp_user'], $form['ftp_pass'], $form['ftp_path']);
            } else {
                $ftp_errors = array();
            }
            $errors = array_merge($mysql_errors, $ftp_errors);
            $ok = empty($errors);
        }
        if (!$ok) {
            echo '<ul class="errors" style="background-image: none;">' . "\n\t" . '<li class="margin-5">';
            echo join("</li>\n\t<li class=\"margin-5\">", $errors);
            echo "</li>\n</ul>\n\n";
        } else {
            $_SESSION['install_values'] = array('gallery_name' => $form['gallery_name'], 'admin_email' => $form['admin_email'], 'admin_password' => $form['admin_password'], 'admin_username' => $form['admin_username']);
            if (is_safe_mode()) {
                $_SESSION['ftp_values'] = array('ftp_host' => $form['ftp_host'], 'ftp_user' => $form['ftp_user'], 'ftp_pass' => $form['ftp_pass'], 'ftp_path' => $form['ftp_path']);
            }
            if (!defined('PLOGGER_DB_HOST') || isset($mysql_fail)) {
                // Serve the config file and ask user to upload it to webhost
                $_SESSION['plogger_config'] = create_config_file($form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name']);
            }
            return true;
        }
    }
    include PLOGGER_DIR . 'plog-admin/includes/install-form-setup.php';
    return false;
//.........这里部分代码省略.........
开发者ID:joshuasiler,项目名称:Rebuilding-Together,代码行数:101,代码来源:install-functions.php

示例8: create_config_file

        ?>

<button class="button" type="submit" id="submit" name="submit" value="<?php 
        echo $submit;
        ?>
"><?php 
        echo $submit;
        ?>
</button>

</form>

<?php 
    }
    if (isset($_GET['view']) && $_GET['view'] == "install" && isset($_GET['cat']) && $_GET['cat'] == "configuration" || isset($_GET['view']) && $_GET['view'] == "db_fix" && isset($_GET['cat']) && $_GET['cat'] == "configuration") {
        $result = create_config_file('../includes/', '../includes/pixelpost.php');
        if ($_GET['view'] != "db_fix") {
            $url = !isset($result['error']) || $result['verifed'] == true ? "install.php?view=install&amp;cat=finalize" : "install.php?view=install&amp;cat=configuration";
            $submit = !isset($result['error']) || $result['verifed'] == true ? $lang_cont . " &raquo;" : $lang_test_btn;
        } else {
            $url = !isset($result['error']) || $result['verifed'] == true ? "index.php" : "install.php?view=db_fix&amp;cat=configuration";
            $submit = !isset($result['error']) || $result['verifed'] == true ? $lang_finished_btn . " &raquo;" : $lang_test_btn;
        }
        $msgBoxCSS = !isset($result['error']) || $result['verifed'] == true ? 'success' : 'error';
        ?>

<h1><?php 
        echo $lang_install_config;
        ?>
</h1>
开发者ID:RoseySoft,项目名称:pixelpost,代码行数:30,代码来源:install.php

示例9: plog_tr

    }
    echo "\n\t\t" . '</ul>';
    echo "\n\n\t\t" . '<form method="get" action="' . $_SERVER['REQUEST_URI'] . '">
		<p><input class="submit" type="submit" value="' . plog_tr('Try again') . '" /></p>
		</form>' . "\n";
} else {
    // End of requirement check
    $errors = "";
    echo "\n" . '<h1>' . plog_tr('Upgrading Plogger') . '</h1>';
    switch ($step) {
        // Step 0 - gather any information needed
        case 0:
            if ($beta1) {
                // Include the old sql database info and create a new plog-config.php file with it
                include_once PLOGGER_DIR . 'plog-connect.php';
                $conf = create_config_file($DB_HOST, $DB_USER, $DB_PW, $DB_NAME);
                // Serve the config file and ask user to upload it to webhost
                $_SESSION['plogger_config'] = $conf;
                echo "\n\n\t" . '<h2 class="upgrade">' . plog_tr('Updating Configuration') . '</h2>';
                echo "\n\n\t\t" . '<p>' . plog_tr('It appears you are updating from Plogger 1.0beta1. Your configuration file needs to be updated.') . '</p>';
                echo "\n\n\t\t" . '<form action="_upgrade.php" method="post">';
                echo "\n\n\t\t" . '<p>' . sprintf(plog_tr('Before you can proceed, please %s to download the configuration file for your gallery, then upload it to your webhost (into the same directory where you installed Plogger itself).'), '<input class="submit-inline" type="submit" name="dlconfig" value=" ' . plog_tr('click here') . '" />') . '</p>';
                echo "\n\n\t\t" . '<p><input class="submit" type="submit" name="continue" id="continue" value=" ' . plog_tr('Continue') . '..." /></p>';
                echo "\n\n\t\t" . '</form>' . "\n";
                break;
            } else {
                if ($needs_ftp) {
                    // If we need to collect ftp information for safe_mode workaround
                    // Handle errors and include the information form
                    if (!empty($ftp_errors)) {
                        echo "\n\n\t\t" . '<ul class="errors" style="background-image: none;">';
开发者ID:nadams810,项目名称:ploto,代码行数:31,代码来源:_upgrade.php

示例10: oc_install

function oc_install()
{
    $dbhost = Params::getParam('dbhost');
    $dbname = Params::getParam('dbname');
    $username = Params::getParam('username');
    $password = Params::getParam('password', false, false);
    $tableprefix = Params::getParam('tableprefix');
    $createdb = false;
    require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
    if ($tableprefix == '') {
        $tableprefix = 'oc_';
    }
    if (Params::getParam('createdb') != '') {
        $createdb = true;
    }
    if ($createdb) {
        $adminuser = Params::getParam('admin_username');
        $adminpwd = Params::getParam('admin_password', false, false);
        $master_conn = new DBConnectionClass($dbhost, $adminuser, $adminpwd, '');
        $error_num = $master_conn->getErrorConnectionLevel();
        if ($error_num > 0) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
            }
            switch ($error_num) {
                case 1049:
                    return array('error' => __("База данных не существует. Необходимо проверить возможность подключения к базе данных. Номер ошибки: \"Create DB\" флажок и заполнить имя пользователя и пароль с правом привилегий"));
                    break;
                case 1045:
                    return array('error' => __('Не удается подключиться к базе данных. Проверьтеесли у пользователя права.'));
                    break;
                case 1044:
                    return array('error' => __('Не удается подключиться к базе данных. Проверьте имя пользователя и пароль.'));
                    break;
                case 2005:
                    return array('error' => __("Не могу определить MySQL хост. Проверьте правильность хоста."));
                    break;
                default:
                    return array('error' => sprintf(__('Не удается подключиться к базе данных. Номер ошибки: %s')), $error_num);
                    break;
            }
        }
        $m_db = $master_conn->getOsclassDb();
        $comm = new DBCommandClass($m_db);
        $comm->query(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname));
        $error_num = $comm->getErrorLevel();
        if ($error_num > 0) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__("Не удается подключиться к базе данных. Номер ошибки: %s"), $error_num), __FILE__ . "::" . __LINE__);
            }
            if (in_array($error_num, array(1006, 1044, 1045))) {
                return array('error' => __("Не удается подключиться к базе данных. Проверьте имя пользователя и пароль администратора."));
            }
            return array('error' => sprintf(__("Невозможно создать базу данных. Номер ошибки: %s"), $error_num));
        }
        unset($conn);
        unset($comm);
        unset($master_conn);
    }
    $conn = new DBConnectionClass($dbhost, $username, $password, $dbname);
    $error_num = $conn->getErrorConnectionLevel();
    if ($error_num == 0) {
        $error_num = $conn->getErrorLevel();
    }
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1049:
                return array('error' => __("База данных не существует. Необходимо проверить \"Create DB\" флажок и заполнить имя пользователя и пароль с правом привилегий"));
                break;
            case 1045:
                return array('error' => __('Не удается подключиться к базе данных. Проверьте если у пользователя есть привилегии.'));
                break;
            case 1044:
                return array('error' => __('Не удается подключиться к базе данных. Проверьте имя пользователя и пароль.'));
                break;
            case 2005:
                return array('error' => __("Не могу определить MySQL хост."));
                break;
            default:
                return array('error' => sprintf(__('Не удается подключиться к базе данных. Номер ошибки: %s'), $error_num));
                break;
        }
    }
    if (file_exists(ABS_PATH . 'config.php')) {
        if (!is_writable(ABS_PATH . 'config.php')) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__("Не удается выполнить запись в файл config.php. Проверьте доступность файла для записи."), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __("Не удается выполнить запись в файл config.php. Проверьте доступность файла для записи."));
        }
        create_config_file($dbname, $username, $password, $dbhost, $tableprefix);
    } else {
        if (!file_exists(ABS_PATH . 'config-sample.php')) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__("config-sample.php не существует. Проверьте все ли файлы правильно распакованы."), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __("config-sample.php не существует. Проверьте все ли файлы правильно распакованы."));
//.........这里部分代码省略.........
开发者ID:bomvendador,项目名称:soroka_r,代码行数:101,代码来源:install-functions.php

示例11: do_install

function do_install($form)
{
    $form = array_map('stripslashes', $form);
    $form = array_map('trim', $form);
    $errors = check_requirements();
    if (sizeof($errors) > 0) {
        print '<p>Plogger wont work until the following problems are resolved</p>';
        print '<ul>';
        foreach ($errors as $error) {
            print '<li>' . $error . '</li>';
        }
        print '</ul>';
        print '<form method="GET" action="_install.php"><input type="submit" value="Try again"/></form>';
        return false;
    }
    if (defined('PLOGGER_DB_HOST')) {
        $mysql = check_mysql(PLOGGER_DB_HOST, PLOGGER_DB_USER, PLOGGER_DB_PW, PLOGGER_DB_NAME);
        // looks like we are already configured
        if (empty($mysql)) {
            print '<p>Plogger is already installed!</p>';
            return false;
        }
    }
    $ok = false;
    $errors = array();
    if (!empty($form['action']) && 'install' == $form['action']) {
        if (empty($form['db_host'])) {
            $errors[] = 'Please enter the name of your MySQL host.';
        }
        if (empty($form['db_user'])) {
            $errors[] = 'Please enter the MySQL username.';
        }
        if (empty($form['db_pass'])) {
            $errors[] = 'Please enter the MySQL password.';
        }
        if (empty($form['db_name'])) {
            $errors[] = 'Please enter the MySQL database name.';
        }
        if (empty($form['gallery_name'])) {
            $errors[] = 'Please enter the name for your gallery.';
        }
        if (empty($form['admin_email'])) {
            $errors[] = 'Please enter your e-mail address.';
        }
        if (empty($errors)) {
            $errors = check_mysql($form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name']);
            $ok = empty($errors);
        }
        if (!$ok) {
            print '<ul><li>';
            print join("</li>\n<li>", $errors);
            print '</li></ul>';
        } else {
            $password = generate_password();
            $_SESSION["install_values"] = array("gallery_name" => $form["gallery_name"], "admin_email" => $form["admin_email"], "admin_password" => $password, "admin_username" => "admin");
            $conf = create_config_file($form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name']);
            // if configuration file is writable, then set the values
            // otherwise serve the config file to user and ask her to
            // upload it to webhost
            if (config_writable()) {
                write_config($conf);
            } else {
                $_SESSION["plogger_config"] = $conf;
            }
            require PLOGGER_DIR . 'lib/plogger/form_setup_complete.php';
            return true;
        }
    }
    // most of the time it's probably running on localhost
    if (empty($form['db_host'])) {
        $form['db_host'] = 'localhost';
    }
    $init_vars = array('db_user', 'db_pass', 'db_name', 'gallery_name', 'admin_email');
    foreach ($init_vars as $var) {
        if (empty($form[$var])) {
            $form[$var] = "";
        }
    }
    require PLOGGER_DIR . 'lib/plogger/form_setup.php';
}
开发者ID:alanhaggai,项目名称:plogger,代码行数:80,代码来源:install_functions.php


注:本文中的create_config_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。