From 6c8c96934c902fe2f1d401e93cbdea23215749d0 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 31 Aug 2019 11:31:29 +0200 Subject: [PATCH] first commit Signed-off-by: Daniel Tartavel --- config.inc.php | 40 +++++++++++++++++++++++ db.class.php | 54 +++++++++++++++++++++++++++++++ entete_mail.php | 7 ++++ log.php | 31 ++++++++++++++++++ nconnector.php | 23 +++++++++++++ session_init.php | 5 +++ synchro dolibarr nextcloud.txt | 59 ++++++++++++++++++++++++++++++++++ 7 files changed, 219 insertions(+) create mode 100755 config.inc.php create mode 100644 db.class.php create mode 100644 entete_mail.php create mode 100644 log.php create mode 100755 nconnector.php create mode 100644 session_init.php create mode 100644 synchro dolibarr nextcloud.txt diff --git a/config.inc.php b/config.inc.php new file mode 100755 index 0000000..50198d3 --- /dev/null +++ b/config.inc.php @@ -0,0 +1,40 @@ + + diff --git a/db.class.php b/db.class.php new file mode 100644 index 0000000..bc64aae --- /dev/null +++ b/db.class.php @@ -0,0 +1,54 @@ +connect ) + { + $this->connect = new mysqli( $this->server, $this->user, $this->passwd, $this->database ); + if ( $this->connect->connect_errno ) + { + log_error( "Échec de la connexion : " . " => " . $this->connect->connect_error . "
" . __file__ . esp( 'ligne' ) . __line__); + return false; + } + } + return true; + } + + function close() + { + $this->connect->close(); + $this->connect = 0; + } + + function query( $string ) + { + if ( empty( $this->connect ) ) $this->open(); + + $this->result = $this->connect->query( $string ) ; + if ( $this->connect->error ) log_error( "Échec de la commande query" . " => ". $this->connect->error . "
" . __file__ . esp( 'ligne' ) . __line__ . "\n" . $string); + } + + function error() + { + print_r( $this ); + $this->error = $this->error; + return $this->error; + } +} + +?> diff --git a/entete_mail.php b/entete_mail.php new file mode 100644 index 0000000..d640173 --- /dev/null +++ b/entete_mail.php @@ -0,0 +1,7 @@ + diff --git a/log.php b/log.php new file mode 100644 index 0000000..7ec504e --- /dev/null +++ b/log.php @@ -0,0 +1,31 @@ + INFO, ALERT, ERROR +function log_write($log, $level=INFO) +{ + global $webmaster, $headers; + if ( $level == ALERT ) + { + mail( $webmaster, "Connecteur nextcloud pour dolibarr: Alerte", $log_mail, $headers ); + }elseif ( $level == ERROR ) + { + mail( $webmaster, "Connecteur nextcloud pour dolibarr: Erreur", $log_mail, $headers ); + } +} + +// $die = true -> execute die() +function log_error($log, $die=true) +{ + global $webmaster, $headers; + echo "$log
" . EOL; + log_write($log); + $log_err = 'erreur dans la requête' . "
" . "un rapport détaillé a été envoyé au webmaster"; + if ( $die ) + { + echo "\n"; + die( $log_err ); + } +} +?> diff --git a/nconnector.php b/nconnector.php new file mode 100755 index 0000000..1c301a3 --- /dev/null +++ b/nconnector.php @@ -0,0 +1,23 @@ +#!/usr/bin/php + +database = "dolibarr"; +$ncdb = new db(); +$ncdb->database = "nextcloud"; +$doldb->query("SELECT login FROM llx_adherents"); + +function esp( $s ) +{ + $s = " $s "; + return $s; +} + +var_print($doldb); +?> diff --git a/session_init.php b/session_init.php new file mode 100644 index 0000000..7c88686 --- /dev/null +++ b/session_init.php @@ -0,0 +1,5 @@ + diff --git a/synchro dolibarr nextcloud.txt b/synchro dolibarr nextcloud.txt new file mode 100644 index 0000000..41cef91 --- /dev/null +++ b/synchro dolibarr nextcloud.txt @@ -0,0 +1,59 @@ +synchro dolibarr nextcloud +Table oc_accounts +uid +data + +{ + "displayname": + { + "value":"[uid]", + "scope":"contacts", + "verified":"0" + }, + "address": + { + "value":"[adresse]", + "scope":"private", + "verified":"0" + }, + "website": + { + "value":"[website]", + "scope":"private", + "verified":"0" + }, + "email": + { + "value":"[email]", + "scope":"contacts","verified":"1" + }, + "avatar": + { + "scope":"contacts", + "verified":"0" + }, + "phone": + { + "value":"[telephone]", + "scope":"private", + "verified":"0" + }, + "twitter": + { + "value":"", + "scope":"private", + "verified":"0" + } +} + +Table oc_users +uid => llx_adherents.login +displayname => llx_adherents.firstname llx_adherents.lastname +password => "1|".llx_adherents.pass_crypted +uid_lower => llx_adherents.login en minuscule + + + +table oc_group_user +uid (table oc_users) => llx_adherents.login +gid (membres, contributeur) =>llx_adherents.fk_adherent_type 2 => membres 3 =>contributeurs