diff --git a/ADDITIONS/fetchmail.pl b/ADDITIONS/fetchmail.pl index cf4cb407..5986d2b7 100644 --- a/ADDITIONS/fetchmail.pl +++ b/ADDITIONS/fetchmail.pl @@ -81,9 +81,9 @@ $lockmgr->lock($lock_file) || log_and_die "can't lock ${lock_file}"; $dbh = DBI->connect($dsn, $db_username, $db_password) || log_and_die "cannot connect the database"; if($db_type eq "Pg") { - $sql_cond = "date_part('epoch',now())-date_part('epoch',date)"; + $sql_cond = "active = 1 AND date_part('epoch',now())-date_part('epoch',date)"; } elsif($db_type eq "mysql") { - $sql_cond = "unix_timestamp(now())-unix_timestamp(date)"; + $sql_cond = "active = 't' AND unix_timestamp(now())-unix_timestamp(date)"; } $sql = " diff --git a/broadcast-message.php b/broadcast-message.php index 0487658a..310ab2be 100644 --- a/broadcast-message.php +++ b/broadcast-message.php @@ -73,11 +73,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") if (!smtp_mail ($fTo, $smtp_from_email, $fHeaders)) { - flash_error($PALANG['pSendmail_result_error']); + flash_error(Config::lang_f('pSendmail_result_error', $fTo)); } else { - flash_info($PALANG['pSendmail_result_success']); + flash_info(Config::lang_f('pSendmail_result_success', $fTo)); } } } diff --git a/config.inc.php b/config.inc.php index 308aaab2..f8260913 100644 --- a/config.inc.php +++ b/config.inc.php @@ -271,6 +271,7 @@ $CONF['domain_struct_hook'] = ''; $CONF['alias_struct_hook'] = ''; $CONF['mailbox_struct_hook'] = ''; $CONF['alias_domain_struct_hook'] = ''; +$CONF['fetchmail_struct_hook'] = ''; // Default Domain Values @@ -345,13 +346,6 @@ $CONF['vacation_choice_of_reply'] = array ( // End Vacation Stuff. // -// Users Control for Domain Admin -// Set to "Yes" if your domain admins schould be able to edit field userscontrole in table domain -// Userscontrol is edited in admin_create-domain.tpl and admin_edit-domain.tpl -// Userscontrol is default set to on when creating a domain -$CONF['users_domain_controle'] = 'YES'; - - // Alias Control // Postfix Admin inserts an alias in the alias table for every mailbox it creates. // The reason for this is that when you want catch-all and normal mailboxes diff --git a/configs/menu.conf b/configs/menu.conf index 71d851ae..f4524064 100644 --- a/configs/menu.conf +++ b/configs/menu.conf @@ -1,7 +1,7 @@ url_main = main.php url_editactive = editactive.php?table= # list_admin -url_list_admin = list-admin.php +url_list_admin = list.php?table=admin url_create_admin = edit.php?table=admin # list-domain url_list_domain = list.php?table=domain @@ -12,8 +12,8 @@ url_create_mailbox = edit.php?table=mailbox url_create_alias = edit.php?table=alias url_create_alias_domain = edit.php?table=aliasdomain # fetchmail -url_fetchmail = fetchmail.php -url_fetchmail_new_entry = fetchmail.php?new=1 +url_fetchmail = list.php?table=fetchmail +url_fetchmail_new_entry = edit.php?table=fetchmail # sendmail url_sendmail = sendmail.php url_broadcast_message = broadcast-message.php @@ -39,7 +39,7 @@ tr_hilightoff = +form_search =
[adminlistadmin] url_edit_admin = edit.php?table=admin diff --git a/edit.php b/edit.php index d864de3b..d3044db6 100644 --- a/edit.php +++ b/edit.php @@ -98,10 +98,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { foreach($form_fields as $key => $field) { if ($field['editable'] && $field['display_in_form']) { if (!isset($inp_values[$key])) { - if($field['type'] == 'bool') { - $values[$key] = 0; # isset() for unchecked checkboxes is always false - } - # do nothing for other field types + $inp_values[$key] = ''; # newer PHP versions don't include empty fields in $_POST (noticed with PHP 5.6.6) + } + + if($field['type'] == 'bool' && $inp_values[$key] == '') { + $values[$key] = 0; # isset() for unchecked checkboxes is always false } elseif($field['type'] == 'txtl') { $values[$key] = $inp_values[$key]; $values[$key] = preg_replace ('/\\\r\\\n/', ',', $values[$key]); diff --git a/editactive.php b/editactive.php index c71683c3..a5d706d0 100644 --- a/editactive.php +++ b/editactive.php @@ -1,16 +1,16 @@ webformConfig(); @@ -44,8 +44,6 @@ if ($handler->init($id)) { # errors will be displayed as last step anyway, no ne die(Config::Lang('invalid_parameter')); } - $values['active'] = $active; - if ( $handler->set(array('active' => $active)) ) { $handler->store(); } diff --git a/fetchmail.php b/fetchmail.php deleted file mode 100644 index 7e99726a..00000000 --- a/fetchmail.php +++ /dev/null @@ -1,409 +0,0 @@ - array(0, 0, 'id' ), - "mailbox" => array(1, 1, 'enum' ), - "src_server" => array(1, 1, 'text' ), - "src_auth" => array(1, 1, 'enum' ), - "src_user" => array(1, 1, 'text' ), - "src_password" => array(1, 0, 'password' ), - "src_folder" => array(1, 1, 'text' ), - "poll_time" => array(1, 1, 'num' ), - "fetchall" => array(1, 1, 'bool' ), - "keep" => array(1, 1, 'bool' ), - "protocol" => array(1, 1, 'enum' ), - "usessl" => array(1, 1, 'bool' ), - "sslcertck" => array(1, 1, 'bool' ), - "sslcertpath" => array($extra_options, $extra_options, 'text' ), # TODO: input validation - "sslfingerprint" => array($extra_options, $extra_options, 'text' ), # TODO: input validation - "extra_options" => array($extra_options, $extra_options, 'longtext' ), - "mda" => array($extra_options, $extra_options, 'longtext' ), - "date" => array(0, $display_status, 'text' ), - "returned_text" => array(0, $display_status, 'longtext' ), -); -# labels and descriptions are taken from $PALANG['pFetchmail_field_xxx'] and $PALANG['pFetchmail_desc_xxx'] - -# TODO: After pressing save or cancel in edit form, date and returned text are not displayed in list view. -# TODO: Reason: $display_status is set before $new and $edit are reset to 0. -# TODO: Fix: split the "display field?" column into "display in list" and "display in edit mode". - -$SESSID_USERNAME = authentication_get_username(); -if (!$SESSID_USERNAME ) - exit; - -$fm_defaults=array( - "id" =>0, - "mailbox" => array($SESSID_USERNAME), - "poll_time" => 10, - "src_auth" => - array('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any'), - "protocol" => - array('POP3','IMAP','POP2','ETRN','AUTO'), -); - -$table_fetchmail = table_by_key('fetchmail'); -$table_mailbox = table_by_key('mailbox'); - -if (authentication_has_role('global-admin')) { - $list_domains = list_domains (); -} else { - $list_domains = list_domains_for_admin(authentication_get_username()); -} - -$user_domains=implode(", ",array_values($list_domains)); # for displaying -$user_domains_sql=implode("','",escape_string(array_values($list_domains))); # for SQL -$sql="SELECT username FROM $table_mailbox WHERE domain in ('".$user_domains_sql."')"; # TODO: replace with domain selection dropdown - -$res = db_query ($sql); -if ($res['rows'] > 0){ - $fm_defaults["mailbox"]=array(); - while ($name = db_array ($res['result'])){ - $fm_defaults["mailbox"][] = $name["username"]; - } -} -else{ - $fm_defaults["mailbox"]=array(); - $fm_defaults["mailbox"][]=$SESSID_USERNAME; # TODO: Does this really make sense? Or should we display a message "please create a mailbox first!"? -} - -$row_id = 0; -if ($delete) { - $row_id = $delete; -} elseif ($edit) { - $row_id = $edit; -} - -$user_mailboxes_sql= "'" . implode("','",escape_string(array_values($fm_defaults["mailbox"]))) . "'"; # mailboxes as SQL -if ($row_id) { - $result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE id=$row_id AND mailbox IN ($user_mailboxes_sql)"); - # TODO: the "AND mailbox IN ..." part should obsolete the check_owner call. Remove it after checking again. - if ($result['rows'] > 0) { - $edit_row = db_array ($result['result']); - $account = $edit_row['src_user'] . " @ " . $edit_row['src_server']; - } - - $edit_row_domain = explode('@', $edit_row['mailbox']); - if ($result['rows'] <= 0 || !check_owner($SESSID_USERNAME, $edit_row_domain[1])) { # owner check for $edit and $delete - flash_error(sprintf($PALANG['pFetchmail_error_invalid_id'], $row_id)); - $edit = 0; $delete = 0; - } -} - - -if ($cancel) { # cancel $new or $edit - $edit=0; - $new=0; -} elseif ($delete) { # delete an entry - $result = db_query ("delete from $table_fetchmail WHERE id=".$delete); - if ($result['rows'] != 1) - { - flash_error($PALANG['pDelete_delete_error']); - } else { - flash_info(sprintf($PALANG['pDelete_delete_success'],$account)); - } - $delete=0; -} elseif ( ($edit || $new) && $save) { # $edit or $new AND save button pressed - $formvars=array(); - foreach($fm_struct as $key=>$row){ - list($editible,$view,$type)=$row; - if ($editible != 0){ - $func="_inp_".$type; - $val=safepost($key); - if ($type!="password" || strlen($val) > 0) { # skip on empty (aka unchanged) password - $formvars[$key]= escape_string( function_exists($func) ?$func($val) :$val); - } - } - } - $formvars['id'] = $edit; # results in 0 on $new - if(db_pgsql() && $new) { - // skip - shouldn't need to specify this as it will default to the next available value anyway. - unset($formvars['id']); - } - - if (!in_array($formvars['mailbox'], $fm_defaults['mailbox'])) { - flash_error($PALANG['pFetchmail_invalid_mailbox']); - $save = 0; - } - if ($formvars['src_server'] == '') { - flash_error($PALANG['pFetchmail_server_missing']); - # TODO: validate domain name - $save = 0; - } - if (empty($formvars['src_user']) ) { - flash_error($PALANG['pFetchmail_user_missing']); - $save = 0; - } - if ($new && empty($formvars['src_password']) ) { - flash_error($PALANG['pFetchmail_password_missing']); - $save = 0; - } - - if ($save) { - if ($new) { - $sql="INSERT INTO $table_fetchmail (".implode(",",escape_string(array_keys($formvars))).") VALUES ('".implode("','",escape_string($formvars))."')"; - } else { # $edit - foreach(array_keys($formvars) as $key) { - $formvars[$key] = escape_string($key) . "='" . escape_string($formvars[$key]) . "'"; - } - $sql="UPDATE $table_fetchmail SET ".implode(",",$formvars).",returned_text='', date=NOW() WHERE id=".$edit; - } - $result = db_query ($sql); - if ($result['rows'] != 1) - { - flash_error($PALANG['pFetchmail_database_save_error']); - } else { - flash_info($PALANG['pFetchmail_database_save_success']); - $edit = 0; $new = 0; # display list after saving - } - } else { - $formvars['src_password'] = ''; # never display password - } - -} elseif ($edit) { # edit entry form - $formvars = $edit_row; - $formvars['src_password'] = ''; - if (db_pgsql()) { - $formvars['fetchall']=('t'==$formvars['fetchall']) ? 1 : 0; - $formvars['keep']=('t'==$formvars['keep']) ? 1 : 0; - $formvars['usessl']=('t'==$formvars['usessl']) ? 1 : 0; - $formvars['sslcertck']=('t'==$formvars['sslcertck']) ? 1: 0; - } -} elseif ($new) { # create entry form - foreach (array_keys($fm_struct) as $value) { - if (isset($fm_defaults[$value])) { - $formvars[$value] = $fm_defaults[$value]; - } else { - $formvars[$value] = ''; - } - } -} - -$tFmail = array(); -if ($edit + $new == 0) { # display list - # TODO: ORDER BY would even be better if it would order by the _domain_ of the target mailbox first - $res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE mailbox IN ($user_mailboxes_sql) ORDER BY mailbox,src_server,src_user"); - if ($res['rows'] > 0) { - while ($row = db_array ($res['result'])) { - if (db_pgsql()) { - //. at least in my database, $row['modified'] already looks like : 2009-04-11 21:38:10.75586+01, - // while gmstrftime expects an integer value. strtotime seems happy though. - //$row['date']=gmstrftime('%c %Z',$row['date']); - $row['date'] = date('Y-m-d H:i:s', strtotime($row['date'])); - $row['fetchall']=('t'==$row['fetchall']) ? 1 : 0; - $row['keep']=('t'==$row['keep']) ? 1 : 0; - $row['usessl']=('t'==$row['usessl']) ? 1 : 0; - $row['sslcertck']=('t'==$row['sslcertck']) ? 1: 0; - } - $tFmail[] = $row; - } - } -} - -function _inp_num($val){ - return (int)($val); -} - -function _inp_bool($val){ - return $val ? db_get_boolean(true): db_get_boolean(false); -} - -function _inp_password($val){ - return base64_encode($val); -} -//***** -$headers=array(); -foreach(array_keys($fm_struct) as $row){ - list($editible,$view,$type)=$fm_struct[$row]; - $title = $PALANG['pFetchmail_field_' . $row]; - $comment = $PALANG['pFetchmail_desc_' . $row]; - if ($view){ - $headers[]=$title; -// $headers[]=array($editible, $view, $type, $title, $comment); - } -} -function fetchmail_edit_row($data=array()) -{ - global $fm_struct,$fm_defaults,$PALANG; - $id = $data["id"]; - $_id = $data["id"] * 100 + 1; - $ret = ""; - $ret .= ''; - # TODO: $formvars possibly contains db-specific boolean values - # TODO: no problems with MySQL, to be tested with PgSQL - # TODO: undefined values may also occour - foreach($fm_struct as $key=>$struct){ - list($editible,$view,$type)=$struct; - $title = $PALANG['pFetchmail_field_' . $key]; - $comment = $PALANG['pFetchmail_desc_' . $key]; - if ($editible){ - $ret.=""; - $ret.="\n"; - } - elseif($view){ - $func="_view_".$type; - $val=isset($data[$key]) - ?(function_exists($func) - ?$func($data[$key]) - :nl2br($data[$key]) - ) - :"--x--"; - $ret.=""; - $ret.="\n"; - } - } - $ret.="\n"; - $ret.="
'.$PALANG['pMenu_fetchmail'] . '
"; - $func="_edit_".$type; - if (! function_exists($func)) - $func="_edit_text"; - $val=isset($data[$key]) - ?$data[$key] - :(! is_array($fm_defaults[$key]) - ?$fm_defaults[$key] - :'' - ); - $fm_defaults_key = ""; if (isset($fm_defaults[$key])) $fm_defaults_key = $fm_defaults[$key]; - $ret.=$func($_id++,$key,$fm_defaults_key,$val); - $ret.="${comment}
${title}:".$val; - $ret.="${comment}
  -   - - "; - if ($id){ - $ret.=""; - } - $ret.="
\n"; - $ret.="
\n"; - $ret.="\n"; - $ret.="\n"; - return $ret; -} -function _edit_text($id,$key,$def_vals,$val=""){ - $val=htmlspecialchars($val); - return ""; -} - -function _edit_password($id,$key,$def_vals,$val=""){ - $val=preg_replace("{.}","*",$val); - return ""; -} - -function _edit_num($id,$key,$def_vals,$val=""){ - $val=(int)($val); - return ""; -} - -function _edit_bool($id,$key,$def_vals,$val=""){ - $ret="${val}"; -} - -function _edit_enum($id,$key,$def_vals,$val=""){ - $ret=" {elseif $field.type == 'txtl'}