Example #1
0
function databaseAddService($account_id, $service_name, $service_description, $identifier)
{
    $identifier = stripAlphaNumeric($identifier);
    //register database
    $service_id = createService($account_id, $service_name, $service_description, "database", array('db_name' => $identifier, 'db_host' => "localhost", 'db_username' => 'root', 'db_password' => ''));
    return $service_id;
}
Example #2
0
function ghostAddService($account_id, $service_name, $service_description, $identifier, $id3 = -1)
{
    global $config;
    $identifier = stripAlphaNumeric($identifier);
    //set target directory
    $directory = $config['ghost_path'] . $identifier . '/';
    if (file_exists($directory)) {
        return "the target directory {$directory} already exists!";
    }
    //register database
    $service_id = createService($account_id, $service_name, $service_description, "ghost", array('id' => $identifier));
    if ($service_id > 999 && $id3 == -1) {
        return "Error: exceeded the maximum three-digit ID!";
    } else {
        if ($id3 == -1) {
            $id3 = $service_id;
        }
    }
    //create parameters needed later
    $id3 = $id3 . "";
    while (strlen($id3) < 3) {
        $id3 = "0" . $id3;
    }
    setServiceParam($service_id, 'id3', $id3);
    //create target directory
    mkdir($directory, 0700);
    //create default.cfg
    $fh = fopen($directory . 'default.cfg', 'w');
    foreach ($GLOBALS['defaultParameters'] as $key => $value) {
        $value = str_replace("{ID3}", $id3, $value);
        fwrite($fh, "{$key} = {$value}\n");
    }
    fclose($fh);
    //create ghost.cfg
    $fh = fopen($directory . 'ghost.cfg', 'w');
    foreach ($GLOBALS['ghostParameters'] as $key => $array) {
        $value = str_replace("{ID3}", $id3, $array[1]);
        fwrite($fh, "{$key} = {$value}\n");
    }
    fclose($fh);
    //create motd.txt, gameloaded.txt, gameover.txt
    $fh = fopen($directory . "motd.txt", 'w');
    fwrite($fh, "This is the default welcome message. If you are the bot administrator, you can change this by logging into uxpanel and going to the message manager.\nThis game is hosted using GHost and uxpanel.\nuxpanel is developed by uakf.b and Luna Ghost.\nFor more information, see codelain.com and uxpanel.entgaming.net.");
    fclose($fh);
    $fh = fopen($directory . "gameloaded.txt", 'w');
    fwrite($fh, "This game is hosted using GHost and uxpanel.\nuxpanel is developed by uakf.b and Luna Ghost.");
    fclose($fh);
    $fh = fopen($directory . "gameover.txt", 'w');
    fwrite($fh, "This game was hosted using GHost and uxpanel.\nuxpanel is developed by uakf.b and Luna Ghost.");
    fclose($fh);
    //copy files
    copy($config['ghost_path'] . "language.cfg", $directory . "language.cfg");
    symlink($config['ghost_path'] . "ghost++", $directory . "ghost++");
    //make the subdirectories
    mkdir($directory . "replays", 0700);
    mkdir($directory . "maps", 0700);
    mkdir($directory . "mapcfgs", 0700);
    return $service_id;
}
Example #3
0
function garenaAddService($account_id, $service_name, $service_description, $identifier, $id3 = -1)
{
    global $config, $garenaDefaultParameters;
    $identifier = stripAlphaNumeric($identifier);
    //set target directory
    $directory = $config['garena_path'] . $identifier . '/';
    if (file_exists($directory)) {
        return "the target directory {$directory} already exists!";
    }
    //register database
    $service_id = createService($account_id, $service_name, $service_description, "garena", array('id' => $identifier));
    if ($service_id > 999 && $id3 == -1) {
        return "Error: exceeded the maximum three-digit ID!";
    } else {
        if ($id3 == -1) {
            $id3 = $service_id;
        }
    }
    //create parameters needed later
    $id3 = $id3 . "";
    while (strlen($id3) < 3) {
        $id3 = "0" . $id3;
    }
    setServiceParam($service_id, 'id3', $id3);
    //create target directory
    mkdir($directory, 0700);
    //create configuration file
    copy($config['garena_path'] . "gcb.cfg", $directory . "gcb.cfg");
    $rewrite = array();
    foreach ($garenaDefaultParameters as $key => $value) {
        $value = str_replace("{ID3}", $id3, $value);
        $rewrite[$key] = $value;
    }
    garenaReconfigure($service_id, $rewrite);
    //link files
    symlink($config['garena_path'] . "gkey.pem", $directory . "gkey.pem");
    symlink($config['garena_path'] . "gcb.jar", $directory . "gcb.jar");
    symlink($config['garena_path'] . "gcbrooms.txt", $directory . "gcbrooms.txt");
    symlink($config['garena_path'] . "lib", $directory . "lib");
    //make the subdirectories
    mkdir($directory . "log", 0700);
    mkdir($directory . "plugins", 0700);
    return $service_id;
}
Example #4
0
function channelAddService($account_id, $service_name, $service_description, $identifier)
{
    global $config;
    $identifier = stripAlphaNumeric($identifier);
    //set target directory
    $directory = $config['channel_path'] . $identifier . '/';
    if (file_exists($directory)) {
        return "the target directory {$directory} already exists!";
    }
    //register database
    $service_id = createService($account_id, $service_name, $service_description, "channel", array('id' => $identifier));
    //create target directory
    mkdir($directory, 0700);
    //write settings
    $fh = fopen($directory . 'chop.cfg', 'w');
    foreach ($GLOBALS['defaultChannelParameters'] as $key => $value) {
        fwrite($fh, "{$key} = {$value}\n");
    }
    foreach ($GLOBALS['channelParameters'] as $key => $array) {
        fwrite($fh, "{$key} = {$array[1]}\n");
    }
    fclose($fh);
    //make the subdirectories
    mkdir($directory . "cfg", 0700);
    mkdir($directory . "plugins", 0700);
    mkdir($directory . "plugins/pychop", 0700);
    //copy files
    copy($config['channel_path'] . "language.cfg", $directory . "language.cfg");
    symlink($config['channel_path'] . "chop++", $directory . "chop++");
    chmod($directory . "chop++", 0700);
    copy($config['channel_path'] . "cfg/ask8ball.txt", $directory . "cfg/ask8ball.txt");
    copy($config['channel_path'] . "cfg/command.txt", $directory . "cfg/command.txt");
    copy($config['channel_path'] . "cfg/quote.txt", $directory . "cfg/quote.txt");
    copy($config['channel_path'] . "cfg/slap_neg.txt", $directory . "cfg/slap_neg.txt");
    copy($config['channel_path'] . "cfg/slap_pos.txt", $directory . "cfg/slap_pos.txt");
    copy($config['channel_path'] . "cfg/phrase.txt", $directory . "cfg/phrase.txt");
    copy($config['channel_path'] . "plugins/__init__.py", $directory . "plugins/__init__.py");
    foreach ($GLOBALS['channelPlugins'] as $plugin) {
        copy($config['channel_path'] . "plugins/pychop/{$plugin}.py", $directory . "plugins/pychop/{$plugin}.py");
    }
    return $service_id;
}
Example #5
0
function minecraftAddService($account_id, $service_name, $service_description, $identifier)
{
    global $config;
    $identifier = stripAlphaNumeric($identifier);
    //set target directory
    $directory = $config['minecraft_path'] . $identifier . '/';
    if (file_exists($directory)) {
        return "the target directory {$directory} already exists!";
    }
    //register database
    $service_id = createService($account_id, $service_name, $service_description, "minecraft", array('id' => $identifier, 'memory' => '1024'));
    if ($service_id > 999 && $id3 == -1) {
        return "Error: exceeded the maximum three-digit ID!";
    } else {
        if ($id3 == -1) {
            $id3 = $service_id;
        }
    }
    //create target directory
    mkdir($directory, 0700);
    //create properties file
    $fh = fopen($directory . 'server.properties', 'w');
    foreach ($GLOBALS['defaultMinecraftParameters'] as $key => $value) {
        if ($value == '$RAND$') {
            $value = uid(32);
        }
        fwrite($fh, "{$key}={$value}\n");
    }
    foreach ($GLOBALS['minecraftParameters'] as $key => $array) {
        fwrite($fh, "{$key}={$array[1]}\n");
    }
    fclose($fh);
    //copy files
    copy($config['minecraft_path'] . "minecraft.jar", $directory . "minecraft.jar");
    chmod($directory . "minecraft.jar", 0700);
    //make the subdirectories
    mkdir($directory . "plugins", 0700);
    return $service_id;
}
Example #6
0
function execute($request, $callback)
{
    try {
        if (!file_exists(CLIENT_SECRET) || filesize(CLIENT_SECRET) < 23) {
            throw new Exception("auth_secret must exist and must not be empty", 404);
        }
        if (!SCRIPT_ID || strlen(SCRIPT_ID) < 42) {
            throw new Exception("script.id must exist and must not be empty ", 404);
        }
        $service = createService();
        $response = $service->scripts->run(SCRIPT_ID, $request);
        if (!isErrorResponse($response)) {
            return call_user_func_array($callback, array($response));
        }
    } catch (Exception $e) {
        // The API encountered a problem before the script started executing.
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }
}
Example #7
0
function main()
{
    $arguments = getopt("f:wvche:t:", array("vv", "rpc::", "service", "model", "mapper"));
    $file = isset($arguments['f']) ? $arguments['f'] : false;
    if (!$file) {
        echo "ERROR Option file -f \n";
        return;
    }
    $help = isset($arguments['h']) ? true : false;
    $Sservice = isset($arguments['service']) ? true : false;
    $Smodel = isset($arguments['model']) ? true : false;
    $Smapper = isset($arguments['mapper']) ? true : false;
    $Sall = $Sservice + $Smodel + $Smapper;
    $Sall = $Sall == 3 || $Sall == 0 ? true : false;
    $write = isset($arguments['w']) ? true : false;
    $clean = isset($arguments['c']) ? true : false;
    $exclus = isset($arguments['e']) ? $arguments['e'] : array();
    $Otable = isset($arguments['t']) ? $arguments['t'] : array();
    if (!is_array($exclus) || is_array($exclus) && count($exclus) == 1) {
        $exclus = array($exclus);
    }
    if (!is_array($Otable) || is_array($Otable) && count($Otable) == 1) {
        $Otable = array($Otable);
    }
    $verbose = isset($arguments['v']) ? true : false;
    $vverbose = isset($arguments['vv']) ? true : false;
    $rpc = isset($arguments['rpc']) ? is_bool($arguments['rpc']) ? true : $arguments['rpc'] : false;
    if ($help) {
        echo "-w                  : write\n";
        echo "-e [NameTable]      : exclus table\n";
        echo "-t [NameTable]      : filtre la table\n";
        echo "--service           : génerer service\n";
        echo "--mapper            : génerer mapper\n";
        echo "--model             : génerer model\n";
        echo "-v                  : verbose\n";
        echo "--vv                : verbose++\n";
        echo "-f                  : file *.mwb (file mysql workbench)\n";
        echo "--rpc[=NameTable]   : ATTENTION! si NameTable n'est pas present tous les JsonRpc des tables seront créés, sinon seule la table JSON-RPC NameTable sera créé \n";
        return 0;
    }
    $pathDal = "../module/Application/src/Application/";
    $pathJsonRpcServer = "../module/JsonRpcServer/src/JsonRpcServer/";
    $pathConf = "../module/Dal/Module.php";
    $pathConfRpc = "../module/JsonRpcServer/config/module.config.php";
    $result = parseMwb($file, $vverbose);
    $handle = opendir($pathDal . '/Model');
    $TableExistante = array();
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != ".." && strpos($entry, 'Abstract') !== 0 && strpos($entry, '.php') !== false && $entry != "ModelInterface.php") {
            $TableExistante[] = substr(toNoCamelCase(substr($entry, 0, -4)), 1);
        }
    }
    foreach ($result as $nameTable => $body) {
        if (!empty($Otable) && in_array($nameTable, $Otable) || empty($Otable)) {
            $columCamel = array();
            foreach ($body['column'] as $colum => $opt) {
                $columCamel[$opt['name']] = toCamelCase($opt['name']);
            }
            if (in_array($nameTable, $TableExistante)) {
                $val = array_search($nameTable, $TableExistante);
                if ($val !== false) {
                    unset($TableExistante[$val]);
                }
            }
            if (!in_array($nameTable, $exclus) && $nameTable != "" && $body['type'] == "table") {
                if ($Sall || $Smodel) {
                    createModel($nameTable, $columCamel, $pathDal, $write, $verbose);
                }
                if ($Sall || $Smapper) {
                    createMapper($nameTable, $pathDal, $write, $verbose);
                }
                if ($Sall || $Sservice) {
                    createService($nameTable, $pathDal, $write, $verbose);
                }
            }
            if ($rpc && !is_string($rpc) || $rpc === $nameTable) {
                createServiceRpc($nameTable, $pathJsonRpcServer, $pathConfRpc, $write, $verbose);
            }
        }
    }
    foreach ($TableExistante as $nameTable) {
        if ($Otable && $Otable == $nameTable || !$Otable) {
            removeModel($nameTable, $pathDal, $write, $verbose);
        }
    }
}
Example #8
0
$error = array();
/******/
$appAutoload = new appAutoload();
$appAutoload->mod("file");
$list = file::folder_list(DIR_APP);
$compile = [];
$serviceInitFile = "services.json";
foreach ($list as $key => $value) {
    $info = pathinfo($value);
    $app = $info["filename"];
    // createService($app);
    /* service */
    /* LOG compile service */
    $c->log("compile service", __FILE__, $app);
    /* END LOG compile service */
    $compile = merge_unique($compile, createService($app));
}
$jsonConfigEncode = json_encode($compile, JSON_PRETTY_PRINT);
$c->saveServices();
file_put_contents(DIR_SERVICES, $jsonConfigEncode);
function createService($app)
{
    /* PAGE */
    $newServiceDir = DIR_APP . "/" . $app . "/config";
    if (!file_exists($newServiceDir)) {
        mkdir($newServiceDir);
    }
    $service = $newServiceDir . "/services.json";
    $serviceContent = '{}';
    // file_put_contents($service,$serviceContent);
    $json = json_decode(file_get_contents($service), true);
Example #9
0
$topologyIP = getTopologyIP($topologyID, $DBConnect);
print $topologyIP . "\n";
$topologyOctet = explode(".", $topologyIP);
$routerIP = $topologyOctet[0] . "." . $topologyOctet[1] . ".0.1";
print $routerIP . "\n";
$routerID = createRouter($DBConnect, $routerHostname, $networkID, $topologyID);
$switchID = createSwitch($switchHostname, $DBConnect, $topologyID, $networkID);
attachInterfaceTo($routerID, $switchID, $DBConnect, $routerIP);
//Assigns services to a node.
$service = array($_POST['ssh'], $_POST['telnet'], $_POST['http'], $_POST['ftp'], $_POST['imServer'], $_POST['mail']);
$i = 0;
//Insert services into node table and assign an interface
while ($i < 7) {
    if (isset($service[$i])) {
        $hostname = $topology_name . "_" . $service[$i] . "";
        $nodeID = createService($hostname, $DBConnect, $topologyID, $networkID);
        $ipAddress = $topologyOctet[0] . "." . $topologyOctet[1] . ".1." . ($i + 2) . "";
        attachInterfaceTo($nodeID, $switchID, $DBConnect, $ipAddress);
    }
    $i++;
}
for ($j = 0; $j < $number_vlan; $j++) {
    $departmentName = $_POST['dptName_' . $j];
    $departmentHost = $_POST['noHost_' . $j];
    $vlanIpAddress = $topologyOctet[0] . "." . $topologyOctet[1] . "." . ($j + 2) . ".0";
    $vlanIP = createVlan($DBConnect, $departmentName, $vlanIpAddress, $switchID);
    for ($k = 0; $k < $departmentHost; $k++) {
        $pcHostname = $departmentName . "_" . ($k + 1) . "";
        $pcID = createWorkstation($DBConnect, $pcHostname, $networkID, $topologyID);
        $vlanIPOctet = explode(".", $vlanIpAddress);
        $pcIP = $vlanIPOctet[0] . "." . $vlanIPOctet[1] . "." . $vlanIPOctet[2] . "." . ($k + 2) . "";