function quick_wget($trailing) { $parts = explode(" ", $trailing); delete_empty_elements($parts); if (count($parts) < 2) { return False; } $url = $parts[0]; array_shift($parts); $trailing = implode(" ", $parts); $parts = explode("<>", $trailing); delete_empty_elements($parts); if (count($parts) < 2) { return False; } $delim1 = trim($parts[0]); $delim2 = trim($parts[1]); $host = ""; $uri = ""; $port = ""; if (get_host_and_uri($url, $host, $uri, $port) == False) { return False; } $response = wget_ssl($host, $uri, $port); $result = extract_text($response, $delim1, $delim2); if ($result === False) { return False; } $result = strip_tags($result); $result = html_decode($result); $result = html_decode($result); $result = trim($result); if ($result == "") { return False; } return $result; }
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"); } }
$alias = $argv[3]; 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;
<?php ##################################################################################################### define("ICEWEASEL_UA", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0"); $url_blacklist = explode(PHP_EOL, file_get_contents("../data/url_blacklist")); delete_empty_elements($url_blacklist, True); ##################################################################################################### function authorization_header_value($uname, $passwd, $prefix) { return "{$prefix} " . base64_encode("{$uname}:{$passwd}"); } ##################################################################################################### function shorten_url($url, $mode = "title") { if ($url == "") { return False; } $params = array(); $params["url"] = $url; if ($mode != "") { $params["mode"] = $mode; # optional } $response = wpost("o.my.to", "/", "80", ICEWEASEL_UA, $params, "", 30); $short_url = trim(strip_headers($response)); if ($short_url != "") { return $short_url; } else { return False; } }
$msg = chr(3) . "08" . "********** " . chr(3) . "03" . chr(2) . "SOYLENTNEWS COMMENT FEED" . chr(2) . chr(3) . "08" . " **********"; pm(MAIN_FEED_CHANNEL, $msg); $last_cid = 87400; if (file_exists(COMMENTS_CID_FILE) == True) { $last_cid = file_get_contents(COMMENTS_CID_FILE); } $msg = "last cid = {$last_cid}"; pm(MAIN_FEED_CHANNEL, $msg); $response = wget($host, $feed_uri, $port, ICEWEASEL_UA, "", 60); $html = strip_headers($response); $items = parse_xml($html); $topcomments = array(); if (file_exists(COMMENTS_TOP_FILE) == True) { $data = file_get_contents(COMMENTS_TOP_FILE); $topcomments = explode("\n", $data); delete_empty_elements($topcomments); } $cids = array(); $item_count = 20; term_echo("*** comment_feed: {$item_count} feed stories to check"); $top_score_pub = 0; $count_new = 0; $count_top = 0; for ($i = 0; $i < $item_count; $i++) { if (isset($items[$i]) == False) { continue; } sleep(5); $story_url = $items[$i]["url"] . "&threshold=-1&highlightthresh=-1&mode=flat&commentsort=0"; $title = $items[$i]["title"]; $title_output = chr(3) . "06" . $title . chr(3);
initialize_buckets(); $exec_errors = array(); # stores exec load errors $exec_list = exec_load(); if ($exec_list === False) { term_echo("error loading exec file"); return; } $ignore_list = array(); if (file_exists(IGNORE_FILE) == True) { $ignore_data = file_get_contents(IGNORE_FILE); if ($ignore_data !== False) { $ignore_list = explode("\n", $ignore_data); } } delete_empty_elements($ignore_list); $direct_stdin = fopen("php://stdin", "r"); stream_set_blocking($direct_stdin, 0); if (file_exists(EXEC_OUTPUT_BUFFER_FILE) == True) { unlink(EXEC_OUTPUT_BUFFER_FILE); } if (IFACE_ENABLE === "1") { if (posix_mkfifo(EXEC_OUTPUT_BUFFER_FILE, 0700) == False) { term_echo("error creating output buffer file"); return; } $out_buffer = fopen(EXEC_OUTPUT_BUFFER_FILE, "a+"); if ($out_buffer === False) { term_echo("error opening output buffer file for writing"); return; }
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; } } } }