diff --git a/src/config.h b/src/config.h index 5cf15c84..04dfd0b8 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "0.1.24-master-branch" -#define BUILD 835 +#define BUILD 836 #define HOSTID "mailarchiver" @@ -87,6 +87,7 @@ #define SQL_OPTION_TABLE "option" #define SQL_DOMAIN_TABLE "domain" #define SQL_CUSTOMER_TABLE "customer" +#define SQL_IMPORT_TABLE "import" #define SQL_MESSAGES_VIEW "v_messages" #define SQL_ATTACHMENTS_VIEW "v_attachment" @@ -109,6 +110,7 @@ #define SQL_PREPARED_STMT_GET_FOLDER_ID "SELECT `id` FROM " SQL_FOLDER_TABLE " WHERE `name`=? AND `parent_id`=?" #define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`name`, `parent_id`) VALUES(?,?)" #define SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE "UPDATE " SQL_METADATA_TABLE " SET reference=? WHERE message_id=? AND reference=''" +#define SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS "SELECT id, type, username, password, server FROM " SQL_IMPORT_TABLE " WHERE started=0 ORDER BY id LIMIT 0,1" /* Error codes */ diff --git a/src/defs.h b/src/defs.h index 4a97a0be..df133d69 100644 --- a/src/defs.h +++ b/src/defs.h @@ -248,11 +248,21 @@ struct memcached_server { #endif +struct import { + int status; + int total_messages; + int processed_messages; + int import_job_id; + time_t started, updated, finished; +}; + + struct __data { int folder; char recursive_folder_names; char starttls[TINYBUFSIZE]; struct node *mydomains[MAXHASH]; + struct import *import; #ifdef NEED_MYSQL MYSQL_STMT *stmt_generic; diff --git a/src/imap.c b/src/imap.c index e1187911..3ed6809c 100644 --- a/src/imap.c +++ b/src/imap.c @@ -91,7 +91,7 @@ int read_response(int sd, char *buf, int buflen, char *tagok, struct __data *dat } -int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, int use_ssl, struct __config *cfg){ +int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg){ int rc=ERR, i, n, pos, endpos, messages=0, len, readlen, fd, lastpos, nreads, processed_messages=0; char *p, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], tagbad[SMALLBUFSIZE], buf[MAXBUFSIZE], filename[SMALLBUFSIZE]; char aggrbuf[3*MAXBUFSIZE]; @@ -199,7 +199,8 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda close(fd); - rc = import_message(filename, sdata, data, cfg); + if(dryrun == 0) rc = import_message(filename, sdata, data, cfg); + else rc = OK; if(rc == ERR) printf("error importing '%s'\n", filename); else unlink(filename); diff --git a/src/import.c b/src/import.c index f4d57ce2..16a67216 100644 --- a/src/import.c +++ b/src/import.c @@ -177,3 +177,13 @@ int add_new_folder(struct session_data *sdata, struct __data *data, char *folder } +void update_import_job_stat(struct __data *data){ + char buf[SMALLBUFSIZE]; + + snprintf(buf, sizeof(buf)-1, "update import set status=%d, started=%ld, updated=%ld, finished=%ld, total=%d, imported=%d where id=%d", data->import->status, data->import->started, data->import->updated, data->import->finished, data->import->total_messages, data->import->processed_messages, data->import->import_job_id); + + p_query(sdata, buf); +} + + + diff --git a/src/pilerimport.c b/src/pilerimport.c index 438b6144..d2167773 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -31,16 +31,20 @@ extern char *optarg; extern int optind; int quiet=0; +int dryrun=0; int remove_after_successful_import = 0; +int import_from_gui=0; int connect_to_imap_server(int sd, int *seq, char *username, char *password, int port, struct __data *data, int use_ssl); int list_folders(int sd, int *seq, char *folders, int foldersize, int use_ssl, struct __data *data); -int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, int use_ssl, struct __config *cfg); +int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg); int connect_to_pop3_server(int sd, char *username, char *password, int port, struct __data *data, int use_ssl); -int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, int use_ssl, struct __config *cfg); +int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg); void close_connection(int sd, struct __data *data, int use_ssl); +void update_import_job_stat(struct __data *data); + int import_from_mailbox(char *mailbox, struct session_data *sdata, struct __data *data, struct __config *cfg){ FILE *F, *f=NULL; @@ -252,7 +256,7 @@ int import_from_maildir(char *directory, struct session_data *sdata, struct __da } -int import_from_imap_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, char *skiplist, struct __config *cfg){ +int import_from_imap_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, char *skiplist, int dryrun, struct __config *cfg){ int rc=ERR, ret=OK, sd, seq=1, skipmatch, use_ssl=0; char *p, puf[SMALLBUFSIZE]; char muf[SMALLBUFSIZE]; @@ -317,7 +321,7 @@ int import_from_imap_server(char *server, char *username, char *password, int po if(quiet == 0) printf("processing folder: %s... ", puf); - if(process_imap_folder(sd, &seq, puf, sdata, data, use_ssl, cfg) == ERR) ret = ERR; + if(process_imap_folder(sd, &seq, puf, sdata, data, use_ssl, dryrun, cfg) == ERR) ret = ERR; } while(p); @@ -331,7 +335,7 @@ ENDE_IMAP: } -int import_from_pop3_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, struct __config *cfg){ +int import_from_pop3_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, int dryrun, struct __config *cfg){ int rc, ret=OK, sd, use_ssl=0; char port_string[6]; struct addrinfo hints, *res; @@ -368,7 +372,7 @@ int import_from_pop3_server(char *server, char *username, char *password, int po goto ENDE_POP3; } - if(process_pop3_emails(sd, sdata, data, use_ssl, cfg) == ERR) ret = ERR; + if(process_pop3_emails(sd, sdata, data, use_ssl, dryrun, cfg) == ERR) ret = ERR; close_connection(sd, data, use_ssl); @@ -379,6 +383,56 @@ ENDE_POP3: } +int read_gui_import_data(struct session_data *sdata, struct __data *data, int dryrun, struct __config *cfg){ + int rc=ERR; + char s_type[SMALLBUFSIZE], s_username[SMALLBUFSIZE], s_password[SMALLBUFSIZE], s_server[SMALLBUFSIZE]; + + memset(s_type, 0, sizeof(s_type)); + memset(s_username, 0, sizeof(s_username)); + memset(s_password, 0, sizeof(s_password)); + memset(s_server, 0, sizeof(s_server)); + + if(prepare_sql_statement(sdata, &(data->stmt_generic), SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS) == ERR) return ERR; + + p_bind_init(data); + + if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE; + + + + p_bind_init(data); + + data->sql[data->pos] = (char *)&(data->import->import_job_id); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++; + data->sql[data->pos] = &s_type[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_type)-2; data->pos++; + data->sql[data->pos] = &s_username[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_username)-2; data->pos++; + data->sql[data->pos] = &s_password[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_password)-2; data->pos++; + data->sql[data->pos] = &s_server[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_server)-2; data->pos++; + + p_store_results(sdata, data->stmt_generic, data); + + if(p_fetch_results(data->stmt_generic) == OK) rc = OK; + + p_free_results(data->stmt_generic); + + + +ENDE: + close_prepared_statement(data->stmt_generic); + + + time(&(data->import->started)); + data->import->status = 1; + update_import_job_stat(data); + + if(strcmp(s_type, "pop3") == 0){ + import_from_pop3_server(s_server, s_username, s_password, 110, sdata, data, dryrun, cfg); + } + + + return rc; +} + + void usage(){ printf("usage: pilerimport [-c ] -e | -m | -d | -i | -K | -u -p -P [-F ] [-R] [-r] [-q]\n"); exit(0); @@ -392,11 +446,18 @@ int main(int argc, char **argv){ struct session_data sdata; struct __config cfg; struct __data data; + struct import import; for(i=0; i +void update_import_job_stat(struct __data *data); + + int is_last_complete_pop3_packet(char *s, int len){ if(*(s+len-5) == '\r' && *(s+len-4) == '\n' && *(s+len-3) == '.' && *(s+len-2) == '\r' && *(s+len-1) == '\n'){ @@ -90,11 +93,14 @@ int connect_to_pop3_server(int sd, char *username, char *password, int port, str } -int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, int use_ssl, struct __config *cfg){ - int i, rc=ERR, n, messages=0, processed_messages=0, pos, readlen, fd, lastpos, nreads; +int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg){ + int i=0, rc=ERR, n, pos, readlen, fd, lastpos, nreads; char *p, buf[MAXBUFSIZE], filename[SMALLBUFSIZE]; char aggrbuf[3*MAXBUFSIZE]; + data->import->processed_messages = 0; + data->import->total_messages = 0; + snprintf(buf, sizeof(buf)-1, "STAT\r\n"); n = write1(sd, buf, strlen(buf), use_ssl, data->ssl); @@ -104,19 +110,19 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, p = strchr(&buf[4], ' '); if(p){ *p = '\0'; - messages = atoi(&buf[4]); + data->import->total_messages = atoi(&buf[4]); } } else return ERR; - printf("found %d messages\n", messages); + printf("found %d messages\n", data->import->total_messages); - if(messages <= 0) return rc; + if(data->import->total_messages <= 0) return rc; - for(i=1; i<=messages; i++){ - processed_messages++; - printf("processed: %7d\r", processed_messages); fflush(stdout); + for(i=1; i<=data->import->total_messages; i++){ + data->import->processed_messages++; + printf("processed: %7d\r", data->import->processed_messages); fflush(stdout); snprintf(buf, sizeof(buf)-1, "RETR %d\r\n", i); @@ -188,7 +194,13 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, close(fd); - rc = import_message(filename, sdata, data, cfg); + if(dryrun == 0) rc = import_message(filename, sdata, data, cfg); + else rc = OK; + + if(i % 100 == 0){ + time(&(data->import->updated)); + update_import_job_stat(data); + } unlink(filename); } @@ -199,6 +211,11 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data, printf("\n"); + time(&(data->import->finished)); + data->import->status = 2; + update_import_job_stat(data); + + return OK; } diff --git a/util/db-mysql.sql b/util/db-mysql.sql index 8a60ba95..a1c18335 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -386,3 +386,23 @@ create table if not exists `online` ( unique(`username`,`ipaddr`) ) Engine=InnoDB; + +create table if not exists `import` ( + `id` int not null auto_increment primary key, + `type` varchar(255) not null, + `username` varchar(255) not null, + `password` varchar(255) not null, + `server` varchar(255) not null, + `created` int default 0, + `started` int default 0, + `finished` int default 0, + `updated` int default 0, + `status` int default 0, + `total` int default 0, + `imported` int default 0, + `duplicate` int default 0, + `error` int default 0, + `cleared` int default 0 +) Engine=InnoDB; + + diff --git a/webui/config.php b/webui/config.php index fca3385c..40a6bfad 100644 --- a/webui/config.php +++ b/webui/config.php @@ -289,6 +289,7 @@ define('TABLE_OPTION', 'option'); define('TABLE_LDAP', 'ldap'); define('TABLE_CUSTOMER_SETTINGS', 'customer_settings'); define('TABLE_ONLINE', 'online'); +define('TABLE_IMPORT', 'import'); define('TABLE_GOOGLE', 'google'); define('TABLE_GOOGLE_IMAP', 'google_imap'); define('VIEW_MESSAGES', 'v_messages'); @@ -376,6 +377,13 @@ $actions = array( ); +$import_status = array( + 0 => 'PENDING', + 1 => 'RUNNING', + 2 => 'FINISHED' + ); + + $counters = array(MEMCACHED_PREFIX . 'rcvd', MEMCACHED_PREFIX . 'virus', MEMCACHED_PREFIX . 'duplicate', MEMCACHED_PREFIX . 'ignore', MEMCACHED_PREFIX . 'counters_last_update'); if(!isset($health_smtp_servers)) { diff --git a/webui/controller/import/jobs.php b/webui/controller/import/jobs.php new file mode 100644 index 00000000..f7cb2df8 --- /dev/null +++ b/webui/controller/import/jobs.php @@ -0,0 +1,126 @@ +id = "content"; + $this->template = "import/jobs.tpl"; + $this->layout = "common/layout"; + + + $request = Registry::get('request'); + $db = Registry::get('db'); + + $this->load->model('saas/import'); + + $this->document->title = $this->data['text_import'] . " jobs"; + + + $this->data['username'] = Registry::get('username'); + + + $this->data['page'] = 0; + $this->data['page_len'] = get_page_length(); + + $this->data['total'] = 0; + + $this->data['entries'] = array(); + + $this->data['id'] = -1; + + if(isset($this->request->get['id'])) { $this->data['id'] = $this->request->get['id']; } + + $this->data['import_status'] = Registry::get('import_status'); + + /* check if we are admin */ + + if(Registry::get('admin_user') == 1) { + + if($this->request->server['REQUEST_METHOD'] == 'POST') { + + if($this->validate() == true) { + + if(isset($this->request->post['id'])) { + if($this->model_saas_import->update($this->request->post) == 1) { + $this->data['x'] = $this->data['text_successfully_modified']; + } else { + $this->data['errorstring'] = $this->data['text_failed_to_modify']; + // set ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } + } + } + else { + if($this->model_saas_import->add($this->request->post) == 1) { + $this->data['x'] = $this->data['text_successfully_added']; + } else { + $this->data['errorstring'] = $this->data['text_failed_to_add']; + } + } + } + else { + $this->data['errorstring'] = $this->data['text_error_message']; + $this->data['errors'] = $this->error; + // set ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } + } + } + + if(isset($this->request->get['id'])) { + $this->data['a'] = $this->model_saas_import->get($this->data['id']); + } + else { + $this->data['entries'] = $this->model_saas_import->get(); + } + + if ( isset($this->data['errorstring']) ) { + // use posted values if they differ from database values (ie - form was submitted but failed validation) + if (isset($this->request->post['server'])) { $this->data['a']['server'] = $this->request->post['server'];} + if (isset($this->request->post['username'])) { $this->data['a']['username'] = $this->request->post['username'];} + if (isset($this->request->post['type'])) { $this->data['a']['type'] = $this->request->post['type'];} + } + + } + else { + $this->template = "common/error.tpl"; + $this->data['errorstring'] = $this->data['text_you_are_not_admin']; + } + + + $this->render(); + } + + + private function validate() { + + if(!isset($this->request->post['type']) || strlen($this->request->post['type']) < 1) { + $this->error['type'] = $this->data['text_field_required']; + } + + if(!isset($this->request->post['server']) || strlen($this->request->post['server']) < 1) { + $this->error['server'] = $this->data['text_field_required']; + } + + if(!isset($this->request->post['username']) || strlen($this->request->post['username']) < 1) { + $this->error['username'] = $this->data['text_field_required']; + } + + if(!isset($this->request->post['password']) || strlen($this->request->post['password']) < 1) { + $this->error['password'] = $this->data['text_field_required']; + } + + if (!$this->error) { + return true; + } else { + return false; + } + + } + + + +} + +?> diff --git a/webui/controller/import/list.php b/webui/controller/import/list.php new file mode 100644 index 00000000..4debd91c --- /dev/null +++ b/webui/controller/import/list.php @@ -0,0 +1,124 @@ +id = "content"; + $this->template = "import/list.tpl"; + $this->layout = "common/layout"; + + + $request = Registry::get('request'); + $db = Registry::get('db'); + + $this->load->model('saas/import'); + + $this->document->title = $this->data['text_import']; + + + $this->data['username'] = Registry::get('username'); + + + $this->data['page'] = 0; + $this->data['page_len'] = get_page_length(); + + $this->data['total'] = 0; + + $this->data['entries'] = array(); + + $this->data['id'] = -1; + + if(isset($this->request->get['id'])) { $this->data['id'] = $this->request->get['id']; } + + /* check if we are admin */ + + if(Registry::get('admin_user') == 1) { + + if($this->request->server['REQUEST_METHOD'] == 'POST') { + + if($this->validate() == true) { + + if(isset($this->request->post['id'])) { + if($this->model_saas_import->update($this->request->post) == 1) { + $this->data['x'] = $this->data['text_successfully_modified']; + } else { + $this->data['errorstring'] = $this->data['text_failed_to_modify']; + // set ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } + } + } + else { + if($this->model_saas_import->add($this->request->post) == 1) { + $this->data['x'] = $this->data['text_successfully_added']; + } else { + $this->data['errorstring'] = $this->data['text_failed_to_add']; + } + } + } + else { + $this->data['errorstring'] = $this->data['text_error_message']; + $this->data['errors'] = $this->error; + // set ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } + } + } + + if(isset($this->request->get['id'])) { + $this->data['a'] = $this->model_saas_import->get($this->data['id']); + } + else { + $this->data['entries'] = $this->model_saas_import->get(); + } + + if ( isset($this->data['errorstring']) ) { + // use posted values if they differ from database values (ie - form was submitted but failed validation) + if (isset($this->request->post['server'])) { $this->data['a']['server'] = $this->request->post['server'];} + if (isset($this->request->post['username'])) { $this->data['a']['username'] = $this->request->post['username'];} + if (isset($this->request->post['type'])) { $this->data['a']['type'] = $this->request->post['type'];} + } + + } + else { + $this->template = "common/error.tpl"; + $this->data['errorstring'] = $this->data['text_you_are_not_admin']; + } + + + $this->render(); + } + + + private function validate() { + + if(!isset($this->request->post['type']) || strlen($this->request->post['type']) < 1) { + $this->error['type'] = $this->data['text_field_required']; + } + + if(!isset($this->request->post['server']) || strlen($this->request->post['server']) < 1) { + $this->error['server'] = $this->data['text_field_required']; + } + + if(!isset($this->request->post['username']) || strlen($this->request->post['username']) < 1) { + $this->error['username'] = $this->data['text_field_required']; + } + + if(!isset($this->request->post['password']) || strlen($this->request->post['password']) < 1) { + $this->error['password'] = $this->data['text_field_required']; + } + + if (!$this->error) { + return true; + } else { + return false; + } + + } + + + +} + +?> diff --git a/webui/controller/import/remove.php b/webui/controller/import/remove.php new file mode 100644 index 00000000..f82a52d6 --- /dev/null +++ b/webui/controller/import/remove.php @@ -0,0 +1,79 @@ +id = "content"; + $this->template = "import/remove.tpl"; + $this->layout = "common/layout"; + + + $request = Registry::get('request'); + $db = Registry::get('db'); + + $this->load->model('saas/import'); + + $this->document->title = $this->data['text_import']; + + + $this->data['username'] = Registry::get('username'); + + $this->data['id'] = $this->request->get['id']; + $this->data['description'] = $this->request->get['name']; + $this->data['confirmed'] = (int)$this->request->get['confirmed']; + + + if($this->validate() == true) { + + if($this->data['confirmed'] == 1) { + $ret = $this->model_saas_import->delete($this->data['id'], $this->data['description']); + if($ret == 1){ + $this->data['x'] = $this->data['text_successfully_removed']; + } + else { + $this->data['x'] = $this->data['text_failed_to_remove']; + } + } + } + else { + $this->template = "common/error.tpl"; + $this->data['errorstring'] = array_pop($this->error); + } + + + + $this->render(); + } + + + private function validate() { + + if(Registry::get('admin_user') == 0) { + $this->error['admin'] = $this->data['text_you_are_not_admin']; + } + + if(!isset($this->request->get['name']) || strlen($this->request->get['name']) < 1) { + $this->error['description'] = $this->data['text_invalid_data']; + } + + if(!isset($this->request->get['id']) || !is_numeric($this->request->get['id'])) { + $this->error['id'] = $this->data['text_invalid_data']; + } + + if (!$this->error) { + return true; + } else { + return false; + } + + } + + +} + +?> diff --git a/webui/controller/import/test.php b/webui/controller/import/test.php new file mode 100644 index 00000000..75964fab --- /dev/null +++ b/webui/controller/import/test.php @@ -0,0 +1,59 @@ +id = "content"; + $this->template = "import/list.tpl"; + $this->layout = "common/layout"; + + require_once 'Zend/Mail/Protocol/Imap.php'; + require_once 'Zend/Mail/Protocol/Pop3.php'; + + $request = Registry::get('request'); + $db = Registry::get('db'); + $lang = Registry::get('language'); + + if($this->request->post['type'] == 'pop3') { + + try { + + $conn = new Zend_Mail_Protocol_Pop3($this->request->post['server'], '110', false); + + } catch (Zend_Mail_Protocol_Exception $e) { + print "" . $this->request->post['server'] . ": " . $lang->data['text_connection_failed'] . " "; + } + + if($conn) { + $s = $conn->connect($this->request->post['server']); + + if($s) { + + try { + $conn->login($this->request->post['username'], $this->request->post['password']); + print "" . $lang->data['text_connection_ok'] . " "; + } + catch (Zend_Mail_Protocol_Exception $e) { + print "" . $this->request->post['username'] . ": " . $lang->data['text_login_failed'] . " "; + + } + } + + } + + + } + + else { + print "" . $lang->data['text_error'] . " "; + } + + } + + +} + +?> diff --git a/webui/index.php b/webui/index.php index d2339154..5b4ac5b7 100644 --- a/webui/index.php +++ b/webui/index.php @@ -67,6 +67,7 @@ Registry::set('ldap_types', array("AD", "iredmail", "lotus", "zimbra")); Registry::set('health_smtp_servers', $health_smtp_servers); Registry::set('partitions_to_monitor', $partitions_to_monitor); Registry::set('actions', $actions); +Registry::set('import_status', $import_status); if(Registry::get('username')) { diff --git a/webui/language/de/messages.php b/webui/language/de/messages.php index 55fe0890..744f88e6 100644 --- a/webui/language/de/messages.php +++ b/webui/language/de/messages.php @@ -151,6 +151,7 @@ $_['text_home'] = "Startseite"; $_['text_image'] = "Bild"; $_['text_import'] = "Import"; +$_['text_import_job_delete_confirm_message'] = "Do you wish to delete import job"; $_['text_import_users'] = "Benutzer importieren"; $_['text_import_users_from_LDAP'] = "Benutzer aus LDAP importieren"; $_['text_inbound'] = "eingehend"; @@ -245,6 +246,7 @@ $_['text_policy_group'] = "Methodengruppe"; $_['text_policy_name'] = "Methodenname"; $_['text_previous'] = "Vorherige"; $_['text_processed_emails'] = "Bearbeitete Nachrichten"; +$_['text_progress'] = "Progress"; $_['text_purge_all_messages_from_quarantine'] = "Alle eigenen Nachrichten im Quarantänebereich löschen"; $_['text_purge_selected_messages'] = "Ausgewählte Nachrichten löschen"; $_['text_purged'] = "Gelöscht"; @@ -339,6 +341,7 @@ $_['text_total'] = "insgesamt"; $_['text_total_ratio'] = "Verhältnis (insgesamt)"; $_['text_total_query_time'] = "Dauer SQL-Abfrage"; $_['text_total_users'] = "insgesamt"; +$_['text_type'] = "Type"; $_['text_uids'] = "Benutzerkennungen"; $_['text_unauthorized_domain'] = "Unauthorized domain"; @@ -370,6 +373,7 @@ $_['text_view_journal'] = "Envelope"; $_['text_view_journal_envelope'] = "Envelope anzeigen"; $_['text_view_message'] = "Nachrichtentext anzeigen"; $_['text_view_message2'] = "Nachricht anzeigen"; +$_['text_view_progress'] = "view progress"; $_['text_view_raw_email'] = "Quelltext anzeigen"; $_['text_view_user_quarantine'] = "Quarantänebereich Benutzer anzeigen"; diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index b5654d7b..908f2129 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -151,6 +151,7 @@ $_['text_home'] = "Home"; $_['text_image'] = "image"; $_['text_import'] = "Import"; +$_['text_import_job_delete_confirm_message'] = "Do you wish to delete import job"; $_['text_import_users'] = "Import users"; $_['text_import_users_from_LDAP'] = "Import users from LDAP"; $_['text_inbound'] = "inbound"; @@ -245,6 +246,7 @@ $_['text_policy_group'] = "Policy group"; $_['text_policy_name'] = "Policy name"; $_['text_previous'] = "Previous"; $_['text_processed_emails'] = "Processed emails"; +$_['text_progress'] = "Progress"; $_['text_purge_all_messages_from_quarantine'] = "Purge all your own messages from quarantine"; $_['text_purge_selected_messages'] = "Purge selected messages"; $_['text_purged'] = "Purged"; @@ -339,6 +341,7 @@ $_['text_total'] = "total"; $_['text_total_ratio'] = "total ratio"; $_['text_total_query_time'] = "Total SQL query time"; $_['text_total_users'] = "total"; +$_['text_type'] = "Type"; $_['text_uids'] = "uids"; $_['text_unauthorized_domain'] = "Unauthorized domain"; @@ -370,6 +373,7 @@ $_['text_view_journal'] = "journal"; $_['text_view_journal_envelope'] = "View envelope"; $_['text_view_message'] = "View message"; $_['text_view_message2'] = "view message"; +$_['text_view_progress'] = "view progress"; $_['text_view_raw_email'] = "View raw email"; $_['text_view_user_quarantine'] = "View user's quarantine"; diff --git a/webui/language/hu/messages.iso-8859-2.php b/webui/language/hu/messages.iso-8859-2.php index a2fe12fa..82275b7d 100644 --- a/webui/language/hu/messages.iso-8859-2.php +++ b/webui/language/hu/messages.iso-8859-2.php @@ -151,6 +151,7 @@ $_['text_group_membership'] = "Csoport tags $_['text_image'] = "kép"; $_['text_import'] = "Import"; +$_['text_import_job_delete_confirm_message'] = "Törölni akarja ezt az import job-ot?"; $_['text_import_users'] = "Felhasználók importálása"; $_['text_import_users_from_LDAP'] = "Felhasználók importálása LDAP-ból"; $_['text_inbound'] = "bejövõ"; @@ -245,6 +246,7 @@ $_['text_policy_group'] = "H $_['text_policy_name'] = "Házirend neve"; $_['text_previous'] = "Elõzõ"; $_['text_processed_emails'] = "Feldolgozott levelek"; +$_['text_progress'] = "Státusz"; $_['text_purge_all_messages_from_quarantine'] = "Összes saját üzenet törlése a karanténból"; $_['text_purge_selected_messages'] = "Kiválasztott üzenetek eltávolítása"; $_['text_purged'] = "Eltávolítva"; @@ -339,6 +341,7 @@ $_['text_total'] = " $_['text_total_ratio'] = "összes arány"; $_['text_total_query_time'] = "SQL lekérdezések összideje"; $_['text_total_users'] = "összes"; +$_['text_type'] = "Típus"; $_['text_uids'] = "Felhasználó azonosítók"; $_['text_unknown'] = "ismeretlen"; @@ -370,6 +373,7 @@ $_['text_view_journal'] = "journal"; $_['text_view_journal_envelope'] = "Journal envelope"; $_['text_view_message'] = "Levél megtekintése"; $_['text_view_message2'] = "levél megtekintése"; +$_['text_view_progress'] = "folyamatban lévõ importálások"; $_['text_view_raw_email'] = "Formázatlan levél megtekintése"; $_['text_view_user_quarantine'] = "Felhasználó karantén megtekintése"; diff --git a/webui/language/hu/messages.php b/webui/language/hu/messages.php index fe7ab384..a7b41e18 100644 --- a/webui/language/hu/messages.php +++ b/webui/language/hu/messages.php @@ -151,6 +151,7 @@ $_['text_group_membership'] = "Csoport tagság"; $_['text_image'] = "kép"; $_['text_import'] = "Import"; +$_['text_import_job_delete_confirm_message'] = "Törölni akarja ezt az import job-ot?"; $_['text_import_users'] = "Felhasználók importálása"; $_['text_import_users_from_LDAP'] = "Felhasználók importálása LDAP-ból"; $_['text_inbound'] = "bejövÅ‘"; @@ -245,6 +246,7 @@ $_['text_policy_group'] = "Házirend azonosító"; $_['text_policy_name'] = "Házirend neve"; $_['text_previous'] = "ElÅ‘zÅ‘"; $_['text_processed_emails'] = "Feldolgozott levelek"; +$_['text_progress'] = "Státusz"; $_['text_purge_all_messages_from_quarantine'] = "Összes saját üzenet törlése a karanténból"; $_['text_purge_selected_messages'] = "Kiválasztott üzenetek eltávolítása"; $_['text_purged'] = "Eltávolítva"; @@ -339,6 +341,7 @@ $_['text_total'] = "összes"; $_['text_total_ratio'] = "összes arány"; $_['text_total_query_time'] = "SQL lekérdezések összideje"; $_['text_total_users'] = "összes"; +$_['text_type'] = "Típus"; $_['text_uids'] = "Felhasználó azonosítók"; $_['text_unknown'] = "ismeretlen"; @@ -370,6 +373,7 @@ $_['text_view_journal'] = "journal"; $_['text_view_journal_envelope'] = "Journal envelope"; $_['text_view_message'] = "Levél megtekintése"; $_['text_view_message2'] = "levél megtekintése"; +$_['text_view_progress'] = "folyamatban lévÅ‘ importálások"; $_['text_view_raw_email'] = "Formázatlan levél megtekintése"; $_['text_view_user_quarantine'] = "Felhasználó karantén megtekintése"; diff --git a/webui/language/pt/messages.php b/webui/language/pt/messages.php index 63626db8..63bb1902 100644 --- a/webui/language/pt/messages.php +++ b/webui/language/pt/messages.php @@ -147,6 +147,7 @@ $_['text_home'] = "Home"; $_['text_image'] = "imagem"; $_['text_import'] = "Importar"; +$_['text_import_job_delete_confirm_message'] = "Do you wish to delete import job"; $_['text_import_users'] = "Importar usuários"; $_['text_import_users_from_LDAP'] = "Importar usuários de LDAP"; $_['text_inbound'] = "interno"; @@ -240,6 +241,7 @@ $_['text_policy_group'] = "Grupo de política"; $_['text_policy_name'] = "Nome da política"; $_['text_previous'] = "Anterior"; $_['text_processed_emails'] = "Emails processados"; +$_['text_progress'] = "Progress"; $_['text_purge_all_messages_from_quarantine'] = "Expurgar todos as suas próprias mensagens da quarentena"; $_['text_purge_selected_messages'] = "Expurgar mensagens selecionadas"; $_['text_purged'] = "Expurgado"; @@ -332,6 +334,7 @@ $_['text_total'] = "total"; $_['text_total_ratio'] = "proporção total"; $_['text_total_query_time'] = "Tempo total de consulta SQL"; $_['text_total_users'] = "total"; +$_['text_type'] = "Type"; $_['text_uids'] = "UIDs"; $_['text_unauthorized_domain'] = "Domínio não autorizado"; @@ -363,6 +366,7 @@ $_['text_view_journal'] = "envelope"; $_['text_view_journal_envelope'] = "Visualizar envelope"; $_['text_view_message'] = "Visualizar mensagem"; $_['text_view_message2'] = "visualizar mensagem"; +$_['text_view_progress'] = "visualizar progress"; $_['text_view_raw_email'] = "Visualizar email em formar RAW"; $_['text_view_user_quarantine'] = "Visualizar quarentena do usuário"; diff --git a/webui/model/saas/import.php b/webui/model/saas/import.php new file mode 100644 index 00000000..9ac543a6 --- /dev/null +++ b/webui/model/saas/import.php @@ -0,0 +1,58 @@ += 0) { + $query = $this->db->query("SELECT * FROM " . TABLE_IMPORT . " WHERE id=?", array($id)); + if($query->num_rows > 0) { return $query->row; } + } + + $query = $this->db->query("SELECT * FROM " . TABLE_IMPORT . " ORDER BY id ASC"); + + if($query->num_rows > 0) { return $query->rows; } + + return array(); + } + + + public function delete($id = 0, $description = '') { + if($id == 0) { return 0; } + + $query = $this->db->query("DELETE FROM " . TABLE_IMPORT . " WHERE id=?", array($id)); + + $rc = $this->db->countAffected(); + + LOGGER("remove import entry: #$id, $description (rc=$rc)"); + + return $rc; + } + + + public function add($arr = array()) { + if(!isset($arr['type']) || !isset($arr['username'])) { return 0; } + + $query = $this->db->query("INSERT INTO " . TABLE_IMPORT . " (type, username, password, server) VALUES (?,?,?,?)", array($arr['type'], $arr['username'], $arr['password'], $arr['server'])); + + $rc = $this->db->countAffected(); + + if($rc == 1){ return 1; } + + return 0; + } + + + public function update($arr = array()) { + if(!isset($arr['id']) || !isset($arr['username']) || !isset($arr['password'])) { return 0; } + + $query = $this->db->query("UPDATE " . TABLE_IMPORT . " SET type=?, server=?, username=?, password=? WHERE id=?", array($arr['type'], $arr['server'], $arr['username'], $arr['password'], $arr['id'])); + + return $this->db->countAffected(); + } + + +} + +?> diff --git a/webui/view/javascript/piler-in.js b/webui/view/javascript/piler-in.js index 370ddee2..06457c67 100644 --- a/webui/view/javascript/piler-in.js +++ b/webui/view/javascript/piler-in.js @@ -969,6 +969,26 @@ var Piler = }, + test_pop3_connection:function() + { + Piler.log("[test_pop3_connection]"); + + jQuery.ajax('index.php?route=import/test', { + data: { + type: $('#type').val(), + server: $('#server').val(), + username: $('#username').val(), + password: $('#password').val() + }, + type: "POST" + }) + .done( function(a) { + $('#LDAPTEST').html(a); + }) + .fail(function(a, b) { alert("Problem retrieving XML data:" + b) }); + }, + + clear_ldap_test: function() { $('#LDAPTEST').html(''); diff --git a/webui/view/theme/default/templates/common/layout.tpl b/webui/view/theme/default/templates/common/layout.tpl index 17292bb5..61457be9 100644 --- a/webui/view/theme/default/templates/common/layout.tpl +++ b/webui/view/theme/default/templates/common/layout.tpl @@ -38,6 +38,7 @@ if(isset($this->request->get['route'])) { if($this->request->get['route'] == 'health/health') { ?> onload="Piler.load_health(); setInterval('Piler.load_health()', Piler.health_refresh * 1000);"request->get['route'] == 'stat/online') { ?> onload="setInterval('Piler.reload_page()', Piler.health_refresh * 1000);"request->get['route'] == 'import/jobs') { ?> onload="setInterval('Piler.reload_page()', 10 * 1000);"> diff --git a/webui/view/theme/default/templates/common/menu.tpl b/webui/view/theme/default/templates/common/menu.tpl index 9dd0d819..3559af5f 100644 --- a/webui/view/theme/default/templates/common/menu.tpl +++ b/webui/view/theme/default/templates/common/menu.tpl @@ -37,6 +37,7 @@
  •  
  •  
  • +
  •  
  •  
  •  
  • diff --git a/webui/view/theme/default/templates/import/jobs.tpl b/webui/view/theme/default/templates/import/jobs.tpl new file mode 100644 index 00000000..d516c4c9 --- /dev/null +++ b/webui/view/theme/default/templates/import/jobs.tpl @@ -0,0 +1,61 @@ + + +
    :
    + +
    + + + + +

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + +  
    /  
    + + +
    + +
    + + + + + +
    + diff --git a/webui/view/theme/default/templates/import/list.tpl b/webui/view/theme/default/templates/import/list.tpl new file mode 100644 index 00000000..c432f19e --- /dev/null +++ b/webui/view/theme/default/templates/import/list.tpl @@ -0,0 +1,104 @@ + + +

    0)) { print $text_edit_entry; } else { print $text_add_new_entry; } ?>

    + +
    :
    + +
    + + +
    + + 0)) { ?> + + + + + +
    "> + +
    + + +
    +
    +
    "> + +
    + + +
    +
    +
    "> + +
    + + +
    +
    + +
    + + 0)) { ?> + + + + +
    + +
    + + + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    +   
    *******  
    + + +
    + +
    + + + + + +
    + diff --git a/webui/view/theme/default/templates/import/remove.tpl b/webui/view/theme/default/templates/import/remove.tpl new file mode 100644 index 00000000..6a59e110 --- /dev/null +++ b/webui/view/theme/default/templates/import/remove.tpl @@ -0,0 +1,13 @@ + +
    + + + +
    .
    + + + +

     

    + +
    + diff --git a/webui/view/theme/mobile/templates/common/layout.tpl b/webui/view/theme/mobile/templates/common/layout.tpl index 55771b56..c82905c6 100644 --- a/webui/view/theme/mobile/templates/common/layout.tpl +++ b/webui/view/theme/mobile/templates/common/layout.tpl @@ -35,6 +35,7 @@ if(isset($this->request->get['route'])) { if($this->request->get['route'] == 'health/health') { ?> onload="Piler.load_health(); setInterval('Piler.load_health()', Piler.health_refresh * 1000);"request->get['route'] == 'stat/online') { ?> onload="setInterval('Piler.reload_page()', Piler.health_refresh * 1000);"request->get['route'] == 'import/jobs') { ?> onload="setInterval('Piler.reload_page()', 10 * 1000);"> diff --git a/webui/view/theme/mobile/templates/common/menu.tpl b/webui/view/theme/mobile/templates/common/menu.tpl index 02b64ae0..42d1a9fe 100644 --- a/webui/view/theme/mobile/templates/common/menu.tpl +++ b/webui/view/theme/mobile/templates/common/menu.tpl @@ -33,6 +33,7 @@
  • +
  • diff --git a/webui/view/theme/mobile/templates/import/jobs.tpl b/webui/view/theme/mobile/templates/import/jobs.tpl new file mode 100644 index 00000000..d516c4c9 --- /dev/null +++ b/webui/view/theme/mobile/templates/import/jobs.tpl @@ -0,0 +1,61 @@ + + +
    :
    + +
    + + + + +

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + +  
    /  
    + + +
    + +
    + + + + + +
    + diff --git a/webui/view/theme/mobile/templates/import/list.tpl b/webui/view/theme/mobile/templates/import/list.tpl new file mode 100644 index 00000000..c432f19e --- /dev/null +++ b/webui/view/theme/mobile/templates/import/list.tpl @@ -0,0 +1,104 @@ + + +

    0)) { print $text_edit_entry; } else { print $text_add_new_entry; } ?>

    + +
    :
    + +
    + + +
    + + 0)) { ?> + + + + + +
    "> + +
    + + +
    +
    +
    "> + +
    + + +
    +
    +
    "> + +
    + + +
    +
    + +
    + + 0)) { ?> + + + + +
    + +
    + + + +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    +   
    *******  
    + + +
    + +
    + + + + + +
    + diff --git a/webui/view/theme/mobile/templates/import/remove.tpl b/webui/view/theme/mobile/templates/import/remove.tpl new file mode 100644 index 00000000..6a59e110 --- /dev/null +++ b/webui/view/theme/mobile/templates/import/remove.tpl @@ -0,0 +1,13 @@ + +
    + + + +
    .
    + + + +

     

    + +
    +