Esempio n. 1
0
function irciv_save_data()
{
    global $dest;
    $games = get_game_list();
    $n = count($games);
    if ($n == 0) {
        if ($dest != "") {
            irciv_privmsg("no games registered");
        } else {
            irciv_term_echo("no games registered");
        }
        return;
    }
    $chanlist = array();
    foreach ($games as $channel => $bucket) {
        $game_bucket = get_array_bucket($bucket);
        $game_bucket = json_encode($game_bucket, JSON_PRETTY_PRINT);
        $filename = DATA_FILE_PATH . $channel;
        if (file_put_contents($filename, $game_bucket) === False) {
            if ($dest != "") {
                irciv_privmsg("error saving channel data file \"{$filename}\"");
            } else {
                irciv_term_echo("error saving channel data file \"{$filename}\"");
            }
        } else {
            $chanlist[] = $channel;
            if ($dest != "") {
                irciv_privmsg("channel data file \"{$filename}\" saved successfully");
            } else {
                irciv_term_echo("channel data file \"{$filename}\" saved successfully");
            }
        }
    }
    $data = implode("\n", $chanlist);
    $filename = DATA_FILE_PATH . "irciv_chan_list";
    if (file_put_contents($filename, $data) === False) {
        if ($dest != "") {
            irciv_privmsg("error saving irciv channel list file \"{$filename}\"");
        } else {
            irciv_term_echo("error saving irciv channel list file \"{$filename}\"");
        }
    } else {
        if ($dest != "") {
            irciv_privmsg("irciv channel list file \"{$filename}\" saved successfully");
        } else {
            irciv_term_echo("irciv channel list file \"{$filename}\" saved successfully");
        }
    }
}
Esempio n. 2
0
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    }
    return $pageURL;
}
$pageURL = curPageURL();
header("Refresh: 300; URL={$pageURL}");
//refresh the page every 5 min
function get_game_list()
{
    global $server_cfg;
    $games = $server_cfg["overview_games"];
    sort($games);
    return $games;
}
$game_list = get_game_list();
$warnMsgArr = array();
function get_instance_util_data($game)
{
    define('TTL', 30 * 60);
    //cache expiry time for apc is 30min
    $key = "instance_util_data_{$game}";
    $instances_obj = apc_fetch($key, $success);
    if ($success) {
        return $instances_obj;
    } else {
        $instance_util_obj = new InstanceUtilAdapter($game);
        $instances_obj = array("instances" => $instance_util_obj->get_instances_detail_data(), "total" => $instance_util_obj->get_game_summary(), "dau" => $instance_util_obj->get_dau());
        apc_add($key, $instances_obj, TTL);
        return $instances_obj;
    }
Esempio n. 3
0
         init_ai();
         $irciv_data_changed = True;
     }
     break;
 case "test-ai":
     if (is_gm() == True) {
         if ($trailing == "") {
             test_ai(1);
         } else {
             test_ai($trailing);
         }
         $irciv_data_changed = True;
     }
     break;
 case "game-list":
     $game_chans = get_game_list();
     $n = count($game_chans);
     if ($n == 0) {
         irciv_privmsg("no irciv games registered");
     } else {
         irciv_privmsg("registered games:");
         $i = 0;
         foreach ($game_chans as $channel => $bucket) {
             if ($i == $n - 1) {
                 irciv_privmsg("  └─ {$channel}");
             } else {
                 irciv_privmsg("  ├─ {$channel}");
             }
             $i++;
         }
     }