diff --git a/ChangeLog b/ChangeLog
index d4a8b55625f..646c1314b1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ English Dolibarr ChangeLog
For users:
----------
+NEW: Several security issues after a second private bug bounty campaign.
For developers:
diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index 8982376ded6..cf2bd2065a2 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -582,6 +582,10 @@ if ($resql) {
$i++;
}
+ if ($num == 0) {
+ print '
'.$langs->trans("None").'
';
+ }
+
print "";
print "";
print '';
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index b75bce38ca9..9b4dbb0203d 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -84,12 +84,10 @@ if (!empty($canvas)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membercard', 'globalcard'));
-// Security check
-$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0);
-
-if ($id > 0) {
+// Fetch object
+if ($id > 0 || !empty($ref)) {
// Load member
- $result = $object->fetch($id);
+ $result = $object->fetch($id, $ref);
// Define variables to know what current user can do on users
$canadduser = ($user->admin || $user->rights->user->user->creer);
@@ -97,9 +95,9 @@ if ($id > 0) {
if ($object->user_id) {
// $User is the user who edits, $object->user_id is the id of the related user in the edited member
$caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
- || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+ || (($user->id != $object->user_id) && $user->rights->user->user->creer));
$caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
- || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ || (($user->id != $object->user_id) && $user->rights->user->user->password));
}
}
@@ -110,6 +108,8 @@ if ($id) {
$caneditfieldmember = $user->rights->adherent->creer;
}
+// Security check
+$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
/*
diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index 88e31ebffb6..c359f539547 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -42,9 +42,6 @@ $ref = GETPOST('ref', 'alphanohtml');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
-// Security check
-$result = restrictedArea($user, 'adherent', $id);
-
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
@@ -63,8 +60,6 @@ if (!$sortfield) {
$sortfield = "name";
}
-
-$form = new Form($db);
$object = new Adherent($db);
$membert = new AdherentType($db);
$result = $object->fetch($id, $ref);
@@ -74,6 +69,33 @@ if ($result < 0) {
}
$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
+// Fetch object
+if ($id > 0 || !empty($ref)) {
+ // Load member
+ $result = $object->fetch($id, $ref);
+
+ // Define variables to know what current user can do on users
+ $canadduser = ($user->admin || $user->rights->user->user->creer);
+ // Define variables to know what current user can do on properties of user linked to edited member
+ if ($object->user_id) {
+ // $User is the user who edits, $object->user_id is the id of the related user in the edited member
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
+ || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+ || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ }
+}
+
+// Define variables to determine what the current user can do on the members
+$canaddmember = $user->rights->adherent->creer;
+// Define variables to determine what the current user can do on the properties of a member
+if ($id) {
+ $caneditfieldmember = $user->rights->adherent->creer;
+}
+
+// Security check
+$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
+
/*
* Actions
diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php
index a1c105bd192..e1f580a3656 100644
--- a/htdocs/adherents/htpasswd.php
+++ b/htdocs/adherents/htpasswd.php
@@ -26,7 +26,16 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
+$status = GETPOST('status', 'int');
+$cotis = GETPOST('cotis', 'int');
+
+$sortfield = GETPOST('sortfield', 'alphanohtml');
+$sortorder = GETPOST('sortorder', 'aZ09');
+
// Security check
+if (empty($conf->adherent->enabled)) {
+ accessforbidden();
+}
if (!$user->rights->adherent->export) {
accessforbidden();
}
@@ -46,19 +55,10 @@ if (empty($sortorder)) {
if (empty($sortfield)) {
$sortfield = "d.login";
}
-if (!isset($statut)) {
- $statut = 1;
-}
-
-if (!isset($cotis)) {
- // by default, members must be up to date of subscription
- $cotis = 1;
-}
-
$sql = "SELECT d.login, d.pass, d.datefin";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d ";
-$sql .= " WHERE d.statut = ".$statut;
+$sql .= " WHERE d.statut = ".((int) $status);
if ($cotis == 1) {
$sql .= " AND datefin > '".$db->idate($now)."'";
}
@@ -70,6 +70,7 @@ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
+ $param = '';
print_barre_liste($langs->trans("HTPasswordExport"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0);
print "\n";
diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php
index 89baf2f5ec5..44d5ee5399b 100644
--- a/htdocs/adherents/ldap.php
+++ b/htdocs/adherents/ldap.php
@@ -32,7 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
// Load translation files required by the page
$langs->loadLangs(array("companies", "members", "ldap", "admin"));
-$rowid = GETPOST('id', 'int');
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alphanohtml');
$action = GETPOST('action', 'aZ09');
// Protection
@@ -42,12 +43,34 @@ if ($user->socid > 0) {
}
$object = new Adherent($db);
-$result = $object->fetch($rowid);
-if (!$result) {
- dol_print_error($db, "Failed to get adherent: ".$object->error);
- exit;
+
+// Fetch object
+if ($id > 0 || !empty($ref)) {
+ // Load member
+ $result = $object->fetch($id, $ref);
+
+ // Define variables to know what current user can do on users
+ $canadduser = ($user->admin || $user->rights->user->user->creer);
+ // Define variables to know what current user can do on properties of user linked to edited member
+ if ($object->user_id) {
+ // $User is the user who edits, $object->user_id is the id of the related user in the edited member
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
+ || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+ || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ }
}
+// Define variables to determine what the current user can do on the members
+$canaddmember = $user->rights->adherent->creer;
+// Define variables to determine what the current user can do on the properties of a member
+if ($id) {
+ $caneditfieldmember = $user->rights->adherent->creer;
+}
+
+// Security check
+$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
+
/*
* Actions
diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php
index 26fec04a5e6..91946094a9a 100644
--- a/htdocs/adherents/note.php
+++ b/htdocs/adherents/note.php
@@ -33,9 +33,7 @@ $langs->loadLangs(array("companies", "members", "bills"));
$action = GETPOST('action', 'aZ09');
$id = GETPOST('id', 'int');
-
-// Security check
-$result = restrictedArea($user, 'adherent', $id);
+$ref = GETPOST('ref', 'alphanohtml');
$object = new Adherent($db);
$result = $object->fetch($id);
@@ -46,6 +44,34 @@ if ($result > 0) {
$permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php
+// Fetch object
+if ($id > 0 || !empty($ref)) {
+ // Load member
+ $result = $object->fetch($id, $ref);
+
+ // Define variables to know what current user can do on users
+ $canadduser = ($user->admin || $user->rights->user->user->creer);
+ // Define variables to know what current user can do on properties of user linked to edited member
+ if ($object->user_id) {
+ // $User is the user who edits, $object->user_id is the id of the related user in the edited member
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
+ || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+ || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ }
+}
+
+// Define variables to determine what the current user can do on the members
+$canaddmember = $user->rights->adherent->creer;
+// Define variables to determine what the current user can do on the properties of a member
+if ($id) {
+ $caneditfieldmember = $user->rights->adherent->creer;
+}
+
+// Security check
+$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
+
+
/*
* Actions
*/
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index ecc0e1cfe47..54729e5ba8a 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -42,7 +42,9 @@ $langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'othe
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
-$rowid = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
+$id = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
+$rowid = $id;
+$ref = GETPOST('ref', 'alphanohtml');
$typeid = GETPOST('typeid', 'int');
$cancel = GETPOST('cancel');
@@ -66,10 +68,6 @@ if (!$sortorder) {
$sortorder = "DESC";
}
-
-// Security check
-$result = restrictedArea($user, 'adherent', $rowid, '', 'cotisation');
-
$object = new Adherent($db);
$extrafields = new ExtraFields($db);
$adht = new AdherentType($db);
@@ -82,29 +80,6 @@ $errmsg = '';
$defaultdelay = 1;
$defaultdelayunit = 'y';
-if ($rowid) {
- // Load member
- $result = $object->fetch($rowid);
-
- // Define variables to know what current user can do on users
- $canadduser = ($user->admin || $user->rights->user->user->creer);
- // Define variables to know what current user can do on properties of user linked to edited member
- if ($object->user_id) {
- // $user is the user editing, $object->user_id is the user's id linked to the edited member
- $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
- || (($user->id != $object->user_id) && $user->rights->user->user->creer));
- $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
- || (($user->id != $object->user_id) && $user->rights->user->user->password));
- }
-}
-
-// Define variables to know what current user can do on members
-$canaddmember = $user->rights->adherent->creer;
-// Define variables to know what current user can do on properties of a member
-if ($rowid) {
- $caneditfieldmember = $user->rights->adherent->creer;
-}
-
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('subscription'));
@@ -117,6 +92,33 @@ $datefrom = 0;
$dateto = 0;
$paymentdate = -1;
+// Fetch object
+if ($id > 0 || !empty($ref)) {
+ // Load member
+ $result = $object->fetch($id, $ref);
+
+ // Define variables to know what current user can do on users
+ $canadduser = ($user->admin || $user->rights->user->user->creer);
+ // Define variables to know what current user can do on properties of user linked to edited member
+ if ($object->user_id) {
+ // $User is the user who edits, $object->user_id is the id of the related user in the edited member
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
+ || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+ || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ }
+}
+
+// Define variables to determine what the current user can do on the members
+$canaddmember = $user->rights->adherent->creer;
+// Define variables to determine what the current user can do on the properties of a member
+if ($id) {
+ $caneditfieldmember = $user->rights->adherent->creer;
+}
+
+// Security check
+$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
+
/*
* Actions
diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php
index bf18a851efb..6b76fc3d502 100644
--- a/htdocs/adherents/subscription/list.php
+++ b/htdocs/adherents/subscription/list.php
@@ -496,11 +496,14 @@ while ($i < min($num, $limit)) {
$adherent->morphy = $obj->morphy;
$adherent->email = $obj->email;
$adherent->typeid = $obj->type;
+ $adherent->datefin = $db->jdate($obj->datef);
$typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
$adht = new AdherentType($db);
$adht->fetch($typeid);
+ $adherent->need_subscription = $adht->subscription;
+
print '
';
// Ref
diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php
index a53cacd2212..902206c7874 100644
--- a/htdocs/adherents/vcard.php
+++ b/htdocs/adherents/vcard.php
@@ -30,71 +30,100 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php';
-$adherent = new adherent($db);
-
-
$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alphanohtml');
+
+$object = new adherent($db);
+
+// Fetch object
+if ($id > 0 || !empty($ref)) {
+ // Load member
+ $result = $object->fetch($id, $ref);
+
+ // Define variables to know what current user can do on users
+ $canadduser = ($user->admin || $user->rights->user->user->creer);
+ // Define variables to know what current user can do on properties of user linked to edited member
+ if ($object->user_id) {
+ // $User is the user who edits, $object->user_id is the id of the related user in the edited member
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
+ || (($user->id != $object->user_id) && $user->rights->user->user->creer));
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
+ || (($user->id != $object->user_id) && $user->rights->user->user->password));
+ }
+}
+
+// Define variables to determine what the current user can do on the members
+$canaddmember = $user->rights->adherent->creer;
+// Define variables to determine what the current user can do on the properties of a member
+if ($id) {
+ $caneditfieldmember = $user->rights->adherent->creer;
+}
// Security check
-$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas);
+$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
-$result = $adherent->fetch($id);
-if ($result <= 0) {
- dol_print_error($adherent->error);
- exit;
-}
+/*
+ * Actions
+ */
-$physicalperson = 1;
+// None
+
+
+/*
+ * View
+ */
$company = new Societe($db);
-if ($adherent->socid) {
- $result = $company->fetch($adherent->socid);
+if ($object->socid) {
+ $result = $company->fetch($object->socid);
}
+
+
// We create VCard
$v = new vCard();
$v->setProdId('Dolibarr '.DOL_VERSION);
-$v->setUid('DOLIBARR-ADHERENTID-'.$adherent->id);
-$v->setName($adherent->lastname, $adherent->firstname, "", $adherent->civility, "");
-$v->setFormattedName($adherent->getFullName($langs, 1));
+$v->setUid('DOLIBARR-ADHERENTID-'.$object->id);
+$v->setName($object->lastname, $object->firstname, "", $object->civility, "");
+$v->setFormattedName($object->getFullName($langs, 1));
-$v->setPhoneNumber($adherent->phone_pro, "TYPE=WORK;VOICE");
-//$v->setPhoneNumber($adherent->phone_perso,"TYPE=HOME;VOICE");
-$v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE");
-$v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX");
+$v->setPhoneNumber($object->phone_pro, "TYPE=WORK;VOICE");
+//$v->setPhoneNumber($object->phone_perso,"TYPE=HOME;VOICE");
+$v->setPhoneNumber($object->phone_mobile, "TYPE=CELL;VOICE");
+$v->setPhoneNumber($object->fax, "TYPE=WORK;FAX");
-$country = $adherent->country_code ? $adherent->country : '';
+$country = $object->country_code ? $object->country : '';
-$v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL");
-$v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK");
+$v->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=WORK;POSTAL");
+$v->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=WORK");
-$v->setEmail($adherent->email);
-$v->setNote($adherent->note_public);
-$v->setTitle($adherent->poste);
+$v->setEmail($object->email);
+$v->setNote($object->note_public);
+$v->setTitle($object->poste);
// Data from linked company
if ($company->id) {
$v->setURL($company->url, "TYPE=WORK");
- if (!$adherent->phone_pro) {
+ if (!$object->phone_pro) {
$v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
}
- if (!$adherent->fax) {
+ if (!$object->fax) {
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
}
- if (!$adherent->zip) {
+ if (!$object->zip) {
$v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
}
// when company e-mail is empty, use only adherent e-mail
if (empty(trim($company->email))) {
// was set before, don't set twice
- } elseif (empty(trim($adherent->email))) {
+ } elseif (empty(trim($object->email))) {
// when adherent e-mail is empty, use only company e-mail
$v->setEmail($company->email);
- } elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) {
+ } elseif (strtolower(end(explode("@", $object->email))) == strtolower(end(explode("@", $company->email)))) {
// when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second)
- $v->setEmail($adherent->email);
+ $v->setEmail($object->email);
// support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($company->email, 'INTERNET');
@@ -103,7 +132,7 @@ if ($company->id) {
$v->setEmail($company->email);
// support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($adherent->email, 'INTERNET');
+ $v->setEmail($object->email, 'INTERNET');
}
// Si adherent lie a un tiers non de type "particulier"
@@ -113,9 +142,9 @@ if ($company->id) {
}
// Personal informations
-$v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE");
-if ($adherent->birth) {
- $v->setBirthday($adherent->birth);
+$v->setPhoneNumber($object->phone_perso, "TYPE=HOME;VOICE");
+if ($object->birth) {
+ $v->setBirthday($object->birth);
}
$db->close();
diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index d94c8a3fffd..a97717412a9 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -93,7 +93,7 @@ print ' ';
// Show info setup module
print img_picto('', 'cog', 'class="paddingright"').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
-if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled
+if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled
$langs->load("errors");
$warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"');
print '
';
diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php
deleted file mode 100644
index 53b9233c130..00000000000
--- a/htdocs/api/admin/explorer.php
+++ /dev/null
@@ -1,216 +0,0 @@
-
- * Copyright (C) 2016 Laurent Destailleur
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * @deprecated Old explorer. Not using Swagger. See instead explorer in htdocs/api/index.php.
- */
-
-/**
- * \defgroup api Module DolibarrApi
- * \brief API loader
- * Search files htdocs//class/api_.class.php
- * \file htdocs/api/admin/explorer.php
- */
-
-use Luracast\Restler\Routes;
-
-require_once '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php';
-require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php';
-
-// Load translation files required by the page
-$langs->load("admin");
-
-
-/*
- * View
- */
-
-// Enable and test if module Api is enabled
-if (empty($conf->global->MAIN_MODULE_API)) {
- dol_syslog("Call Dolibarr API interfaces with module REST disabled");
- print $langs->trans("WarningModuleNotActive", 'Api').'.
';
- print $langs->trans("ToActivateModule");
- exit;
-}
-
-
-$api = new DolibarrApi($db);
-
-$api->r->addAPIClass('Luracast\\Restler\\Resources'); //this creates resources.json at API Root
-$api->r->setSupportedFormats('JsonFormat', 'XmlFormat');
-$api->r->addAuthenticationClass('DolibarrApiAccess', '');
-
-$listofapis = array();
-
-$modulesdir = dolGetModulesDirs();
-foreach ($modulesdir as $dir) {
- /*
- * Search available module
- */
- //dol_syslog("Scan directory ".$dir." for API modules");
-
- $handle = @opendir(dol_osencode($dir));
- if (is_resource($handle)) {
- while (($file = readdir($handle)) !== false) {
- if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) {
- $modulename = $reg[1];
-
- // Defined if module is enabled
- $enabled = true;
- $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename));
- //if ($part == 'propale') $part='propal';
- if ($module == 'societe') {
- $obj = 'thirdparty';
- }
- if ($module == 'categorie') {
- $part = 'categories';
- $obj = 'category';
- }
- if ($module == 'facture') {
- $part = 'compta/facture';
- $obj = 'facture';
- }
- if ($module == 'ficheinter') {
- $obj = 'fichinter';
- $part = 'fichinter';
- $module = 'fichinter';
- }
-
- if (empty($conf->$module->enabled)) {
- $enabled = false;
- }
-
- if ($enabled) {
- /*
- * If exists, load the API class for enable module
- *
- * Search files named api_