Example #1
0
     }
     sn_logout();
     return;
 case "~funding":
     $verifier_nick = get_bucket(BUCKET_VERIFIER_NICK);
     $verifier_account = "chromas";
     $verifier_msg = "exec_test_sn_site_down";
     $host = "soylentnews.org";
     $host_g = "google.com";
     $uri = "/";
     $port = 443;
     $response = wtouch($host, $uri, $port, 120);
     $response_g = wtouch($host_g, $uri, $port, 120);
     if ($response === False and $response_g !== False) {
         pm("crutchy", "ALERT: \"" . strtoupper($host) . "\" HOST IS UNAVAILABLE ON PORT {$port}");
         $account = users_get_account($verifier_nick);
         if ($account == $verifier_account) {
             pm($verifier_nick, $verifier_msg);
         } else {
             # DON'T TRUST EXEC TO ALERT ANYTHING ON IT'S OWN
             #pm("#soylent",chr(3)."08".chr(2)."*** ALERT: \"".strtoupper($host)."\" HOST IS UNAVAILABLE ON PORT $port ***");
         }
         return;
     }
     $extra_headers = array();
     $extra_headers["Cookie"] = sn_login();
     $response = wget($host, $uri, $port, ICEWEASEL_UA, $extra_headers);
     $delim1 = "<b>Progress So Far: \$";
     $delim2 = "</b>";
     $amount = extract_text($response, $delim1, $delim2);
     if ($amount !== False) {
Example #2
0
function wiki_unblockuser($nick, $trailing, $return = False)
{
    $username = trim(substr($trailing, strlen(".unblockuser") + 1));
    if ($username == "") {
        wiki_privmsg(False, "http://sylnt.us/wikispamctl");
        return;
    }
    $allowed1 = array("ncommander", "funpika", "mrcoolbp", "paulej72");
    # official wiki admins
    $allowed2 = array("juggs", "crutchy", "chromas", "themightybuzzard", "martyb");
    # trusted irc nickserv accounts
    $account = users_get_account($nick);
    if (in_array($account, $allowed1) == False and in_array($account, $allowed2) == False) {
        wiki_privmsg(False, "wiki: unblockuser=not authorized");
        return;
    }
    if (file_exists(DATA_PATH . "wiki_block_users") == False) {
        wiki_privmsg(False, "wiki: unblockuser=wiki_block_users file not found");
        return;
    }
    $block_users_list = explode(PHP_EOL, file_get_contents(DATA_PATH . "wiki_block_users"));
    delete_empty_elements($block_users_list, True);
    $username_exists = False;
    for ($i = 0; $i < count($block_users_list); $i++) {
        $parts = explode(" ", $block_users_list[$i]);
        array_shift($parts);
        $block_username = implode(" ", $parts);
        if ($block_username === $username) {
            $username_exists = True;
            unset($block_users_list[$i]);
        }
    }
    if ($username_exists == False) {
        wiki_privmsg(False, "wiki: unblockuser=username not found in wiki_block_users file");
        return;
    }
    if (file_put_contents(DATA_PATH . "wiki_block_users", implode(PHP_EOL, $block_users_list)) === False) {
        wiki_privmsg(False, "wiki: unblockuser=error writing wiki_block_users file");
    } else {
        wiki_privmsg(False, "  deleted \"{$username}\" from wiki_block_users file");
    }
}
Example #3
0
             $suffix = ": " . $data[$id]["options"][$option_id];
         }
         if ($i == $n - 1) {
             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;
Example #4
0
if (count($parts) < 3) {
    return;
}
$nick = strtolower($parts[0]);
$channel = strtolower($parts[1]);
array_shift($parts);
array_shift($parts);
$trailing = trim(implode(" ", $parts));
return;
define("PREVIOUS_MSG_TRACK", 5);
if (get_bucket("<<IRC_CONNECTION_ESTABLISHED>>") != "1") {
    return;
}
$items = unserialize($argv[1]);
$nick = $items["nick"];
if (users_get_account($nick) == get_bot_nick()) {
    return;
}
$trailing = $items["trailing"];
$dest = strtolower($items["destination"]);
$exec = users_get_data(get_bot_nick());
if (isset($exec["channels"][$dest]) == True) {
    if (strpos($exec["channels"][$dest], "@") === False) {
        return;
    }
} else {
    return;
}
$user = users_get_data($nick);
if (isset($user["channels"][$dest]) == False) {
    return;
Example #5
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);
    }
}
Example #6
0
        }
        if (isset($user["account"]) == True) {
            privmsg("account: " . $user["account"]);
        }
        if (isset($user["prefix"]) == True) {
            privmsg("prefix: " . $user["prefix"]);
        }
        if (isset($user["user"]) == True) {
            privmsg("user: "******"user"]);
        }
        if (isset($user["hostname"]) == True) {
            privmsg("hostname: " . $user["hostname"]);
        }
        if (isset($user["connected"]) == True) {
            if ($user["connected"] == True) {
                privmsg("connected: yes");
            } else {
                privmsg("connected: no");
            }
        }
        var_dump($user);
        break;
    case "account":
        $subject_nick = strtolower(trim($trailing));
        $account = users_get_account($subject_nick);
        if ($account !== False) {
            privmsg("account for {$subject_nick}: {$account}");
        }
        break;
}
#####################################################################################################
Example #7
0
function verify_quorum()
{
    global $dest;
    global $board_member_accounts;
    global $board_member_quorum;
    global $meeting_data;
    if (isset($meeting_data["quorum"]) == False) {
        privmsg("verifying quorum...");
    } else {
        meeting_msg("verifying quorum...");
    }
    $members = array();
    # first try nick same as account
    for ($i = 0; $i < count($board_member_accounts); $i++) {
        $nick = $board_member_accounts[$i];
        $user = users_get_data($nick);
        $account = "";
        if (isset($user["account"]) == True and isset($user["account_updated"]) == True) {
            $delta = microtime(True) - $user["account_updated"];
            if ($delta <= 30 * 60) {
                $account = $user["account"];
                #privmsg("1: [get_data] nick=$nick, account=$account");
            }
        }
        if ($account == "") {
            $account = users_get_account($nick);
            usleep(500000.0);
            #privmsg("1: [whois] nick=$nick, account=$account");
        }
        if (in_array($account, $board_member_accounts) == True and in_array($account, $members) == False) {
            $members[] = $account;
            #privmsg("[".count($members)."] nick=$nick, account=$account");
            if (count($members) >= $board_member_quorum) {
                return $members;
            }
        }
    }
    # cycle through all nicks in channel (except for nicks that are the same as board member accounts)
    $nicks = users_get_nicks($dest);
    for ($i = 0; $i < count($nicks); $i++) {
        $nick = $nicks[$i];
        if (in_array($nick, $board_member_accounts) == True) {
            continue;
        }
        $user = users_get_data($nick);
        $account = "";
        if (isset($user["account"]) == True and isset($user["account_updated"]) == True) {
            $delta = microtime(True) - $user["account_updated"];
            if ($delta <= 30 * 60) {
                $account = $user["account"];
                #privmsg("2: [get_data] nick=$nick, account=$account");
            }
        }
        if ($account == "") {
            $account = users_get_account($nick);
            usleep(500000.0);
            #privmsg("2: [whois] nick=$nick, account=$account");
        }
        if (in_array($account, $board_member_accounts) == True and in_array($account, $members) == False) {
            $members[] = $account;
            #privmsg("[".count($members)."] nick=$nick, account=$account");
            if (count($members) >= $board_member_quorum) {
                return $members;
            }
        }
    }
    return False;
}
Example #8
0
 delete_empty_elements($parts);
 if (count($parts) == 0) {
     privmsg("  syntax: ~comments filter-add|filter-delete|filter-list");
     return;
 }
 $action = strtolower($parts[0]);
 array_shift($parts);
 $trailing = trim(implode(" ", $parts));
 switch ($action) {
     case "feed":
         if (users_get_account($nick) == "crutchy") {
             break;
         }
         return;
     case "test":
         if (users_get_account($nick) == "crutchy") {
             if (preg_match("~{$trailing}~", "stuff") == 1) {
                 privmsg("1");
             } else {
                 privmsg("not 1");
             }
         }
         return;
     case "filter-list":
         foreach ($filters as $id => $filter) {
             $filter = unserialize(base64_decode($filter));
             $id = $filter["id"];
             $target = $filter["target"];
             if (isset($filter["cid"]) == False) {
                 $field = $filter["field"];
                 $pattern = $filter["pattern"];
Example #9
0
function handle_macros($nick, $channel, $trailing)
{
    $reserved_triggers = array(".macro", ".macro-list");
    $reserved_commands = array("~restart-internal", "~q", "~ps", "~kill", "~killall", "~restart", "~rehash", "~dest-override", "~dest-clear", "~ignore", "~unignore", "~ignore-list", "~buckets-dump", "~eval", "~say", "~bucket", "~buckets-save", "~buckets-load", "~buckets-flush", "~buckets-list", "~exec-conflicts", "~exec-list", "~exec-timers", "~exec-errors", "~op", "~deop", "~voice", "~devoice", "~invite", "~kick", "~topic", "~exec-add", "~exec-del", "~exec-save", "<init>", "<quit>", "<startup>");
    $allowed = array("crutchy", "chromas", "TheMightyBuzzard", "Bytram", "arti", "paulej72", "mrcoolbp", "juggs");
    if ($nick == "" or $channel == "" or $trailing == "") {
        return;
    }
    if ($trailing == ".macro") {
        pm($channel, chr(3) . "02" . "  syntax to add: .macro <trigger> <chanlist> PRIVMSG|INTERNAL <command_template>");
        pm($channel, chr(3) . "02" . "  syntax to delete: .macro <trigger> -");
        #pm($channel,chr(3)."02"."  <chanlist> is comma-separated or * for any");
    }
    $macro_file = DATA_PATH . "exec_macros.txt";
    $macros = load_settings($macro_file, "=");
    if ($macros !== False and $trailing == ".macro-list") {
        foreach ($macros as $trigger => $data) {
            $data = unserialize($data);
            $cmd = "INTERNAL";
            if (isset($data["cmd"]) == True) {
                $cmd = $data["cmd"];
            }
            pm($channel, chr(3) . "13" . "  {$trigger} [" . $data["chanlist"] . "] {$cmd} " . $data["command"]);
        }
    }
    if ($macros === False) {
        $macros = array();
    }
    $parts = explode(" ", $trailing);
    delete_empty_elements($parts);
    if (count($parts) == 0) {
        return;
    }
    if (trim($parts[0]) == ".macro" and count($parts) > 2) {
        $account = users_get_account($nick);
        if (in_array($account, $allowed) == False) {
            return;
        }
        $trigger = trim($parts[1]);
        if (in_array($trigger, $reserved_triggers) == True) {
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" not permitted");
            return;
        }
        if (in_array($trigger, $reserved_commands) == True) {
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" not permitted");
            return;
        }
        $exec_list = unserialize(base64_decode(trim(get_bucket("<<EXEC_LIST>>"))));
        if (isset($exec_list[$trigger]) == True) {
            privmsg(chr(3) . "02" . "  *** error: macro with trigger that is the same as existing alias is not permitted");
            return;
        }
        $chanlist = trim($parts[2]);
        if ($chanlist == "-") {
            unset($macros[$trigger]);
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" deleted");
        } elseif (count($parts) >= 5) {
            array_shift($parts);
            array_shift($parts);
            array_shift($parts);
            $cmd = strtoupper(trim($parts[0]));
            if ($cmd != "PRIVMSG" and $cmd != "INTERNAL") {
                privmsg(chr(3) . "02" . "  *** error: invalid cmd (must be either INTERNAL or PRIVMSG)");
                return;
            }
            array_shift($parts);
            if (isset($macros[$parts[0]]) == True) {
                privmsg(chr(3) . "02" . "  *** error: triggering other macros is not permitted");
                return;
            }
            $command = implode(" ", $parts);
            for ($i = 0; $i < count($reserved_commands); $i++) {
                if (strtolower(substr($command, 0, strlen($reserved_commands[$i]))) == strtolower($reserved_commands[$i])) {
                    privmsg(chr(3) . "02" . "  *** macro with command \"{$command}\" not permitted");
                    return;
                }
            }
            $data = array();
            $data["chanlist"] = $chanlist;
            $data["command"] = $command;
            $data["cmd"] = $cmd;
            $macros[$trigger] = serialize($data);
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" and {$cmd} command template \"{$command}\" saved");
        }
        save_settings($macros, $macro_file, "=");
    } else {
        foreach ($macros as $trigger => $data) {
            if (trim($parts[0]) == $trigger) {
                $data = unserialize($data);
                if ($data["chanlist"] == "*" or in_array(strtolower($channel), explode(",", strtolower($data["chanlist"]))) == True) {
                    $account = users_get_account($nick);
                    if ($account != "") {
                        $cmd = "INTERNAL";
                        if (isset($data["cmd"]) == True) {
                            $cmd = $data["cmd"];
                        }
                        $trailing = trim(substr($trailing, strlen($trigger)));
                        # TODO: MAKE MORE TRAILING PARSING REPLACE ARGS
                        $command = str_replace("%%channel%%", $channel, $data["command"]);
                        $command = str_replace("%%nick%%", $nick, $command);
                        $command = str_replace("%%trailing%%", $trailing, $command);
                        echo "/IRC :" . get_bot_nick() . " {$cmd} {$channel} :{$command}\n";
                    }
                }
                return;
            }
        }
    }
}