@@ -128,13 +128,26 @@ 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 );
133- if ($ remote_user ['remote_userid ' ] > 0 ) {
131+ $ sql = "SELECT * FROM remote_user WHERE remote_username = ? " ;
132+ $ remote_user = $ app ->db ->queryOneRecord ($ sql , $ username );
133+ if ($ remote_user ) {
134+ if (substr ($ remote_user ['remote_password ' ], 0 , 1 ) === '$ ' ) {
135+ if (crypt (stripslashes ($ password ), $ remote_user ['remote_password ' ]) != $ remote_user ['remote_password ' ]) {
136+ $ remote_user = null ;
137+ }
138+ } elseif (md5 ($ password ) == $ remote_user ['remote_password ' ]) {
139+ // update hash algo
140+ $ sql = 'UPDATE `remote_user` SET `remote_password` = ? WHERE `remote_username` = ? ' ;
141+ $ app ->db ->query ($ sql , $ app ->auth ->crypt_password ($ password ), $ username );
142+ } else {
143+ $ remote_user = null ;
144+ }
145+ }
146+ if ($ remote_user && $ remote_user ['remote_userid ' ] > 0 ) {
134147 if (trim ($ remote_user ['remote_ips ' ]) != '' ) {
135148 $ allowed_ips = explode (', ' ,$ remote_user ['remote_ips ' ]);
136- foreach ($ allowed_ips as $ i => $ allowed ) {
137- if (!filter_var ($ allowed , FILTER_VALIDATE_IP )) {
149+ foreach ($ allowed_ips as $ i => $ allowed ) {
150+ if (!filter_var ($ allowed , FILTER_VALIDATE_IP )) {
138151 // get the ip for a hostname
139152 unset($ allowed_ips [$ i ]);
140153 $ temp =dns_get_record ($ allowed , DNS_A +DNS_AAAA );
@@ -169,7 +182,7 @@ public function login($username, $password, $client_login = false)
169182 if (!$ remote_allowed ) {
170183 throw new SoapFault ('login_failed ' , 'The login is not allowed from ' .$ _SERVER ['REMOTE_ADDR ' ]);
171184 return false ;
172- }
185+ }
173186 //* Create a remote user session
174187 //srand ((double)microtime()*1000000);
175188 $ remote_session = md5 (mt_rand ().uniqid ('ispco ' ));
@@ -368,22 +381,22 @@ protected function updateQueryPrepare($formdef_file, $client_id, $primary_id, $p
368381
369382 //* Load the form definition
370383 $ app ->remoting_lib ->loadFormDef ($ formdef_file );
371-
384+
372385 //* get old record and merge with params, so only new values have to be set in $params
373386 $ old_rec = $ app ->remoting_lib ->getDataRecord ($ primary_id , $ client_id );
374-
387+
375388 foreach ($ app ->remoting_lib ->formDef ['fields ' ] as $ fieldName => $ fieldConf )
376389 {
377390 if ($ fieldConf ['formtype ' ] === 'PASSWORD ' && empty ($ params [$ fieldName ])) {
378391 unset($ old_rec [$ fieldName ]);
379392 }
380393 }
381-
394+
382395 $ params = $ app ->functions ->array_merge ($ old_rec ,$ params );
383396
384397 //* Get the SQL query
385398 $ sql = $ app ->remoting_lib ->getSQL ($ params , 'UPDATE ' , $ primary_id );
386-
399+
387400 // throw new SoapFault('debug', $sql);
388401 if ($ app ->remoting_lib ->errorMessage != '' ) {
389402 throw new SoapFault ('data_processing_error ' , $ app ->remoting_lib ->errorMessage );
@@ -546,7 +559,7 @@ public function server_get($session_id, $server_id = null, $section ='') {
546559 return false ;
547560 }
548561 }
549-
562+
550563 /**
551564 Gets a list of all servers
552565 @param int session_id
0 commit comments