示例#1
0
文件: ngcsWP.php 项目: uaktags/ngcsWP
function server_management_page()
{
    ?>
    <table id="server_table" class="display">
        <thead>
            <tr>
                <th>Server Name</th>
                <th>Status</th>
                <th>OS</th>
                <th>IP</th>
                <th>CPU</th>
                <th>Ram</th>
                <th>SSD</th>
            </tr>
        </thead>
        <tbody>
        <?php 
    $options = get_option('ngcs_api_settings');
    // create an adapter with your user's API Token
    // found in your CloudPanel under "Users"
    $adapter = new HttpAdapter($options['ngcs_api_text_field_0']);
    // create a ngcs object with the previous adapter
    $ngcs = new NGCSv1($adapter);
    $server = $ngcs->server();
    $servers = $server->getAll();
    foreach ($servers as $k) {
        $hardware = $k->hardware;
        $status = '<div class="circle ' . $k->status['state'] . '"></div>';
        $appliance = $ngcs->appliances()->getById($k->image->id);
        $image = $appliance->os . ' ' . $appliance->architecture . 'Bit';
        $osver = $appliance->osVersion;
        $ip = $k->ips['0']->ip;
        echo "<tr style='height:30px;'>\r\n                    <td>{$k->name}</td>\r\n                    <td><center>{$status}</center></td>\r\n                    <td><center><span class='os {$osver}'>{$image}</span></center></td>\r\n                    <th>{$ip}</th>\r\n                    <th>{$hardware->vcore}</th>\r\n                    <th>{$hardware->ram}</th>\r\n                    <th>SSD</th>\r\n                  </tr>\r\n                    ";
    }
    ?>
        </tbody></table>
    <?php 
}
示例#2
0
文件: index.php 项目: uaktags/ngcsv1
<?php

require 'vendor/autoload.php';
use NGCSv1\Adapter\HttpAdapter;
use NGCSv1\NGCSv1;
// create an adapter with your user's API Token
// found in your CloudPanel under "Users"
$adapter = new HttpAdapter('0d5f7035afb9aadc0e19a94b46b9a5b9');
// create a ngcs object with the previous adapter
$ngcs = new NGCSv1($adapter);
var_dump($ngcs->Roles()->getAll());