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


PHP get_available_dbms函数代码示例

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


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

示例1: load_schema

/**
 * Load a schema (and execute)
 *
 * @param string $install_path
 */
function load_schema($install_path = '', $install_dbms = false)
{
    global $db;
    global $table_prefix;
    static $available_dbms = false;
    if ($install_dbms === false) {
        global $dbms;
        $install_dbms = $dbms;
    }
    if (!function_exists('get_available_dbms')) {
        global $phpbb_root_path, $phpEx;
        include $phpbb_root_path . 'includes/functions_install.' . $phpEx;
    }
    if (!$available_dbms) {
        $available_dbms = get_available_dbms($install_dbms);
        if ($install_dbms == 'mysql') {
            if (version_compare($db->mysql_version, '4.1.3', '>=')) {
                $available_dbms[$install_dbms]['SCHEMA'] .= '_41';
            } else {
                $available_dbms[$install_dbms]['SCHEMA'] .= '_40';
            }
        }
    }
    $remove_remarks = $available_dbms[$install_dbms]['COMMENTS'];
    $delimiter = $available_dbms[$install_dbms]['DELIM'];
    $dbms_schema = $install_path . $available_dbms[$install_dbms]['SCHEMA'] . '_schema.sql';
    if (file_exists($dbms_schema)) {
        $sql_query = @file_get_contents($dbms_schema);
        $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
        $remove_remarks($sql_query);
        $sql_query = split_sql_file($sql_query, $delimiter);
        foreach ($sql_query as $sql) {
            $db->sql_query($sql);
        }
        unset($sql_query);
    }
    if (file_exists($install_path . 'schema_data.sql')) {
        $sql_query = file_get_contents($install_path . 'schema_data.sql');
        switch ($install_dbms) {
            case 'mssql':
            case 'mssql_odbc':
                $sql_query = preg_replace('#\\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \\##s', 'SET IDENTITY_INSERT \\1 \\2;', $sql_query);
                break;
            case 'postgres':
                $sql_query = preg_replace('#\\# POSTGRES (BEGIN|COMMIT) \\##s', '\\1; ', $sql_query);
                break;
        }
        $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
        $sql_query = preg_replace_callback('#\\{L_([A-Z0-9\\-_]*)\\}#s', 'adjust_language_keys_callback', $sql_query);
        remove_remarks($sql_query);
        $sql_query = split_sql_file($sql_query, ';');
        foreach ($sql_query as $sql) {
            $db->sql_query($sql);
        }
        unset($sql_query);
    }
}
开发者ID:Gfksx,项目名称:quickinstall,代码行数:62,代码来源:functions_install.php

示例2: dbms_select

/**
* Generate the drop down of available database options
*/
function dbms_select($default = '', $only_20x_options = false)
{
    global $lang;
    $available_dbms = get_available_dbms(false, false, $only_20x_options);
    $dbms_options = '';
    foreach ($available_dbms as $dbms_name => $details) {
        $selected = $dbms_name == $default ? ' selected="selected"' : '';
        $dbms_options .= '<option value="' . $dbms_name . '"' . $selected . '>' . $lang['DLL_' . strtoupper($dbms_name)] . '</option>';
    }
    return $dbms_options;
}
开发者ID:eyumay,项目名称:ju.ejhs,代码行数:14,代码来源:functions_install.php

示例3: table_add

 /**
  * Table Add
  *
  * This only supports input from the array format of db_tools or create_schema_files.
  */
 function table_add($table_name, $table_data = array())
 {
     global $dbms, $user;
     // Multicall
     if (is_array($table_name)) {
         foreach ($table_name as $params) {
             call_user_func_array(array($this, 'table_add'), $params);
         }
         return;
     }
     /**
      * $table_data can be empty when uninstalling a mod and table_remove was used, but no 2rd argument was given.
      * In that case we'll assume that it was a column previously added by the mod (if not the author should specify a 2rd argument) and skip this to prevent an error
      */
     if (empty($table_data)) {
         return;
     }
     $this->get_table_name($table_name);
     $this->umil_start('TABLE_ADD', $table_name);
     if ($this->table_exists($table_name)) {
         return $this->umil_end('TABLE_ALREADY_EXISTS', $table_name);
     }
     if (!is_array($table_data)) {
         return $this->umil_end('NO_TABLE_DATA');
     }
     if (!function_exists('get_available_dbms')) {
         global $phpbb_root_path, $phpEx;
         include "{$phpbb_root_path}includes/functions_install.{$phpEx}";
     }
     if (method_exists($this->db_tools, 'sql_create_table')) {
         // Added in 3.0.5
         $this->db_tools->sql_create_table($table_name, $table_data);
     } else {
         $available_dbms = get_available_dbms($dbms);
         $sql_query = $this->create_table_sql($table_name, $table_data);
         $sql_query = split_sql_file($sql_query, $available_dbms[$dbms]['DELIM']);
         foreach ($sql_query as $sql) {
             $this->db->sql_query($sql);
         }
     }
     return $this->umil_end();
 }
开发者ID:poyntesm,项目名称:phpbbgarage,代码行数:47,代码来源:umil.php

示例4: build_search_index

    /**
     * Build the search index...
     */
    function build_search_index($mode, $sub)
    {
        global $db, $lang, $phpbb_root_path, $phpbb_dispatcher, $phpEx, $config, $auth, $user;
        // Obtain any submitted data
        $data = $this->get_submitted_data();
        $table_prefix = $data['table_prefix'];
        // If we get here and the extension isn't loaded it should be safe to just go ahead and load it
        $available_dbms = get_available_dbms($data['dbms']);
        if (!isset($available_dbms[$data['dbms']])) {
            // Someone's been silly and tried providing a non-existant dbms
            $this->p_master->redirect("index.{$phpEx}?mode=install");
        }
        $dbms = $available_dbms[$data['dbms']]['DRIVER'];
        // Instantiate the database
        $db = new $dbms();
        $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
        // NOTE: trigger_error does not work here.
        $db->sql_return_on_error(true);
        include_once $phpbb_root_path . 'includes/constants.' . $phpEx;
        include_once $phpbb_root_path . 'phpbb/search/fulltext_native.' . $phpEx;
        // We need to fill the config to let internal functions correctly work
        $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy(), CONFIG_TABLE);
        $error = false;
        $search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
        $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
			FROM ' . POSTS_TABLE;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
        }
        $db->sql_freeresult($result);
    }
开发者ID:hgchen,项目名称:phpbb,代码行数:35,代码来源:install_install.php

示例5: repair

    function repair()
    {
        include PHPBB_ROOT_PATH . 'includes/functions_install.' . PHP_EXT;
        $available_dbms = get_available_dbms();
        $error = array();
        $data = array('dbms' => isset($_POST['dbms']) ? $_POST['dbms'] : '', 'dbhost' => isset($_POST['dbhost']) ? $_POST['dbhost'] : '', 'dbport' => isset($_POST['dbport']) ? $_POST['dbport'] : '', 'dbname' => isset($_POST['dbname']) ? $_POST['dbname'] : '', 'dbuser' => isset($_POST['dbuser']) ? $_POST['dbuser'] : '', 'dbpasswd' => isset($_POST['dbpasswd']) ? $_POST['dbpasswd'] : '', 'table_prefix' => isset($_POST['table_prefix']) ? $_POST['table_prefix'] : 'phpbb_');
        if (isset($_POST['submit'])) {
            if (!isset($available_dbms[$data['dbms']])) {
                $error[] = 'Database Connection not available.';
            } else {
                $connect_test = $this->critical_connect_check_db(true, $error, $available_dbms[$data['dbms']], $data['table_prefix'], $data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport']);
                if (!$connect_test) {
                    $error[] = 'Database Connection failed.';
                }
            }
        }
        if (isset($_POST['submit']) && empty($error)) {
            // Time to convert the data provided into a config file
            $config_data = "<?php\n";
            $config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n";
            $config_data_array = array('dbms' => $available_dbms[$data['dbms']]['DRIVER'], 'dbhost' => $data['dbhost'], 'dbport' => $data['dbport'], 'dbname' => $data['dbname'], 'dbuser' => $data['dbuser'], 'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']), 'table_prefix' => $data['table_prefix'], 'acm_type' => 'file', 'load_extensions' => '');
            foreach ($config_data_array as $key => $value) {
                $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n";
            }
            unset($config_data_array);
            $config_data .= "\n@define('PHPBB_INSTALLED', true);\n";
            $config_data .= "// @define('DEBUG', true);\n";
            $config_data .= "// @define('DEBUG_EXTRA', true);\n";
            $config_data .= '?' . '>';
            // Done this to prevent highlighting editors getting confused!
            // Assume it will work ... if nothing goes wrong below
            $written = true;
            if (!($fp = @fopen(PHPBB_ROOT_PATH . 'config.' . PHP_EXT, 'w'))) {
                // Something went wrong ... so let's try another method
                $written = false;
            }
            if (!@fwrite($fp, $config_data)) {
                // Something went wrong ... so let's try another method
                $written = false;
            }
            @fclose($fp);
            if ($written) {
                // We may revert back to chmod() if we see problems with users not able to change their config.php file directly
                phpbb_chmod(PHPBB_ROOT_PATH . 'config.' . PHP_EXT, CHMOD_READ);
            } else {
                header('Content-type: text/html; charset=UTF-8');
                echo 'ERROR: Could not write config file.  Please copy the text below, put it in a file named config.php, and place it in the root directory of your forum.<br /><br />';
                echo nl2br(htmlspecialchars($config_data));
                exit;
            }
        } else {
            header('Content-type: text/html; charset=UTF-8');
            ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
		<head>
			<meta http-equiv="content-type" content="text/html; charset=utf-8" />
			<meta http-equiv="content-style-type" content="text/css" />
			<meta http-equiv="imagetoolbar" content="no" />
			<title>Config Repair - Support Toolkit</title>
			<link href="<?php 
            echo STK_ROOT_PATH;
            ?>
style/style.css" rel="stylesheet" type="text/css" media="screen" />
			<link href="<?php 
            echo STK_ROOT_PATH;
            ?>
style/erk_style.css" rel="stylesheet" type="text/css" media="screen" />
		</head>
		<body id="errorpage">
			<div id="wrap">
				<div id="page-header">

				</div>
				<div id="page-body">
					<div id="acp">
						<div class="panel">
							<span class="corners-top"><span></span></span>
								<div id="content">
									<h1>Config Repair</h1>
									<br />
									<p>
										Through this tool you can regenerate your configuration file.
									</p>
									<form id="stk" method="post" action="<?php 
            echo STK_ROOT_PATH . 'index.' . PHP_EXT;
            ?>
" name="support_tool_kit">
										<fieldset>
											<?php 
            if (!empty($error)) {
                ?>
												<div class="errorbox">
													<h3>Error</h3>
													<p><?php 
                echo implode('<br />', $error);
                ?>
</p>
												</div>
											<?php 
//.........这里部分代码省略.........
开发者ID:napus,项目名称:support-toolkit,代码行数:101,代码来源:config_repair.php

示例6: plugin_update

 /**
  * Update a plugin
  */
 public static function plugin_update($which)
 {
     global $auth, $auth_admin, $blog_plugins_path, $cache, $config, $db, $dbmd, $dbms, $db_tool, $phpbb_root_path, $phpEx, $table_prefix, $user;
     if (!array_key_exists($which, self::$plugins)) {
         trigger_error('PLUGIN_NOT_INSTALLED');
     }
     $newer_files = false;
     if (self::$available_plugins[$which]['plugin_version'] != self::$plugins[$which]['plugin_version']) {
         $version = array('files' => explode('.', self::$available_plugins[$which]['plugin_version']), 'db' => explode('.', self::$plugins[$which]['plugin_version']));
         $i = 0;
         foreach ($version['files'] as $v) {
             if ($v > $version['db'][$i]) {
                 $newer_files = true;
                 break;
             } else {
                 if ($v < $version['db'][$i]) {
                     break;
                 }
             }
             $i++;
         }
     }
     if ($newer_files) {
         include $phpbb_root_path . 'includes/functions_install.' . $phpEx;
         include $phpbb_root_path . 'includes/db/db_tools.' . $phpEx;
         include $phpbb_root_path . '/includes/acp/auth.' . $phpEx;
         $auth_admin = new auth_admin();
         $db_tool = new phpbb_db_tools($db);
         $dbmd = get_available_dbms($dbms);
         define('PLUGIN_UPDATE', true);
         $current_version = self::$plugins[$which]['plugin_version'];
         if (file_exists($blog_plugins_path . $which . '/update.' . $phpEx)) {
             include $blog_plugins_path . $which . '/update.' . $phpEx;
         }
         $sql = 'UPDATE ' . BLOGS_PLUGINS_TABLE . ' SET plugin_version = \'' . self::$available_plugins[$which]['plugin_version'] . '\' WHERE plugin_name = \'' . $db->sql_escape($which) . '\'';
         $db->sql_query($sql);
         self::$plugins[$which]['plugin_version'] = self::$available_plugins[$which]['plugin_version'];
         add_log('admin', 'LOG_BLOG_PLUGIN_UPDATED', $which);
         handle_blog_cache('plugins');
     }
 }
开发者ID:EXreaction,项目名称:User-Blog-Mod,代码行数:44,代码来源:plugins.php

示例7: build_search_index

	/**
	* Build the search index...
	*/
	function build_search_index($mode, $sub)
	{
		global $db, $lang, $phpbb_root_path, $phpEx, $config;

		// Obtain any submitted data
		$data = $this->get_submitted_data();
		$table_prefix = $data['table_prefix'];

		// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
		$available_dbms = get_available_dbms($data['dbms']);

		if (!isset($available_dbms[$data['dbms']]))
		{
			// Someone's been silly and tried providing a non-existant dbms
			$this->p_master->redirect("index.$phpEx?mode=install");
		}

		$dbms = $available_dbms[$data['dbms']]['DRIVER'];

		// Load the appropriate database class if not already loaded
		include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);

		// Instantiate the database
		$db = new $sql_db();
		$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);

		// NOTE: trigger_error does not work here.
		$db->sql_return_on_error(true);

		include_once($phpbb_root_path . 'includes/constants.' . $phpEx);
		include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx);

		// Fill the config array - it is needed by those functions we call
		$sql = 'SELECT *
			FROM ' . CONFIG_TABLE;
		$result = $db->sql_query($sql);

		$config = array();
		while ($row = $db->sql_fetchrow($result))
		{
			$config[$row['config_name']] = $row['config_value'];
		}
		$db->sql_freeresult($result);

		$error = false;
		$search = new fulltext_native($error);

		$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
			FROM ' . POSTS_TABLE;
		$result = $db->sql_query($sql);

		while ($row = $db->sql_fetchrow($result))
		{
			$search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
		}
		$db->sql_freeresult($result);
	}
开发者ID:steveh,项目名称:phpbb,代码行数:60,代码来源:install_install.php

示例8: generate_sql

}
$dbms = $db->sql_layer;
$table = '';
generate_sql($table, $dbms);
if (empty($table)) {
    // Should never happen.
    trigger_error('This error should not happen');
}
$config_items = array('as_interval' => 3600, 'as_prune' => 24 * 14, 'as_max_posts' => 0, 'as_flood_interval' => 15, 'as_version' => VERSION, 'as_ie_nr' => 5, 'as_non_ie_nr' => 20);
$config_items_dyn = array('last_as_run' => 0);
$permissions = array('global' => array('u_as_post', 'u_as_view', 'u_as_info', 'u_as_delete', 'u_as_edit', 'u_as_smilies', 'u_as_bbcode', 'u_as_mod_edit', 'u_as_ignore_flood', 'a_as_manage'));
if (!function_exists('get_available_dbms')) {
    global $phpbb_root_path, $phpEx;
    include $phpbb_root_path . 'includes/functions_install.' . $phpEx;
}
$available_dbms = get_available_dbms();
if ($dbms == 'mysql4' || $dbms == 'mysql') {
    if (version_compare($db->mysql_version, '4.1.3', '>=')) {
        $available_dbms['mysql']['SCHEMA'] .= '_41';
        $dbms = 'mysql';
    } else {
        $available_dbms[$dbms]['SCHEMA'] .= '_40';
    }
}
$remove_remarks = $available_dbms[$dbms]['COMMENTS'];
$delimiter = $available_dbms[$dbms]['DELIM'];
$sql_query = preg_replace('#phpbb_#i', $table_prefix, $table);
$remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql) {
    $db->sql_query($sql);
开发者ID:paul999,项目名称:ajax-shoutbox,代码行数:31,代码来源:index.php

示例9: run_tool

 /**
  * Run Tool
  *
  * Does the actual stuff we want the tool to do after submission
  */
 function run_tool(&$error)
 {
     global $cache, $db, $dbms, $table_prefix, $template;
     if (!check_form_key('sql_query')) {
         $error[] = 'FORM_INVALID';
         return;
     }
     $sql_query = utf8_normalize_nfc(request_var('sql_query', '', true));
     $sql_query = htmlspecialchars_decode($sql_query);
     // Need special chars like < and > see bug #59755
     // Replace phpbb_ with the correct table prefix.  Do the double replace otherwise you can have issues with prefixes like phpbb_3
     $sql_query = str_replace('phpbb_', $table_prefix, str_replace($table_prefix, 'phpbb_', $sql_query));
     if (!$sql_query) {
         $error[] = 'NO_SQL_QUERY';
         return;
     }
     if (!function_exists('remove_comments')) {
         include PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT;
     }
     if (!function_exists('split_sql_file')) {
         include PHPBB_ROOT_PATH . 'includes/functions_install.' . PHP_EXT;
     }
     $dbmd = get_available_dbms($dbms);
     $remove_remarks = $dbmd[$dbms]['COMMENTS'];
     $delimiter = $dbmd[$dbms]['DELIM'];
     $remove_remarks($sql_query);
     $sql_query = split_sql_file($sql_query, $delimiter);
     // Return on error
     $db->sql_return_on_error(true);
     foreach ($sql_query as $sql) {
         // Run the query and make sure that nothing went wrong
         $result = $db->sql_query($sql);
         if ($db->sql_error_triggered) {
             // Write the error result to the cache and return the user back
             // to the main page
             $error[] = $this->_format_sql_error($sql);
             continue;
         }
         if (isset($_POST['show_results'])) {
             // Display the query
             $template->assign_block_vars('queries', array('QUERY' => $sql));
             $cnt = 0;
             while ($row = $db->sql_fetchrow($result)) {
                 if ($cnt == 0) {
                     // Assign the return fields
                     foreach (array_keys($row) as $key) {
                         $template->assign_block_vars('queries.headings', array('FIELD_NAME' => $key));
                     }
                 }
                 // Set row class
                 $template->assign_block_vars('queries.resultdata', array('ROWSTYLE' => $cnt % 2 == 0 ? 1 : 2));
                 // Output resultset
                 foreach ($row as $value) {
                     $template->assign_block_vars('queries.resultdata.resultdatafields', array('VALUE' => $value));
                 }
                 $cnt++;
             }
         }
         $db->sql_freeresult($result);
     }
     // Purge the cache
     $cache->purge();
     if (empty($error)) {
         trigger_error('SQL_QUERY_SUCCESS');
     }
 }
开发者ID:napus,项目名称:support-toolkit,代码行数:71,代码来源:sql_query.php

示例10: dbms_select

/**
* Generate the drop down of available database options
*/
function dbms_select($default = '')
{
    global $lang;
    $available_dbms = get_available_dbms(false, false);
    $dbms_options = '';
    foreach ($available_dbms as $dbms_name => $details) {
        $selected = $dbms_name == $default ? ' selected="selected"' : '';
        $dbms_options .= '<option value="' . $dbms_name . '"' . $selected . '>' . $details['LABEL'] . '</option>';
    }
    return $dbms_options;
}
开发者ID:noikiy,项目名称:owaspbwa,代码行数:14,代码来源:installFunctions.php

示例11: trigger_error

if (USER_BLOG_MOD_VERSION == $config['user_blog_version']) {
    trigger_error(sprintf($user->lang['ALREADY_UPDATED'], '<a href="' . append_sid("{$phpbb_root_path}blog.{$phpEx}") . '">', '</a>'));
}
if (confirm_box(true)) {
    // This may help...
    @set_time_limit(120);
    $sql_array = array();
    include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
    // Needed for remove_comments function for some DB types
    include $phpbb_root_path . 'includes/functions_install.' . $phpEx;
    include $phpbb_root_path . 'includes/db/db_tools.' . $phpEx;
    include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
    include $phpbb_root_path . 'blog/includes/eami.' . $phpEx;
    $auth_admin = new auth_admin();
    $db_tool = new phpbb_db_tools($db);
    $dbmd = get_available_dbms($dbms);
    $eami = new eami();
    switch ($config['user_blog_version']) {
        case 'A6':
        case 'A7':
            $sql = 'ALTER TABLE ' . BLOGS_TABLE . ' ADD blog_real_reply_count MEDIUMINT( 8 ) NOT NULL DEFAULT \'0\'';
            $db->sql_query($sql);
        case 'A8':
            resync_blog('real_reply_count');
            resync_blog('reply_count');
            $sql_array[] = 'CREATE TABLE ' . BLOGS_SUBSCRIPTION_TABLE . ' (
				sub_user_id mediumint(8) UNSIGNED DEFAULT \'0\' NOT NULL,
				sub_type tinyint(1) UNSIGNED DEFAULT \'0\' NOT NULL,
				blog_id mediumint(8) UNSIGNED DEFAULT \'0\' NOT NULL,
				user_id mediumint(8) UNSIGNED DEFAULT \'0\' NOT NULL,
				PRIMARY KEY (sub_user_id)
开发者ID:EXreaction,项目名称:User-Blog-Mod,代码行数:31,代码来源:update.php

示例12: repair

    function repair()
    {
        global $critical_repair, $user;
        $critical_repair->user_setup($user);
        include PHPBB_ROOT_PATH . 'includes/functions_install.' . PHP_EXT;
        include STK_ROOT_PATH . 'includes/functions.' . PHP_EXT;
        $available_dbms = get_available_dbms();
        $error = array();
        $data = array('dbms' => isset($_POST['dbms']) ? $_POST['dbms'] : '', 'dbhost' => isset($_POST['dbhost']) ? $_POST['dbhost'] : '', 'dbport' => isset($_POST['dbport']) ? $_POST['dbport'] : '', 'dbname' => isset($_POST['dbname']) ? $_POST['dbname'] : '', 'dbuser' => isset($_POST['dbuser']) ? $_POST['dbuser'] : '', 'dbpasswd' => isset($_POST['dbpasswd']) ? $_POST['dbpasswd'] : '', 'table_prefix' => isset($_POST['table_prefix']) ? $_POST['table_prefix'] : 'phpbb_');
        if (isset($_POST['submit'])) {
            if (!isset($available_dbms[$data['dbms']])) {
                $error[] = $user->lang['CONFIG_REPAIR_NO_DBMS'];
            } else {
                $connect_test = $this->critical_connect_check_db($user, true, $error, $available_dbms[$data['dbms']], $data['table_prefix'], $data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport']);
                if (!$connect_test) {
                    $error[] = $user->lang['CONFIG_REPAIR_CONNECT_FAIL'];
                }
            }
        }
        if (isset($_POST['submit']) && empty($error)) {
            // Time to convert the data provided into a config file
            $config_data = "<?php\n";
            $config_data .= "// phpBB 3.1.x auto-generated configuration file\n// Do not change anything in this file!\n";
            $config_data_array = array('dbms' => $available_dbms[$data['dbms']]['DRIVER'], 'dbhost' => $data['dbhost'], 'dbport' => $data['dbport'], 'dbname' => $data['dbname'], 'dbuser' => $data['dbuser'], 'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']), 'table_prefix' => $data['table_prefix'], 'phpbb_adm_relative_path' => 'adm/', 'acm_type' => 'phpbb\\cache\\driver\\file');
            foreach ($config_data_array as $key => $value) {
                $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n";
            }
            unset($config_data_array);
            $config_data .= "\n@define('PHPBB_INSTALLED', true);\n";
            $config_data .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n";
            $config_data .= "// @define('DEBUG', true);\n";
            $config_data .= "// @define('DEBUG_CONTAINER', true);\n";
            $config_data .= '?' . '>';
            // Done this to prevent highlighting editors getting confused!
            // Assume it will work ... if nothing goes wrong below
            $written = true;
            if (!($fp = @fopen(PHPBB_ROOT_PATH . 'config.' . PHP_EXT, 'w'))) {
                // Something went wrong ... so let's try another method
                $written = false;
            }
            if (!@fwrite($fp, $config_data)) {
                // Something went wrong ... so let's try another method
                $written = false;
            }
            @fclose($fp);
            if ($written) {
                // We may revert back to chmod() if we see problems with users not able to change their config.php file directly
                if (!function_exists('phpbb_chmod')) {
                    include PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT;
                }
                phpbb_chmod(PHPBB_ROOT_PATH . 'config.' . PHP_EXT, CHMOD_READ);
            } else {
                header('Content-type: text/html; charset=UTF-8');
                echo $user->lang['CONFIG_REPAIR_WRITE_ERROR'];
                echo nl2br(htmlspecialchars($config_data));
                exit;
            }
        } else {
            header('Content-type: text/html; charset=UTF-8');
            ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
		<head>
			<meta http-equiv="content-type" content="text/html; charset=utf-8" />
			<meta http-equiv="content-style-type" content="text/css" />
			<meta http-equiv="imagetoolbar" content="no" />
			<title>Config Repair - Support Toolkit</title>
			<link href="<?php 
            echo STK_ROOT_PATH;
            ?>
style/style.css" rel="stylesheet" type="text/css" media="screen" />
			<link href="<?php 
            echo STK_ROOT_PATH;
            ?>
style/erk_style.css" rel="stylesheet" type="text/css" media="screen" />
		</head>
		<body id="errorpage">
			<div id="wrap">
				<div id="page-header">

				</div>
				<div id="page-body">
					<div id="acp">
						<div class="panel">
							<span class="corners-top"><span></span></span>
								<div id="content">
									<h1><?php 
            echo $user->lang['CONFIG_REPAIR'];
            ?>
</h1>
									<br />
									<p>
										<?php 
            echo $user->lang['CONFIG_REPAIR_EXPLAIN'];
            ?>
									</p>
									<form id="stk" method="post" action="<?php 
            echo STK_ROOT_PATH . 'erk.' . PHP_EXT;
            ?>
" name="support_tool_kit">
//.........这里部分代码省略.........
开发者ID:melvingb,项目名称:phpbb3.1-STK,代码行数:101,代码来源:config_repair.php

示例13: load_schema

 /**
  * Load the contents of the schema into the database and then alter it based on what has been input during the installation
  */
 function load_schema($mode, $sub)
 {
     global $db, $lang, $template, $phpbb_root_path, $phpEx, $dbms, $table_prefix;
     $this->page_title = $lang['STAGE_CREATE_TABLE'];
     $s_hidden_fields = '';
     // Obtain any submitted data
     $data = $this->get_submitted_data();
     //We will just setup $db here rather than try work it in earlier - might need to rethink this though for languages
     require $phpbb_root_path . 'includes/functions_convert.' . $phpEx;
     $available_dbms = get_available_dbms($dbms);
     // If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
     if ($dbms == 'mysql') {
         if (version_compare($db->mysql_version, '4.1.3', '>=')) {
             $available_dbms[$dbms]['SCHEMA'] .= '_41';
         } else {
             $available_dbms[$dbms]['SCHEMA'] .= '_40';
         }
     }
     // Ok we have the db info go ahead and read in the relevant schema
     // and work on building the table
     $create_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
     // How should we treat this schema?
     $remove_remarks = $available_dbms[$dbms]['COMMENTS'];
     $delimiter = $available_dbms[$dbms]['DELIM'];
     $create_query = file_get_contents($create_schema);
     $create_query = preg_replace('#phpbb_#i', $table_prefix, $create_query);
     $remove_remarks($create_query);
     $create_query = split_sql_file($create_query, $delimiter);
     foreach ($create_query as $sql) {
         //$sql = trim(str_replace('|', ';', $sql));
         if (!$db->sql_query($sql)) {
             $error = $db->sql_error();
             $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
         }
     }
     unset($create_query);
     // Ok tables have been built, let's fill in the basic information & prepare optional data too
     $sql_query = file_get_contents('schemas/schema_data.sql');
     $make_query = file_get_contents('schemas/schema_make_data.sql');
     $category_query = file_get_contents('schemas/schema_category_data.sql');
     // Deal with any special comments
     switch ($dbms) {
         case 'mssql':
         case 'mssql_odbc':
             $sql_query = preg_replace('#\\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \\##s', 'SET IDENTITY_INSERT \\1 \\2;', $sql_query);
             $make_query = preg_replace('#\\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \\##s', 'SET IDENTITY_INSERT \\1 \\2;', $make_query);
             $category_query = preg_replace('#\\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \\##s', 'SET IDENTITY_INSERT \\1 \\2;', $category_query);
             break;
         case 'postgres':
             $sql_query = preg_replace('#\\# POSTGRES (BEGIN|COMMIT) \\##s', '\\1; ', $sql_query);
             $make_query = preg_replace('#\\# POSTGRES (BEGIN|COMMIT) \\##s', '\\1; ', $make_query);
             $category_query = preg_replace('#\\# POSTGRES (BEGIN|COMMIT) \\##s', '\\1; ', $category_query);
             break;
     }
     // Change prefix
     $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
     $make_query = preg_replace('#phpbb_#i', $table_prefix, $make_query);
     $category_query = preg_replace('#phpbb_#i', $table_prefix, $category_query);
     // Since we know the comment style and are able to remove it directly with remove_remarks
     remove_remarks($sql_query);
     remove_remarks($make_query);
     remove_remarks($category_query);
     $sql_query = split_sql_file($sql_query, ';');
     $make_query = split_sql_file($make_query, ';');
     $category_query = split_sql_file($category_query, ';');
     foreach ($sql_query as $sql) {
         if (!$db->sql_query($sql)) {
             $error = $db->sql_error();
             $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
         }
     }
     unset($sql_query);
     // Does the user want default makes
     if ($data['insert_makes']) {
         foreach ($make_query as $sql) {
             //$sql = trim(str_replace('|', ';', $sql));
             if (!$db->sql_query($sql)) {
                 $error = $db->sql_error();
                 $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
             }
         }
         unset($make_query);
     }
     // Does the user want default categories
     if ($data['insert_categories']) {
         foreach ($category_query as $sql) {
             //$sql = trim(str_replace('|', ';', $sql));
             if (!$db->sql_query($sql)) {
                 $error = $db->sql_error();
                 $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
             }
         }
         unset($category_query);
     }
     $schema_changes = array('add_columns' => array(USERS_TABLE => array('user_garage_index_columns' => array('BOOL', 2), 'user_garage_guestbook_email_notify' => array('BOOL', 1), 'user_garage_guestbook_pm_notify' => array('BOOL', 1), 'user_garage_mod_email_optout' => array('BOOL', 0), 'user_garage_mod_pm_optout' => array('BOOL', 0))));
     require $phpbb_root_path . 'includes/db/db_tools.' . $phpEx;
     $mod_db = new phpbb_db_tools($db);
//.........这里部分代码省略.........
开发者ID:poyntesm,项目名称:phpbbgarage,代码行数:101,代码来源:install_install.php

示例14: load_schema

	/**
	* Load the contents of the schema into the database and then alter it based on what has been input during the installation
	*/
	function load_schema($mode, $sub)
	{
		global $dbms, $db, $user, $template, $table_prefix, $config, $auth, $cache;

		$this->page_title = $user->lang['INSTALL_KARMA_STAGE_CREATE_TABLE'];
		$s_hidden_fields = '';

		// Obtain any submitted data
		foreach ($this->request_vars as $var)
		{
			$$var = request_var($var, '');
		}

		if (!$karma_time)
		{
			$karma_time = $this->admin_config_options['karma_time']['value'];
		}

		if (!$karma_posts)
		{
			$karma_posts = $this->admin_config_options['karma_posts']['value'];
		}

		// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
		$available_dbms = get_available_dbms($dbms);

		// If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
		if ($dbms == 'mysql')
		{
			if (version_compare($db->sql_server_version, '4.1.3', '>='))
			{
				$available_dbms[$dbms]['SCHEMA'] .= '_41';
			}
			else
			{
				$available_dbms[$dbms]['SCHEMA'] .= '_40';
			}
		}

		// Ok we have the db info go ahead and read in the relevant schema
		// and work on building the table
		$dbms_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';

		// How should we treat this schema?
		$remove_remarks = $available_dbms[$dbms]['COMMENTS'];
		$delimiter = $available_dbms[$dbms]['DELIM'];

		$sql_query = @file_get_contents($dbms_schema);

		$sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);

		$remove_remarks($sql_query);

		$sql_query = split_sql_file($sql_query, $delimiter);

		foreach ($sql_query as $sql)
		{
			//$sql = trim(str_replace('|', ';', $sql));
			if (!$db->sql_query($sql))
			{
				$error = $db->sql_error();
				$this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
			}
		}
		unset($sql_query);

		// Ok tables have been built, let's fill in the basic information
		$sql_query = file_get_contents('schemas/schema_data.sql');

		// Deal with any special comments
		switch ($dbms)
		{
			case 'mssql':
			case 'mssql_odbc':
				$sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
			break;

			case 'postgres':
				$sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
			break;
		}

		// Change prefix
		$sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);

		// Change language strings...
		$sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);

		// Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks
		remove_remarks($sql_query);
		$sql_query = split_sql_file($sql_query, ';');

		foreach ($sql_query as $sql)
		{
			//$sql = trim(str_replace('|', ';', $sql));
			if (!$db->sql_query($sql))
			{
//.........这里部分代码省略.........
开发者ID:esacinc,项目名称:forum-sitplatform-org-website,代码行数:101,代码来源:install_install.php

示例15: get_convert_settings

	/**
	*/
	function get_convert_settings($sub)
	{
		global $lang, $language, $template, $db, $phpbb_root_path, $phpEx, $config, $cache;

		require($phpbb_root_path . 'config.' . $phpEx);
		require($phpbb_root_path . 'includes/constants.' . $phpEx);
		require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
		require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);

		$db = new $sql_db();
		$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
		unset($dbpasswd);

		$this->page_title = $lang['STAGE_SETTINGS'];

		// We need to fill the config to let internal functions correctly work
		$sql = 'SELECT *
			FROM ' . CONFIG_TABLE;
		$result = $db->sql_query($sql);

		$config = array();
		while ($row = $db->sql_fetchrow($result))
		{
			$config[$row['config_name']] = $row['config_value'];
		}
		$db->sql_freeresult($result);

		$convertor_tag = request_var('tag', '');

		if (empty($convertor_tag))
		{
			$this->p_master->error($lang['NO_CONVERT_SPECIFIED'], __LINE__, __FILE__);
		}
		$get_info = true;

		// check security implications of direct inclusion
		$convertor_tag = basename($convertor_tag);
		if (!file_exists('./convertors/convert_' . $convertor_tag . '.' . $phpEx))
		{
			$this->p_master->error($lang['CONVERT_NOT_EXIST'], __LINE__, __FILE__);
		}

		include('./convertors/convert_' . $convertor_tag . '.' . $phpEx);

		// The test_file is a file that should be present in the location of the old board.
		if (!isset($test_file))
		{
			$this->p_master->error($lang['DEV_NO_TEST_FILE'], __LINE__, __FILE__);
		}

		$submit = (isset($_POST['submit'])) ? true : false;

		$src_dbms			= request_var('src_dbms', $convertor_data['dbms']);
		$src_dbhost			= request_var('src_dbhost', $convertor_data['dbhost']);
		$src_dbport			= request_var('src_dbport', $convertor_data['dbport']);
		$src_dbuser			= request_var('src_dbuser', $convertor_data['dbuser']);
		$src_dbpasswd		= request_var('src_dbpasswd', $convertor_data['dbpasswd']);
		$src_dbname			= request_var('src_dbname', $convertor_data['dbname']);
		$src_table_prefix	= request_var('src_table_prefix', $convertor_data['table_prefix']);
		$forum_path			= request_var('forum_path', $convertor_data['forum_path']);
		$refresh			= request_var('refresh', 1);

		// Default URL of the old board
		// @todo Are we going to use this for attempting to convert URL references in posts, or should we remove it?
		//		-> We should convert old urls to the new relative urls format
		// $src_url = request_var('src_url', 'Not in use at the moment');

		// strip trailing slash from old forum path
		$forum_path = (strlen($forum_path) && $forum_path[strlen($forum_path) - 1] == '/') ? substr($forum_path, 0, -1) : $forum_path;

		$error = array();
		if ($submit)
		{
			if (!@file_exists('./../' . $forum_path . '/' . $test_file))
			{
				$error[] = sprintf($lang['COULD_NOT_FIND_PATH'], $forum_path);
			}

			$connect_test = false;
			$available_dbms = get_available_dbms(false, true, true);

			if (!isset($available_dbms[$src_dbms]) || !$available_dbms[$src_dbms]['AVAILABLE'])
			{
				$error['db'][] = $lang['INST_ERR_NO_DB'];
				$connect_test = false;
			}
			else
			{
				$connect_test = connect_check_db(true, $error, $available_dbms[$src_dbms], $src_table_prefix, $src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd), $src_dbname, $src_dbport, true, ($src_dbms == $dbms) ? false : true, false);
			}

			// The forum prefix of the old and the new forum can only be the same if two different databases are used.
			if ($src_table_prefix == $table_prefix && $src_dbms == $dbms && $src_dbhost == $dbhost && $src_dbport == $dbport && $src_dbname == $dbname)
			{
				$error[] = sprintf($lang['TABLE_PREFIX_SAME'], $src_table_prefix);
			}

			// Check table prefix
//.........这里部分代码省略.........
开发者ID:steveh,项目名称:phpbb,代码行数:101,代码来源:install_convert.php


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