@@ -32,12 +32,12 @@ public function init()
3232 $ this ->register_action ('plugin.fetchmail.save ' , [$ this , 'save ' ]);
3333 $ this ->register_action ('plugin.fetchmail.delete ' , [$ this , 'delete ' ]);
3434 }
35-
35+
3636 public function init_html ()
3737 {
3838 $ this ->rc ->output ->set_pagetitle ($ this ->gettext ('fetchmail ' ));
3939 $ this ->include_script ('fetchmail.js ' );
40-
40+
4141 if ($ this ->rc ->action == 'plugin.fetchmail.edit ' ) {
4242 $ this ->rc ->output ->add_handler ('fetchmailform ' , [$ this , 'gen_form ' ]);
4343 $ this ->rc ->output ->send ('fetchmail.fetchmailedit ' );
@@ -47,7 +47,7 @@ public function init_html()
4747 $ this ->rc ->output ->send ('fetchmail.fetchmail ' );
4848 }
4949 }
50-
50+
5151 public function delete ()
5252 {
5353 $ this ->_db_connect ('w ' );
@@ -63,7 +63,7 @@ public function delete()
6363 ));
6464 }
6565 }
66-
66+
6767 public function quota ($ attrib )
6868 {
6969 $ this ->_db_connect ('w ' );
@@ -74,12 +74,12 @@ public function quota($attrib)
7474 $ num_rows = $ this ->db ->num_rows ($ result );
7575 $ percent = ($ num_rows / $ limit ) * 100 ;
7676 $ out = "<div id= \"" .$ attrib ['id ' ]."\" class= \"quota-widget \"><span class= \"count \"> " .$ num_rows ."/ " .$ limit ."</span><span class= \"bar \"><span class= \"value \" style= \"width: $ percent% \"></span></span></div> " ;
77-
77+
7878 $ this ->rc ->output ->add_gui_object ('fetchmail.quota ' , $ attrib ['id ' ]);
7979 $ this ->rc ->output ->set_env ('fetchmail_limit ' , $ limit );
8080 return $ out ;
8181 }
82-
82+
8383 public function save ()
8484 {
8585 $ this ->_db_connect ('w ' );
@@ -133,7 +133,7 @@ public function save()
133133 $ fetchall = 1 ;
134134 }
135135 $ mda = $ this ->rc ->config ->get ('fetchmail_mda ' );
136-
136+
137137 //Validate server
138138 $ server_valid = $ this ->_check_server ($ server );
139139 if (!$ server_valid ) {
@@ -151,7 +151,12 @@ public function save()
151151 $ num_rows = $ this ->db ->num_rows ($ result );
152152 if ($ num_rows < $ limit )
153153 {
154- $ sql = "INSERT INTO fetchmail (mailbox, domain, active, src_server, src_user, src_password, src_folder, poll_time, fetchall, keep, protocol, usessl, sslcertck, src_auth, mda) VALUES (' $ mailbox', ' $ mailbox_domain', ' $ enabled', ' $ server', ' $ user', ' $ pass', ' $ folder', ' $ pollinterval', ' $ fetchall', ' $ keep', ' $ protocol', ' $ usessl', true, 'password', ' $ mda' ) " ;
154+ if ($ mda != '' )
155+ {
156+ $ sql = "INSERT INTO fetchmail (mailbox, domain, active, src_server, src_user, src_password, src_folder, poll_time, fetchall, keep, protocol, usessl, sslcertck, src_auth, mda) VALUES (' $ mailbox', ' $ mailbox_domain', ' $ enabled', ' $ server', ' $ user', ' $ pass', ' $ folder', ' $ pollinterval', ' $ fetchall', ' $ keep', ' $ protocol', ' $ usessl', true, 'password', ' $ mda' ) " ;
157+ } else {
158+ $ sql = "INSERT INTO fetchmail (mailbox, domain, active, src_server, src_user, src_password, src_folder, poll_time, fetchall, keep, protocol, usessl, sslcertck, src_auth) VALUES (' $ mailbox', ' $ mailbox_domain', ' $ enabled', ' $ server', ' $ user', ' $ pass', ' $ folder', ' $ pollinterval', ' $ fetchall', ' $ keep', ' $ protocol', ' $ usessl', true, 'password') " ;
159+ }
155160 $ insert = $ this ->db ->query ($ sql );
156161 if ($ err_str = $ this ->db ->is_error ())
157162 {
@@ -177,9 +182,9 @@ public function save()
177182 {
178183 if ($ mda != '' )
179184 {
180- $ sql = "UPDATE fetchmail SET mailbox = ' $ mailbox', domain = ' $ mailbox_domain', active = ' $ enabled', keep = ' $ keep', protocol = ' $ protocol', src_server = ' $ server', src_user = ' $ user', src_password = ' $ pass', src_folder = ' $ folder', poll_time = ' $ pollinterval', fetchall = ' $ fetchall', usessl = ' $ usessl', src_auth = 'password', mda = ' $ mda' WHERE id = ' $ id' " ;
185+ $ sql = "UPDATE fetchmail SET mailbox = ' $ mailbox', domain = ' $ mailbox_domain', active = ' $ enabled', keep = ' $ keep', protocol = ' $ protocol', src_server = ' $ server', src_user = ' $ user', src_password = ' $ pass', src_folder = ' $ folder', poll_time = ' $ pollinterval', fetchall = ' $ fetchall', usessl = ' $ usessl', src_auth = 'password', mda = ' $ mda' WHERE id = ' $ id' " ;
181186 } else {
182- $ sql = "UPDATE fetchmail SET mailbox = ' $ mailbox', domain = ' $ mailbox_domain', active = ' $ enabled', keep = ' $ keep', protocol = ' $ protocol', src_server = ' $ server', src_user = ' $ user', src_password = ' $ pass', src_folder = ' $ folder', poll_time = ' $ pollinterval', fetchall = ' $ fetchall', usessl = ' $ usessl', src_auth = 'password' WHERE id = ' $ id' " ;
187+ $ sql = "UPDATE fetchmail SET mailbox = ' $ mailbox', domain = ' $ mailbox_domain', active = ' $ enabled', keep = ' $ keep', protocol = ' $ protocol', src_server = ' $ server', src_user = ' $ user', src_password = ' $ pass', src_folder = ' $ folder', poll_time = ' $ pollinterval', fetchall = ' $ fetchall', usessl = ' $ usessl', src_auth = 'password' WHERE id = ' $ id' " ;
183188 }
184189 $ update = $ this ->db ->query ($ sql );
185190 if ($ err_str = $ this ->db ->is_error ())
@@ -197,7 +202,7 @@ public function save()
197202 }
198203 }
199204 }
200-
205+
201206 public function gen_form ($ attrib )
202207 {
203208 $ this ->_db_connect ('r ' );
@@ -395,20 +400,20 @@ public function gen_form($attrib)
395400 $ this ->rc ->output ->add_gui_object ('fetchmailform ' , 'fetchmail-form ' );
396401 return $ out ;
397402 }
398-
403+
399404 public function section_list ($ attrib )
400405 {
401406 // add id to result list table if not specified
402407 if (!strlen ($ attrib ['id ' ])) {
403408 $ attrib ['id ' ] = 'rcmsectionslist ' ;
404409 }
405-
410+
406411 //Fetch existing entries from Database
407412 $ this ->_db_connect ('r ' );
408413 $ mailbox = $ this ->rc ->user ->data ['username ' ];
409414 $ sql = "SELECT id, CONCAT(src_server, ': ', src_user) as title FROM fetchmail WHERE mailbox=' $ mailbox' " ;
410415 $ result = $ this ->db ->query ($ sql );
411-
416+
412417 $ accounts = $ result ->fetchAll ();
413418 $ sections = array ();
414419 foreach ($ accounts as $ account ) {
@@ -418,17 +423,17 @@ public function section_list($attrib)
418423 'section ' => $ account ['title ' ]
419424 );
420425 }
421-
426+
422427 // create HTML table
423428 $ out = $ this ->rc ->table_output ($ attrib , $ sections , array ('section ' ), 'id ' );
424429
425430 // set client env
426431 $ this ->rc ->output ->add_gui_object ('sectionslist ' , $ attrib ['id ' ]);
427432 $ this ->rc ->output ->include_script ('list.js ' );
428-
433+
429434 return $ out ;
430435 }
431-
436+
432437 public function settings_actions ($ args )
433438 {
434439 $ args ['actions ' ][] = array (
@@ -446,7 +451,7 @@ private function _db_connect($mode)
446451 if (!$ db_dsn ) {
447452 $ this ->db = $ this ->rc ->db ;
448453 }
449-
454+
450455 if (!$ this ->db )
451456 {
452457 $ this ->db = rcube_db::factory ($ db_dsn , '' , false );
@@ -460,26 +465,24 @@ private function _db_connect($mode)
460465 rcube::raise_error (['code ' => 603 , 'type ' => 'db ' , 'message ' => $ err_str ], false , true );
461466 }
462467 }
463-
468+
464469 private function _check_server ($ server )
465470 {
466471 if ($ this ->rc ->config ->get ('fetchmail_check_server ' ) == false ) {
467472 return true ;
468473 }
469-
474+
470475 if (!is_string ($ server ))
471476 {
472477 return false ;
473478 }
474-
479+
475480 $ result = dns_get_record ($ server , DNS_A +DNS_AAAA );
476481 if (is_array ($ result ))
477482 {
478483 return (sizeof ($ result ) > 0 );
479484 }
480-
485+
481486 return false ;
482487 }
483488}
484-
485-
0 commit comments