Newer
Older
'autoresponder_text' => ($has_responder ? $responder['text'] : ''),
'autoresponder' => yes_no($has_responder ? 1 : 0),
'autoresponder_start_date' => ($has_responder && $responder['resp_on'] === 'true' ? strftime('%Y-%m-%d', time()) : strftime('%Y-%m-%d', time() - (3600*24))),
'autoresponder_end_date' => ($has_responder && $responder['resp_on'] === 'true' ? strftime('%Y-%m-%d', time() + (3600*24*365)) : strftime('%Y-%m-%d', time())),
'move_junk' => yes_no(0)
);
$client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]];
// if this is no postbox we do not need to create a mailuser
if($entry['postbox'] !== 'false') {
$old_mail = $app->db->queryOneRecord("SELECT mailuser_id FROM mail_user WHERE email = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "'");
if($old_mail) {
$new_id = $old_mail['mailuser_id'];
$ok = $importer->mail_user_update($session_id, $client_id, $new_id, $params);
if($ok === false) $msg .= " Error: " . $importer->getFault() . "<br />";
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
} else {
$new_id = $importer->mail_user_add($session_id, $client_id, $params);
}
if($new_id === false) {
//something went wrong here...
$msg .= "Mail" . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . ") could not be inserted/updated.<br />";
$msg .= " Error: " . $importer->getFault() . "<br />";
} else {
$msg .= "Mail " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . ") inserted/updated.<br />";
}
$mail_ids[$entry['id']] = $new_id;
}
// select all redirs for this address
$mail_redir = $exdb->queryAllRecords("SELECT id, mn_id, address FROM mail_redir WHERE mn_id = '" . $entry['id'] . "'");
foreach($mail_redir as $redir) {
$params = array(
'server_id' => $server_id,
'source' => $entry['mail_name'] . "@" . $parent_domain['name'],
'destination' => $redir['address'],
'type' => 'forward', // or forward
'active' => yes_no(1)
);
$old_mail = $app->db->queryOneRecord("SELECT forwarding_id FROM mail_forwarding WHERE source = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "' AND destination = '" . $redir['address'] . "'");
if($old_mail) {
$new_id = $old_mail['forwarding_id'];
$ok = $importer->mail_forward_update($session_id, $client_id, $new_id, $params);
if($ok === false) $msg .= " Error: " . $importer->getFault() . "<br />";
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
} else {
$new_id = $importer->mail_forward_add($session_id, $client_id, $params);
}
if($new_id === false) {
//something went wrong here...
$msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") could not be inserted/updated.<br />";
$msg .= " Error: " . $importer->getFault() . "<br />";
} else {
$msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") inserted/updated.<br />";
}
}
unset($mail_redir);
}
unset($mail_addresses);
$mail_aliases = $exdb->queryAllRecords("SELECT a.id, a.mn_id, a.alias, m.dom_id, m.mail_name FROM mail_aliases as a INNER JOIN mail as m ON (m.id = a.mn_id)");
foreach($mail_aliases as $entry) {
$parent_domain = $exdb->queryOneRecord("SELECT d.id, d.cl_id, d.name FROM domains as d WHERE d.id = '" . $entry['dom_id'] . "'");
if(!$parent_domain) {
$msg .= "Could not insert/update mail alias " . $entry['alias'] . " as domain is missing.<br />";
continue;
}
$params = array(
'server_id' => $server_id,
'source' => $entry['alias'] . "@" . $parent_domain['name'],
'destination' => $entry['mail_name'] . "@" . $parent_domain['name'],
'type' => 'alias', // or forward
'active' => yes_no(1)
);
$client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]];
$old_mail = $app->db->queryOneRecord("SELECT forwarding_id FROM mail_forwarding WHERE source = '" . $entry['alias'] . "@" . $parent_domain['name'] . "' AND destination = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "'");
if($old_mail) {
$new_id = $old_mail['forwarding_id'];
$ok = $importer->mail_alias_update($session_id, $client_id, $new_id, $params);
if($ok === false) $msg .= " Error: " . $importer->getFault() . "<br />";
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
} else {
$new_id = $importer->mail_alias_add($session_id, $client_id, $params);
}
if($new_id === false) {
//something went wrong here...
$msg .= "Mail alias " . $entry['id'] . " (" . $entry['alias'] . "@" . $parent_domain['name'] . ") could not be inserted/updated.<br />";
$msg .= " Error: " . $importer->getFault() . "<br />";
} else {
$msg .= "Mail alias " . $entry['id'] . " (" . $entry['alias'] . "@" . $parent_domain['name'] . ") inserted/updated.<br />";
}
}
unset($mail_aliases);
//spamfilter // preferences = true/false, username = email address, can be *@*
//id, username, preferences
//spamfilter_preferences
//prefid, spamfilter_id, preference, value
//$client_traffic = $exdb->queryAllRecords("SELECT t.cl_id, t.date, t.http_in, t.http_out, t.ftp_in, t.ftp_out, t.smtp_in, t.smtp_out, t.pop3_imap_in, t.pop3_imap_out FROM ClientsTraffic as t");
$db_users = $exdb->queryAllRecords("SELECT u.id, u.login, u.account_id, u.db_id, a.password, a.type as `pwtype` FROM db_users as u LEFT JOIN accounts as a ON (a.id = u.account_id)");
foreach($db_users as $db_user) {
// database user
$params = array('server_id' => $server_id,
'database_user' => $db_user['login'],
'database_password' => $db_user['password']);
$check = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user` = \'' . $app->db->quote($db_user['login']) . '\'');
$db_user_id = 0;
if($check) {
$ok = $importer->sites_database_user_update($session_id, $client_id, $check['database_user_id'], array_merge($check, $params));
if($ok === false) $msg .= " Error: " . $importer->getFault() . "<br />";
$db_user_id = $check['database_user_id'];
} else {
$db_user_id = $importer->sites_database_user_add($session_id, $client_id, $params);
}
if(!isset($db_userids[$db_user['db_id']])) $db_userids[$db_user['db_id']] = $db_user_id;
$msg .= 'Created / updated database user: ' . $db_user['login'] . '<br />';
$databases = $exdb->queryAllRecords("SELECT d.id, d.name, d.type, d.dom_id, d.db_server_id, d.default_user_id FROM `data_bases` as d");
foreach($databases as $database) {
$params = array('server_id' => $server_id,
'parent_domain_id' => $domain_ids[$database['dom_id']],
'type' => 'mysql',
'database_name' => $database['name'],
'database_user_id' => $db_userids[$database['id']],
'database_ro_user_id' => 0,
'database_charset' => 'utf8',
'remote_access' => 'n',
'active' => 'y',
'remote_ips' => '');
$check = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_name` = \'' . $app->db->quote($database['name']) . '\'');
if($check) {
$ok = $importer->sites_database_update($session_id, $client_id, $check['database_id'], array_merge($check, $params));
if($ok === false) $msg .= " Error: " . $importer->getFault() . "<br />";
} else {
$importer->sites_database_add($session_id, $client_id, $params);
}
$msg .= 'Created / updated database: ' . $database['name'] . '<br />';
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
// do we need table disk_usage for import? i think we don't
// name is domain name, displayName is including "Umlaute"
//$anon_ftp = $exdb->queryAllRecords("SELECT f.id, f.dom_id, f.max_conn, f.bandwidth, f.incoming, f.incoming_readable, f.incoming_subdirs, f.status, f.quota, f.display_login, f.login_text FROM anon_ftp as f");
//DomainServices
//id, dom_id, type, status, parameters_id, ipCollectionId
//DomainsTraffic
//dom_id, date, http_in, http_out, ftp_in, ftp_out, smtp_in, smtp_out, pop3_imap_in, pop3_imap_out
//IP_Adresses
//id, ip_address, mask, iface, ssl_certificate_id, default_domain_id, ftps, main, status
//ip_pool
//id, ip_address_id, type
/* TODO:
*/
//misc // needed? global settings
//param, val
//Permissions
//id, permission, value
//smb_users // pass is base64 encoded plaintext
//id, login, password, contactName, email, companyName, phone, fax, address, city, state, zip, country, creationDate, isBuiltIn, roleId, uuid, isLocked, authCookie, sessionId, externalId, ownerId, isDomainAdmin, additionalInfo, imNumber, imType, isLegacyUser
/* TODO:
sys_users // mapped_to = parent_id
id, login, account_id, home, shell, quota, mapped_to
*/
} else {
$msg .= 'Connecting to external database failed!<br />';
$msg .= $exdb->connect_error;
$msg .= substr($exdb->errorMessage, 0, 25);
$error .= $exdb->errorMessage;
}
//* restore db login details
/*$conf['db_host'] = $conf_bak['db_host'];
$conf['db_database'] = $conf_bak['db_database'];
$conf['db_user'] = $conf_bak['db_user'];
$conf['db_password'] = $conf_bak['db_password'];*/
}
$app->tpl->setVar('msg',$msg);
$app->tpl->setVar('error',$error);
$app->tpl_defaults();
$app->tpl->pparse();
?>