-
Notifications
You must be signed in to change notification settings - Fork 0
/
reorg.php
74 lines (66 loc) · 1.99 KB
/
reorg.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
/*
* Copyright 2018 JP P
* This program is free software; Distributed under the terms of the GNU GPL v3.
* Added to replace "optimise" in Database cleanup every time
* you run it.
*/
include './amilogged.php';
include './header_management.php';
include './run_his.php';
if ( ! $ISADMIN )
{ print("<html><body><br><br><br><h3>You are not admin</h3></br></br></br></body></html>");
exit("fatal");
}
?>
<link href="./css/style.css" rel="stylesheet" type="text/css"/>
<link href="./css/sticky-footer.css" rel="stylesheet">
<script src="./js/amcharts.js" type="text/javascript"></script>
<script src="./js/serial.js" type="text/javascript"></script>
<script src="./js/themes/light.js" type="text/javascript"></script>
<div class="contents" >
<br>
Reorganisation de la base de données
</div>
<br>
<div text-align: center;>
<H2>Reorganizing database, this could take time</H2>
</div>
<?php
require_once './db_OpenArmor.php';
require './config.php';
ini_set('display_errors',1);
error_reporting(E_ALL);
$ret = ReorgTable('alert');
if ( DB_TYPE_O == 'history' )
{ print '<H2> "History" database, "alert" is the only relevant table</H2>';
} else
{ $ret = ReorgTable('agent');
$ret = ReorgTable('category');
$ret = ReorgTable('location');
$ret = ReorgTable('server');
$ret = ReorgTable('signature');
$ret = ReorgTable('signature_category_mapping');
}
function ReorgTable($table)
{
$result = '';
$query = "OPTIMIZE TABLE ".$table.";";
$pdo = new PDO('mysql:host=' . DB_HOST_O . ';dbname=' . DB_NAME_O . ';charset=utf8', DB_USER_O, DB_PASSWORD_O);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare($query);
$zex = $stmt->execute();
$result = $stmt->fetch();
$affiche = $result[3];
$stmt->closeCursor();
$res = strtoupper($result[2]);
# print "--------".$res."--------";
if ( $res == 'ERROR' )
{ print "<H2>Erreur ".$result[3]." </H2>";
return 1;
}
print "<H3> Table ".$table." : reorganized <br>Note: ".$affiche." </H3>";
return 0;
}
include './footer.php';
?>