function get_header_login($host, $uri, $port, $header, $url) { $extra_headers = array(); $extra_headers["Cookie"] = sn_login(); $response = whead($host, $uri, $port, ICEWEASEL_UA, $extra_headers); sn_logout(); $header_value = exec_get_header($response, $header, False); if ($header_value != "") { privmsg(" {$header} header for {$url} = {$header_value}"); } }
$previous = ""; if (count($data) > 0) { $previous = trim($data[0]); } else { term_echo("funding: count(data) = 0"); } if ($previous != $amount) { pm("#soylent", chr(3) . "05" . "*** SN funding has changed from \${$previous} to \${$amount}"); exec_file_write("previous_sn_funding", array($amount)); } else { term_echo("funding: previous = amount ({$amount})"); } } else { term_echo("funding: amount not found in http response"); } sn_logout(); return; case "~verifier-nick-change": $parts = explode(" ", $trailing); if (count($parts) == 2) { $old_nick = trim(strtolower($parts[0])); $new_nick = trim(strtolower($parts[1])); $registered_nick = get_bucket(BUCKET_VERIFIER_NICK); if ($old_nick == $registered_nick) { set_bucket(BUCKET_VERIFIER_NICK, $new_nick); pm("#", "SN status verifier nick updated from \"{$registered_nick}\" to \"{$new_nick}\""); } } return; case "~verifier-nick": $registered_nick = get_bucket(BUCKET_VERIFIER_NICK);
function sn_comment_sid($subject, $comment_body, $article_sid, $parent_cid = "") { $host = "dev.soylentnews.org"; $port = 443; $params = array(); if ($parent_cid == "") { $params["pid"] = "0"; $uri = "/comments.pl?sid={$article_sid}&op=Reply"; } else { $params["pid"] = $parent_cid; $uri = "/comments.pl?sid={$article_sid}&pid={$parent_cid}&op=Reply"; } $extra_headers = array(); $extra_headers["Cookie"] = sn_login(); if ($extra_headers["Cookie"] == "") { privmsg("error: login failure (2)"); return False; } $response = wget($host, $uri, $port, ICEWEASEL_UA, $extra_headers); $html = strip_headers($response); $delim1 = "<input type=\"hidden\" name=\"formkey\" value=\""; $delim2 = "\">"; $formkey = extract_text($html, $delim1, $delim2); if ($formkey === False) { privmsg("error: unable to get formkey"); sn_logout(); return False; } var_dump($formkey); $uri = "/comments.pl"; $params["sid"] = $article_sid; $params["mode"] = "improvedthreaded"; $params["startat"] = ""; $params["threshold"] = "-1"; $params["commentsort"] = "0"; $params["formkey"] = $formkey; $params["postersubj"] = $subject; $params["postercomment"] = $comment_body; #$params["nobonus_present"]="1"; #$params["nobonus"]=""; $params["postanon_present"] = "1"; #$params["postanon"]=""; $params["posttype"] = "1"; # Plain Old Text $params["op"] = "Submit"; sleep(8); $response = wpost($host, $uri, $port, ICEWEASEL_UA, $params, $extra_headers); $html = strip_headers($response); $delim = "start template: ID 104"; $result = False; if (strpos($html, $delim) !== False) { privmsg("SoylentNews requires you to wait between each successful posting of a comment to allow everyone a fair chance at posting."); } $delim = "This exact comment has already been posted."; if (strpos($html, $delim) !== False) { privmsg("This exact comment has already been posted. Try to be more original."); } $delim = "Comment Submitted. There will be a delay before the comment becomes part of the static page."; if (strpos($html, $delim) !== False) { $result = array(); $delim1 = "<input type=\"hidden\" name=\"sid\" value=\""; $delim2 = "\">"; $result["sid"] = extract_text($html, $delim1, $delim2); $delim1 = "<input type=\"hidden\" name=\"cid\" value=\""; $result["cid"] = extract_text($html, $delim1, $delim2); $delim1 = "<input type=\"hidden\" name=\"pid\" value=\""; $result["pid"] = extract_text($html, $delim1, $delim2); # if pid=cid, then comment is at root level $delim1 = "<div id=\"comment_body_" . $result["cid"] . "\">"; $delim2 = "</div>"; $result["body"] = extract_text($html, $delim1, $delim2); $delim1 = "<a name=\"" . $result["cid"] . "\">"; $delim2 = "</a>"; $result["subject"] = extract_text($html, $delim1, $delim2); privmsg(" comment submitted successfully => https://" . $host . "/comments.pl?sid=" . $result["sid"] . "&cid=" . $result["cid"]); } #var_dump($html); sn_logout(); return $result; }