Beispiel #1
0
function run_array_bucket_element_file_test()
{
    global $passed;
    $test_array = array();
    $test_array[TEST_KEY] = TEST_VALUE;
    set_array_bucket($test_array, TEST_BUCKET, True);
    if (save_array_bucket_element_to_file(TEST_BUCKET, TEST_KEY, TEST_FILE) == False) {
        term_echo("run_array_bucket_element_file_test failed! (1)");
        $passed = False;
    }
    if (load_array_bucket_element_from_file(TEST_BUCKET, TEST_KEY, TEST_FILE) == False) {
        term_echo("run_array_bucket_element_file_test failed! (2)");
        $passed = False;
    }
    $test_array = array();
    $test_array = get_array_bucket(TEST_BUCKET);
    if (isset($test_array[TEST_KEY]) == False) {
        term_echo("run_array_bucket_element_file_test failed! (3)");
        $passed = False;
    } elseif ($test_array[TEST_KEY] != TEST_VALUE) {
        term_echo("run_array_bucket_element_file_test failed! (4)");
        $passed = False;
    }
    unset_bucket(TEST_BUCKET);
    if (exec_file_delete(TEST_FILE) == False) {
        term_echo("run_array_bucket_element_file_test failed! (5)");
        $passed = False;
    }
    if (get_bucket(TEST_BUCKET) != "") {
        term_echo("run_array_bucket_element_file_test failed! (6)");
        $passed = False;
    }
}
Beispiel #2
0
function set_fs()
{
    global $fs;
    if ($fs["modified"] == False) {
        return;
    }
    $fs["modified"] = False;
    set_array_bucket($fs, BUCKET_FS, True);
    echo "/IRC :" . get_bot_nick() . " INTERNAL :~execfs sync\n";
}
Beispiel #3
0
function load_array_bucket_element_from_file($index, $key, $filename)
{
    $fn = DATA_PATH . $filename;
    if (file_exists($fn) == False) {
        return False;
    }
    $data = file_get_contents($fn);
    $element = json_decode($data, True);
    if ($element == NULL) {
        return False;
    }
    $bucket = get_array_bucket($index);
    $bucket[$key] = $element;
    set_array_bucket($bucket, $index, True);
    return True;
}
Beispiel #4
0
    return;
}
$user = users_get_data($nick);
if (isset($user["channels"][$dest]) == False) {
    return;
}
var_dump($items);
return;
$timestamp = $items["time"];
$index = "ANTISPAM_DATA_" . $dest . "_" . $nick;
$bucket = get_array_bucket($index);
if (isset($bucket["timestamps"]) == False) {
    $bucket["timestamps"] = array();
    $bucket["trailings"] = array();
}
$bucket["timestamps"][] = $timestamp;
$bucket["trailings"][] = $trailing;
$n = count($bucket["timestamps"]);
if ($n > PREVIOUS_MSG_TRACK) {
    array_shift($bucket);
}
set_array_bucket($bucket, $index);
if ($n < PREVIOUS_MSG_TRACK) {
    return;
}
$delta = $timestamp - $bucket["timestamps"][0];
$trailings = array_count_values($bucket["trailings"]);
if ($delta < 5 and count($trailings) == 1) {
    rawmsg("KICK {$dest} {$nick} :suspected flood");
}
#####################################################################################################
Beispiel #5
0
                        notice($nick, "  └─" . $option_id . $suffix . " => {$result}");
                    } else {
                        notice($nick, "  ├─" . $option_id . $suffix . " => {$result}");
                    }
                    $i++;
                }
                return;
            }
            if ($data[$id]["status"] != "open") {
                notice($nick, "  poll \"{$id}\"{$suffix} is not currently open for voting");
                return;
            }
            $account = users_get_account($nick);
            if ($account == "") {
                return;
            }
            if (isset($data[$id]["options"][$action]) == False) {
                notice($nick, "  invalid option for poll \"{$id}\"{$suffix}");
                return;
            }
            $data[$id]["votes"][$account] = $action;
            set_array_bucket($data, "<<IRC_VOTE_DATA>>");
            $opt_suffix = "";
            if ($data[$id]["options"][$action] != "") {
                $opt_suffix = " [" . $data[$id]["options"][$action] . "]";
            }
            notice($nick, "  vote registered by account \"{$account}\" with option \"{$action}\"{$opt_suffix} for poll \"{$id}\"{$suffix}");
            return;
    }
}
#####################################################################################################
Beispiel #6
0
function minion_talk($nick, $channel, $trailing)
{
    $relays_bucket = "activity.php/minion_talk/relays";
    $relays = get_array_bucket($relays_bucket);
    # flush all outdated relays
    $save_bucket = False;
    foreach ($relays as $freenode_nick => $freenode_channels) {
        foreach ($relays[$freenode_nick] as $freenode_channel => $data) {
            if (microtime(True) - $data["timestamp"] > 10 * 60) {
                unset($relays[$freenode_nick][$freenode_channel]);
                $save_bucket = True;
            }
        }
    }
    if ($nick != "") {
        $account = users_get_account($nick);
        $allowed = array("crutchy", "chromas", "mrcoolbp", "NCommander", "juggs", "TheMightyBuzzard");
        if (in_array($account, $allowed) == True) {
            if ($trailing == ".relays") {
                $n = 0;
                foreach ($relays as $freenode_nick => $freenode_channels) {
                    foreach ($relays[$freenode_nick] as $freenode_channel => $data) {
                        $rem = round(($data["timestamp"] + 10 * 60 - microtime(True)) / 60, 0);
                        pm($channel, chr(3) . "13  {$freenode_nick}: {$freenode_channel} => " . $data["channel"] . " (unset in {$rem} minutes)");
                        $n++;
                    }
                }
                if ($n == 0) {
                    pm($channel, chr(3) . "13  no channel relays currently active");
                }
                return;
            }
            $params = explode(">", $trailing);
            if (count($params) >= 2) {
                $freenode_channel = strtolower(trim($params[0]));
                if (substr($freenode_channel, 0, 1) == "#") {
                    array_shift($params);
                    $msg = trim(implode(">", $params));
                    if (strlen($msg) > 0) {
                        $commands = array("~minion raw sylnt :sylnt PRIVMSG {$freenode_channel} :<{$nick}> {$msg}");
                        internal_macro($commands);
                        $parts = explode(",", $msg);
                        $freenode_nick = strtolower(trim($parts[0]));
                        if (count($parts) > 1 and strpos($freenode_nick, " ") === False) {
                            $relays[$freenode_nick][$freenode_channel] = array("channel" => $channel, "timestamp" => microtime(True));
                            pm($channel, chr(3) . "13  ten minute relay set for \"{$freenode_nick}\" in \"{$freenode_channel}\" on freenode to \"{$channel}\" on this server");
                            $save_bucket = True;
                        }
                    }
                }
            }
        }
    }
    if ($channel == "#freenode") {
        $freenode_nick = extract_text($trailing, chr(3) . "03", chr(3) . " [", False);
        $freenode_channel = extract_text($trailing, chr(3) . " [" . chr(3) . "02", chr(3) . "] " . chr(3) . "05", False);
        if (isset($relays[strtolower($freenode_nick)][$freenode_channel]) == True) {
            $freenode_trailing = extract_text($trailing, chr(3) . "] " . chr(3) . "05", chr(3), True);
            pm($relays[strtolower($freenode_nick)][$freenode_channel]["channel"], chr(3) . "03" . $freenode_nick . chr(3) . " [" . chr(3) . "02" . $freenode_channel . chr(3) . "] " . chr(3) . "05" . $freenode_trailing);
        }
    }
    if ($save_bucket == True) {
        set_array_bucket($relays, $relays_bucket);
    }
}
Beispiel #7
0
    case "chair":
        meeting_chair();
        break;
    case "vote":
    case "motion":
        meeting_vote();
        break;
    case "assign":
    case "assignment":
    case "todo":
    case "to-do":
        meeting_assign();
        break;
}
if ($meeting_data_changed == True and $dest != "") {
    set_array_bucket($meeting_data, "MEETING_DATA_" . $dest);
}
#####################################################################################################
function meeting_join()
{
    global $parts;
    global $meeting_data;
    if (count($parts) != 2) {
        return;
    }
    # trailing = <nick> <channel>
    $nick = strtolower($parts[0]);
    $channel = strtolower($parts[1]);
    term_echo("meeting_join: nick={$nick}, channel={$channel}");
    $meeting_data = get_array_bucket("MEETING_DATA_" . $channel);
    if (isset($meeting_data["description"]) == False) {
Beispiel #8
0
            privmsg("error: line number not found");
            break;
        }
        if ($trailing == "") {
            privmsg("error: no code to insert");
            break;
        }
        array_splice($script_lines, $line_no - 1, 0, $trailing);
        $data_changed = True;
        privmsg("script line inserted");
        break;
    case "add":
        # ~x add while (True) { privmsg("flooding++"); }
        if ($script_name == "") {
            privmsg("error: no scripts opened for editing by {$nick} in {$dest}");
            break;
        }
        if ($trailing == "") {
            privmsg("error: nothing to append");
            break;
        }
        $script_lines[] = $trailing;
        $data_changed = True;
        privmsg("script line appended");
        break;
}
if ($data_changed == True and $script_name != "") {
    $scripts[$script_name]["code"] = base64_encode(implode("\n", $script_lines));
    set_array_bucket($scripts, "<<LIVE_SCRIPTS>>");
}
#####################################################################################################
Beispiel #9
0
if ($msg == "") {
    return;
}
$data = get_array_bucket("EXEC_KARMA");
if ($alias != "~karma") {
    $operator = substr($msg, strlen($msg) - 2);
    $msg = substr($msg, 0, strlen($msg) - 2);
    if (isset($data[$server][$dest][$msg]) == False) {
        $data[$server][$dest][$msg] = 0;
    }
    if ($msg == $nick) {
        return;
    }
    switch ($operator) {
        case "++":
            $data[$server][$dest][$msg] = $data[$server][$dest][$msg] + 1;
            break;
        case "--":
            $data[$server][$dest][$msg] = $data[$server][$dest][$msg] - 1;
            break;
        default:
            return;
    }
    set_array_bucket($data, "EXEC_KARMA");
}
if (isset($data[$server][$dest][$msg]) == False) {
    privmsg(chr(3) . "{$msg} doesn't have karma yet");
} else {
    privmsg(chr(2) . "karma" . chr(2) . " - {$msg}: " . $data[$server][$dest][$msg]);
}
#####################################################################################################
Beispiel #10
0
function irciv_load_data()
{
    $filename = DATA_FILE_PATH . "irciv_chan_list";
    if (file_exists($filename) == False) {
        irciv_term_echo("error: channel list file not found");
        return;
    }
    $game_chans = file_get_contents($filename);
    $game_chans = explode("\n", $game_chans);
    for ($i = 0; $i < count($game_chans); $i++) {
        $chan = trim($game_chans[$i]);
        if ($chan == "") {
            continue;
        }
        if (users_chan_exists($chan) == False) {
            irciv_privmsg("error: channel \"{$chan}\" not found");
            continue;
        }
        $filename = DATA_FILE_PATH . $chan;
        if (file_exists($filename) == False) {
            irciv_privmsg("error: file \"{$filename}\" not found");
            continue;
        }
        $game_bucket = file_get_contents($filename);
        $game_bucket = json_decode($game_bucket, True);
        if ($game_bucket === NULL) {
            irciv_privmsg("error: json_decode returned null when processing \"{$filename}\"");
            continue;
        }
        set_array_bucket($game_bucket, GAME_BUCKET_PREFIX . $chan, True);
        irciv_privmsg("game data for channel \"{$chan}\" loaded successfully");
    }
}
Beispiel #11
0
            $name = $trailing;
            $player_data[$account]["flags"][$name] = "";
            $irciv_data_changed = True;
            irciv_privmsg("flag \"{$name}\" set for player \"{$account}\"");
        } else {
            irciv_privmsg("syntax: [~civ] flag name");
        }
        break;
    case "unflag":
        if (player_ready($account) == False) {
            break;
        }
        if ($trailing != "") {
            $name = $trailing;
            if (isset($player_data[$account]["flags"][$name]) == True) {
                unset($player_data[$account]["flags"][$name]);
                $irciv_data_changed = True;
                irciv_privmsg("flag \"{$name}\" unset for player \"{$account}\"");
            } else {
                irciv_privmsg("flag \"{$name}\" not set for player \"{$account}\"");
            }
        } else {
            irciv_privmsg("syntax: [~civ] unflag name");
        }
        break;
}
if ($dest != "" and $irciv_data_changed == True) {
    set_array_bucket($game_data, GAME_BUCKET_PREFIX . $dest);
}
irc_unpause();
#####################################################################################################