function get_fs() { global $false; $fs = get_array_bucket(BUCKET_FS); if (isset($fs["modified"]) == False) { $fs["filesystem"][PATH_DELIM] = array(); $fs["filesystem"][PATH_DELIM]["name"] = PATH_DELIM; $fs["filesystem"][PATH_DELIM]["vars"] = array(); $fs["filesystem"][PATH_DELIM]["permissions"] = array(); $fs["filesystem"][PATH_DELIM]["children"] = array(); $fs["filesystem"][PATH_DELIM]["parent"] =& $false; $fs["paths"] = array(); $fs["modified"] = True; } return $fs; }
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; }
function check_handler($bucket_index, $cmd, $data) { $handlers = get_array_bucket($bucket_index); for ($i = 0; $i < count($handlers); $i++) { $handler = unserialize($handlers[$i]); if (isset($handler[$cmd]) == True) { if ($handler[$cmd] == $data) { return True; } } } return False; }
$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); #####################################################################################################
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; } 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];
if ($alias == "~quickpoll") { # TODO: ~quickpoll description wth spaces [yes|no|maybe|light it on fire] # TODO: ~quickpoll maybe # TODO: quickpoll is automatically opened for 1 minute and then outputs results and then deletes return; } if ($trailing == "" or $trailing == "?" or strtolower($trailing) == "help") { notice($nick, " to vote: ~vote poll_id option_id"); notice($nick, " example: ~vote beverage coffee"); notice($nick, " http://sylnt.us/vote"); return; } $founders = array("crutchy", "chromas", "bytram", "mrcoolbp", "juggs", "themightybuzzard", "arti", "paulej72"); $parts = explode(" ", $trailing); delete_empty_elements($parts); $data = get_array_bucket("<<IRC_VOTE_DATA>>"); $id = strtolower(filter($parts[0], VALID_UPPERCASE . VALID_LOWERCASE . VALID_NUMERIC . "_-.?")); array_shift($parts); $trailing = implode(" ", $parts); $commands = array("list", "l", "register", "unregister", "breakdown", "b", "add-option", "ao", "oa", "del-option", "do", "od", "add-admin", "del-admin", "list-admin", "open", "close", "sort"); switch ($id) { case "list": case "l": if (count($data) == 0) { notice($nick, " no polls registered"); } else { foreach ($data as $poll_id => $poll_data) { if (isset($data[strtolower($trailing)]) == True) { if ($poll_id != strtolower($trailing)) { continue; }
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); } }
function meeting_privmsg() { global $parts; global $meeting_data; global $board_member_accounts; global $options_yes; global $options_no; if (count($parts) < 3) { term_echo("meeting: invalid number of trailing parts"); return; } # trailing = <nick> <channel> <trailing> $nick = strtolower($parts[0]); $channel = strtolower($parts[1]); array_shift($parts); array_shift($parts); $trailing = trim(implode(" ", $parts)); term_echo("meeting_privmsg: nick={$nick}, channel={$channel}, trailing={$trailing}"); $meeting_data = get_array_bucket("MEETING_DATA_" . $channel); if (isset($meeting_data["description"]) == False) { term_echo("meeting: no meeting open"); return; } $data = array(); $data["nick"] = $nick; $data["timestamp"] = microtime(True); $data["trailing"] = $trailing; $meeting_data["messages"][] = $data; $test = strtolower($trailing); if (in_array($test, $options_yes) == True or in_array($test, $options_no) == True) { $account = users_get_account($nick); if (in_array($account, $board_member_accounts) == False) { meeting_event_msg($channel, "{$nick} is not an authenticated board member. vote not counted"); } $n = count($meeting_data["motions"]); if ($n == 0) { meeting_event_msg($channel, "no motions registered. vote not counted"); } else { $motion =& $meeting_data["motions"][$n - 1]; $vote_yes = array_search($account, $motion["votes"]["yes"]); $vote_no = array_search($account, $motion["votes"]["no"]); if ($vote_yes !== False) { unset($motion["votes"]["yes"][$vote_yes]); $motion["votes"]["yes"] = array_values($motion["votes"]["yes"]); } if ($vote_no !== False) { unset($motion["votes"]["no"][$vote_no]); $motion["votes"]["no"] = array_values($motion["votes"]["no"]); } if ($vote_yes !== False or $vote_no !== False) { meeting_event_msg($channel, "vote by {$nick} [{$account}] for current motion already registered. previous vote deleted"); } if (in_array($test, $options_yes) == True) { $motion["votes"]["yes"][] = $account; meeting_event_msg($channel, "'aye' vote registered for {$nick} [{$account}] for current motion"); } else { $motion["votes"]["no"][] = $account; meeting_event_msg($channel, "'nay' vote registered for {$nick} [{$account}] for current motion"); } } } }
re-enable the script for changes to come into effect. */ ##################################################################################################### ini_set("display_errors", "on"); require_once "lib.php"; $trailing = $argv[1]; $dest = strtolower(trim($argv[2])); $nick = strtolower(trim($argv[3])); $start = $argv[4]; $alias = strtolower(trim($argv[5])); $cmd = strtoupper(trim($argv[6])); $data = $argv[7]; $params = $argv[8]; $timestamp = $argv[9]; $global_execute = get_bucket("LIVE_SCRIPT_GLOBAL_EXECUTE"); $scripts = get_array_bucket("<<LIVE_SCRIPTS>>"); $code = ""; $script_data = array(); $script_lines = array(); $script_name = get_bucket("LOADED_SCRIPT_" . $nick . "_" . $dest); if ($script_name != "") { if (isset($scripts[$script_name]["code"]) == True) { $code = base64_decode($scripts[$script_name]["code"]); if ($code != "") { $script_lines = explode("\n", $code); } } } $parts = explode(" ", $trailing); $action = strtolower($parts[0]); array_shift($parts);
case 4: privmsg("karma already disabled for " . chr(3) . "10{$dest}"); return; case 7: case 11: break; default: return; } if ($alias == ".karma") { $msg = $trailing; } 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;
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"); } } }
$start = trim($argv[4]); $alias = strtolower(trim($argv[5])); $cmd = strtoupper(trim($argv[6])); $account = users_get_account($nick); $gm_accounts = array("crutchy"); if ($trailing == "") { irciv_privmsg("http://sylnt.us/irciv"); return; } irc_pause(); $game_chans = get_game_list(); $player_data = array(); $map_data = array(); $game_data = array(); if ($dest != "") { $game_data = get_array_bucket(GAME_BUCKET_PREFIX . $dest); $player_data =& $game_data["players"]; $map_data =& $game_data["map"]; } $irciv_data_changed = False; $parts = explode(" ", $trailing); $action = strtolower($parts[0]); array_shift($parts); $trailing = trim(implode(" ", $parts)); switch ($action) { case "dev-op": if (is_gm() == True) { /*foreach ($player_data as $account => $data) { $n=count($player_data[$account]["units"]); for ($i=0;$i<$n;$i++)
function users_nick_exists($nick) { $result = array(); $users = get_array_bucket(BUCKET_USERS); if (isset($users[$nick]) == True) { return True; } else { return False; } }