-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdatabase.php
62 lines (56 loc) · 1.5 KB
/
database.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
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 that you put this file in the same place as SMF\'s index.php and SSI.php files.');
if ((SMF == 'SSI') && !$user_info['is_admin'])
die('Admin privileges required.');
$tables[] = array(
'name' => 'topic_ratings',
'columns' => array(
array(
'name' => 'id',
'type' => 'mediumint',
'size' => 8,
'unsigned' => true,
'null' => false
),
array(
'name' => 'total_votes',
'type' => 'mediumint',
'size' => 8,
'null' => false,
'default' => 0
),
array(
'name' => 'total_value',
'type' => 'mediumint',
'size' => 8,
'null' => false,
'default' => 0
),
array(
'name' => 'user_ids',
'type' => 'longtext',
'null' => false
)
),
'indexes' => array(
array(
'type' => 'unique',
'columns' => array('id')
),
array(
'type' => 'index',
'columns' => array('total_votes', 'total_value')
)
)
);
db_extend('packages');
foreach($tables as $table) {
$smcFunc['db_create_table']('{db_prefix}' . $table['name'], $table['columns'], $table['indexes'], array(), 'update');
if (isset($table['default']))
$smcFunc['db_insert']('ignore', '{db_prefix}' . $table['name'], $table['default']['columns'], $table['default']['values'], $table['default']['keys']);
}
if (SMF == 'SSI')
echo 'Database changes are complete! Please wait...';