Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
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
1045
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
// 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) $new_id = false;
} 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) $new_id = false;
} 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");
$databases = $exdb->queryAllRecords("SELECT d.id, d.name, d.type, d.dom_id, d.db_server_id, d.default_user_id FROM databases as d");
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
$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)");
// 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();
?>