Ejemplo n.º 1
0
/**
 * 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();
}
Ejemplo n.º 2
0
$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);
Ejemplo n.º 3
0
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."));
        }
        if (!is_writable(ABS_PATH)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__('Can\'t copy config-sample.php. Check if the root directory is writable.'), __FILE__ . "::" . __LINE__);
            }
            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');
    $c_db = $conn->getOsclassDb();
    $comm = new DBCommandClass($c_db);
    $comm->importSQL($sql);
    $error_num = $comm->getErrorLevel();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__('Cannot create the database structure. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1050:
                return array('error' => __('There are tables with the same name in the database. Change the table prefix or the database and try again.'));
                break;
            default:
                return array('error' => sprintf(__('Cannot create the database structure. Error number: %s'), $error_num));
                break;
        }
    }
    require_once LIB_PATH . 'osclass/model/OSCLocale.php';
    $localeManager = OSCLocale::newInstance();
    $locales = osc_listLocales();
    $values = array('pk_c_code' => $locales[osc_current_admin_locale()]['code'], 's_name' => $locales[osc_current_admin_locale()]['name'], 's_short_name' => $locales[osc_current_admin_locale()]['short_name'], 's_description' => $locales[osc_current_admin_locale()]['description'], 's_version' => $locales[osc_current_admin_locale()]['version'], 's_author_name' => $locales[osc_current_admin_locale()]['author_name'], 's_author_url' => $locales[osc_current_admin_locale()]['author_url'], 's_currency_format' => $locales[osc_current_admin_locale()]['currency_format'], 's_date_format' => $locales[osc_current_admin_locale()]['date_format'], 'b_enabled' => 1, 'b_enabled_bo' => 1);
    if (isset($locales[osc_current_admin_locale()]['stop_words'])) {
        $values['s_stop_words'] = $locales[osc_current_admin_locale()]['stop_words'];
    }
    $localeManager->insert($values);
    $required_files = array(ABS_PATH . 'oc-includes/osclass/installer/basic_data.sql', ABS_PATH . 'oc-includes/osclass/installer/pages.sql', ABS_PATH . 'oc-content/languages/' . osc_current_admin_locale() . '/mail.sql');
    $sql = '';
    foreach ($required_files as $file) {
        if (!file_exists($file)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__('The file %s doesn\'t exist'), $file), __FILE__ . "::" . __LINE__);
            }
            return array('error' => sprintf(__('The file %s doesn\'t exist'), $file));
        } else {
            $sql .= file_get_contents($file);
        }
    }
    $comm->importSQL($sql);
    $error_num = $comm->getErrorLevel();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__('Cannot insert basic configuration. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1471:
                return array('error' => __('Cannot insert basic configuration. This user has no privileges to \'INSERT\' into the database.'));
                break;
            default:
                return array('error' => sprintf(__('Cannot insert basic configuration. Error number: '), $error_num));
                break;
        }
    }
    osc_set_preference('language', osc_current_admin_locale());
    osc_set_preference('admin_language', osc_current_admin_locale());
    oc_install_example_data();
    if (reportToOsclass()) {
        set_allow_report_osclass(true);
    } else {
        set_allow_report_osclass(false);
    }
    return false;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
     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());
Ejemplo n.º 6
0
Archivo: admin.php Proyecto: nqv/eposys
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');
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;
}
Ejemplo n.º 8
0
        ?>

<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>
Ejemplo n.º 9
0
    }
    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;">';
Ejemplo n.º 10
0
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 не существует. Проверьте все ли файлы правильно распакованы."));
        }
        if (!is_writable(ABS_PATH)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__('Не удается скопировать config-sample.php. Проверьте доступен ли для записи корневой каталог.'), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __('Не удается скопировать config-sample.php. Проверьте доступен ли для записи корневой каталог.'));
        }
        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');
    $c_db = $conn->getOsclassDb();
    $comm = new DBCommandClass($c_db);
    $comm->importSQL($sql);
    $error_num = $comm->getErrorLevel();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__("Не удается создать структуру базы данных. Номер ошибки: %s"), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1050:
                return array('error' => __('Таблицы с таким же именем уже существуют в базе данных. Измените префикс таблиц или базу данных и повторите попытку.'));
                break;
            default:
                return array('error' => sprintf(__("Не удается создать структуру базы данных. Номер ошибки: %s"), $error_num));
                break;
        }
    }
    require_once LIB_PATH . 'osclass/model/OSCLocale.php';
    $localeManager = OSCLocale::newInstance();
    $locales = osc_listLocales();
    $values = array('pk_c_code' => $locales[osc_current_admin_locale()]['code'], 's_name' => $locales[osc_current_admin_locale()]['name'], 's_short_name' => $locales[osc_current_admin_locale()]['short_name'], 's_description' => $locales[osc_current_admin_locale()]['description'], 's_version' => $locales[osc_current_admin_locale()]['version'], 's_author_name' => $locales[osc_current_admin_locale()]['author_name'], 's_author_url' => $locales[osc_current_admin_locale()]['author_url'], 's_currency_format' => $locales[osc_current_admin_locale()]['currency_format'], 's_date_format' => $locales[osc_current_admin_locale()]['date_format'], 'b_enabled' => 1, 'b_enabled_bo' => 1);
    if (isset($locales[osc_current_admin_locale()]['stop_words'])) {
        $values['s_stop_words'] = $locales[osc_current_admin_locale()]['stop_words'];
    }
    $localeManager->insert($values);
    $required_files = array(ABS_PATH . 'oc-includes/osclass/installer/basic_data.sql', ABS_PATH . 'oc-includes/osclass/installer/pages.sql', ABS_PATH . 'oc-content/languages/' . osc_current_admin_locale() . '/mail.sql');
    $sql = '';
    foreach ($required_files as $file) {
        if (!file_exists($file)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__('Файл %s не существует'), $file), __FILE__ . "::" . __LINE__);
            }
            return array('error' => sprintf(__('Файл %s не существует'), $file));
        } else {
            $sql .= file_get_contents($file);
        }
    }
    $comm->importSQL($sql);
    $error_num = $comm->getErrorLevel();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__("Не удается установить базовую конфигурацию. Номер ошибки: %s"), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1471:
                return array('error' => __("Не удается установить базовую конфигурацию. Этот пользователь не имеет привилегий делать записи 'INSERT' в базе данных."));
                break;
            default:
                return array('error' => sprintf(__("Не удается установить базовую конфигурацию. Номер ошибки: %s"), $error_num));
                break;
        }
    }
    osc_set_preference('language', osc_current_admin_locale());
    osc_set_preference('admin_language', osc_current_admin_locale());
    osc_set_preference('csrf_name', 'CSRF' . mt_rand(0, mt_getrandmax()));
    oc_install_example_data();
    if (reportToOsclass()) {
        set_allow_report_osclass(true);
    } else {
        set_allow_report_osclass(false);
    }
    return false;
}
Ejemplo n.º 11
0
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';
}