23 if (!defined(
"NOCSRFCHECK")) {
24 define(
"NOCSRFCHECK",
'1');
27 require
'../master.inc.php';
28 require_once NUSOAP_PATH.
'/nusoap.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
35 dol_syslog(
"Call Dolibarr webservices interfaces");
40 if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
41 $langs->load(
"admin");
42 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
43 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
44 print $langs->trans(
"ToActivateModule");
49 $server =
new nusoap_server();
50 $server->soap_defencoding =
'UTF-8';
51 $server->decode_utf8 =
false;
52 $ns =
'http://www.dolibarr.org/ns/';
53 $server->configureWSDL(
'WebServicesDolibarrOther', $ns);
54 $server->wsdl->schemaTargetNamespace = $ns;
58 $server->wsdl->addComplexType(
65 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
66 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
67 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
68 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
69 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
73 $server->wsdl->addComplexType(
80 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
81 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
86 $server->wsdl->addComplexType(
93 'filename' => array(
'name'=>
'filename',
'type'=>
'xsd:string'),
94 'mimetype' => array(
'name'=>
'mimetype',
'type'=>
'xsd:string'),
95 'content' => array(
'name'=>
'content',
'type'=>
'xsd:string'),
96 'length' => array(
'name'=>
'length',
'type'=>
'xsd:string')
108 $styleuse =
'encoded';
115 array(
'authentication'=>
'tns:authentication'),
117 array(
'result'=>
'tns:result',
'dolibarr'=>
'xsd:string',
'os'=>
'xsd:string',
'php'=>
'xsd:string',
'webserver'=>
'xsd:string'),
129 array(
'authentication'=>
'tns:authentication',
'modulepart'=>
'xsd:string',
'file'=>
'xsd:string'),
131 array(
'result'=>
'tns:result',
'document'=>
'tns:document'),
151 dol_syslog(
"Function: getVersions login=".$authentication[
'login']);
153 if ($authentication[
'entity']) {
154 $conf->entity = $authentication[
'entity'];
158 $objectresp = array();
159 $errorcode =
''; $errorlabel =
'';
166 $objectresp[
'result'] = array(
'result_code'=>
'OK',
'result_label'=>
'');
174 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
190 function getDocument($authentication, $modulepart, $file, $refname =
'')
194 dol_syslog(
"Function: getDocument login=".$authentication[
'login'].
' - modulepart='.$modulepart.
' - file='.$file);
196 if ($authentication[
'entity']) {
197 $conf->entity = $authentication[
'entity'];
200 $objectresp = array();
201 $errorcode =
''; $errorlabel =
'';
205 $original_file = $file;
215 $socid = $fuser->socid;
219 if (!$error && (!$file || !$modulepart)) {
221 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter file and modulepart must be both provided.";
228 $original_file = str_replace(
"../",
"/", $original_file);
231 if (empty($refname)) {
232 $refname = basename(dirname($original_file).
"/");
237 $accessallowed = $check_access[
'accessallowed'];
238 $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
239 $original_file = $check_access[
'original_file'];
242 if ($fuser->socid > 0) {
243 if ($sqlprotectagainstexternals) {
244 $resql = $db->query($sqlprotectagainstexternals);
246 $num = $db->num_rows(
$resql);
249 $obj = $db->fetch_object(
$resql);
250 if ($fuser->socid != $obj->fk_soc) {
262 if (!$accessallowed) {
263 $errorcode =
'NOT_PERMITTED';
264 $errorlabel =
'Access not allowed';
271 if (preg_match(
'/\.\./', $original_file) || preg_match(
'/[<>|]/', $original_file)) {
272 dol_syslog(
"Refused to deliver file ".$original_file);
273 $errorcode =
'REFUSED';
281 if (file_exists($original_file)) {
282 dol_syslog(
"Function: getDocument $original_file content-type=$type");
284 $f = fopen($original_file,
'r');
285 $content_file = fread($f, filesize($original_file));
288 'filename' => basename($original_file),
290 'content' => base64_encode($content_file),
291 'length' => filesize($original_file)
296 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
297 'document'=>$objectret
300 dol_syslog(
"File doesn't exist ".$original_file);
301 $errorcode =
'NOT_FOUND';
310 'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel)
318 $server->service(file_get_contents(
"php://input"));
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.