forked from geokrety/geokrety-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defektoskop.php
135 lines (120 loc) · 4.33 KB
/
defektoskop.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// defektoskop - wypisuje bledy z tablicy
function defektoskop($tablica, $logerrors = true, $error_msg = '', $severity = '3', $code = '')
{
$return .= "<div style='
border:solid 2px #BC1301;
width:75%;
margin-left: auto;
margin-right: auto;
background:white;
padding:10px;
margin-top:40px;
'><img src='".CONFIG_CDN_ICONS."/warning.png' style='display: block; margin-left: auto; margin-right: auto; padding-bottom:10px;'>";
if (is_array($tablica)) {
$return .= '<ul>';
foreach ($tablica as $linia) {
$return .= "<li style='padding:0;margin-bottom:10px;'>$linia</li>";
$wszystkie_linie = "$wszystkie_linie<br />*$linia";
}
$return .= '</ul>';
} else {
$return .= "<div style='text-align:center;margin-bottom:10px;'>$tablica</div>";
$wszystkie_linie = $tablica;
}
if ($logerrors) {
if ($error_msg != '') {
$error_msg = $error_msg.'<br/>';
}
errory_add("<b>$error_msg</b><u>Defektoskop</u>: $wszystkie_linie", $severity, $code);
}
$return .= '</div>';
return $return;
}
function success($tablica, $logerrors = true, $error_msg = '', $severity = '1', $code = '')
{
$return .= "<div style='
border:solid 2px #80D07C;
width:75%;
margin-left: auto;
margin-right: auto;
background:white;
padding:10px;
margin-top:40px;
'><img src='".CONFIG_CDN_IMAGES."/success.png' style='display: block; margin-left: auto; margin-right: auto; padding-bottom:10px;'>";
if (is_array($tablica)) {
$return .= '<ul>';
foreach ($tablica as $linia) {
$return .= "<li style='padding:0;margin-bottom:10px;'>$linia</li>";
$wszystkie_linie = "$wszystkie_linie<br />*$linia";
}
$return .= '</ul>';
} else {
$return .= "<div style='text-align:center;margin-bottom:10px;'>$tablica</div>";
$wszystkie_linie = $tablica;
}
if ($logerrors) {
if ($error_msg != '') {
$error_msg = $error_msg.'<br/>';
}
errory_add("<b>$error_msg</b><u>Success</u>: $wszystkie_linie", $severity, $code);
}
$return .= '</div>';
return $return;
}
function table_exists($table)
{
$result = mysqli_query($link, "show tables like '$table'") or die('error reading database');
if (mysqli_num_rows($result) > 0) {
return true;
} else {
return false;
}
}
// error_add dopisuje rekord do tabeli gk-errory ktora zawiera rozne dziwne zdarzenia na serwerze - np takie ktore nie powinno miec miejsca.
function errory_add($details, $severity = 0, $error_uid = '')
{
include 'templates/konfig.php'; // config
$link = DBConnect();
include_once 'longin_chceck.php';
$longin_status = longin_chceck();
$userid = $longin_status['userid'];
// $file = $_SERVER["SCRIPT_NAME"];
// $break = Explode('/', $file);
// $pfile = $break[count($break) - 1];
$pfile = $_SERVER['REQUEST_URI'];
if ($_POST['formname'] == '-') {
return;
}//niepotrzebne - wychodzimy
$posty = '';
foreach ($_GET as $var => $value) {
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
if ($var == 'gk_id' && ctype_digit($value)) {
$posty .= "G|$var| = |<a href='konkret.php?id=$value'>$value</a>|<br/>";
} else {
$posty .= "G|$var| = |$value|<br/>";
}
}
foreach ($_POST as $var => $value) {
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
if ($var == 'gk_id' && ctype_digit($value)) {
$posty .= "P|$var| = |<a href='konkret.php?id=$value'>$value</a>|<br/>";
} elseif (($var != 'haslo1') && ($var != 'haslo2')) {
$posty .= "P|$var| = |$value|<br/>";
}
}
if ($details != '') {
$details = mysqli_real_escape_string($link, $details);
}
if ($posty != '') {
$posty = mysqli_real_escape_string($link, "<hr>$posty");
}
if (!empty($_SERVER['HTTP_REFERER'])) {
$referer = '<br/>REF:'.$_SERVER['HTTP_REFERER'];
} else {
$referer = '<br/>REF: --MISSING--';
}
$sql = "INSERT INTO `gk-errory` (`uid`, `userid`, `ip` ,`date`, `file` ,`details` ,`severity`)
VALUES ('$error_uid', '$userid', '".$_SERVER['REMOTE_ADDR']."', '".date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])."', '$pfile$referer', '$details$posty', '$severity')";
$result = mysqli_query($link, $sql);
}