23 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK",
'1');
25 require
'../master.inc.php';
26 require_once NUSOAP_PATH.
'/nusoap.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33 dol_syslog(
"Call Dolibarr webservices interfaces");
38 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
40 $langs->load(
"admin");
41 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
42 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
43 print $langs->trans(
"ToActivateModule");
48 $server =
new nusoap_server();
49 $server->soap_defencoding =
'UTF-8';
50 $server->decode_utf8 =
false;
51 $ns =
'http://www.dolibarr.org/ns/';
52 $server->configureWSDL(
'WebServicesDolibarrOther', $ns);
53 $server->wsdl->schemaTargetNamespace = $ns;
57 $server->wsdl->addComplexType(
64 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
65 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
66 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
67 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
68 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string'),
72 $server->wsdl->addComplexType(
79 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
80 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
85 $server->wsdl->addComplexType(
92 'filename' => array(
'name'=>
'filename',
'type'=>
'xsd:string'),
93 'mimetype' => array(
'name'=>
'mimetype',
'type'=>
'xsd:string'),
94 'content' => array(
'name'=>
'content',
'type'=>
'xsd:string'),
95 'length' => array(
'name'=>
'length',
'type'=>
'xsd:string')
107 $styleuse =
'encoded';
114 array(
'authentication'=>
'tns:authentication'),
116 array(
'result'=>
'tns:result',
'dolibarr'=>
'xsd:string',
'os'=>
'xsd:string',
'php'=>
'xsd:string',
'webserver'=>
'xsd:string'),
128 array(
'authentication'=>
'tns:authentication',
'modulepart'=>
'xsd:string',
'file'=>
'xsd:string'),
130 array(
'result'=>
'tns:result',
'document'=>
'tns:document'),
150 dol_syslog(
"Function: getVersions login=".$authentication[
'login']);
152 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
155 $objectresp = array();
156 $errorcode =
''; $errorlabel =
'';
164 $objectresp[
'result'] = array(
'result_code'=>
'OK',
'result_label'=>
'');
173 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
189 function getDocument($authentication, $modulepart, $file, $refname =
'')
193 dol_syslog(
"Function: getDocument login=".$authentication[
'login'].
' - modulepart='.$modulepart.
' - file='.$file);
195 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
197 $objectresp = array();
198 $errorcode =
''; $errorlabel =
'';
202 $original_file = $file;
211 if ($fuser->socid) $socid = $fuser->socid;
214 if (!$error && (!$file || !$modulepart))
217 $errorcode =
'BAD_PARAMETERS'; $errorlabel =
"Parameter file and modulepart must be both provided.";
225 $original_file = str_replace(
"../",
"/", $original_file);
228 if (empty($refname)) $refname = basename(dirname($original_file).
"/");
232 $accessallowed = $check_access[
'accessallowed'];
233 $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
234 $original_file = $check_access[
'original_file'];
237 if ($fuser->socid > 0)
239 if ($sqlprotectagainstexternals)
241 $resql = $db->query($sqlprotectagainstexternals);
244 $num = $db->num_rows(
$resql);
248 $obj = $db->fetch_object(
$resql);
249 if ($fuser->socid != $obj->fk_soc)
264 $errorcode =
'NOT_PERMITTED';
265 $errorlabel =
'Access not allowed';
272 if (preg_match(
'/\.\./', $original_file) || preg_match(
'/[<>|]/', $original_file))
274 dol_syslog(
"Refused to deliver file ".$original_file);
275 $errorcode =
'REFUSED';
284 if (file_exists($original_file))
286 dol_syslog(
"Function: getDocument $original_file content-type=$type");
288 $f = fopen($original_file,
'r');
289 $content_file = fread($f, filesize($original_file));
292 'filename' => basename($original_file),
294 'content' => base64_encode($content_file),
295 'length' => filesize($original_file)
300 'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
301 'document'=>$objectret
305 dol_syslog(
"File doesn't exist ".$original_file);
306 $errorcode =
'NOT_FOUND';
316 'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel)
324 $server->service(file_get_contents(
"php://input"));
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.
getVersions($authentication)
Full methods code.
version_webserver()
Return web server version.
version_os($option= '')
Return OS version.
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) ...
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
version_dolibarr()
Return Dolibarr version.
version_php()
Return PHP version.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
getDocument($authentication, $modulepart, $file, $refname= '')
Method to get a document by webservice.