Пример #1
0
     }
     $user_networks = Network::get_user_networks($user_id);
     if (count($user_networks)) {
         foreach ($user_networks as $network) {
             if ($network->user_type != NETWORK_OWNER) {
                 $network_prefix = $network->address;
                 try {
                     User::delete_user($user_id);
                     Network::leave($network->network_id, $user_id);
                     //leave
                 } catch (PAException $e) {
                     $message_array[] = $e->message;
                 }
             } else {
                 try {
                     Network::delete($network->network_id);
                 } catch (PAException $e) {
                     $message_array[] = $e->message;
                 }
             }
         }
     }
     //deleting user
     try {
         User::delete($user_id);
     } catch (PAException $e) {
         Logger::log('User has been already deleted');
     }
 } else {
     //user delete for network owner
     $network_prefix = $network_info->address;
    $form_data['email_validation'] = $extra['email_validation'];
    $form_data['top_navigation_bar'] = @$extra['top_navigation_bar'];
    $form_data['network_content_moderation'] = @$extra['network_content_moderation'];
    // can be missing
    $form_data['action'] = 'edit';
    $form_data['inner_logo_image'] = $network_info->inner_logo_image;
}
// also check if the person who is editing the network is really the owner of network
if (@$_POST['action'] == 'delete' && !$error) {
    if (@$_POST['delete_network'] == 1) {
        $delete_permission = current_user_can('delete_network');
        if ($delete_permission) {
            //delete network and redirect to mother network homepage
            // FIX ME where we want to send after deletion
            $m = mothership_info();
            Network::delete($network_info->network_id);
            header('location:' . $m['url'] . "?msg=7029");
            exit;
        } else {
            throw new PAException(OPERATION_NOT_PERMITTED, 'You are not authorised to delete the network.');
        }
    } else {
        $error = TRUE;
        $error_msg = 'Please confirm network deletion by selecting deletion checkbox.';
    }
}
if (@$_POST['action'] == 'edit' && !$error) {
    $vartoset = array('name', 'tagline', 'category', 'desc', 'header_image', 'header_image_option', 'network_group_title', 'action', 'type');
    filter_all_post($_POST);
    //filters all data of html
    for ($i = 0; $i < count($vartoset); $i += 1) {
    $form_data['inner_logo_image'] = $network_settings->inner_logo_image;
    $form_data['language_bar_enabled'] = isset($extra['language_bar_enabled']) ? $extra['language_bar_enabled'] : NET_YES;
    $form_data['default_language'] = isset($extra['default_language']) ? $extra['default_language'] : 'english';
}
// also check if the person who is editing the network is really the owner of network
if (@$_POST['action'] == 'delete' && !$error) {
    if (@$_POST['delete_network'] == 1) {
        $delete_permission = false;
        if (PA::$login_uid) {
            $delete_permission = User::has_network_permissions(PA::$login_uid, array('delete_network'), true);
        }
        if ($delete_permission) {
            //delete network and redirect to mother network homepage
            // FIX ME where we want to send after deletion
            $m = mothership_info();
            Network::delete(PA::$network_info->network_id);
            header('location:' . $m['url'] . "?msg=7029");
            exit;
        } else {
            throw new CNException(OPERATION_NOT_PERMITTED, 'You are not authorised to delete the network.');
        }
    } else {
        $error = TRUE;
        $error_msg = __('Please confirm network deletion by selecting deletion checkbox.');
    }
}
if (@$_POST['action'] == 'edit' && !$error) {
    $vartoset = array('name', 'tagline', 'category', 'desc', 'header_image', 'header_image_option', 'network_group_title', 'action', 'type');
    filter_all_post($_POST);
    //filters all data of html
    for ($i = 0; $i < count($vartoset); $i += 1) {
/**
 * @author   Z.Hron
 * @name     delete_users
 * @brief    This function delete array of users
 * @return   array of error messages
 *
 *
 */
function delete_users($params, $true_delete = FALSE)
{
    $message_array = array();
    $user_id_array = $params['user_id_array'];
    foreach ($user_id_array as $user_id) {
        if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
            if (!Network::member_exists(PA::$network_info->network_id, (int) $user_id)) {
                $message_array[] = "UserID {$user_id} does not exists.";
                continue;
            }
            //deleting user data from mothership
            try {
                User::delete_user($user_id);
                Activities::delete_for_user($user_id);
            } catch (CNException $e) {
                $message_array[] = $e->message;
            }
            $user_networks = Network::get_user_networks($user_id);
            if (count($user_networks)) {
                foreach ($user_networks as $network) {
                    if ($network->user_type != NETWORK_OWNER) {
                        $network_prefix = $network->address;
                        try {
                            User::delete_user($user_id);
                            Activities::delete_for_user($user_id);
                            Network::leave($network->network_id, $user_id);
                            //leave
                        } catch (CNException $e) {
                            $message_array[] = $e->message;
                        }
                    } else {
                        try {
                            Network::delete($network->network_id);
                        } catch (CNException $e) {
                            $message_array[] = $e->message;
                        }
                    }
                }
            }
            //deleting user
            try {
                User::delete($user_id, $true_delete);
            } catch (CNException $e) {
                Logger::log('User has been already deleted');
            }
        } else {
            //user delete for network owner
            if (!Network::member_exists(PA::$network_info->network_id, (int) $user_id)) {
                $message_array[] = "UserID {$user_id} does not exists.";
                continue;
            }
            $network_prefix = PA::$network_info->address;
            try {
                User::delete_user($user_id);
                Activities::delete_for_user($user_id);
                Network::leave(PA::$network_info->network_id, $user_id);
                //network leave
            } catch (CNException $e) {
                $message_array[] = $e->message;
            }
        }
    }
    return $message_array;
}
Пример #5
0
    // NO root users
    if ($url_login_user == 'root') {
        die('Do not set <b>Login User</b> to <font color="red">root</font>!  Set this to the normal Linux user created during Remote Server installation. See <a href="http://gamepanelx.com/wikiv3/index.php?title=Remote_Install" class="links" target="_blank">Remote Server Documentation</a>');
    }
    echo $Network->create($url_ip, $url_local, $url_os, $url_dc, $url_location, $url_login_user, $url_login_pass, $url_login_port);
} elseif ($url_do == 'save') {
    // Include config
    require DOCROOT . '/configuration.php';
    $enc_key = $settings['enc_key'];
    if (empty($enc_key)) {
        die($lang['no_enc_key']);
    }
    @mysql_query("UPDATE network SET ip='{$url_ip}',is_local='{$url_local}',os='{$url_os}',datacenter='{$url_dc}',location='{$url_location}',login_user=AES_ENCRYPT('{$url_login_user}', '{$enc_key}'),login_pass=AES_ENCRYPT('{$url_login_pass}', '{$enc_key}'),login_port=AES_ENCRYPT('{$url_login_port}', '{$enc_key}'),homedir='{$url_homedir}' WHERE id = '{$url_id}'") or die('Failed to update network settings');
    echo 'success';
} elseif ($url_do == 'delete') {
    echo $Network->delete($url_id);
} elseif ($url_do == 'delete_ip') {
    @mysql_query("DELETE FROM network WHERE id = '{$url_id}'") or die('Failed to delete the IP Address');
    echo 'success';
} elseif ($url_do == 'show_addip') {
    // Get original IP
    $result_ip = @mysql_query("SELECT ip FROM network WHERE id = '{$url_id}' LIMIT 1") or die('Failed to get IP!');
    $row_ip = mysql_fetch_row($result_ip);
    $this_ip = $row_ip[0];
    $arr_ip = explode('.', $this_ip);
    $first_3 = $arr_ip[0] . '.' . $arr_ip[1] . '.' . $arr_ip[2] . '.';
    echo '<b>' . $lang['new_ip'] . ':</b> <input type="text" class="inputs" id="new_ip" value="' . $first_3 . '" /><br />
    <div align="center"><div class="button" onClick="javascript:network_addip(' . $url_id . ');">' . $lang['save'] . '</div></div>';
    exit;
} elseif ($url_do == 'addip') {
    // Check existing
 function testNetworkCreation()
 {
     // check that we can create networks
     $can = Network::can_network_be_created();
     $this->assertFalse($can['error'], $can['error_msg']);
     // get network owner user and figure out name etc
     $user = Test::get_test_user();
     $name = "testnet" . rand(10000, 99999);
     $network_basic_controls = array();
     // with crossed fingers, we hope that it will succeed without any of the detail here!
     // make a new network
     $net = new Network();
     $net->set_params(array('user_id' => $user->user_id, 'name' => "auto-test network ({$name})", 'address' => $name, 'tagline' => "not much of a tagline", 'category_id' => 8, 'type' => 0, 'description' => "This network has been created automatically by a PHPUnit test.  If the test succeeds, it will be deleted, too!", 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time()));
     $net->save();
     //default_page_setting($net->address);
     // read it in again and see if it still works
     $net_read = Network::get_network_by_address($net->address);
     $this->assertEquals($net_read->network_id, $net->network_id);
     $this->assertEquals($net_read->type, 0);
     $this->assertEquals($net_read->member_count, 1);
     $this->assertEquals($net_read->owner_id, $user->user_id);
     // a user joins
     $user2 = Test::get_test_user(2);
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // a user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // make it into a moderated network
     $net->type = 2;
     $net->save();
     // check that it really is moderated
     $net_read = Network::get_network_by_address($net->address);
     $this->assertEquals($net_read->network_id, $net->network_id);
     $this->assertEquals($net_read->type, 2);
     // a user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // request approved
     Network::approve($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // all requests accepted (of course, there will only be the one)
     Network::approve_all($net->network_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // request denied
     Network::deny($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // delete network
     Network::delete($net->network_id);
 }
 public function delete($id = null)
 {
     if ($this->perm->can_delete == 'y') {
         if ($id) {
             $data = new Network($id);
             $action = 'DELETE';
             save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->title . ' Network');
             $data->delete();
         }
     }
     redirect("admin/networks");
 }
Пример #8
0
 public function deleteNetwork()
 {
     $this->needsApp();
     $this->printHeader = false;
     $this->printFooter = false;
     $nid = $_REQUEST['nid'];
     $network = new Network($nid);
     $network->delete();
     $networks = $this->networks = NetworkUtil::getNetworksByAidIndexNid($this->app->id);
     unset($networks[$nid]);
     App::setPriorities($networks);
     $sum = App::setWeights($networks);
     $url = '/apps/oneApp/appNetworks?aid=' . $this->app->id;
     if ($sum != 100) {
         $url .= '&showNoNetworkRunning=true';
     }
     fb("sum", $sum);
     fb('url', $url);
     $this->redirect($url);
 }
Пример #9
0
<?php

require_once 'runtime.php';
require_once ROOT_DIR . '/lib/core/Networklist.class.php';
$smarty->assign('message', Message::getMessage());
if (isset($_GET['action']) and $_GET['action'] == 'delete') {
    $network = new Network((int) $_GET['network_id']);
    $network->fetch();
    if (permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $network->getUserId())) {
        $network->delete();
        header('Location: ./networks.php');
    } else {
        Permission::denyAccess(PERM_ROOT, $network->getUserId());
    }
} elseif (empty($_POST)) {
    $networklist = new Networklist();
    $smarty->assign('networklist', $networklist->getNetworklist());
    $smarty->display("header.tpl.html");
    $smarty->display("networks.tpl.html");
    $smarty->display("footer.tpl.html");
} else {
    if (Permission::checkPermission(PERM_ROOT)) {
        $network = new Network(false, (int) $_SESSION['user_id'], $_POST['ip'], (int) $_POST['netmask'], (int) $_POST['ipv']);
        $network->store();
        header('Location: ./networks.php');
    } else {
        Permission::denyAccess(PERM_ROOT);
    }
}