23if (!defined(
'NOCSRFCHECK')) {
24 define(
'NOCSRFCHECK',
'1');
26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
29if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32if (!defined(
'NOREQUIREHTML')) {
33 define(
'NOREQUIREHTML',
'1');
35if (!defined(
'NOREQUIREAJAX')) {
36 define(
'NOREQUIREAJAX',
'1');
38if (!defined(
"NOLOGIN")) {
39 define(
"NOLOGIN",
'1');
41if (!defined(
"NOSESSION")) {
42 define(
"NOSESSION",
'1');
45require
'../main.inc.php';
46require_once NUSOAP_PATH.
'/nusoap.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
53dol_syslog(
"Call Dolibarr webservices interfaces");
58if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
59 $langs->load(
"admin");
60 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
61 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
62 print $langs->trans(
"ToActivateModule");
67$server =
new nusoap_server();
68$server->soap_defencoding =
'UTF-8';
69$server->decode_utf8 =
false;
70$ns =
'http://www.dolibarr.org/ns/';
71$server->configureWSDL(
'WebServicesDolibarrOther', $ns);
72$server->wsdl->schemaTargetNamespace = $ns;
76$server->wsdl->addComplexType(
83 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
84 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
85 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
86 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
87 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
91$server->wsdl->addComplexType(
98 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
99 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
104$server->wsdl->addComplexType(
111 'filename' => array(
'name'=>
'filename',
'type'=>
'xsd:string'),
112 'mimetype' => array(
'name'=>
'mimetype',
'type'=>
'xsd:string'),
113 'content' => array(
'name'=>
'content',
'type'=>
'xsd:string'),
114 'length' => array(
'name'=>
'length',
'type'=>
'xsd:string')
126$styleuse =
'encoded';
133 array(
'authentication'=>
'tns:authentication'),
135 array(
'result'=>
'tns:result',
'dolibarr'=>
'xsd:string',
'os'=>
'xsd:string',
'php'=>
'xsd:string',
'webserver'=>
'xsd:string'),
147 array(
'authentication'=>
'tns:authentication',
'modulepart'=>
'xsd:string',
'file'=>
'xsd:string'),
149 array(
'result'=>
'tns:result',
'document'=>
'tns:document'),
169 dol_syslog(
"Function: getVersions login=".$authentication[
'login']);
171 if ($authentication[
'entity']) {
172 $conf->entity = $authentication[
'entity'];
176 $objectresp = array();
177 $errorcode =
''; $errorlabel =
'';
184 $objectresp[
'result'] = array(
'result_code'=>
'OK',
'result_label'=>
'');
192 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
208function getDocument($authentication, $modulepart, $file, $refname =
'')
212 dol_syslog(
"Function: getDocument login=".$authentication[
'login'].
' - modulepart='.$modulepart.
' - file='.$file);
214 if ($authentication[
'entity']) {
215 $conf->entity = $authentication[
'entity'];
218 $objectresp = array();
219 $errorcode =
''; $errorlabel =
'';
223 $original_file = $file;
233 $socid = $fuser->socid;
237 if (!$error && (!$file || !$modulepart)) {
239 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter file and modulepart must be both provided.";
246 $original_file = str_replace(
"../",
"/", $original_file);
249 if (empty($refname)) {
250 $refname = basename(dirname($original_file).
"/");
255 $accessallowed = $check_access[
'accessallowed'];
256 $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
257 $original_file = $check_access[
'original_file'];
260 if ($fuser->socid > 0) {
261 if ($sqlprotectagainstexternals) {
262 $resql = $db->query($sqlprotectagainstexternals);
264 $num = $db->num_rows($resql);
267 $obj = $db->fetch_object($resql);
268 if ($fuser->socid != $obj->fk_soc) {
280 if (!$accessallowed) {
281 $errorcode =
'NOT_PERMITTED';
282 $errorlabel =
'Access not allowed';
289 if (preg_match(
'/\.\./', $original_file) || preg_match(
'/[<>|]/', $original_file)) {
290 dol_syslog(
"Refused to deliver file ".$original_file);
291 $errorcode =
'REFUSED';
299 if (file_exists($original_file)) {
300 dol_syslog(
"Function: getDocument $original_file content-type=$type");
302 $f = fopen($original_file,
'r');
303 $content_file = fread($f, filesize($original_file));
306 'filename' => basename($original_file),
308 'content' => base64_encode($content_file),
309 'length' => filesize($original_file)
314 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
315 'document'=>$objectret
318 dol_syslog(
"File doesn't exist ".$original_file);
319 $errorcode =
'NOT_FOUND';
328 'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel)
336$server->service(file_get_contents(
"php://input"));
dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser='', $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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.