Ejemplo n.º 1
0
function onapp_UnsuspendAccount($params)
{
    global $_LANG;
    if (wrapper_check()) {
        return wrapper_check();
    }
    $status = serviceStatus($params['serviceid']);
    serviceStatus($params['serviceid'], 'Active');
    $vm = get_vm($params['serviceid']);
    if ($vm->_obj->_id && $vm->_obj->_suspended) {
        $vm->_obj->auth($params['serverip'] ? $params['serverip'] : $params['serverhostname'], $params['serverusername'], $params['serverpassword']);
        $vm->_obj->suspend();
        if (!is_null($vm->error)) {
            return is_array($vm->error) ? $_LANG["onappcantdeletevm"] . "<br/>\n " . implode(', ', $vm->error) : $_LANG["onappcantdeletevm"] . $vm->error;
        } elseif (!is_null($vm->_obj->error)) {
            return is_array($vm->_obj->error) ? $_LANG["onappcantdeletevm"] . "<br/>\n " . implode(', ', $vm->_obj->error) : $_LANG["onappcantdeletevm"] . $vm->_obj->error;
        }
    } else {
        return $_LANG['onappvmalreadyactive'];
    }
    serviceStatus($params['serviceid'], 'Suspended');
    return 'success';
}
Ejemplo n.º 2
0
/**
 * Show user Virtual machines list
 */
function clientareaproducts()
{
    global $user_id, $_ONAPPVARS, $_LANG;
    if (wrapper_check()) {
        show_template("onapp/clientareaproducts", array('services' => array(), 'not_resolved_vms' => array(), 'error' => $_LANG['onapponmaintenance']));
        return;
    }
    $services = array();
    $not_resolved_vms = array();
    // Get OnApp VMs
    $select_onapp_users = sprintf("SELECT\n            *,\n            tblonappclients.password as userpassword\n        FROM\n            tblonappclients\n            LEFT JOIN tblservers ON tblservers.id = server_id\n        WHERE client_id = '%s';", $user_id);
    $onapp_users_query = full_query($select_onapp_users);
    while ($onapp_user = mysql_fetch_assoc($onapp_users_query)) {
        if (!$onapp_user['ipaddress'] && !$onapp_user['hostname']) {
            continue;
        }
        $vm = new ONAPP_VirtualMachine();
        $vm->auth($onapp_user["ipaddress"] != "" ? $onapp_user["ipaddress"] : $onapp_user["hostname"], $onapp_user["email"], decrypt($onapp_user["userpassword"]));
        $tmp_vms = $vm->getList();
        if (is_array($tmp_vms)) {
            foreach ($tmp_vms as $tmp_vm) {
                $not_resolved_vms[$onapp_user["server_id"]][$tmp_vm->_id] = array('vm' => $tmp_vm, 'server' => $onapp_user);
            }
        }
    }
    // Get services
    $select_services = "SELECT\n        tblhosting.id as id,\n        tblhosting.domain as domain,\n        tblhosting.server as serverid,\n        tblonappservices.vm_id as vmid,\n        tblproducts.name as product\n    FROM\n        tblhosting\n        LEFT JOIN tblproducts ON tblproducts.id = packageid\n        LEFT JOIN tblonappservices ON service_id = tblhosting.id\n    WHERE\n        servertype = 'onapp'\n        AND tblhosting.domainstatus = 'Active'\n        AND userid = '{$user_id}'\n    ORDER BY tblhosting.id ASC";
    $services_rows = full_query($select_services);
    if ($services_rows) {
        while ($service = mysql_fetch_assoc($services_rows)) {
            $services[$service['id']] = $service;
            if (is_null($service['vmid'])) {
                $services[$service['id']]['error'] = $_LANG["onappvmnotcreated"];
            } elseif (!isset($not_resolved_vms[$service['serverid']][$service['vmid']])) {
                $services[$service['id']]['error'] = sprintf($_LANG["onappvmnotfound"], $service['vmid']);
            } else {
                $services[$service['id']]['obj'] = $not_resolved_vms[$service['serverid']][$service['vmid']]['vm'];
                unset($not_resolved_vms[$service['serverid']][$service['vmid']]);
                if (count($not_resolved_vms[$service['serverid']]) == 0) {
                    unset($not_resolved_vms[$service['serverid']]);
                }
            }
        }
    }
    show_template("onapp/clientareaproducts", array('services' => $services, 'not_resolved_vms' => $not_resolved_vms, 'error' => isset($_ONAPPVARS['error']) ? $_ONAPPVARS['error'] : NULL));
}