[go: up one dir, main page]

Menu

[r99]: / tags / 1.3 / checks.php  Maximize  Restore  History

Download this file

159 lines (139 with data), 4.9 kB

  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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
# $Id: checks.php 86 2010-10-05 12:19:27Z rediculum $
#
# Includes
####################################################################
include "includes/session.inc.php";
include "includes/layout.inc.php";
include "includes/functions.inc.php";
include "includes/db.inc.php";
include "includes/variables.inc.php";
$status = "OK";
function statusOK($status)
{
require("includes/layout.inc.php");
if ($status == "OK")
{
echo "<tr><td><img src=\"images/ok.gif\"> All OK</td></tr>";
}
}
# Main
#####################################################################?>
<html>
<head>
<?php echo "$headtitle $head";?>
</head>
<body>
<div id=menu>
<?php include("includes/menu.inc.php");?>
</div>
<div id=mainframe>
<b> Content checks of entries in DB:</b><br>
<table border=1 cellpadding=4 cellspacing=0>
<tr><td>
<table bgcolor=#EEEEEE>
<tr><td> <u>Unknown maincategories in entries:</u></td></tr>
<?
$kats = mysql_query("SELECT DISTINCT hk_id,id FROM verbuchungen ORDER BY hk_id ASC");
while ($kat = mysql_fetch_array($kats))
{
$kat_verify = mysql_fetch_row(mysql_query("SELECT hk_id,hk_name FROM hauptkategorien WHERE hk_id='$kat[0]'"));
if ($kat_verify == "")
{
echo "<tr><td><img src=\"images/nok.gif\"> Entryno. <i>$kat[1]</i>: hk_id $kat[0] not known in database </td></tr>";
$status = "NOK";
}
}
statusOK($status);
$status = "OK";?>
</table><p>
<hr>
<table bgcolor=#EEEEEE>
<tr><td> <u>Unknown subcategories in entries:</u></td></tr>
<?php $kats = mysql_query("SELECT DISTINCT sk_id,id FROM verbuchungen ORDER BY sk_id ASC");
while ($kat = mysql_fetch_array($kats))
{
$kat_verify = mysql_fetch_row(mysql_query("SELECT sk_id,sk_name FROM subkategorien WHERE sk_id='$kat[0]'"));
if ($kat_verify == "")
{
echo "<tr><td><img src=\"images/nok.gif\"> Entryno. <i>$kat[1]</i>: sk_id $kat[0] not known in database </td></tr>";
$status = "NOK";
}
}
statusOK($status);
$status = "OK";?>
</table><p>
<hr>
<table bgcolor=#EEEEEE>
<tr><td> <u>Referential integrity from subcategory to maincategory in entries:</u></td></tr>
<?php $entries = mysql_query("SELECT id,hk_id,sk_id FROM verbuchungen ORDER BY id ASC");
while ($entry = mysql_fetch_array($entries))
{
$hk_f = mysql_fetch_row(mysql_query("SELECT hk_id,hk_name FROM hauptkategorien WHERE hk_id='$entry[1]'"));
$kat = mysql_fetch_row(mysql_query("SELECT sk_name,hk_id,sk_id FROM subkategorien WHERE sk_id='$entry[2]'"));
$hk_r= mysql_fetch_row(mysql_query("SELECT hk_id,hk_name FROM hauptkategorien WHERE hk_id='$kat[1]'"));
if ($entry[1] != $kat[1])
{
echo "<tr><td><img src=\"images/nok.gif\"> Entryno. <i>$entry[0]</i>: \"$hk_f[1]($hk_f[0])_$kat[0]\" is wrong. Correct: \"$hk_r[1]($hk_r[0])_$kat[0]\"</td></tr>";
$status = "NOK";
}
}
statusOK($status);
$status = "OK";?>
</table><p>
<hr>
<table bgcolor=#EEEEEE>
<tr><td> <u>Wrong date in entries:</u></td></tr>
<?php $entries = mysql_query("SELECT id FROM verbuchungen WHERE tag >'31'");
while ($entry = mysql_fetch_array($entries))
{
echo "<tr><td><img src=\"images/nok.gif\"> Entryno. <i>$entry[0]</i>: day over 31</td></tr>";
$status = "NOK";
}
$entries = mysql_query("SELECT id FROM verbuchungen WHERE monat >'12'");
while ($entry = mysql_fetch_array($entries))
{
echo "<tr><td><img src=\"images/nok.gif\"> Entryno. <i>$entry[0]</i>: month over 12</td></tr>";
$status = "NOK";
}
statusOK($status);
$status = "OK";?>
</table>
</td></tr>
</table>
<p>
<b> Content checks of categories in DB:</b><br>
<table border=1 cellpadding=4 cellspacing=0>
<tr><td>
<table bgcolor=#EEEEEE>
<tr><td> <u>Referential integrity from subcategory to maincategory in DB:</u></td></tr>
<?php $entries = mysql_query("SELECT sk_name,sk_id,hk_id FROM subkategorien ORDER BY sk_id ASC");
while ($entry = mysql_fetch_array($entries))
{
$hk_f = mysql_fetch_row(mysql_query("SELECT hk_name,hk_id FROM hauptkategorien WHERE hk_id='$entry[2]'"));
if ($hk_f[0] == NULL)
{
echo "<tr><td><img src=\"images/nok.gif\"> Category <i>$entry[0]</i> has an unknown reference </td></tr>";
$status = "NOK";
}
}
statusOK($status);
$status = "OK";
?>
</td></tr>
</table>
</td></tr>
</table>
<p>
Version: <?php echo $version;?>
<p>
<?php echo mysql_result(mysql_query("SELECT COUNT(*) FROM hauptkategorien"),0) ." Maincategories";?><br>
<?php echo mysql_result(mysql_query("SELECT COUNT(*) FROM subkategorien"),0) ." Subcategories";?><br>
<?php echo mysql_result(mysql_query("SELECT COUNT(*) FROM verbuchungen"),0) . " Entries";?>
<p>
<?php echo "Database Version: MySQL " . mysql_result(mysql_query("SELECT VERSION()"),0) ?>
<br>
<?php echo "Webserver Version: " . $_SERVER['SERVER_SOFTWARE'] ?>
</div>
</body>
</html>