MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mwebservice.class
Ir para a documentação deste ficheiro.
1
<?php
29
class
MWebService
30
{
34
public
function
__construct
()
35
{
36
require_once
'../classes/miolo.class'
;
37
require_once
'../classes/support.inc'
;
38
39
$MIOLO
=
MIOLO::getInstance
();
40
$MIOLO
->conf =
new
MConfigLoader
();
41
$MIOLO
->conf->loadConf();
42
$MIOLO
->init();
43
}
44
52
protected
function
checkPermission
($user, $password)
53
{
54
$MIOLO
=
MIOLO::getInstance
();
55
return
$MIOLO
->auth->authenticate($user, $password);
56
}
57
61
protected
function
requestIsLocal
()
62
{
63
return
$_SERVER[
'REMOTE_ADDR'
] == $_SERVER[
'SERVER_ADDR'
];
64
}
65
69
protected
function
accessError
()
70
{
71
$this->
error
(
'Server'
, _M(
'Access denied'
));
72
}
73
80
protected
function
error
($code, $message)
81
{
82
throw
new
SoapFault($code, $message);
83
}
84
91
protected
function
requestIsFromSubnet
()
92
{
93
$binaryClient = sprintf(
"%032b"
,ip2long($_SERVER[
'REMOTE_ADDR'
]));
94
$binaryServer = sprintf(
"%032b"
,ip2long($_SERVER[
'SERVER_ADDR'
]));
95
$netMask = $this->netmask();
96
97
return
(substr_compare($binaryClient, $binaryServer, 0, $netMask) === 0);
98
}
99
103
private
function
netmask()
104
{
105
if
( !($p = popen(
'ifconfig'
,
'r'
)) )
106
{
107
$this->
error
(
'Could not get network information'
);
108
}
109
110
$out =
""
;
111
while
( !feof($p) )
112
{
113
$out .= fread($p,1024);
114
}
115
fclose($p);
116
117
$match =
"/^.*Bcast:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.*Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/im"
;
118
119
if
( !preg_match($match,$out,$regs) )
120
{
121
$this->
error
(
'Could not detemine the network mask'
);
122
}
123
124
$base = ip2long(
'255.255.255.255'
);
125
$mask = ip2long($regs[1]);
126
127
return
32 - log(($mask ^ $base) + 1, 2);
128
}
129
}
130
?>
MConfigLoader
Definição
mconfigloader.class:7
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MWebService
Definição
mwebservice.class:30
MWebService\checkPermission
checkPermission($user, $password)
Definição
mwebservice.class:52
MWebService\__construct
__construct()
Definição
mwebservice.class:34
MWebService\accessError
accessError()
Definição
mwebservice.class:69
MWebService\error
error($code, $message)
Definição
mwebservice.class:80
MWebService\requestIsLocal
requestIsLocal()
Definição
mwebservice.class:61
MWebService\requestIsFromSubnet
requestIsFromSubnet()
Definição
mwebservice.class:91
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
classes
services
mwebservice.class
Gerado por
1.10.0