@@ -150,14 +150,23 @@ function onAfterInsert() {
150150 $ active = 1 ;
151151 $ language = $ app ->db ->quote ($ this ->dataRecord ["language " ]);
152152
153+ $ salt ="$1$ " ;
154+ $ base64_alphabet ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ ' ;
155+ for ($ n =0 ;$ n <8 ;$ n ++) {
156+ $ salt .=$ base64_alphabet [mt_rand (0 ,63 )];
157+ }
158+ $ salt .="$ " ;
159+ $ password = crypt (stripslashes ($ password ),$ salt );
160+
161+ // Create the controlpaneluser for the client
153162 //Generate ssh-rsa-keys
154163 exec ('ssh-keygen -t rsa -C ' .$ username .'-rsa-key- ' .time ().' -f /tmp/id_rsa -N "" ' );
155164 $ app ->db ->query ("UPDATE client SET created_at = " .time ().", id_rsa = ' " .file_get_contents ('/tmp/id_rsa ' )."', ssh_rsa = ' " .file_get_contents ('/tmp/id_rsa.pub ' )."' WHERE client_id = " .$ this ->id ;
156165 exec ('rm -f /tmp/id_rsa /tmp/id_rsa.pub ' );
157166
158167 // Create the controlpaneluser for the client
159168 $ sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
160- VALUES (' $ username',md5( ' $ password') ,' $ modules',' $ startmodule',' $ usertheme',' $ type',' $ active',' $ language', $ groups, $ groupid, " .$ this ->id .") " ;
169+ VALUES (' $ username',' $ password',' $ modules',' $ startmodule',' $ usertheme',' $ type',' $ active',' $ language', $ groups, $ groupid, " .$ this ->id .") " ;
161170 $ app ->db ->query ($ sql );
162171
163172 //* If the user who inserted the client is a reseller (not admin), we will have to add this new client group
@@ -198,8 +207,15 @@ function onAfterUpdate() {
198207 // password changed
199208 if ($ conf ['demo_mode ' ] != true && isset ($ this ->dataRecord ["password " ]) && $ this ->dataRecord ["password " ] != '' ) {
200209 $ password = $ app ->db ->quote ($ this ->dataRecord ["password " ]);
210+ $ salt ="$1$ " ;
211+ $ base64_alphabet ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ ' ;
212+ for ($ n =0 ;$ n <8 ;$ n ++) {
213+ $ salt .=$ base64_alphabet [mt_rand (0 ,63 )];
214+ }
215+ $ salt .="$ " ;
216+ $ password = crypt (stripslashes ($ password ),$ salt );
201217 $ client_id = $ this ->id ;
202- $ sql = "UPDATE sys_user SET passwort = md5( ' $ password') WHERE client_id = $ client_id " ;
218+ $ sql = "UPDATE sys_user SET passwort = ' $ password' WHERE client_id = $ client_id " ;
203219 $ app ->db ->query ($ sql );
204220 }
205221
@@ -232,4 +248,4 @@ function onAfterUpdate() {
232248$ page = new page_action ;
233249$ page ->onLoad ();
234250
235- ?>
251+ ?>
0 commit comments