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");
 
   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();
 
  185    $objectresp[
'result'] = array(
'result_code'=>
'OK', 
'result_label'=>
'');
 
  193    $objectresp = array(
'result'=>array(
'result_code' => $errorcode, 
'result_label' => $errorlabel));
 
 
  209function getDocument($authentication, $modulepart, $file, $refname = 
'')
 
  213  dol_syslog(
"Function: getDocument login=".$authentication[
'login'].
' - modulepart='.$modulepart.
' - file='.$file);
 
  215  if ($authentication[
'entity']) {
 
  216    $conf->entity = $authentication[
'entity'];
 
  219  $objectresp = array();
 
  225  $original_file = $file;
 
  235    $socid = $fuser->socid;
 
  239  if (!$error && (!$file || !$modulepart)) {
 
  241    $errorcode = 
'BAD_PARAMETERS';
 
  242    $errorlabel = 
"Parameter file and modulepart must be both provided.";
 
  249    $original_file = str_replace(
"../", 
"/", $original_file);
 
  252    if (empty($refname)) {
 
  253      $refname = basename(dirname($original_file).
"/");
 
  258    $accessallowed              = $check_access[
'accessallowed'];
 
  259    $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
 
  260    $original_file              = $check_access[
'original_file'];
 
  263    if ($fuser->socid > 0) {
 
  264      if ($sqlprotectagainstexternals) {
 
  265        $resql = $db->query($sqlprotectagainstexternals);
 
  267          $num = $db->num_rows($resql);
 
  270            $obj = $db->fetch_object($resql);
 
  271            if ($fuser->socid != $obj->fk_soc) {
 
  283    if (!$accessallowed) {
 
  284      $errorcode = 
'NOT_PERMITTED';
 
  285      $errorlabel = 
'Access not allowed';
 
  292    if (preg_match(
'/\.\./', $original_file) || preg_match(
'/[<>|]/', $original_file)) {
 
  293      dol_syslog(
"Refused to deliver file ".$original_file);
 
  294      $errorcode = 
'REFUSED';
 
  302      if (file_exists($original_file)) {
 
  303        dol_syslog(
"Function: getDocument $original_file  content-type=$type");
 
  305        $f = fopen($original_file, 
'r');
 
  306        $content_file = fread($f, filesize($original_file));
 
  309          'filename' => basename($original_file),
 
  311          'content' => base64_encode($content_file),
 
  312          'length' => filesize($original_file)
 
  317          'result'=>array(
'result_code'=>
'OK', 
'result_label'=>
''),
 
  318          'document'=>$objectret
 
  321        dol_syslog(
"File doesn't exist ".$original_file);
 
  322        $errorcode = 
'NOT_FOUND';
 
  331    'result'=>array(
'result_code' => $errorcode, 
'result_label' => $errorlabel)
 
 
  339$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.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
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.