-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathinit.php
74 lines (60 loc) · 2.93 KB
/
init.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
63
64
65
66
67
68
69
70
71
72
73
74
<?php
// No html errors. They break ajax
ini_set('html_errors', 0);
// Set default settings here. Can be overridden in config.php.
$settings = array();
$settings['sqlColor'] = true;
$settings['title'] = null;
$settings['oldSlowQueryFormat'] = false;
$settings['defaultColumnVis'] = array();
$settings['defaultColumnVis']['Checksum'] = true;
$settings['defaultColumnVis']['Count'] = true;
$settings['defaultColumnVis']['TotalMS'] = true;
$settings['defaultColumnVis']['AvgMS'] = true;
$settings['defaultColumnVis']['tmpDisk'] = false;
$settings['defaultColumnVis']['tmpTbl'] = false;
$settings['defaultColumnVis']['FirstSeen'] = true;
$settings['defaultColumnVis']['LastSeen'] = true;
$settings['defaultColumnVis']['Fingerprint'] = true;
$settings['defaultColumnVis']['ReviewedOn'] = true;
$settings['defaultColumnVis']['ReviewedBy'] = true;
$settings['defaultColumnVis']['Comments'] = true;
require_once('config.php');
if (!isset($reviewhost['history_table_primary']))
$reviewhost['history_table_primary'] = array();
// If the history_table is blank, hide a few extra columns
if (!strlen($reviewhost['history_table'])) {
$settings['defaultColumnVis']['Count'] = false;
$settings['defaultColumnVis']['TotalMS'] = false;
$settings['defaultColumnVis']['AvgMS'] = false;
}
if ($settings['oldSlowQueryFormat']) {
define('Tmp_table_on_disk_cnt', 'Disk_tmp_table_cnt');
define('Tmp_table_on_disk_sum', 'Disk_tmp_table_sum');
define('Filesort_on_disk_cnt', 'Disk_filesort_cnt');
define('Filesort_on_disk_sum', 'Disk_filesort_sum');
}
else {
define('Tmp_table_on_disk_cnt', 'Tmp_table_on_disk_cnt');
define('Tmp_table_on_disk_sum', 'Tmp_table_on_disk_sum');
define('Filesort_on_disk_cnt', 'Filesort_on_disk_cnt');
define('Filesort_on_disk_sum', 'Filesort_on_disk_sum');
}
require_once('util.php');
require_once('libs/Database/Database.php');
$options = array('dsn' => $reviewhost['dsn'],
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
);
Database::connect(null, $reviewhost['user'], $reviewhost['password'], null, null, 'pdo', $options, 'review');
// Needed for SqlParser
$dbh = new PDO($reviewhost['dsn'], $reviewhost['user'], $reviewhost['password'], $options);
require_once('libs/sqlquery/SqlParser.php');
require_once('classes/QueryRewrite.php');
// Figure out the PRIMARY key for the history table
if (strlen($reviewhost['history_table']) && count($reviewhost['history_table_primary']) == 0) {
$res = Database::find('review')->query('SHOW INDEXES FROM '.Database::escapeField($reviewhost['history_table']).'
WHERE key_name = "PRIMARY"');
while ($row = $res->fetch_assoc()) {
$reviewhost['history_table_primary'][] = $row['Column_name'];
}
}