Example #1
0
 $limits = read_limit_data($exdb);
 $msg .= 'read all limit data...<br />';
 // param_id -> cl_params table - not needed for import
 // tpye = admin, reseller, client
 $admins = $exdb->queryAllRecords("SELECT c.id, c.parent_id, c.type, c.cr_date, c.cname, c.pname, c.login, c.account_id, a.password, a.type as `pwtype`, c.status, c.phone, c.fax, c.email, c.address, c.city, c.state, c.pcode, c.country, c.locale, c.limits_id, c.params_id, c.perm_id, c.pool_id, c.logo_id, c.tmpl_id, c.guid, c.overuse, c.vendor_id, c.external_id FROM clients as c LEFT JOIN accounts as a ON (a.id = c.account_id) WHERE c.type = 'admin' ORDER BY c.parent_id, c.id");
 $resellers = $exdb->queryAllRecords("SELECT c.id, c.parent_id, c.type, c.cr_date, c.cname, c.pname, c.login, c.account_id, a.password, a.type as `pwtype`, c.status, c.phone, c.fax, c.email, c.address, c.city, c.state, c.pcode, c.country, c.locale, c.limits_id, c.params_id, c.perm_id, c.pool_id, c.logo_id, c.tmpl_id, c.guid, c.overuse, c.vendor_id, c.external_id FROM clients as c LEFT JOIN accounts as a ON (a.id = c.account_id) WHERE c.type = 'reseller' ORDER BY c.parent_id, c.id");
 $clients = $exdb->queryAllRecords("SELECT c.id, c.parent_id, c.type, c.cr_date, c.cname, c.pname, c.login, c.account_id, a.password, a.type as `pwtype`, c.status, c.phone, c.fax, c.email, c.address, c.city, c.state, c.pcode, c.country, c.locale, c.limits_id, c.params_id, c.perm_id, c.pool_id, c.logo_id, c.tmpl_id, c.guid, c.overuse, c.vendor_id, c.external_id FROM clients as c LEFT JOIN accounts as a ON (a.id = c.account_id) WHERE c.type = 'client' ORDER BY c.parent_id, c.id");
 $users = array_merge($admins, $resellers, $clients);
 $msg .= 'read all users (' . count($users) . ')...<br />';
 $plesk_ispc_ids = array();
 // array with key = plesk id, value = ispc id
 $phpopts = array('no', 'fast-cgi', 'cgi', 'mod', 'suphp', 'php-fpm');
 // import admins / resellers
 for ($i = 0; $i < count($users); $i++) {
     $entry = $users[$i];
     $old_client = $importer->client_get_by_username($session_id, $entry['login']);
     if ($old_client) {
         if ($old_client['client_id'] == 0) {
             $entry['login'] = '******' . $entry['login'];
             $old_client = $importer->client_get_by_username($session_id, $entry['login']);
             if ($old_client) {
                 $msg .= $entry['login'] . ' existed, updating id ' . $old_client['client_id'] . '<br />';
             }
         } else {
             $msg .= $entry['login'] . ' existed, updating id ' . $old_client['client_id'] . '<br />';
         }
     }
     $params = array('company_name' => $entry['cname'], 'contact_name' => $entry['pname'], 'customer_no' => 'Plesk' . $entry['id'], 'username' => $entry['login'], 'password' => $entry['password'], 'language' => substr($entry['locale'], 0, 2), 'street' => $entry['address'], 'zip' => $entry['pcode'], 'city' => $entry['city'], 'state' => $entry['state'], 'country' => $entry['country'], 'telephone' => $entry['phone'], 'fax' => $entry['fax'], 'email' => $entry['email'], 'notes' => 'imported from Plesk id ' . $entry['id'], 'limit_maildomain' => get_limit($limits, $entry['id'], 'max_site', -1), 'limit_mailbox' => get_limit($limits, $entry['id'], 'max_box', -1), 'limit_mailalias' => get_limit($limits, $entry['id'], 'max_mn', -1), 'limit_mailaliasdomain' => get_limit($limits, $entry['id'], 'max_dom_aliases', -1), 'limit_mailmailinglist' => get_limit($limits, $entry['id'], 'max_maillists', -1), 'limit_mailforward' => get_limit($limits, $entry['id'], 'max_mn', -1), 'limit_mailcatchall' => 1, 'limit_mailrouting' => 0, 'limit_mailfilter' => 0, 'limit_fetchmail' => 0, 'limit_mailquota' => get_limit($limits, $entry['id'], 'mbox_quota', -1), 'limit_spamfilter_wblist' => 0, 'limit_spamfilter_user' => 0, 'limit_spamfilter_policy' => 0, 'limit_web_domain' => get_limit($limits, $entry['id'], 'max_site', -1), 'limit_web_quota' => intval(get_limit($limits, $entry['id'], 'disk_space', -1)), 'web_php_options' => implode(',', $phpopts), 'limit_web_aliasdomain' => get_limit($limits, $entry['id'], 'max_dom_aliases', -1), 'limit_web_subdomain' => get_limit($limits, $entry['id'], 'max_subdom', -1), 'limit_ftp_user' => (string) ($app->functions->intval(get_limit($limits, $entry['id'], 'max_subftp_users', -2)) + 1), 'limit_shell_user' => 0, 'ssh_chroot' => 'no,jailkit', 'limit_webdav_user' => get_limit($limits, $entry['id'], 'max_wu', 0), 'limit_dns_zone' => -1, 'limit_dns_slave_zone' => -1, 'limit_dns_record' => -1, 'limit_client' => $entry['type'] == 'client' ? 0 : -1, 'limit_database' => get_limit($limits, $entry['id'], 'max_db', -1), 'limit_cron' => 0, 'limit_cron_type' => 'url', 'limit_cron_frequency' => '5', 'limit_traffic_quota' => intval(get_limit($limits, $entry['id'], 'max_traffic', -1)), 'limit_openvz_vm' => 0, 'limit_openvz_vm_template_id' => '');
     $reseller_id = 0;
     if ($entry['parent_id'] != 0) {
         if (array_key_exists($entry['parent_id'], $plesk_ispc_ids)) {