.
+
diff --git a/plugins/Ldap_Login/README.md b/sources/extra_files/app/plugins/Ldap_Login/README.md
similarity index 97%
rename from plugins/Ldap_Login/README.md
rename to sources/extra_files/app/plugins/Ldap_Login/README.md
index 1439b2d..1ae2970 100644
--- a/plugins/Ldap_Login/README.md
+++ b/sources/extra_files/app/plugins/Ldap_Login/README.md
@@ -1,20 +1,20 @@
-# Ldap_Login
-LDAP authentication plugin for piwigo with user-group support
-
-## Exmaple-Config for an M$-AD:
-
-#### LDAP-Serververbindung
-**LDAP-Server**: srv.emxample.com
-(x) **Secure connection** _(--> remember that the LDAPS-Server certificate must be imported on your piwigo server)_
-**LDAP-Port**: 636
-
-#### LDAP Attribute
-**Base DN wo LDAP-Benutzer gefunden werden sollen (zB.: ou=users,dc=example,dc=com):**: cn=Users,dc=example,dc=com
-**Attribute entsprechend des Benutzernamens**: sAMACcountName
-**DN of group for membership-check (memberOf)**: dn=piwigo_users,cn=Users,dc=example,dc=com
-
-#### LDAP-Verbindungsreferenzen
-**Bind DN im LDAP-Style (zB.: cn=admin,dc=example,dc=com).**: cn=binduser,cn=Users,dc=exmaple,dc=com
-**Bind passwort**: mysecret123
-
-_--> SAVE and enjoy :)_
+# Ldap_Login
+LDAP authentication plugin for piwigo with user-group support
+
+## Exmaple-Config for an M$-AD:
+
+#### LDAP-Serververbindung
+**LDAP-Server**: srv.emxample.com
+(x) **Secure connection** _(--> remember that the LDAPS-Server certificate must be imported on your piwigo server)_
+**LDAP-Port**: 636
+
+#### LDAP Attribute
+**Base DN wo LDAP-Benutzer gefunden werden sollen (zB.: ou=users,dc=example,dc=com):**: cn=Users,dc=example,dc=com
+**Attribute entsprechend des Benutzernamens**: sAMACcountName
+**DN of group for membership-check (memberOf)**: dn=piwigo_users,cn=Users,dc=example,dc=com
+
+#### LDAP-Verbindungsreferenzen
+**Bind DN im LDAP-Style (zB.: cn=admin,dc=example,dc=com).**: cn=binduser,cn=Users,dc=exmaple,dc=com
+**Bind passwort**: mysecret123
+
+_--> SAVE and enjoy :)_
diff --git a/plugins/Ldap_Login/TODO b/sources/extra_files/app/plugins/Ldap_Login/TODO
similarity index 98%
rename from plugins/Ldap_Login/TODO
rename to sources/extra_files/app/plugins/Ldap_Login/TODO
index 0bb46f7..0ed4ec8 100644
--- a/plugins/Ldap_Login/TODO
+++ b/sources/extra_files/app/plugins/Ldap_Login/TODO
@@ -1,30 +1,30 @@
-TODO :
-auto config (may use ajax): fill in the settings, then the page guess the next settings.
-Ex : after filled the host address, the page guess the base dn. The last to guess is the users OU.
- Users OU can come with a select field, as the ld_attr.
-
-correct init plugin
-if mail isn't furnished ?
-create common piwigo users upon successfull ldap connection when piwigo user doesn't exist => done !
- Groups : users may belong to ldap group to allow connection
- Groups : users belonging to «sudo» or «admin» ldap group become piwigo admin when created this way
- fetching attributes from ldap (mail…).
-
-config of the previous one (need tabs)
-config page to render better
-
-########
-
-à faire :
-initialisation du plugin correcte
-qu'est-ce qu'on fait si le mail est pas fourni ?
-configuration automatique (javascript/ajax probable): entrée des paramètres et la page recherche le paramètre suivant si possible.
-Ex : adresse du serveur -> la page trouve toute seule la racine ldap, reste plus que la OU des utilisateurs (qu'on peut selectionner via une liste déroulante).
- l'attribut d'identification peut être selectionné par une liste déroulante.
-
-creation d'un utilisateur piwigo suite à une authentification ldap quand l'utilisateur n'existe pas. => fait !
- question de groups : les utilisateurs membres du groupe ldap «sudo» ou autre pourraient automatiquement être admins piwigo
- question de groupe : les utilisateurs devraient appartenir à un groupe ldap pour se connecter…
- récuperer les attributs dans le ldap (mail…).
-
-page de config à peaufiner, option précédente à intégrer dans un onglet.
+TODO :
+auto config (may use ajax): fill in the settings, then the page guess the next settings.
+Ex : after filled the host address, the page guess the base dn. The last to guess is the users OU.
+ Users OU can come with a select field, as the ld_attr.
+
+correct init plugin
+if mail isn't furnished ?
+create common piwigo users upon successfull ldap connection when piwigo user doesn't exist => done !
+ Groups : users may belong to ldap group to allow connection
+ Groups : users belonging to «sudo» or «admin» ldap group become piwigo admin when created this way
+ fetching attributes from ldap (mail…).
+
+config of the previous one (need tabs)
+config page to render better
+
+########
+
+à faire :
+initialisation du plugin correcte
+qu'est-ce qu'on fait si le mail est pas fourni ?
+configuration automatique (javascript/ajax probable): entrée des paramètres et la page recherche le paramètre suivant si possible.
+Ex : adresse du serveur -> la page trouve toute seule la racine ldap, reste plus que la OU des utilisateurs (qu'on peut selectionner via une liste déroulante).
+ l'attribut d'identification peut être selectionné par une liste déroulante.
+
+creation d'un utilisateur piwigo suite à une authentification ldap quand l'utilisateur n'existe pas. => fait !
+ question de groups : les utilisateurs membres du groupe ldap «sudo» ou autre pourraient automatiquement être admins piwigo
+ question de groupe : les utilisateurs devraient appartenir à un groupe ldap pour se connecter…
+ récuperer les attributs dans le ldap (mail…).
+
+page de config à peaufiner, option précédente à intégrer dans un onglet.
diff --git a/plugins/Ldap_Login/admin.php b/sources/extra_files/app/plugins/Ldap_Login/admin.php
similarity index 100%
rename from plugins/Ldap_Login/admin.php
rename to sources/extra_files/app/plugins/Ldap_Login/admin.php
diff --git a/plugins/Ldap_Login/admin/configuration.php b/sources/extra_files/app/plugins/Ldap_Login/admin/configuration.php
similarity index 97%
rename from plugins/Ldap_Login/admin/configuration.php
rename to sources/extra_files/app/plugins/Ldap_Login/admin/configuration.php
index 5410454..d8cc188 100644
--- a/plugins/Ldap_Login/admin/configuration.php
+++ b/sources/extra_files/app/plugins/Ldap_Login/admin/configuration.php
@@ -1,74 +1,74 @@
-set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/configuration.tpl') );
-$template->assign(
- array(
- 'PLUGIN_ACTION' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration',
- 'PLUGIN_CHECK' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration',
- ));
-
-$me = new Ldap();
-$me->load_config();
-//$me = get_plugin_data($plugin_id);
-
-// Save LDAP configuration when submitted
-if (isset($_POST['save'])){
- $me->config['host'] = $_POST['HOST'];
- $me->config['basedn'] = $_POST['BASEDN'];
- $me->config['port'] = $_POST['PORT'];
- $me->config['ld_attr'] = $_POST['LD_ATTR'];
- $me->config['ld_group'] = $_POST['LD_GROUP'];
- $me->config['ld_binddn'] = $_POST['LD_BINDDN'];
- $me->config['ld_bindpw'] = $_POST['LD_BINDPW'];
-
- if (isset($_POST['LD_USE_SSL'])){
- $me->config['ld_use_ssl'] = True;
- } else {
- $me->config['ld_use_ssl'] = False;
- }
-
- $me->save_config();
-}
-
-// Checki LDAP configuration
-$me->ldap_conn();
-if (isset($_POST['check_ldap'])){
- //$me->write_log("[function]> admin");
- //$check = $me->ldap_name($_POST['USERNAME']);
- $username = $me->ldap_search_dn($_POST['USERNAME']);
- //$me->write_log("[admin]> bind=".$username);
- $error=$me->check_ldap();
- if($error==1 && $username) {
- if ($me->ldap_bind_as($username,$_POST['PASSWORD'])){
- if($me->check_ldap_group_membership($username,$_POST['USERNAME'])){
- $template->assign('LD_CHECK_LDAP','Configuration LDAP OK : '.$username.'
');
- } else {
- $template->assign('LD_CHECK_LDAP','Credentials OK, Check GroupMembership for: '.$username.'
');
- }
- }
- else {
- $template->assign('LD_CHECK_LDAP',' Binding OK, but check credentials on server '.$me->config['uri'].' for user '.$username.'
');
- }
- } elseif($error==1 && !$username){
- $template->assign('LD_CHECK_LDAP','Error : Binding OK, but no valid DN found on server '.$me->config['uri'].' for user '.$_POST['USERNAME'].'
');
- } elseif($error && $username){
- $template->assign('LD_CHECK_LDAP','Error : Binding OK, but check credentials on '.$me->config['uri'].' for user '.$_POST['USERNAME'].'
');
- } else {
- $template->assign('LD_CHECK_LDAP','Error : '.$error.' for binding on server '.$me->config['uri'].' for user '.$_POST['USERNAME'].', check your binding!
');
- }
-}
-
-// And build up the form with the new values
-$template->assign('HOST', $me->config['host']);
-$template->assign('BASEDN', $me->config['basedn']); // racine !
-$template->assign('PORT', $me->config['port']);
-$template->assign('LD_ATTR', $me->config['ld_attr']);
-$template->assign('LD_GROUP', $me->config['ld_group']);
-$template->assign('LD_USE_SSL', $me->config['ld_use_ssl']);
-$template->assign('LD_BINDPW', $me->config['ld_bindpw']);
-$template->assign('LD_BINDDN', $me->config['ld_binddn']);
-
-$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
-?>
+set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/configuration.tpl') );
+$template->assign(
+ array(
+ 'PLUGIN_ACTION' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration',
+ 'PLUGIN_CHECK' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration',
+ ));
+
+$me = new Ldap();
+$me->load_config();
+//$me = get_plugin_data($plugin_id);
+
+// Save LDAP configuration when submitted
+if (isset($_POST['save'])){
+ $me->config['host'] = $_POST['HOST'];
+ $me->config['basedn'] = $_POST['BASEDN'];
+ $me->config['port'] = $_POST['PORT'];
+ $me->config['ld_attr'] = $_POST['LD_ATTR'];
+ $me->config['ld_group'] = $_POST['LD_GROUP'];
+ $me->config['ld_binddn'] = $_POST['LD_BINDDN'];
+ $me->config['ld_bindpw'] = $_POST['LD_BINDPW'];
+
+ if (isset($_POST['LD_USE_SSL'])){
+ $me->config['ld_use_ssl'] = True;
+ } else {
+ $me->config['ld_use_ssl'] = False;
+ }
+
+ $me->save_config();
+}
+
+// Checki LDAP configuration
+$me->ldap_conn();
+if (isset($_POST['check_ldap'])){
+ //$me->write_log("[function]> admin");
+ //$check = $me->ldap_name($_POST['USERNAME']);
+ $username = $me->ldap_search_dn($_POST['USERNAME']);
+ //$me->write_log("[admin]> bind=".$username);
+ $error=$me->check_ldap();
+ if($error==1 && $username) {
+ if ($me->ldap_bind_as($username,$_POST['PASSWORD'])){
+ if($me->check_ldap_group_membership($username,$_POST['USERNAME'])){
+ $template->assign('LD_CHECK_LDAP','Configuration LDAP OK : '.$username.'
');
+ } else {
+ $template->assign('LD_CHECK_LDAP','Credentials OK, Check GroupMembership for: '.$username.'
');
+ }
+ }
+ else {
+ $template->assign('LD_CHECK_LDAP',' Binding OK, but check credentials on server '.$me->config['uri'].' for user '.$username.'
');
+ }
+ } elseif($error==1 && !$username){
+ $template->assign('LD_CHECK_LDAP','Error : Binding OK, but no valid DN found on server '.$me->config['uri'].' for user '.$_POST['USERNAME'].'
');
+ } elseif($error && $username){
+ $template->assign('LD_CHECK_LDAP','Error : Binding OK, but check credentials on '.$me->config['uri'].' for user '.$_POST['USERNAME'].'
');
+ } else {
+ $template->assign('LD_CHECK_LDAP','Error : '.$error.' for binding on server '.$me->config['uri'].' for user '.$_POST['USERNAME'].', check your binding!
');
+ }
+}
+
+// And build up the form with the new values
+$template->assign('HOST', $me->config['host']);
+$template->assign('BASEDN', $me->config['basedn']); // racine !
+$template->assign('PORT', $me->config['port']);
+$template->assign('LD_ATTR', $me->config['ld_attr']);
+$template->assign('LD_GROUP', $me->config['ld_group']);
+$template->assign('LD_USE_SSL', $me->config['ld_use_ssl']);
+$template->assign('LD_BINDPW', $me->config['ld_bindpw']);
+$template->assign('LD_BINDDN', $me->config['ld_binddn']);
+
+$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
+?>
diff --git a/plugins/Ldap_Login/admin/configuration.tpl b/sources/extra_files/app/plugins/Ldap_Login/admin/configuration.tpl
similarity index 96%
rename from plugins/Ldap_Login/admin/configuration.tpl
rename to sources/extra_files/app/plugins/Ldap_Login/admin/configuration.tpl
index 072613a..4196166 100644
--- a/plugins/Ldap_Login/admin/configuration.tpl
+++ b/sources/extra_files/app/plugins/Ldap_Login/admin/configuration.tpl
@@ -1,114 +1,114 @@
-{'Ldap_Login Plugin'|@translate}
-
-
-
-
{'All LDAP users can use their ldap password everywhere on piwigo if needed.'|@translate}
-
-
-
-
-
+{'Ldap_Login Plugin'|@translate}
+
+
+
+
{'All LDAP users can use their ldap password everywhere on piwigo if needed.'|@translate}
+
+
+
+
+
diff --git a/plugins/Ldap_Login/admin/index.php b/sources/extra_files/app/plugins/Ldap_Login/admin/index.php
similarity index 100%
rename from plugins/Ldap_Login/admin/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/admin/index.php
diff --git a/plugins/Ldap_Login/admin/ldap_login_plugin_admin.php b/sources/extra_files/app/plugins/Ldap_Login/admin/ldap_login_plugin_admin.php
similarity index 100%
rename from plugins/Ldap_Login/admin/ldap_login_plugin_admin.php
rename to sources/extra_files/app/plugins/Ldap_Login/admin/ldap_login_plugin_admin.php
diff --git a/plugins/Ldap_Login/admin/ldap_login_plugin_admin.tpl b/sources/extra_files/app/plugins/Ldap_Login/admin/ldap_login_plugin_admin.tpl
similarity index 100%
rename from plugins/Ldap_Login/admin/ldap_login_plugin_admin.tpl
rename to sources/extra_files/app/plugins/Ldap_Login/admin/ldap_login_plugin_admin.tpl
diff --git a/plugins/Ldap_Login/admin/newusers.php b/sources/extra_files/app/plugins/Ldap_Login/admin/newusers.php
similarity index 96%
rename from plugins/Ldap_Login/admin/newusers.php
rename to sources/extra_files/app/plugins/Ldap_Login/admin/newusers.php
index 35d0aa6..8555e4f 100644
--- a/plugins/Ldap_Login/admin/newusers.php
+++ b/sources/extra_files/app/plugins/Ldap_Login/admin/newusers.php
@@ -1,50 +1,50 @@
-set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/newusers.tpl') );
-$template->assign(
- array(
- 'PLUGIN_NEWUSERS' => get_root_url().'admin.php?page=plugin-Ldap_Login-newusers',
- ));
-
-$me = new Ldap();
-$me->load_config();
-//$me = get_plugin_data($plugin_id);
-
-// Save LDAP configuration when submitted
-if (isset($_POST['save'])){
-
- if (isset($_POST['ALLOW_NEWUSERS'])){
- $me->config['allow_newusers'] = True;
- } else {
- $me->config['allow_newusers'] = False;
- }
-
- if (isset($_POST['ADVERTISE_ADMINS'])){
- $me->config['advertise_admin_new_ldapuser'] = True;
- } else {
- $me->config['advertise_admin_new_ldapuser'] = False;
- }
-
- if (isset($_POST['SEND_CASUAL_MAIL'])){
- $me->config['send_password_by_mail_ldap'] = True;
- } else {
- $me->config['send_password_by_mail_ldap'] = False;
-
- $me->save_config();
-}
-
-// do we allow to create new piwigo users in case of auth along the ldap ?
-// does he have to belong an ldap group ?
-// does ldap groups give some power ?
-// what do we do when there's no mail in the ldap ?
-// do we send mail to admins ?
-
-// And build up the form with the new values
-$template->assign('ALLOW_NEWUSERS', $me->config['allow_newusers']);
-$template->assign('ADVERTISE_ADMINS', $me->config['advertise_admin_new_ldapuser']);
-$template->assign('SEND_CASUAL_MAIL', $me->config['send_password_by_mail_ldap']);
-
-$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
-?>
+set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/newusers.tpl') );
+$template->assign(
+ array(
+ 'PLUGIN_NEWUSERS' => get_root_url().'admin.php?page=plugin-Ldap_Login-newusers',
+ ));
+
+$me = new Ldap();
+$me->load_config();
+//$me = get_plugin_data($plugin_id);
+
+// Save LDAP configuration when submitted
+if (isset($_POST['save'])){
+
+ if (isset($_POST['ALLOW_NEWUSERS'])){
+ $me->config['allow_newusers'] = True;
+ } else {
+ $me->config['allow_newusers'] = False;
+ }
+
+ if (isset($_POST['ADVERTISE_ADMINS'])){
+ $me->config['advertise_admin_new_ldapuser'] = True;
+ } else {
+ $me->config['advertise_admin_new_ldapuser'] = False;
+ }
+
+ if (isset($_POST['SEND_CASUAL_MAIL'])){
+ $me->config['send_password_by_mail_ldap'] = True;
+ } else {
+ $me->config['send_password_by_mail_ldap'] = False;
+
+ $me->save_config();
+}
+
+// do we allow to create new piwigo users in case of auth along the ldap ?
+// does he have to belong an ldap group ?
+// does ldap groups give some power ?
+// what do we do when there's no mail in the ldap ?
+// do we send mail to admins ?
+
+// And build up the form with the new values
+$template->assign('ALLOW_NEWUSERS', $me->config['allow_newusers']);
+$template->assign('ADVERTISE_ADMINS', $me->config['advertise_admin_new_ldapuser']);
+$template->assign('SEND_CASUAL_MAIL', $me->config['send_password_by_mail_ldap']);
+
+$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
+?>
diff --git a/plugins/Ldap_Login/admin/newusers.tpl b/sources/extra_files/app/plugins/Ldap_Login/admin/newusers.tpl
similarity index 100%
rename from plugins/Ldap_Login/admin/newusers.tpl
rename to sources/extra_files/app/plugins/Ldap_Login/admin/newusers.tpl
diff --git a/plugins/Ldap_Login/class.ldap.php b/sources/extra_files/app/plugins/Ldap_Login/class.ldap.php
similarity index 97%
rename from plugins/Ldap_Login/class.ldap.php
rename to sources/extra_files/app/plugins/Ldap_Login/class.ldap.php
index efe6192..8026f1e 100644
--- a/plugins/Ldap_Login/class.ldap.php
+++ b/sources/extra_files/app/plugins/Ldap_Login/class.ldap.php
@@ -1,263 +1,263 @@
-0){
- @file_put_contents('/var/log/ldap_login.log',$message."\n",FILE_APPEND);
- }
- }
-
- /**
- * check ldap configuration
- *
- * Dans le cas ou l'acces au ldap est anonyme il faut impérativement faire une recherche
- * pour tester la connection.
- *
- * When OpenLDAP 2.x.x is used, ldap_connect() will always return a resource as it does not actually connect
- * but just initializes the connecting parameters. The actual connect happens with the next calls
- * to ldap_* funcs, usually with ldap_bind().
- */
- public function check_ldap(){
- //$this->write_log("[function]> check_ldap");
- if (!$this->ldap_conn()) {
- return $this->getErrorString();
- }
-
- // test du compte root si renseigné
- if (!empty($this->config['ld_binddn']) && !empty($this->config['ld_bindpw'])){ // if empty ld_binddn, anonymous search
- // authentication with rootdn and rootpw for search
- if (!$this->ldap_bind_as($this->config['ld_binddn'],$this->config['ld_bindpw'])){
- return $this->getErrorString();
- }
- } else {
- // sinon recherche du basedn (cf comportement ldap_connect avec OpenLDAP)
- if (!$this->ldap_check_basedn()){ // search userdn
- return $this->getErrorString();
- }
- }
- return true;
- }
-
- public function load_default_config(){
- $this->config['host'] = 'localhost';
- $this->config['basedn'] = 'ou=people,dc=example,dc=com'; // racine !
- $this->config['port'] = ''; // if port is empty, I count on the software to care of it !
- $this->config['ld_attr'] = 'uid';
- $this->config['ld_group'] = 'cn=myPiwigoLDAPGroup,cn=users,dc=example,dc=com';
- $this->config['ld_use_ssl'] = False;
- $this->config['ld_bindpw'] ='';
- $this->config['ld_binddn'] ='';
-
- $this->config['allow_newusers'] = False;
- $this->config['advertise_admin_new_ldapuser'] = False;
- $this->config['send_password_by_mail_ldap'] = False;
- }
-
- function load_config() {
- // first we load the base config
- $conf_file = @file_get_contents( LDAP_LOGIN_PATH.'data.dat' );
- if ($conf_file!==false)
- {
- $this->config = unserialize($conf_file);
- }
- }
-
- function save_config()
- {
- $file = fopen( LDAP_LOGIN_PATH.'/data.dat', 'w' );
- fwrite($file, serialize($this->config) );
- fclose( $file );
- }
-
- function ldap_admin_menu($menu)
- {
- array_push($menu,
- array(
- 'NAME' => 'Ldap Login',
- 'URL' => get_admin_plugin_menu_link(LDAP_LOGIN_PATH.'/admin.php') )
- );
- return $menu;
- }
-
- // LDAP connection public
- public function ldap_conn(){
- if( $this->cnx = $this->make_ldap_conn() ){
- return true;
- }
- return false;
- }
-
- // LDAP connection private
- private function make_ldap_conn(){
- if ($this->config['ld_use_ssl'] == 1){
- if (empty($this->config['port'])){
- $this->config['uri'] = 'ldaps://'.$this->config['host'];
- }
- else {
- $this->config['uri'] = 'ldaps://'.$this->config['host'].':'.$this->config['port'];
- }
- }
-
- // now, it's without ssl
- else {
- if (empty($this->config['port'])){
- $this->config['uri'] = 'ldap://'.$this->config['host'];
- }
- else {
- $this->config['uri'] = 'ldap://'.$this->config['host'].':'.$this->config['port'];
- }
- }
-
- if ($conn = @ldap_connect($this->config['uri'])){
- @ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3); // LDAPv3 if possible
- return $conn;
- }
- return false;
- }
-
- // return ldap error
- public function getErrorString(){
- return ldap_err2str(ldap_errno($this->cnx));
- }
-
- // authentication public
- public function ldap_bind_as($user,$user_passwd){
- $this->write_log("[function]> ldap_bind_as");
- $this->write_log("[ldap_bind_as]> ".$user.",".$user_passwd);
- if($this->make_ldap_bind_as($this->cnx,$user,$user_passwd)){
- $this->write_log("[ldap_bind_as]> Bind was successfull");
- return true;
- }
- return false;
- }
-
- // authentication private
- private function make_ldap_bind_as($conn,$user,$user_passwd){
- $this->write_log("[function]> make_ldap_bind_as");
- $this->write_log("[make_ldap_bind_as]> \$conn,".$user.",".$user_passwd);
- $bind = @ldap_bind($conn,$user,$user_passwd);
- if($bind){
- return true;
- }
- return false;
- }
-
- public function ldap_get_email($user_dn){
- $sr=@ldap_read($this->cnx, $user_dn, "(objectclass=*)", array('mail'));
- $entry = @ldap_get_entries($this->cnx, $sr);
-
- if (!empty($entry[0]['mail'])) {
- return $entry[0]['mail'][0];
- }
- return null;
- }
-
- public function ldap_get_user_email($username) {
- return $this->ldap_email($this->ldap_get_dn($username));
- }
-
- // return userdn (and username) for authentication
- public function ldap_search_dn($value_to_search){
- $this->write_log("[function]> ldap_search_dn(".$value_to_search.")");
- $filter = '(&(objectClass=person)('.$this->config['ld_attr'].'='.$value_to_search.'))';
-
- // connection handling
- $this->write_log("[ldap_search_dn]> Connecting to server");
- //if(!$bcnx = $this->make_ldap_conn()){
- if(!$this->cnx){
- $this->write_log("[ldap_search_dn]> Cannot connect to server!");
- return false;
- }
- $this->write_log("[ldap_search_dn]> make_ldap_bind_as(\$this->cnx,".$this->config['ld_binddn'].",".$this->config['ld_bindpw'].")");
- //if(!$this->make_ldap_bind_as($bcnx,$this->config['ld_binddn'],$this->config['ld_bindpw'])){
- if(!$this->make_ldap_bind_as($this->cnx,$this->config['ld_binddn'],$this->config['ld_bindpw'])){
- $this->write_log("[ldap_search_dn]> Cannot bind to server!");
- return false;
- }
-
- $this->write_log("[ldap_search_dn]> @ldap_search(\$this->cnx,".$this->config['basedn'].",".$filter.",array('dn'),0,1)");
-
- // look for our attribute and get always the DN for login
- //if($search = ldap_search($bcnx,$this->config['basedn'],$filter,array('dn'),0,1)){
- if($search = @ldap_search($this->cnx,$this->config['basedn'],$filter,array('dn'),0,1)){
- $this->write_log("[ldap_search_dn]> ldap_search successfull");
- //$entry = ldap_get_entries($bcnx, $search);
- $entry = @ldap_get_entries($this->cnx, $search);
- //if (!empty($entry[0][strtolower($this->config['ld_attr'])][0])) {
- if (!empty($entry[0]["dn"])) {
- $this->write_log("[ldap_search_dn]> RESULT: ".$entry[0]["dn"]);
- //@ldap_unbind($bcnx);
- return $entry[0]["dn"];
- }
- $this->write_log("[ldap_search_dn]> result is empty!");
- return false;
- }
- $this->write_log("[ldap_search_dn]> ldap_search NOT successfull:");
- return false;
- }
-
- // look for LDAP group membership
- public function check_ldap_group_membership($user_dn, $user_login){
- $group_dn = $this->config['ld_group'];
- $this->write_log("[function]> check_ldap_group_membership('$user_dn', '$group_dn', '$user_login')");
- //if no group specified return true
- if(!$group_dn){
- return true;
- }
- if(!$this->cnx){
- $this->write_log("[check_ldap_group_membership]> Cannot connect to server!");
- return false;
- }
- if(!$this->make_ldap_bind_as($this->cnx,$this->config['ld_binddn'],$this->config['ld_bindpw'])){
- $this->write_log("[check_ldap_group_membership]> Cannot bind to server!");
- return false;
- }
- // search for all member and memberUid attributes for a group_dn
- $search_filter = "(|(&(objectClass=posixGroup)(memberUid=$user_login))(&(objectClass=group)(member=$user_dn)))";
- $this->write_log("[check_ldap_group_membership]> @ldap_search(\$this->cnx,'$group_dn', '$search_filter', array('memberOf'),0,1)");
- if($search = @ldap_search($this->cnx, $group_dn, $search_filter, array("dn"),0,1)){
- $entry = @ldap_get_entries($this->cnx, $search);
- //check if there are dn-attributes
- if (!empty($entry[0]["dn"])) {
- $this->write_log("[check_ldap_group_membership]> match found: ".$entry[0]["dn"]);
- return true;
- } else {
- $this->write_log("[check_ldap_group_membership]> no group membership for user found for given group and user, check on ldap side");
- }
- } else {
- $this->write_log("[check_ldap_group_membership]> ldap_search NOT successfull: " .$this->getErrorString());
- }
- $this->write_log("[check_ldap_group_membership]> No matching groups found for given group_dn: ". $group_dn);
- return false;
- }
-
-
- public function getAttr() {
- $search = @ldap_read($this->cnx, "cn=subschema", "(objectClass=*)", array('*', 'subschemasubentry'));
- $entries = @ldap_get_entries($this->cnx, $search);
- echo count($entries);
- }
-
- public function getRootDse() {
- $search = @ldap_read($this->cnx, NULL, 'objectClass=*', array("*", "+"));
- $entries = @ldap_get_entries($this->cnx, $search);
- return $entries[0];
- }
-
-
- public function ldap_check_basedn(){
- if ($read = @ldap_read($this->cnx,$this->config['basedn'],'(objectClass=*)',array('dn'))){
- $entry = @ldap_get_entries($this->cnx, $read);
- if (!empty($entry[0]['dn'])) {
- return true;
- }
- }
- return false;
- }
-}
-?>
+0){
+ @file_put_contents('/var/log/ldap_login.log',$message."\n",FILE_APPEND);
+ }
+ }
+
+ /**
+ * check ldap configuration
+ *
+ * Dans le cas ou l'acces au ldap est anonyme il faut impérativement faire une recherche
+ * pour tester la connection.
+ *
+ * When OpenLDAP 2.x.x is used, ldap_connect() will always return a resource as it does not actually connect
+ * but just initializes the connecting parameters. The actual connect happens with the next calls
+ * to ldap_* funcs, usually with ldap_bind().
+ */
+ public function check_ldap(){
+ //$this->write_log("[function]> check_ldap");
+ if (!$this->ldap_conn()) {
+ return $this->getErrorString();
+ }
+
+ // test du compte root si renseigné
+ if (!empty($this->config['ld_binddn']) && !empty($this->config['ld_bindpw'])){ // if empty ld_binddn, anonymous search
+ // authentication with rootdn and rootpw for search
+ if (!$this->ldap_bind_as($this->config['ld_binddn'],$this->config['ld_bindpw'])){
+ return $this->getErrorString();
+ }
+ } else {
+ // sinon recherche du basedn (cf comportement ldap_connect avec OpenLDAP)
+ if (!$this->ldap_check_basedn()){ // search userdn
+ return $this->getErrorString();
+ }
+ }
+ return true;
+ }
+
+ public function load_default_config(){
+ $this->config['host'] = 'localhost';
+ $this->config['basedn'] = 'ou=people,dc=example,dc=com'; // racine !
+ $this->config['port'] = ''; // if port is empty, I count on the software to care of it !
+ $this->config['ld_attr'] = 'uid';
+ $this->config['ld_group'] = 'cn=myPiwigoLDAPGroup,cn=users,dc=example,dc=com';
+ $this->config['ld_use_ssl'] = False;
+ $this->config['ld_bindpw'] ='';
+ $this->config['ld_binddn'] ='';
+
+ $this->config['allow_newusers'] = False;
+ $this->config['advertise_admin_new_ldapuser'] = False;
+ $this->config['send_password_by_mail_ldap'] = False;
+ }
+
+ function load_config() {
+ // first we load the base config
+ $conf_file = @file_get_contents( LDAP_LOGIN_PATH.'data.dat' );
+ if ($conf_file!==false)
+ {
+ $this->config = unserialize($conf_file);
+ }
+ }
+
+ function save_config()
+ {
+ $file = fopen( LDAP_LOGIN_PATH.'/data.dat', 'w' );
+ fwrite($file, serialize($this->config) );
+ fclose( $file );
+ }
+
+ function ldap_admin_menu($menu)
+ {
+ array_push($menu,
+ array(
+ 'NAME' => 'Ldap Login',
+ 'URL' => get_admin_plugin_menu_link(LDAP_LOGIN_PATH.'/admin.php') )
+ );
+ return $menu;
+ }
+
+ // LDAP connection public
+ public function ldap_conn(){
+ if( $this->cnx = $this->make_ldap_conn() ){
+ return true;
+ }
+ return false;
+ }
+
+ // LDAP connection private
+ private function make_ldap_conn(){
+ if ($this->config['ld_use_ssl'] == 1){
+ if (empty($this->config['port'])){
+ $this->config['uri'] = 'ldaps://'.$this->config['host'];
+ }
+ else {
+ $this->config['uri'] = 'ldaps://'.$this->config['host'].':'.$this->config['port'];
+ }
+ }
+
+ // now, it's without ssl
+ else {
+ if (empty($this->config['port'])){
+ $this->config['uri'] = 'ldap://'.$this->config['host'];
+ }
+ else {
+ $this->config['uri'] = 'ldap://'.$this->config['host'].':'.$this->config['port'];
+ }
+ }
+
+ if ($conn = @ldap_connect($this->config['uri'])){
+ @ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3); // LDAPv3 if possible
+ return $conn;
+ }
+ return false;
+ }
+
+ // return ldap error
+ public function getErrorString(){
+ return ldap_err2str(ldap_errno($this->cnx));
+ }
+
+ // authentication public
+ public function ldap_bind_as($user,$user_passwd){
+ $this->write_log("[function]> ldap_bind_as");
+ $this->write_log("[ldap_bind_as]> ".$user.",".$user_passwd);
+ if($this->make_ldap_bind_as($this->cnx,$user,$user_passwd)){
+ $this->write_log("[ldap_bind_as]> Bind was successfull");
+ return true;
+ }
+ return false;
+ }
+
+ // authentication private
+ private function make_ldap_bind_as($conn,$user,$user_passwd){
+ $this->write_log("[function]> make_ldap_bind_as");
+ $this->write_log("[make_ldap_bind_as]> \$conn,".$user.",".$user_passwd);
+ $bind = @ldap_bind($conn,$user,$user_passwd);
+ if($bind){
+ return true;
+ }
+ return false;
+ }
+
+ public function ldap_get_email($user_dn){
+ $sr=@ldap_read($this->cnx, $user_dn, "(objectclass=*)", array('mail'));
+ $entry = @ldap_get_entries($this->cnx, $sr);
+
+ if (!empty($entry[0]['mail'])) {
+ return $entry[0]['mail'][0];
+ }
+ return null;
+ }
+
+ public function ldap_get_user_email($username) {
+ return $this->ldap_email($this->ldap_get_dn($username));
+ }
+
+ // return userdn (and username) for authentication
+ public function ldap_search_dn($value_to_search){
+ $this->write_log("[function]> ldap_search_dn(".$value_to_search.")");
+ $filter = '(&(objectClass=person)('.$this->config['ld_attr'].'='.$value_to_search.'))';
+
+ // connection handling
+ $this->write_log("[ldap_search_dn]> Connecting to server");
+ //if(!$bcnx = $this->make_ldap_conn()){
+ if(!$this->cnx){
+ $this->write_log("[ldap_search_dn]> Cannot connect to server!");
+ return false;
+ }
+ $this->write_log("[ldap_search_dn]> make_ldap_bind_as(\$this->cnx,".$this->config['ld_binddn'].",".$this->config['ld_bindpw'].")");
+ //if(!$this->make_ldap_bind_as($bcnx,$this->config['ld_binddn'],$this->config['ld_bindpw'])){
+ if(!$this->make_ldap_bind_as($this->cnx,$this->config['ld_binddn'],$this->config['ld_bindpw'])){
+ $this->write_log("[ldap_search_dn]> Cannot bind to server!");
+ return false;
+ }
+
+ $this->write_log("[ldap_search_dn]> @ldap_search(\$this->cnx,".$this->config['basedn'].",".$filter.",array('dn'),0,1)");
+
+ // look for our attribute and get always the DN for login
+ //if($search = ldap_search($bcnx,$this->config['basedn'],$filter,array('dn'),0,1)){
+ if($search = @ldap_search($this->cnx,$this->config['basedn'],$filter,array('dn'),0,1)){
+ $this->write_log("[ldap_search_dn]> ldap_search successfull");
+ //$entry = ldap_get_entries($bcnx, $search);
+ $entry = @ldap_get_entries($this->cnx, $search);
+ //if (!empty($entry[0][strtolower($this->config['ld_attr'])][0])) {
+ if (!empty($entry[0]["dn"])) {
+ $this->write_log("[ldap_search_dn]> RESULT: ".$entry[0]["dn"]);
+ //@ldap_unbind($bcnx);
+ return $entry[0]["dn"];
+ }
+ $this->write_log("[ldap_search_dn]> result is empty!");
+ return false;
+ }
+ $this->write_log("[ldap_search_dn]> ldap_search NOT successfull:");
+ return false;
+ }
+
+ // look for LDAP group membership
+ public function check_ldap_group_membership($user_dn, $user_login){
+ $group_dn = $this->config['ld_group'];
+ $this->write_log("[function]> check_ldap_group_membership('$user_dn', '$group_dn', '$user_login')");
+ //if no group specified return true
+ if(!$group_dn){
+ return true;
+ }
+ if(!$this->cnx){
+ $this->write_log("[check_ldap_group_membership]> Cannot connect to server!");
+ return false;
+ }
+ if(!$this->make_ldap_bind_as($this->cnx,$this->config['ld_binddn'],$this->config['ld_bindpw'])){
+ $this->write_log("[check_ldap_group_membership]> Cannot bind to server!");
+ return false;
+ }
+ // search for all member and memberUid attributes for a group_dn
+ $search_filter = "(|(&(objectClass=posixGroup)(memberUid=$user_login))(&(objectClass=group)(member=$user_dn)))";
+ $this->write_log("[check_ldap_group_membership]> @ldap_search(\$this->cnx,'$group_dn', '$search_filter', array('memberOf'),0,1)");
+ if($search = @ldap_search($this->cnx, $group_dn, $search_filter, array("dn"),0,1)){
+ $entry = @ldap_get_entries($this->cnx, $search);
+ //check if there are dn-attributes
+ if (!empty($entry[0]["dn"])) {
+ $this->write_log("[check_ldap_group_membership]> match found: ".$entry[0]["dn"]);
+ return true;
+ } else {
+ $this->write_log("[check_ldap_group_membership]> no group membership for user found for given group and user, check on ldap side");
+ }
+ } else {
+ $this->write_log("[check_ldap_group_membership]> ldap_search NOT successfull: " .$this->getErrorString());
+ }
+ $this->write_log("[check_ldap_group_membership]> No matching groups found for given group_dn: ". $group_dn);
+ return false;
+ }
+
+
+ public function getAttr() {
+ $search = @ldap_read($this->cnx, "cn=subschema", "(objectClass=*)", array('*', 'subschemasubentry'));
+ $entries = @ldap_get_entries($this->cnx, $search);
+ echo count($entries);
+ }
+
+ public function getRootDse() {
+ $search = @ldap_read($this->cnx, NULL, 'objectClass=*', array("*", "+"));
+ $entries = @ldap_get_entries($this->cnx, $search);
+ return $entries[0];
+ }
+
+
+ public function ldap_check_basedn(){
+ if ($read = @ldap_read($this->cnx,$this->config['basedn'],'(objectClass=*)',array('dn'))){
+ $entry = @ldap_get_entries($this->cnx, $read);
+ if (!empty($entry[0]['dn'])) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
+?>
diff --git a/plugins/Ldap_Login/data.dat b/sources/extra_files/app/plugins/Ldap_Login/data.dat
similarity index 100%
rename from plugins/Ldap_Login/data.dat
rename to sources/extra_files/app/plugins/Ldap_Login/data.dat
diff --git a/plugins/Ldap_Login/index.php b/sources/extra_files/app/plugins/Ldap_Login/index.php
similarity index 100%
rename from plugins/Ldap_Login/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/index.php
diff --git a/plugins/Ldap_Login/language/da_DK/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/da_DK/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/da_DK/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/da_DK/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/de_DE/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/de_DE/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/de_DE/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/de_DE/index.php
diff --git a/plugins/Ldap_Login/language/de_DE/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/de_DE/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/de_DE/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/de_DE/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/el_GR/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/el_GR/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/el_GR/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/el_GR/index.php
diff --git a/plugins/Ldap_Login/language/el_GR/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/el_GR/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/el_GR/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/el_GR/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/en_UK/description.txt b/sources/extra_files/app/plugins/Ldap_Login/language/en_UK/description.txt
similarity index 100%
rename from plugins/Ldap_Login/language/en_UK/description.txt
rename to sources/extra_files/app/plugins/Ldap_Login/language/en_UK/description.txt
diff --git a/plugins/Ldap_Login/language/en_UK/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/en_UK/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/en_UK/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/en_UK/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/es_ES/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/es_ES/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/es_ES/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/es_ES/index.php
diff --git a/plugins/Ldap_Login/language/es_ES/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/es_ES/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/es_ES/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/es_ES/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/fr_CA/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/fr_CA/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/fr_CA/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/fr_CA/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/fr_FR/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/fr_FR/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/fr_FR/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/fr_FR/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/index.php
diff --git a/plugins/Ldap_Login/language/it_IT/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/it_IT/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/it_IT/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/it_IT/index.php
diff --git a/plugins/Ldap_Login/language/it_IT/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/it_IT/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/it_IT/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/it_IT/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/lv_LV/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/lv_LV/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/lv_LV/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/lv_LV/index.php
diff --git a/plugins/Ldap_Login/language/lv_LV/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/lv_LV/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/lv_LV/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/lv_LV/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/pt_BR/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/pt_BR/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/pt_BR/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/pt_BR/index.php
diff --git a/plugins/Ldap_Login/language/pt_BR/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/pt_BR/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/pt_BR/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/pt_BR/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/pt_PT/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/pt_PT/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/pt_PT/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/pt_PT/index.php
diff --git a/plugins/Ldap_Login/language/pt_PT/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/pt_PT/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/pt_PT/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/pt_PT/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/ru_RU/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/ru_RU/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/ru_RU/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/ru_RU/index.php
diff --git a/plugins/Ldap_Login/language/ru_RU/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/ru_RU/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/ru_RU/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/ru_RU/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/sk_SK/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/sk_SK/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/sk_SK/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/sk_SK/index.php
diff --git a/plugins/Ldap_Login/language/sk_SK/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/sk_SK/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/sk_SK/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/sk_SK/plugin.lang.php
diff --git a/plugins/Ldap_Login/language/tr_TR/index.php b/sources/extra_files/app/plugins/Ldap_Login/language/tr_TR/index.php
similarity index 100%
rename from plugins/Ldap_Login/language/tr_TR/index.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/tr_TR/index.php
diff --git a/plugins/Ldap_Login/language/tr_TR/plugin.lang.php b/sources/extra_files/app/plugins/Ldap_Login/language/tr_TR/plugin.lang.php
similarity index 100%
rename from plugins/Ldap_Login/language/tr_TR/plugin.lang.php
rename to sources/extra_files/app/plugins/Ldap_Login/language/tr_TR/plugin.lang.php
diff --git a/plugins/Ldap_Login/main.inc.php b/sources/extra_files/app/plugins/Ldap_Login/main.inc.php
similarity index 97%
rename from plugins/Ldap_Login/main.inc.php
rename to sources/extra_files/app/plugins/Ldap_Login/main.inc.php
index 58ce0ac..a19508d 100644
--- a/plugins/Ldap_Login/main.inc.php
+++ b/sources/extra_files/app/plugins/Ldap_Login/main.inc.php
@@ -1,113 +1,113 @@
-load_config();
-set_plugin_data($plugin['id'], $ldap);
-unset($ldap);
-
-// +-----------------------------------------------------------------------+
-// | functions |
-// +-----------------------------------------------------------------------+
-
-function random_password( $length = 8 ) {
- $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
- $password = substr( str_shuffle( $chars ), 0, $length );
- return $password;
-}
-
-function ld_init(){
- load_language('plugin.lang', LDAP_LOGIN_PATH);
-}
-
-
-function login($success, $username, $password, $remember_me){
-
- global $conf;
-
- $obj = new Ldap();
- $obj->load_config();
- $obj->ldap_conn() or die("Unable to connect LDAP server : ".$ldap->getErrorString());
-
- $user_dn = $obj->ldap_search_dn($username); // retrieve the userdn
-
- // If we have userdn, attempt to login an check user's group access
- if (!($user_dn && $obj->ldap_bind_as($user_dn,$password) &&
- $obj->check_ldap_group_membership($user_dn, $username))) {
- trigger_notify('login_failure', stripslashes($username));
- return false; // wrong user/password or no group access
- }
-
- // search user in piwigo database
- $query = 'SELECT '.$conf['user_fields']['id'].' AS id FROM '.USERS_TABLE.' WHERE '.$conf['user_fields']['username'].' = \''.pwg_db_real_escape_string($username).'\' ;';
-
- $row = pwg_db_fetch_assoc(pwg_query($query));
-
- // if query is not empty, it means everything is ok and we can continue, auth is done !
- if (!empty($row['id'])) {
- log_user($row['id'], $remember_me);
- trigger_notify('login_success', stripslashes($username));
- return true;
- }
-
- // if query is empty but ldap auth is done we can create a piwigo user if it's said so !
- else {
- // this is where we check we are allowed to create new users upon that.
- if ($obj->config['allow_newusers']) {
-
- // retrieve LDAP e-mail address and create a new user
- $mail = $obj->ldap_get_email($user_dn);
- $new_id = register_user($username,random_password(8),$mail);
-
- // Login user
- log_user($new_id, False);
- trigger_notify('login_success', stripslashes($username));
-
- // in case the e-mail address is empty, redirect to profile page
- if($mail==NULL) {
- redirect('profile.php');
- }
-
- return true;
- }
- // else : this is the normal behavior ! user is not created.
- else {
- trigger_notify('login_failure', stripslashes($username));
- return false;
- }
- }
-}
-
-?>
+load_config();
+set_plugin_data($plugin['id'], $ldap);
+unset($ldap);
+
+// +-----------------------------------------------------------------------+
+// | functions |
+// +-----------------------------------------------------------------------+
+
+function random_password( $length = 8 ) {
+ $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
+ $password = substr( str_shuffle( $chars ), 0, $length );
+ return $password;
+}
+
+function ld_init(){
+ load_language('plugin.lang', LDAP_LOGIN_PATH);
+}
+
+
+function login($success, $username, $password, $remember_me){
+
+ global $conf;
+
+ $obj = new Ldap();
+ $obj->load_config();
+ $obj->ldap_conn() or die("Unable to connect LDAP server : ".$ldap->getErrorString());
+
+ $user_dn = $obj->ldap_search_dn($username); // retrieve the userdn
+
+ // If we have userdn, attempt to login an check user's group access
+ if (!($user_dn && $obj->ldap_bind_as($user_dn,$password) &&
+ $obj->check_ldap_group_membership($user_dn, $username))) {
+ trigger_notify('login_failure', stripslashes($username));
+ return false; // wrong user/password or no group access
+ }
+
+ // search user in piwigo database
+ $query = 'SELECT '.$conf['user_fields']['id'].' AS id FROM '.USERS_TABLE.' WHERE '.$conf['user_fields']['username'].' = \''.pwg_db_real_escape_string($username).'\' ;';
+
+ $row = pwg_db_fetch_assoc(pwg_query($query));
+
+ // if query is not empty, it means everything is ok and we can continue, auth is done !
+ if (!empty($row['id'])) {
+ log_user($row['id'], $remember_me);
+ trigger_notify('login_success', stripslashes($username));
+ return true;
+ }
+
+ // if query is empty but ldap auth is done we can create a piwigo user if it's said so !
+ else {
+ // this is where we check we are allowed to create new users upon that.
+ if ($obj->config['allow_newusers']) {
+
+ // retrieve LDAP e-mail address and create a new user
+ $mail = $obj->ldap_get_email($user_dn);
+ $new_id = register_user($username,random_password(8),$mail);
+
+ // Login user
+ log_user($new_id, False);
+ trigger_notify('login_success', stripslashes($username));
+
+ // in case the e-mail address is empty, redirect to profile page
+ if($mail==NULL) {
+ redirect('profile.php');
+ }
+
+ return true;
+ }
+ // else : this is the normal behavior ! user is not created.
+ else {
+ trigger_notify('login_failure', stripslashes($username));
+ return false;
+ }
+ }
+}
+
+?>
diff --git a/plugins/Ldap_Login/maintain.inc.php b/sources/extra_files/app/plugins/Ldap_Login/maintain.inc.php
similarity index 100%
rename from plugins/Ldap_Login/maintain.inc.php
rename to sources/extra_files/app/plugins/Ldap_Login/maintain.inc.php
diff --git a/plugins/Ldap_Login/obsolete.list b/sources/extra_files/app/plugins/Ldap_Login/obsolete.list
similarity index 91%
rename from plugins/Ldap_Login/obsolete.list
rename to sources/extra_files/app/plugins/Ldap_Login/obsolete.list
index 502f623..5bf9b8f 100644
--- a/plugins/Ldap_Login/obsolete.list
+++ b/sources/extra_files/app/plugins/Ldap_Login/obsolete.list
@@ -1,16 +1,16 @@
-DO
-min/
-min/index.php
-min/ldap_login_plugin_admin.php
-min/ldap_login_plugin_admin.tpl
-ass.ldap.php
-dex.php
-nguage/
-nguage/en_UK/
-nguage/en_UK/plugin.lang.php
-nguage/fr_CA/
-nguage/fr_CA/plugin.lang.php
-nguage/fr_FR/
-nguage/fr_FR/plugin.lang.php
-nguage/index.php
+DO
+min/
+min/index.php
+min/ldap_login_plugin_admin.php
+min/ldap_login_plugin_admin.tpl
+ass.ldap.php
+dex.php
+nguage/
+nguage/en_UK/
+nguage/en_UK/plugin.lang.php
+nguage/fr_CA/
+nguage/fr_CA/plugin.lang.php
+nguage/fr_FR/
+nguage/fr_FR/plugin.lang.php
+nguage/index.php
in.inc.php
\ No newline at end of file
diff --git a/plugins/Ldap_Login/pem_metadata.txt b/sources/extra_files/app/plugins/Ldap_Login/pem_metadata.txt
similarity index 100%
rename from plugins/Ldap_Login/pem_metadata.txt
rename to sources/extra_files/app/plugins/Ldap_Login/pem_metadata.txt