20 <LINK REL=
"stylesheet" type=
"text/css" HREF=
"Layout/wg.css" >
23 border:solid 1px black;
29 -moz-border-radius:0px 10px 0px 0px;
32 background-color:yellow;
35 <title>Check
List</title>
39 define(
"OK",
"green");
41 define(
"BOF",
"orange");
43 include (
"../WHAT/Lib.Common.php");
47 $result = pg_query(
$conn,
"SELECT * FROM paramv where type='G'");
51 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
52 $pout[$row[
"name"]] = $row[
"val"];
60 print
"<H1>Check List : <i>$wcontext</i> </H1>";
64 while (
false !== (
$file = readdir($handle))) {
65 if (
$file[0] !=
".") {
76 foreach ($contexts as $k => $v) {
77 if ($v ==
$wcontext) $sty =
'style="background-color:lightblue";';
79 print
"<a href=\"?context=$v\" $sty class=\"context\">$v</a>";
81 print
"<hr style=\"clear:both\">";
83 $r = @pg_connect(
"service='$pgservice_core'");
87 $tout[
"main connection db"] = array(
96 $appNameList = array();
97 $result = pg_query(
$r,
"SELECT name FROM application;");
98 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
99 $appNameList[] = $row[
'name'];
102 $result = pg_query(
$r,
"SELECT * from groups where iduser not in (select id from users);");
104 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
105 $pout[$row[
"iduser"]][] = $row[
"idgroup"];
107 if (count($pout) > 0) $msg = sprintf(
"%d unreference users<pre>%s</pre>", count($pout) , print_r($pout,
true));
109 $tout[
"unreference user in group"] = array(
110 "status" => (count($pout) == 0) ?
OK :
BOF,
114 $result = pg_query(
$r,
"SELECT distinct(idgroup) from groups where idgroup not in (select id from users where isgroup='Y');");
116 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
117 $pout[] = $row[
"idgroup"];
119 if (count($pout) > 0) $msg = sprintf(
"%d users detected as group<br><kbd>%s</kbd>", count($pout) , implode(
", ", $pout));
121 $tout[
"user as group"] = array(
122 "status" => (count($pout) == 0) ?
OK :
KO,
126 $result = pg_query(
$r,
"SELECT * from action where id_application not in (select id from application);");
128 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
129 $pout[] = $row[
"name"];
131 if (count($pout) > 0) $msg = sprintf(
"%d unreference actions<br><kbd>%s</kbd>", count($pout) , implode(
", ", $pout));
133 $tout[
"unreference actions"] = array(
134 "status" => (count($pout) == 0) ?
OK :
BOF,
138 $result = pg_query(
$r,
"SELECT * from paramdef where appid not in (select id from application);");
140 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
141 $pout[] = $row[
"name"];
143 $result = pg_query(
$r,
"SELECT * from paramv where appid not in (select id from application);");
144 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
145 $pout[] = $row[
"name"];
147 if (count($pout) > 0) $msg = sprintf(
"%d unreference parameters<br><kbd>%s</kbd>", count($pout) , implode(
", ", $pout));
149 $tout[
"unreference parameters"] = array(
150 "status" => (count($pout) == 0) ?
OK :
BOF,
154 $result = pg_query(
$r,
"SELECT * from acl where id_application not in (select id from application);");
156 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
157 $pout[] = $row[
"name"];
159 if (count($pout) > 0) $msg = sprintf(
"%d unreference acl<br><kbd>%s</kbd>", count($pout) , implode(
", ", $pout));
161 $tout[
"unreference acl"] = array(
162 "status" => (count($pout) == 0) ?
OK :
BOF,
166 $result = pg_query(
$r,
"SELECT * from permission where id_acl not in (select id from acl);");
167 $nb = pg_num_rows($result);
168 $result = pg_query(
$r,
"SELECT * from permission where id_user not in (select id from users);");
169 $nb+= pg_num_rows($result);
170 $result = pg_query(
$r,
"SELECT * from permission where id_application not in (select id from application);");
171 $nb+= pg_num_rows($result);
173 if ($nb > 0) $msg = sprintf(
"%d unreference permission", ($nb));
174 $tout[
"unreference permission"] = array(
175 "status" => ($nb == 0) ?
OK :
BOF,
179 $fdb = $GP[
"FREEDOM_DB"];
180 $dbr_freedom =
false;
182 $rf = @pg_connect($fdb);
183 if (
$rf) $dbr_freedom =
true;
186 $tout[
"connection db dynacase"] = array(
187 "status" => $dbr_freedom ?
OK :
KO,
193 $result = pg_query(
$rf,
"SELECT * from (SELECT id, count(id) as c from doc group by id) as Z where Z.c > 1;");
195 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
196 $pout[$row[
"id"]] = $row[
"c"];
198 if (count($pout) > 0) $msg = sprintf(
"%d double id detected<pre>%s</pre>", count($pout) , print_r($pout,
true));
200 $tout[
"double doc id"] = array(
201 "status" => (count($pout) == 0) ?
OK :
KO,
205 $result = pg_query(
$rf,
"select * from (select name, count(name) as c from doc where name is not null and name != '' and locked != -1 group by name) as Z where Z.c >1");
207 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
208 $pout[$row[
"name"]] = $row[
"c"];
210 if (count($pout) > 0) $msg = sprintf(
"%d double detected<pre>%s</pre>", count($pout) , print_r($pout,
true));
212 $tout[
"double doc name"] = array(
213 "status" => (count($pout) == 0) ?
OK :
KO,
217 $result = pg_query(
$rf,
"select id, title from docread where id in (SELECT m AS id FROM (SELECT min(id) AS m, initid, count(initid) AS c FROM docread WHERE locked != -1 AND doctype != 'T' GROUP BY docread.initid) AS z where z.c > 1);");
219 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
220 $pout[$row[
"id"]] = $row[
"title"];
222 if (count($pout) > 0) $msg = sprintf(
"%d multiple alive<pre>%s</pre>", count($pout) , print_r($pout,
true));
224 $tout[
"multiple alive"] = array(
225 "status" => (count($pout) == 0) ?
OK :
KO,
229 $result = pg_query(
$rf,
"select * from docfam");
231 while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
232 $fromid = intval($row[
"fromid"]);
233 if ($fromid == 0) $fromid =
"";
234 $fid = intval($row[
"id"]);
235 $test = pg_query(
$rf, sprintf(
"SELECT relname from pg_class where oid in (SELECT inhparent from pg_inherits where inhrelid =(SELECT oid FROM pg_class where relname='doc%d'));", $fid));
236 $dbfrom = pg_fetch_array(
$test, NULL, PGSQL_ASSOC);
237 if ($dbfrom[
"relname"] !=
"doc$fromid") {
238 $pout[] = sprintf(
"Family %s [%d]: fromid = %d, pg inherit=%s", $row[
"name"], $row[
"id"], $row[
"fromid"], $dbfrom[
"relname"]);
241 $tout[
"family inheritance"] = array(
242 "status" => (count($pout) == 0) ?
OK :
KO,
243 "msg" => implode(
"<br/>", $pout)
246 $result = pg_query(
$rf,
"select * from groups");
247 $result2 = pg_query(
$r,
"select * from groups");
248 if (pg_num_rows($result) != pg_num_rows($result2)) $msg =
"tables group are differents between <b>$dbaccess</b> <br>and <b>$fdb</b>";
250 $tout[
"user group synchro"] = array(
251 "status" => ($msg ==
"") ?
OK : KO,
256 $fdb = $GP[
"WEBDAV_DB"];
260 $rw = @pg_connect($fdb);
261 if ($rw) $dbr_webdav =
true;
264 $tout[
"connection db webdav"] = array(
265 "status" => $dbr_webdav ?
OK : KO,
270 $nuAppExists = (array_search(
'NU', $appNameList) ===
false) ?
false :
true;
272 $ldapport = $GP[
"NU_LDAP_PORT"];
273 $ldapmode = $GP[
"NU_LDAP_MODE"];
275 include_once (
'../NU/Lib.NU.php');
277 $ldapBindDn = $GP[
'NU_LDAP_BINDDN'];
278 $ldapPassword = $GP[
'NU_LDAP_PASSWORD'];
281 array_push($baseList, array(
282 'dn' => $GP[
'NU_LDAP_USER_BASE_DN'],
283 'filter' => $GP[
'NU_LDAP_USER_FILTER']
285 array_push($baseList, array(
286 'dn' => $GP[
'NU_LDAP_GROUP_BASE_DN'],
287 'filter' => $GP[
'NU_LDAP_GROUP_FILTER']
290 foreach ($baseList as $base) {
291 $testName = sprintf(
"connection to '%s'", $base[
'dn']);
292 $tout[$testName] = array();
294 $uri = getLDAPUri($ldapmode,
$ldaphost, $ldapport);
295 $conn = ldap_connect($uri);
296 if (
$conn ===
false) {
297 $tout[$testName][
'status'] =
KO;
298 $tout[$testName][
'msg'] = sprintf(
"Could not connect to LDAP server '%s': %s", $uri, $php_errormsg);
302 ldap_set_option(
$conn, LDAP_OPT_PROTOCOL_VERSION, 3);
303 ldap_set_option(
$conn, LDAP_OPT_REFERRALS, 0);
305 if ($ldapmode ==
'tls') {
307 if (
$ret ===
false) {
308 $tout[$testName][
'status'] =
KO;
309 $tout[$testName][
'msg'] = sprintf(
"Could not negotiate TLS with server '%s': %s", $uri, ldap_error(
$conn));
314 $bind = ldap_bind(
$conn, $ldapBindDn, $ldapPassword);
315 if ($bind ===
false) {
316 $tout[$testName][
'status'] =
KO;
317 $tout[$testName][
'msg'] = sprintf(
"Could not bind with bind DN '%s' on server '%s': %s", $ldapBindDn, $uri, ldap_error(
$conn));
322 $res = ldap_search(
$conn, $base[
'dn'], sprintf(
"(&(objectClass=*)%s)", $base[
'filter']));
323 if ($res ===
false) {
324 $tout[$testName][
'status'] =
KO;
325 $tout[$testName][
'msg'] = sprintf(
"LDAP search on base '%s' with filter '%s' failed: %s", $base[
'dn'], $base[
'filter'], ldap_error(
$conn));
330 $count = ldap_count_entries(
$conn, $res);
331 if ($count ===
false) {
332 $tout[$testName][
'status'] =
KO;
333 $tout[$testName][
'msg'] = sprintf(
"Error counting result entries: %s", ldap_error(
$conn));
339 $tout[$testName][
'msg'] = sprintf(
"Search returned 0 entries...");
344 $tout[$testName][
'status'] =
OK;
345 $tout[$testName][
'msg'] = sprintf(
"Search returned %s entries.", $count);
351 print
"<table border=1>";
352 foreach (
$tout as $k => $v) {
353 print sprintf(
"<tr><td><span style=\"background-color:%s;margin:3px;border:inset 2px %s\"> </span></td><td>%s</td><td>%s</td></tr>", $v[
"status"], $v[
"status"], $k, $v[
"msg"]);