Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
indexq.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* Main program to activate action in WHAT software
9
*
10
* All HTTP requests call index.php to execute action within application
11
*
12
* @author Anakeen 2000
13
* @version $Id: index.php,v 1.64 2008/12/16 15:51:53 jerome Exp $
14
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
15
* @package FDL
16
* @subpackage
17
*/
18
/**
19
*/
20
global
$tic1
;
21
22
$deb
= gettimeofday();
23
$tic1
=
$deb
[
"sec"
] +
$deb
[
"usec"
] / 1000000;
24
include_once (
'WHAT/Lib.Main.php'
);
25
include_once (
'WHAT/Class.AuthenticatorManager.php'
);
26
include_once (
'WHAT/wdebug.php'
);
27
28
global
$SQLDELAY
,
$SQLDEBUG
;
29
global
$TSQLDELAY
;
30
31
$authtype
=
getAuthType
();
32
33
if
(
$authtype
==
'apache'
) {
34
// Apache has already handled the authentication
35
global
$_SERVER
;
36
if
($_SERVER[
'PHP_AUTH_USER'
] ==
""
) {
37
header(
'HTTP/1.0 403 Forbidden'
);
38
echo _(
"User must be authenticate"
);
39
exit
;
40
}
41
}
else
{
42
43
$status =
AuthenticatorManager::checkAccess
();
44
switch
($status) {
45
case
0:
// it'good, user is authentified
46
break
;
47
48
case
-1:
49
// User must change his password
50
$action
->session->close();
51
AuthenticatorManager::$auth
->logout(
"guest.php?sole=A&app=AUTHENT&action=ERRNO_BUG_639"
);
52
exit
(0);
53
break
;
54
55
default
:
56
sleep(1);
// for robots
57
// Redirect to authentication
58
global
$_POST
;
59
AuthenticatorManager::$auth
->logout(
"guest.php?sole=A&app=AUTHENT&action=ERRNO_BUG_639"
);
60
AuthenticatorManager::$auth
->askAuthentication(array(
61
"error"
=> $status
62
));
63
Redirect
(
$action
,
'AUTHENT'
,
'LOGINFORM&error='
. $status .
'&auth_user='
. urlencode($_POST[
'auth_user'
]));
64
exit
(0);
65
}
66
67
$_SERVER[
'PHP_AUTH_USER'
] =
AuthenticatorManager::$auth
->getAuthUser();
68
}
69
70
if
(file_exists(
'maintenance.lock'
)) {
71
if
($_SERVER[
'PHP_AUTH_USER'
] !=
'admin'
) {
72
include_once (
'TOOLBOX/stop.php'
);
73
exit
(0);
74
}
75
}
76
#
77
# This is the main body of App manager
78
# It is used to launch application and
79
# function giving them all necessary environment
80
# element
81
#
82
#
83
// First control
84
if
(!isset($_SERVER[
'PHP_AUTH_USER'
])) {
85
Header(
"Location:guest.php"
);
86
exit
;
87
}
88
// ----------------------------------------
89
getmainAction(
AuthenticatorManager::$auth
,
$action
);
90
$deb
= gettimeofday();
91
$ticainit
=
$deb
[
"sec"
] +
$deb
[
"usec"
] / 1000000;
92
$trace
=
$action
->read(
"trace"
);
93
$trace
[
"url"
] = $_SERVER[
"REQUEST_URI"
];
94
$trace
[
"init"
] = sprintf(
"%.03fs"
,
$ticainit
-
$tic1
);
95
$out
=
''
;
96
$action
->parent->AddJsRef(
$action
->GetParam(
"CORE_JSURL"
) .
"/tracetime.js"
);
97
executeAction
(
$action
,
$out
);
98
function
sortqdelay
(
$a
, $b)
99
{
100
$xa = doubleval(
$a
[
"t"
]);
101
$xb = doubleval($b[
"t"
]);
102
if
($xa > $xb)
return
-1;
103
else
if
($xa < $xb)
return
1;
104
return
0;
105
}
106
//usort($TSQLDELAY, "sortqdelay");
107
addLogMsg(
$TSQLDELAY
);
108
$deb
= gettimeofday();
109
$tic4
=
$deb
[
"sec"
] +
$deb
[
"usec"
] / 1000000;
110
$trace
[
"app"
] = sprintf(
"%.03fs"
,
$tic4
-
$ticainit
);
111
$trace
[
"memory"
] = sprintf(
"%dkb"
, round(memory_get_usage() / 1024));
112
$trace
[
"queries"
] = sprintf(
"%.03fs #%d"
,
$SQLDELAY
, count(
$TSQLDELAY
));
113
$trace
[
"server all"
] = sprintf(
"%.03fs"
,
$tic4
-
$tic1
);
114
$trace
[
"n"
] =
"-------------"
;
115
$strace
=
'var TTRACE=new Object();'
.
"\n"
;
116
117
foreach
(
$trace
as $k => $v)
$strace
.= sprintf(
" TTRACE['%s']='%s';\n"
, $k, str_replace(
"'"
,
" "
, $v));
118
119
$logcode
=
$action
->lay->GenJsCode(
true
,
true
);
120
$out
= str_replace(
"<head>"
,
"<head><script>;$strace</script>"
,
$out
);
121
$out
= str_replace(
"</head>"
,
"<script>$logcode</script></head>"
,
$out
);
122
echo (
$out
);
123
$action
->unregister(
"trace"
);
124
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase