Beispiel #1
0
<?php

if (!defined('SMF'))
{
	require_once(dirname(dirname(__FILE__)) . '/SSI.php');
	require_once(dirname(__FILE__) . '/Database.php');
	require_once(dirname(__FILE__) . '/Subs-Install.php');
}

global $txt, $smcFunc, $db_prefix, $modSettings;
global $addSettings, $permissions, $tables, $sourcedir;

// Step 1: Do tables
doTables($tables);

// Step 2: Do Settings
doSettings($addSettings);

// Step 3: Update admin features
updateAdminFeatures('posthistory', !empty($modSettings['posthistoryEnabled']));

//
add_integration_function('integrate_pre_include', '$sourcedir/PostHistory.php');
add_integration_function('integrate_actions', 'PH_actions');
add_integration_function('integrate_core_features', 'PH_core_features');
add_integration_function('integrate_load_permissions', 'PH_load_permissions');

?>
	ATTENTION: If you are trying to INSTALL this package, please access
	it directly, with a URL like the following:
		http://www.yourdomain.tld/forum/related_topics.php (or similar.)

*******************************************************************************/
global $db_prefix, $db_type;
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) {
    require_once dirname(__FILE__) . '/SSI.php';
} elseif (!defined('SMF')) {
    die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
}
$index_type = $db_type == 'mysql' ? 'fulltext' : '';
$relatedSettings = array('relatedTopicsEnabled' => array(0, false), 'relatedTopicsCount' => array(5, false), 'relatedIndex' => array($index_type, false), 'relatedIgnoredboards' => array('', false));
$tables = array('related_topics' => array('name' => 'related_topics', 'columns' => array(array('name' => 'id_topic_first', 'type' => 'int', 'null' => false, 'unsigned' => true), array('name' => 'id_topic_second', 'type' => 'int', 'null' => false, 'unsigned' => true), array('name' => 'score', 'type' => 'float', 'null' => false, 'unsigned' => true)), 'indexes' => array(array('type' => 'primary', 'columns' => array('id_topic_first', 'id_topic_second')))));
doSettings($relatedSettings);
doTables($tables);
// Functions
function doTables($tables, $columnRename = array())
{
    global $smcFunc, $db_prefix, $db_type, $db_show_debug;
    $log = array();
    $existingTables = $smcFunc['db_list_tables']();
    foreach ($tables as $table) {
        $table_name = $table['name'];
        $tableExists = in_array($db_prefix . $table_name, $existingTables);
        // Create table
        if (!$tableExists && empty($table['smf'])) {
            $smcFunc['db_create_table']('{db_prefix}' . $table_name, $table['columns'], $table['indexes']);
        } else {
            $currentTable = $smcFunc['db_table_structure']('{db_prefix}' . $table_name);