@@ -128,13 +128,23 @@ public function login($username, $password, $client_login = false)
128128 $ app ->db ->query ($ sql , $ remote_session ,$ remote_userid ,$ remote_functions ,$ tstamp );
129129 return $ remote_session ;
130130 } else {
131- $ sql = "SELECT * FROM remote_user WHERE remote_username = ? and remote_password = md5(?) " ;
132- $ remote_user = $ app ->db ->queryOneRecord ($ sql , $ username , $ password );
131+ $ sql = "SELECT * FROM remote_user WHERE remote_username = ? and remote_password = ? " ;
132+ $ remote_user = $ app ->db ->queryOneRecord ($ sql , $ username , $ app ->auth ->crypt_password ($ password ));
133+ if (!$ remote_user ) {
134+ // fallback to md5
135+ $ sql = "SELECT * FROM remote_user WHERE remote_username = ? and remote_password = ? " ;
136+ $ remote_user = $ app ->db ->queryOneRecord ($ sql , $ username , md5 ($ password ));
137+ if ($ remote_user ) {
138+ // update hash algo
139+ $ sql = 'UPDATE `remote_user` SET `remote_password` = ? WHERE `remote_username` = ? ' ;
140+ $ app ->db ->query ($ sql , $ app ->auth ->crypt_password ($ password ), $ username );
141+ }
142+ }
133143 if ($ remote_user ['remote_userid ' ] > 0 ) {
134144 if (trim ($ remote_user ['remote_ips ' ]) != '' ) {
135145 $ allowed_ips = explode (', ' ,$ remote_user ['remote_ips ' ]);
136- foreach ($ allowed_ips as $ i => $ allowed ) {
137- if (!filter_var ($ allowed , FILTER_VALIDATE_IP )) {
146+ foreach ($ allowed_ips as $ i => $ allowed ) {
147+ if (!filter_var ($ allowed , FILTER_VALIDATE_IP )) {
138148 // get the ip for a hostname
139149 unset($ allowed_ips [$ i ]);
140150 $ temp =dns_get_record ($ allowed , DNS_A +DNS_AAAA );
@@ -169,7 +179,7 @@ public function login($username, $password, $client_login = false)
169179 if (!$ remote_allowed ) {
170180 throw new SoapFault ('login_failed ' , 'The login is not allowed from ' .$ _SERVER ['REMOTE_ADDR ' ]);
171181 return false ;
172- }
182+ }
173183 //* Create a remote user session
174184 //srand ((double)microtime()*1000000);
175185 $ remote_session = md5 (mt_rand ().uniqid ('ispco ' ));
@@ -368,22 +378,22 @@ protected function updateQueryPrepare($formdef_file, $client_id, $primary_id, $p
368378
369379 //* Load the form definition
370380 $ app ->remoting_lib ->loadFormDef ($ formdef_file );
371-
381+
372382 //* get old record and merge with params, so only new values have to be set in $params
373383 $ old_rec = $ app ->remoting_lib ->getDataRecord ($ primary_id , $ client_id );
374-
384+
375385 foreach ($ app ->remoting_lib ->formDef ['fields ' ] as $ fieldName => $ fieldConf )
376386 {
377387 if ($ fieldConf ['formtype ' ] === 'PASSWORD ' && empty ($ params [$ fieldName ])) {
378388 unset($ old_rec [$ fieldName ]);
379389 }
380390 }
381-
391+
382392 $ params = $ app ->functions ->array_merge ($ old_rec ,$ params );
383393
384394 //* Get the SQL query
385395 $ sql = $ app ->remoting_lib ->getSQL ($ params , 'UPDATE ' , $ primary_id );
386-
396+
387397 // throw new SoapFault('debug', $sql);
388398 if ($ app ->remoting_lib ->errorMessage != '' ) {
389399 throw new SoapFault ('data_processing_error ' , $ app ->remoting_lib ->errorMessage );
@@ -546,7 +556,7 @@ public function server_get($session_id, $server_id = null, $section ='') {
546556 return false ;
547557 }
548558 }
549-
559+
550560 /**
551561 Gets a list of all servers
552562 @param int session_id
0 commit comments