Пример #1
0
function logout($return = False)
{
    $response = wget(WIKI_HOST, "/w/api.php?action=logout&format=php", 80);
    $lines = explode("\n", $response);
    $loggedout = False;
    for ($i = 0; $i < count($lines); $i++) {
        if (substr($lines[$i], 0, strlen("Set-Cookie")) == "Set-Cookie" and strpos($lines[$i], "LoggedOut") !== False) {
            $loggedout = True;
        }
    }
    unset_bucket("wiki_login_cookieprefix");
    unset_bucket("wiki_login_sessionid");
    if ($loggedout == True) {
        wiki_privmsg($return, "wiki: successfully logged out");
    } else {
        wiki_privmsg($return, "wiki: logout confirmation not received");
    }
}
Пример #2
0
function run_event_registration_test()
{
    global $passed;
    unset_bucket(TEST_BUCKET);
    $bucket_index = "<<EXEC_EVENT_HANDLERS>>";
    $test_cmd = "PRIVMSG";
    $test_data = ":%%nick%% INTERNAL %%dest%% :~event-test %%trailing%%";
    $data1 = get_bucket($bucket_index);
    if (check_handler($bucket_index, $test_cmd, $test_data) == True) {
        term_echo("run_event_registration_test failed! (1)");
        $passed = False;
    }
    register_event_handler($test_cmd, $test_data);
    if (check_handler($bucket_index, $test_cmd, $test_data) == False) {
        term_echo("run_event_registration_test failed! (2)");
        $passed = False;
    }
    set_bucket("<<SELF_TRIGGER_EVENTS_FLAG>>", "1");
    privmsg("event test message");
    sleep(2);
    $test = get_bucket(TEST_BUCKET);
    term_echo("*** TEST BUCKET => {$test}");
    if ($test != TEST_VALUE) {
        term_echo("run_event_registration_test failed! (3)");
        $passed = False;
    }
    unset_bucket(TEST_BUCKET);
    unset_bucket("<<SELF_TRIGGER_EVENTS_FLAG>>");
    delete_event_handler($test_cmd, $test_data);
    sleep(2);
    if (check_handler($bucket_index, $test_cmd, $test_data) == True) {
        term_echo("run_event_registration_test failed! (4)");
        $passed = False;
    }
    $data2 = get_bucket($bucket_index);
    if ($data1 != $data2) {
        term_echo("run_event_registration_test failed! (5)");
        $passed = False;
    }
}
Пример #3
0
$trailing = trim($argv[1]);
$dest = $argv[2];
$nick = strtolower($argv[3]);
$alias = $argv[4];
$server = $argv[5];
if ($trailing == "register-events") {
    register_event_handler("PRIVMSG", ":%%nick%% INTERNAL %%dest%% :~tell-internal %%trailing%%");
    return;
}
if ($alias == "~tell") {
    if ($trailing == "") {
        privmsg("syntax: ~tell <nick> <message>");
        return;
    }
    $parts = explode(" ", $trailing);
    $target = strtolower($parts[0]);
    array_shift($parts);
    $trailing = trim(implode(" ", $parts));
    append_array_bucket("TELL_MESSAGES_" . $server . "_" . $target, $target . ", at " . date("Y-m-d H:i:s", microtime(True)) . " (UTC), " . $nick . " left message from " . $dest . ": " . $trailing);
    privmsg("message saved");
    return;
}
if (substr($trailing, 0, 5) == "~tell") {
    return;
}
$messages = get_array_bucket("TELL_MESSAGES_" . $server . "_" . $nick);
for ($i = 0; $i < count($messages); $i++) {
    notice($nick, $messages[$i]);
}
unset_bucket("TELL_MESSAGES_" . $server . "_" . $nick);
#####################################################################################################
Пример #4
0
         $out=$out.$host;
       }
       privmsg("definition sources: $out");*/
     foreach ($sources as $host => $params) {
         privmsg("{$host} => " . $params["name"] . "|" . $params["port"] . "|" . $params["uri"] . "|" . $params["template"] . "|" . $params["get_param"] . "|" . $params["order"] . "|" . $params["delim_start"] . "|" . $params["delim_end"] . "|" . $params["ignore"] . "|" . $params["space_delim"]);
         usleep(0.5 * 1000000.0);
     }
     break;
 case "~define-source-edit":
     if ($trailing == "debug on") {
         set_bucket("<<DEFINE_DEBUG>>", "ON");
         privmsg("define: debug mode enabled");
         return;
     }
     if ($trailing == "debug off") {
         unset_bucket("<<DEFINE_DEBUG>>");
         privmsg("define: debug mode disabled");
         return;
     }
     $params = explode("|", $trailing);
     if (count($params) == 11) {
         $host = trim($params[0]);
         $action = "inserted";
         if (isset($sources[$host]) == True) {
             $action = "updated";
         }
         $sources[$host]["name"] = trim($params[1]);
         $sources[$host]["port"] = trim($params[2]);
         $sources[$host]["uri"] = trim($params[3]);
         $sources[$host]["template"] = trim($params[4]);
         $sources[$host]["get_param"] = trim($params[5]);
Пример #5
0
 }
 $socket = fsockopen($server, $port);
 if ($socket === False) {
     term_echo("ERROR CREATING IRC SOCKET");
     return;
 }
 stream_set_blocking($socket, 0);
 rawmsg("NICK {$bot_nick}");
 rawmsg("USER {$bot_nick} 0host 0server :{$bot_nick}.bot");
 #add_minion($bot_nick);
 while (True) {
     usleep(100000.0);
     $data = get_bucket("MINION_CMD_{$bot_nick}");
     if ($data != "") {
         term_echo($data);
         if (unset_bucket("MINION_CMD_{$bot_nick}") == True) {
             $items = parse_data($data);
             if ($items !== False) {
                 rawmsg($data);
             } else {
                 $tokens = explode(" ", $data);
                 if (count($tokens) == 2 and strtoupper($tokens[0]) == "FORWARD") {
                     $forward = $tokens[1];
                     term_echo("*** FORWARD SET: ALL DATA WILL BE FORWARDED TO {$forward} ON EXEC BOT HOST NETWORK");
                 }
                 unset($tokens);
             }
         }
     }
     $data = fgets($socket);
     if ($data === False) {
Пример #6
0
function meeting_close()
{
    global $nick;
    global $dest;
    global $trailing;
    global $meeting_chair_accounts;
    global $meeting_data_changed;
    global $meeting_data;
    if ($dest == "") {
        return;
    }
    $account = users_get_account($nick);
    if (in_array($account, $meeting_chair_accounts) == False) {
        return;
    }
    if (isset($meeting_data["description"]) == False) {
        meeting_msg("meeting not currently registered in this channel");
        return;
    }
    $finish_time = microtime(True);
    #meeting_msg("$nick hereby adjourns the meeting at ".date("H:i (T)",$finish_time)." on ".date("l, j F Y",$finish_time));
    meeting_msg("================== // ==================");
    #privmsg("preparing minutes and posting to wiki...");
    $title = "Test page";
    $section = $meeting_data["description"] . " - " . date("F j Y", $meeting_data["chairs"][0]["start"]);
    $start_time = $meeting_data["chairs"][0]["start"];
    $text = "<p>start time: " . date("H:i (T)", $start_time) . " on " . date("l, j F Y", $start_time) . "<br />";
    $text = $text . "finish time: " . date("H:i (T)", $finish_time) . " on " . date("l, j F Y", $finish_time) . "</p>";
    $text = $text . "<p>location: irc.sylent.us, channel {$dest}</p>";
    $text = $text . "<p>opening chair: " . $meeting_data["chairs"][0]["nick"] . "</p>";
    if (count($meeting_data["chairs"]) > 1) {
        $text = $text . "<p>other chair(s):<br />";
        for ($i = 1; $i < count($meeting_data["chairs"]); $i++) {
            if ($i > 1) {
                $text = $text . "<br />";
            }
            $text = $text . "* " . $meeting_data["chairs"][$i]["nick"];
        }
        $text = $text . "</p>";
    }
    $text = $text . "<p>attendees (voiced/voter/joined/parted/quit/kicked):</p>";
    $text = $text . "<p>" . implode(", ", $meeting_data["nicks"]) . "</p>";
    if ($meeting_data["description"] == BOARD_MEETING) {
        $agenda = get_text("Issues to Be Raised at the Next Board Meeting", "Issues/Agenda", True, True);
        if ($agenda !== False) {
            if (count($agenda) > 0) {
                $text = $text . "<p>agenda items:<br />";
                for ($i = 0; $i < count($agenda); $i++) {
                    if ($i > 1) {
                        $text = $text . "<br />";
                    }
                    $text = $text . "* " . $agenda[$i];
                }
            }
        }
    }
    $text = $text . "<p>table of motions (ayes/nays/carried):</p>";
    $text = $text . "<p>table of assignments:</p>";
    $text = $text . "<p>formatted irc script:</p>";
    /*if (login(True)==False)
      {
        privmsg("error logging into wiki");
        return;
      }
      if (edit($title,$section,$text,True)==False)
      {
        privmsg("error updating wiki");
      }
      else
      {
        privmsg("successfully updated wiki - http://wiki.soylentnews.org/wiki/Test_page");
      }
      logout(True);*/
    $meeting_data = array();
    unset_bucket("MEETING_DATA_" . $dest);
}
Пример #7
0
exec:~count|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~log|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
*/
#####################################################################################################
require_once "lib.php";
require_once "chromas_log_lib.php";
$trailing = trim($argv[1]);
$dest = $argv[2];
$nick = $argv[3];
$alias = substr($argv[4], 1);
if ($trailing == "debug on") {
    set_bucket("chromas_irc_log_debug", "on");
    privmsg("  enabled debug pm");
    return;
} elseif ($trailing == "debug off") {
    unset_bucket("chromas_irc_log_debug");
    privmsg("  disabled debug pm");
    return;
}
$lines = chromas_log($alias, $trailing, $dest);
if ($lines === False) {
    $response = wget("chromas.0x.no", "/s/soylent_log.php", 80);
    $html = trim(strip_headers($response));
    $html = str_replace("\n", " ", $html);
    privmsg(chr(3) . "03" . $html);
    privmsg(chr(3) . "  http://chromas.0x.no/s/soylent_log.php");
    return;
}
$cutoff_index = 4;
for ($i = 0; $i < count($lines); $i++) {
    if ($i > $cutoff_index) {
Пример #8
0
function set_array_bucket($array, $bucket, $unset = True)
{
    $bucket_data = serialize($array);
    if ($bucket_data === False) {
        term_echo("error serializing \"{$bucket}\" bucket");
    } else {
        if ($unset == True) {
            unset_bucket($bucket);
        }
        set_bucket($bucket, $bucket_data);
    }
}
Пример #9
0
         privmsg("error: script name not specified");
         break;
     }
     $script_name = $trailing;
     set_bucket("LOADED_SCRIPT_" . $nick . "_" . $dest, $trailing);
     if (isset($scripts[$script_name]) == False) {
         $scripts[$script_name] = array();
         $data_changed = True;
     }
     privmsg("script \"{$script_name}\" opened for editing by {$nick} in {$dest}");
     break;
 case "close":
     # close currently open script
     # ~x close
     if ($script_name != "") {
         unset_bucket("LOADED_SCRIPT_" . $nick . "_" . $dest);
         privmsg("script \"{$script_name}\" closed by {$nick} in {$dest}");
     } else {
         privmsg("error: no script opened for editing by {$nick} in {$dest}");
     }
     break;
 case "code":
     # outputs lines of code for currently open script
     # TODO: $script_name contains serialized array
     # ~x code
     if ($script_name != "") {
         $n = count($script_lines);
         if ($n == 0) {
             privmsg("no lines in \"{$script_name}\" script");
         } else {
             for ($i = 0; $i < $n; $i++) {
Пример #10
0
require_once "lib.php";
$trailing = trim($argv[1]);
$nick = strtolower(trim($argv[2]));
$dest = strtolower(trim($argv[3]));
$alias = strtolower(trim($argv[4]));
if ($trailing == "") {
    privmsg("GET:   ~bucket <index>");
    privmsg("SET:   ~bucket <index> <data>");
    privmsg("UNSET: ~bucket <index> unset");
    return;
}
$parts = explode(" ", $trailing);
$index = $parts[0];
if (count($parts) == 2) {
    if ($parts[1] == "unset") {
        unset_bucket($index);
        if (get_bucket($index) == "") {
            privmsg("unset bucket");
        } else {
            privmsg("error unsetting bucket");
        }
        return;
    }
}
if (count($parts) >= 2) {
    array_shift($parts);
    $data = implode(" ", $parts);
    set_bucket($index, $data);
    if (get_bucket($index) == "") {
        privmsg("error setting bucket");
    } else {
Пример #11
0
function flush_channel($dest)
{
    unset_bucket(GAME_BUCKET_PREFIX . $dest);
    irciv_privmsg("game data for channel \"{$dest}\" deleted");
}
Пример #12
0
     } else {
         set_bucket("<exec_title_{$dest}>", "on");
         privmsg("  titles enabled for " . chr(3) . "10{$dest}");
     }
 } elseif (strtolower($trailing) == "off") {
     if ($bucket == "") {
         privmsg("  titles already disabled for " . chr(3) . "10{$dest}");
     } else {
         unset_bucket("<exec_title_{$dest}>");
         privmsg("  titles disabled for " . chr(3) . "10{$dest}");
     }
 } elseif (strtolower($trailing) == "url on") {
     set_bucket("<exec_title_url_{$dest}>", "on");
     privmsg("  enabled redirected url output for titles in " . chr(3) . "10{$dest}");
 } elseif (strtolower($trailing) == "url off") {
     unset_bucket("<exec_title_url_{$dest}>");
     privmsg("  disabled redirected url output for titles in " . chr(3) . "10{$dest}");
 } else {
     $redirect_data = get_redirected_url($trailing, "", "", array());
     if ($redirect_data === False) {
         term_echo("  title: get_redirected_url=false");
         return;
     }
     $rd_url = $redirect_data["url"];
     $raw = get_raw_title($redirect_data);
     if ($raw !== False) {
         $def = translate("auto", "en", $raw);
         $msg = chr(3) . "13" . $raw . chr(3);
         if ($def != $raw) {
             $msg = $msg . " [" . chr(3) . "04" . $def . chr(3) . "]";
         }