25if (!defined(
'NOCSRFCHECK')) {
26 define(
'NOCSRFCHECK',
'1');
28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
40if (!defined(
"NOLOGIN")) {
41 define(
"NOLOGIN",
'1');
43if (!defined(
"NOSESSION")) {
44 define(
"NOSESSION",
'1');
47require
'../main.inc.php';
48require_once NUSOAP_PATH.
'/nusoap.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
59dol_syslog(
"Call Dolibarr webservices interfaces");
65 $langs->load(
"admin");
66 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
67 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
68 print $langs->trans(
"ToActivateModule");
73$server =
new nusoap_server();
74$server->soap_defencoding =
'UTF-8';
75$server->decode_utf8 =
false;
76$ns =
'http://www.dolibarr.org/ns/';
77$server->configureWSDL(
'WebServicesDolibarrOther', $ns);
81$server->wsdl->schemaTargetNamespace = $ns;
85$server->wsdl->addComplexType(
92 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
93 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
94 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
95 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
96 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string'),
100$server->wsdl->addComplexType(
107 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
108 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
113$server->wsdl->addComplexType(
120 'filename' => array(
'name' =>
'filename',
'type' =>
'xsd:string'),
121 'mimetype' => array(
'name' =>
'mimetype',
'type' =>
'xsd:string'),
122 'content' => array(
'name' =>
'content',
'type' =>
'xsd:string'),
123 'length' => array(
'name' =>
'length',
'type' =>
'xsd:string')
135$styleuse =
'encoded';
142 array(
'authentication' =>
'tns:authentication'),
144 array(
'result' =>
'tns:result',
'dolibarr' =>
'xsd:string',
'os' =>
'xsd:string',
'php' =>
'xsd:string',
'webserver' =>
'xsd:string'),
156 array(
'authentication' =>
'tns:authentication',
'modulepart' =>
'xsd:string',
'file' =>
'xsd:string'),
158 array(
'result' =>
'tns:result',
'document' =>
'tns:document'),
178 dol_syslog(
"Function: getVersions login=".$authentication[
'login']);
180 if ($authentication[
'entity']) {
181 $conf->entity = $authentication[
'entity'];
185 $objectresp = array();
194 $objectresp[
'result'] = array(
'result_code' =>
'OK',
'result_label' =>
'');
202 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
219function getDocument($authentication, $modulepart, $file, $refname =
'')
223 dol_syslog(
"Function: getDocument login=".$authentication[
'login'].
' - modulepart='.$modulepart.
' - file='.$file);
225 if ($authentication[
'entity']) {
226 $conf->entity = $authentication[
'entity'];
229 $objectresp = array();
235 $original_file = $file;
245 $socid = $fuser->socid;
249 if (!$error && (!$file || !$modulepart)) {
251 $errorcode =
'BAD_PARAMETERS';
252 $errorlabel =
"Parameter file and modulepart must be both provided.";
256 $fuser->loadRights();
259 $original_file = str_replace(
"../",
"/", $original_file);
262 if (empty($refname)) {
263 $refname = basename(dirname($original_file).
"/");
268 $accessallowed = $check_access[
'accessallowed'];
269 $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
270 $original_file = $check_access[
'original_file'];
273 if ($fuser->socid > 0) {
274 if ($sqlprotectagainstexternals) {
275 $resql = $db->query($sqlprotectagainstexternals);
277 $num = $db->num_rows($resql);
280 $obj = $db->fetch_object($resql);
281 if ($fuser->socid != $obj->fk_soc) {
293 if (!$accessallowed) {
294 $errorcode =
'NOT_PERMITTED';
295 $errorlabel =
'Access not allowed';
302 if (preg_match(
'/\.\./', $original_file) || preg_match(
'/[<>|]/', $original_file)) {
303 dol_syslog(
"Refused to deliver file ".$original_file);
304 $errorcode =
'REFUSED';
312 if (file_exists($original_file)) {
313 dol_syslog(
"Function: getDocument $original_file content-type=$type");
315 $f = fopen($original_file,
'r');
316 $content_file = fread($f, filesize($original_file));
319 'filename' => basename($original_file),
321 'content' => base64_encode($content_file),
322 'length' => filesize($original_file)
327 'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
328 'document' => $objectret
331 dol_syslog(
"File doesn't exist ".$original_file);
332 $errorcode =
'NOT_FOUND';
341 'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel)
349$server->service(file_get_contents(
"php://input"));
dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser=null, $refname='', $mode='read')
Security check when accessing to a document (used by document.php, viewimage.php and webservices to g...
version_webserver()
Return web server version.
version_dolibarr()
Return Dolibarr version.
version_php()
Return PHP version.
version_os($option='')
Return OS version.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getDocument($authentication, $modulepart, $file, $refname='')
Method to get a document by webservice.
getVersions($authentication)
Full methods code.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.