- initial version of fetchmail support (by Viktor Gotwig,info AT symateam.de)

(see postfixadmin-devel mailinglist for detailed description and known 
  problems, subject "fetchmail support")
- encoded some german umlauts as htmlentities


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@140 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
Christian Boltz 17 years ago
parent 4386bf3f85
commit c4040c8227

@ -0,0 +1,174 @@
<?php
/**
* Postfix Admin
*
* LICENSE
* This source file is subject to the GPL license that is bundled with
* this package in the file LICENSE.TXT.
*
* Further details on the project are available at :
* http://www.postfixadmin.com or http://postfixadmin.sf.net
*
* @version $Id$
* @license GNU GPL v2 or later.
*
* File: fetchmail.php
* Responsible for setting up fetchmail
*
* @version $Id$
* @license GNU GPL v2 or later.
*
* Template Variables:
*
* TODO
*
* Form POST \ GET Variables:
*
* TODO
*/
/* new sql table: fetchmail
create table fetchmail(
id int(11) unsigned not null auto_increment,
mailbox varchar(255) not null default '',
src_server varchar(255) not null default '',
src_auth enum('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any'),
src_user varchar(255) not null default '',
src_password varchar(255) not null default '',
src_folder varchar(255) not null default '',
pool_time int(11) unsigned not null default 10,
fetchall tinyint(1) unsigned not null default 0,
keep tinyint(1) unsigned not null default 0,
protocol enum('POP3','IMAP','POP2','ETRN','AUTO'),
extra_options text,
returned_text text,
mda varchar(255) not null default '',
date timestamp(14),
primary key(id)
);
*/
require_once('common.php');
authentication_require_role('admin');
$fm_struct=array( // list($editible,$view,$type,$title,$comment)
"id" =>array(0,1,'id', 'ID','Record ID'),
"mailbox" =>array(1,1,'enum', 'Mailbox','Local mailbox'),
"src_server" =>array(1,1,'text', 'Server','Remote Server'),
"src_auth" =>array(1,1,'enum', 'Auth Type','Mostly password'),
"src_user" =>array(1,1,'text', 'User','Remote User'),
"src_password" =>array(1,1,'password', 'Password','Remote Password'),
"src_folder" =>array(1,1,'text', 'Folder','Remote Folder'),
"pool_time" =>array(1,1,'num', 'Poll','Poll Time (min)'),
"fetchall" =>array(1,1,'bool', 'Fetch All','Retrieve both old (seen) and new messages'),
"keep" =>array(1,1,'bool', 'Keep','Keep retrieved messages on the remote mailserver'),
"protocol" =>array(1,1,'enum', 'Protocol','Protocol to use'),
"extra_options" =>array(1,1,'longtext', 'Extra Options','Extra fetchmail Options'),
"mda" =>array(1,1,'longtext', 'MDA','Mail Delivery Agent'),
"date" =>array(0,1,'text', 'Date','Date of last pooling/configuration change'),
"returned_text" =>array(0,1,'longtext', 'Returned Text','Text message from last pooling'),
);
$SESSID_USERNAME = authentication_get_username();
if (!$SESSID_USERNAME )
exit;
$fm_defaults=array(
"id" =>0,
"mailbox" => array($SESSID_USERNAME),
"pool_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'),
);
$list_domains = list_domains_for_admin ($SESSID_USERNAME);
$user_domains=implode("','",array_values($list_domains));
$sql="SELECT username FROM mailbox WHERE domain in ('".$user_domains."')";
$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;
}
$new=$_REQUEST["new"];
$edit=(int)$_REQUEST["edit"];
$delete=$_REQUEST["delete"];
$save=$_REQUEST["save"];
$cancel=$_REQUEST["cancel"];
if ($cancel){
$edit=0;
}
elseif($edit && $save){
$_vals=array();
foreach($fm_struct as $key=>$row){
list($editible,$view,$type,$title,$comment)=$row;
if ($editible){
$func="_inp_".$type;
$val=$_REQUEST[$key];
if ($type!="password" || substr($val,0,1)!="*"){
$_vals[]=$key."='".mysql_escape_string(
function_exists($func)
?$func($val)
:$val)."'";
}
}
}
$sql="UPDATE fetchmail SET ".implode(",",$_vals).",returned_text='' WHERE id=".$edit;
$res= db_query ($sql);
}
elseif($delete){
db_query ("delete from fetchmail WHERE id=".$edit);
}
elseif ($new){
$_keys=array();
$_vals=array();
foreach($fm_defaults as $key=>$val){
$_keys[]=$key;
$_vals[]="'".(is_array($val)?$val[0]:mysql_escape_string($val))."'";
}
$sql="INSERT fetchmail (".implode(",",$_keys).") VALUES (".implode(",",$_vals).")";
$res= db_query ($sql);
$sql="SELECT id FROM fetchmail order by id desc limit 1";
$res= db_query ($sql);
list($edit)=mysql_fetch_row($res['result']);
}
$res = db_query ("SELECT ".implode(",",array_keys($fm_struct))." FROM fetchmail order by id desc");
if ($res['rows'] > 0){
while ($row = db_array ($res['result'])){
$tFmail[] = $row;
}
}
function _inp_num($val){
return (int)($val);
}
function _inp_bool($val){
return $val?1:0;
}
function _inp_password($val){
return base64_encode($val);
}
include ("./templates/header.tpl");
include ("./templates/menu.tpl");
include ("./templates/fetchmail.tpl");
include ("./templates/footer.tpl");
?>

@ -25,6 +25,7 @@ $PALANG['pLogin_login_users'] = 'eMail-Benutzer bitte hier einloggen.';
$PALANG['pMenu_overview'] = '&Uuml;berblick';
$PALANG['pMenu_create_alias'] = 'Alias hinzuf&uuml;gen';
$PALANG['pMenu_create_mailbox'] = 'Mailbox hinzuf&uuml;gen';
$PALANG['pMenu_fetchmail'] = 'E-Mail Abruf bearbeiten';
$PALANG['pMenu_sendmail'] = 'Email versenden';
$PALANG['pMenu_password'] = 'Passwort &auml;ndern';
$PALANG['pMenu_viewlog'] = 'Log ansehen';
@ -32,7 +33,7 @@ $PALANG['pMenu_logout'] = 'Logout';
$PALANG['pMain_welcome'] = 'Willkommen zu Postfix Admin!';
$PALANG['pMain_overview'] = 'Listet Ihre Aliase und Mailboxen auf. Sie k&ouml;nnen sie hier editieren und l&ouml;schen.';
$PALANG['pMain_create_alias'] = 'Fügt einen neuen Alias f&uuml;r Ihre Domain hinzu.';
$PALANG['pMain_create_alias'] = 'F&uuml;gt einen neuen Alias f&uuml;r Ihre Domain hinzu.';
$PALANG['pMain_create_mailbox'] = 'Legt eine neue Mailbox f&uuml;r Ihre Domain an.';
$PALANG['pMain_sendmail'] = 'Versenden Sie eine Email.';
$PALANG['pMain_password'] = '&Auml;ndern Sie Ihr Admin-Passwort.';
@ -280,24 +281,28 @@ $PALANG['pUsersVacation_subject'] = 'Betreff';
$PALANG['pUsersVacation_subject_text'] = 'Ich bin weg...';
$PALANG['pUsersVacation_body'] = 'Text';
$PALANG['pUsersVacation_body_text'] = <<<EOM
Ich bin vom <date> bis <date> nicht zu Hause / im Büro.
In dringenden Fällen setzen Sie sich bitte mit <contact person> in Verbindung.
Vielen Dank für Ihr Verständniss.
Ich bin vom <date> bis <date> nicht zu Hause / im B&uuml;ro.
In dringenden F&auml;llen setzen Sie sich bitte mit <contact person> in Verbindung.
Vielen Dank f&uuml;r Ihr Verst&auml;ndnis.
EOM;
$PALANG['pUsersVacation_button_away'] = 'Ich gehe weg';
$PALANG['pUsersVacation_button_back'] = 'Ich bin zur&uuml;ck';
$PALANG['pUsersVacation_result_error'] = '<span class="error_msg">Konnte Ihre Automatische Antwort nicht einstellen!</span>';
$PALANG['pUsersVacation_result_success'] = 'Ihre Automatische Antwort wurde gel&ouml;scht!';
$PALANG['pCreate_dbLog_createmailbox'] = 'Mailbox hinzufügen';
$PALANG['pCreate_dbLog_createalias'] = 'Alias hinzugen';
$PALANG['pDelete_dbLog_deletealias'] = 'Alias löschen';
$PALANG['pDelete_dbLog_deletemailbox'] = 'Mailbox löschen';
$PALANG['pCreate_dbLog_createmailbox'] = 'Mailbox hinzuf&uuml;gen';
$PALANG['pCreate_dbLog_createalias'] = 'Alias hinzu&uuml;¼gen';
$PALANG['pDelete_dbLog_deletealias'] = 'Alias l&uuml;schen';
$PALANG['pDelete_dbLog_deletemailbox'] = 'Mailbox l&ouml;schen';
$PALANG['pEdit_dbLog_editactive'] = 'Aktiv-Status ändern';
$PALANG['pEdit_dbLog_editactive'] = 'Aktiv-Status &auml;ndern';
$PALANG['pEdit_dbLog_editalias'] = 'Alias bearbeiten';
$PALANG['pEdit_dbLog_editmailbox'] = 'Mailbox bearbeiten';
$PALANG['pSearch'] = 'suche';
$PALANG['pSearch_welcome'] = 'Suche nach: ';
$PALANG['pFetchmail_welcome'] = 'E-Mail Abruf f&uuml;r: ';
$PALANG['pFetchmail_new_entry'] = 'Neuer Eintrag';
?>

@ -28,6 +28,7 @@ $PALANG['pMenu_main'] = 'Main';
$PALANG['pMenu_overview'] = 'Overview';
$PALANG['pMenu_create_alias'] = 'Add Alias';
$PALANG['pMenu_create_mailbox'] = 'Add Mailbox';
$PALANG['pMenu_fetchmail'] = 'Fetch Email';
$PALANG['pMenu_sendmail'] = 'Send Email';
$PALANG['pMenu_password'] = 'Password';
$PALANG['pMenu_viewlog'] = 'View Log';
@ -354,4 +355,8 @@ $PALANG['pStatus_custom'] = 'Delivers to ';
$PALANG['pStatus_popimap'] = 'POP/IMAP ';
$PALANG['pPasswordTooShort'] = "Password is too short - requires %s characters";
$PALANG['pFetchmail_welcome'] = 'Fetch mail for:';
$PALANG['pFetchmail_new_entry'] = 'New entry';
?>

@ -0,0 +1,155 @@
<div id="overview">
<form name="overview" method="post">
<?php
$headers=array();
foreach($fm_struct as $row){
list($editible,$view,$type,$title,$comment)=$row;
if ($view){
$headers[]=$row;
}
}
print "<table id=\"log_table\" border=0>\n";
print " <tr>\n";
print " <td colspan=\"".(sizeof($headers)-1)."\"><h3>".$PALANG['pFetchmail_welcome'].$user_domains."</h3></td>\n";
print " <td align=right><a href='?new=1'>&gt;&gt;&nbsp;".$PALANG['pFetchmail_new_entry']."</a></td>\n";
print " </tr>\n";
print " <tr class=\"header\">\n";
foreach($headers as $row){
list($editible,$view,$type,$title,$comment)=$row;
print " <td>" . $title . "</td>\n";
}
print " </tr>\n";
if (sizeof ($tFmail) > 0){
foreach($tFmail as $row){
if ($edit && $edit==$row["id"]){
print "<tr><td colspan=".sizeof($headers).">".fetchmail_edit_row($row)."</td></tr>\n";
}
else{
print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
foreach($row as $key=>$val){
list($editible,$view,$type,$title,$comment)=$fm_struct[$key];
if ($view){
$func="_listview_".$type;
print " <td nowrap>" . (function_exists($func)?$func($val):$val) . "</td>\n";
}
}
print " </tr>\n";
}
}
}
function fetchmail_edit_row($data=array()){
global $fm_struct,$fm_defaults;
$id=$data["id"];
$_id=$data["id"]*100+1;
$ret="<table cellspacing=1 cellpadding=0 border=0 width=100%>";
foreach($fm_struct as $key=>$struct){
list($editible,$view,$type,$title,$comment)=$struct;
if ($editible){
$ret.="<tr><td align=left valign=top><label for=${_id} style='width:20em;'>${title}:&nbsp;</label></td>";
$ret.="<td align=left style='padding-left:.25em;padding-right:.25em;background-color:white;'>";
$func="_edit_".$type;
if (! function_exists($func))
$func="_edit_text";
$val=isset($data[$key])
?$data[$key]
:(! is_array($fm_defaults[$key])
?$fm_defaults[$key]
:''
);
$ret.=$func($_id++,$key,$fm_defaults[$key],$val);
$ret.="</td><td align=left valign=top><i>&nbsp;${comment}</i></td></tr>\n";
}
elseif($view){
$func="_view_".$type;
$val=isset($data[$key])
?(function_exists($func)
?$func($data[$key])
:nl2br($data[$key])
)
:"--x--";
$ret.="<tr><td align=left valign=top>${title}:&nbsp;</label></td>";
$ret.="<td align=left valign=top style='padding-left:.25em;padding-right:.25em;background-color:white;'>".$val;
$ret.="</td><td align=left valign=top><i>&nbsp;${comment}</i></td></tr>\n";
}
}
$ret.="<tr><td align=left><input type=submit name=cancel value='Abbrechen'></td><td align=right><input type=submit name=save value='Save'></td><td align=right><input type=submit name=delete value='Delete'>";
if ($id){
$ret.="<input type=hidden name=edit value='${id}'>";
}
$ret.="</td></tr>\n";
$ret.="</table>\n";
return $ret;
}
function _edit_text($id,$key,$def_vals,$val=""){
$val=htmlspecialchars($val);
return "<input type=text name=${key} id=${id} value='${val}'>";
}
function _edit_password($id,$key,$def_vals,$val=""){
$val=preg_replace("{.}","*",$val);
return "<input type=password name=${key} id=${id} value='${val}'>";
}
function _edit_num($id,$key,$def_vals,$val=""){
$val=(int)($val);
return "<input type=text name=${key} id=${id} value='${val}'>";
}
function _edit_bool($id,$key,$def_vals,$val=""){
$ret="<input type=checkbox name=${key} id=${id}";
if ($val)
$ret.=" checked";
$ret.=">";
return $ret;
}
function _edit_longtext($id,$key,$def_vals,$val=""){
$val=htmlspecialchars($val);
return "<textarea name=${key} id=${id} rows=2 style='width:20em;'>${val}</textarea>";
}
function _edit_enum($id,$key,$def_vals,$val=""){
$ret="<select name=${key} id=${id}>";
foreach($def_vals as $opt_val){
$ret.="<option";
if ($opt_val==$val)
$ret.=" selected";
$ret.=">${opt_val}</option>\n";
}
$ret.="</select>\n";
return $ret;
}
function _listview_id($val){
return "<a href='?edit=${val}'>&nbsp;${val}&nbsp;</a>";
}
function _listview_bool($val){
return $val?"+":"";
}
function _listview_longtext($val){
return strlen($val)?"Text - ".strlen($val)." chars":"--x--";
}
function _listview_text($val){
return sizeof($val)?$val:"--x--";
}
function _listview_password($val){
return preg_replace("{.}","*",$val);
}
?>
</table>
<p />
</form>
</div>
Loading…
Cancel
Save