/** * Post data to a page, nicely. * @param $page Page title. * @param $data Data to post to page. * @param $summery Edit summary. (Default '') * @param $minor Whether to mark edit as minor. (Default false) * @param $rv Revision data. If not given, it will be fetched. (Default null) * @param $bot Whether to mark edit as bot. (Default true) * @return HTML data from the page. * @deprecated * @see wikipediaapi::edit **/ function post($page, $data, $summery = '', $minor = false, $rv = null, $bot = true) { $wpq = new wikipediaquery(); $wpq->queryurl = str_replace('index.php', 'query.php', $this->indexurl); $wpapi = new wikipediaapi(); $wpapi->apiurl = str_replace('index.php', 'api.php', $this->indexurl); if (!$this->edittoken or $this->edittoken == '') { $this->edittoken = $wpapi->getedittoken(); } if ($rv == null) { $rv = $wpapi->revisions($page, 1, 'older', true); } if (!$rv[0]['*']) { $rv[0]['*'] = $wpq->getpage($page); } //Fake the edit form. $now = gmdate('YmdHis', time()); $token = htmlspecialchars($this->edittoken); $tmp = date_parse($rv[0]['timestamp']); $edittime = gmdate('YmdHis', gmmktime($tmp['hour'], $tmp['minute'], $tmp['second'], $tmp['month'], $tmp['day'], $tmp['year'])); $html = "<input type='hidden' value=\"{$now}\" name=\"wpStarttime\" />\n"; $html .= "<input type='hidden' value=\"{$edittime}\" name=\"wpEdittime\" />\n"; $html .= "<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n"; $html .= '<input name="wpAutoSummary" type="hidden" value="' . md5('') . '" />' . "\n"; if (preg_match('/' . preg_quote('{{nobots}}', '/') . '/iS', $rv[0]['*'])) { return false; } /* Honor the bots flags */ if (preg_match('/' . preg_quote('{{bots|allow=none}}', '/') . '/iS', $rv[0]['*'])) { return false; } if (preg_match('/' . preg_quote('{{bots|deny=all}}', '/') . '/iS', $rv[0]['*'])) { return false; } if (preg_match('/' . preg_quote('{{bots|deny=', '/') . '(.*)' . preg_quote('}}', '/') . '/iS', $rv[0]['*'], $m)) { if (in_array(explode(',', $m[1]), Config::$user)) { return false; } } /* /Honor the bots flags */ if (!preg_match('/' . preg_quote($user, '/') . '/iS', $rv['currentuser'])) { return false; } /* We need to be logged in */ // if (preg_match('/'.preg_quote('You have new messages','/').'/iS',$rv[0]['*'])) { return false; } /* Check talk page */ $x = $this->forcepost($page, $data, $summery, $minor, $html, Config::$maxlag, Config::$maxlagkeepgoing, $bot); /* Go ahead and post. */ $this->lastpost = time(); return $x; }
function post($page, $data, $summery = '', $minor = false, $rv = null, $bot = true) { global $user; global $maxlag; global $irc; global $irctechchannel; global $run; global $maxlagkeepgoing; $wpq = new wikipediaquery(); $wpq->queryurl = str_replace('index.php', 'query.php', $this->indexurl); $wpapi = new wikipediaapi(); $wpapi->apiurl = str_replace('index.php', 'api.php', $this->indexurl); if (!$this->edittoken or $this->edittoken == '') { $this->edittoken = $wpapi->getedittoken(); } if ($rv == null) { $rv = $wpapi->revisions($page, 1, 'older', true); } if (!$rv[0]['*']) { $rv[0]['*'] = $wpq->getpage($page); } //print_r($rv); //Fake the edit form. $now = gmdate('YmdHis', time()); $token = htmlspecialchars($this->edittoken); $tmp = date_parse($rv[0]['timestamp']); $edittime = gmdate('YmdHis', gmmktime($tmp['hour'], $tmp['minute'], $tmp['second'], $tmp['month'], $tmp['day'], $tmp['year'])); $html = "<input type='hidden' value=\"{$now}\" name=\"wpStarttime\" />\n"; $html .= "<input type='hidden' value=\"{$edittime}\" name=\"wpEdittime\" />\n"; $html .= "<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n"; $html .= '<input name="wpAutoSummary" type="hidden" value="' . md5('') . '" />' . "\n"; if (preg_match('/' . preg_quote('{{nobots}}', '/') . '/iS', $rv[0]['*'])) { return false; } /* Honor the bots flags */ //echo "No {{nobots}}..."; if (preg_match('/' . preg_quote('{{bots|allow=none}}', '/') . '/iS', $rv[0]['*'])) { return false; } //echo "No {{bots|allow=none}}..."; // if (preg_match('/' . preg_quote('{{bots|deny=all}}', '/') . '/iS', $rv[0]['*'])) { return false; } //echo "No {{bots|deny=all}}.."; if (preg_match('/\\{\\{bots\\|deny=(.*)\\}\\}/iS', $rv[0]['*'], $m)) { if (in_array($user, explode(',', $m[1]))) { return false; } } /* /Honor the bots flags */ //echo "No {{bots|deny=SoxBot..."; if (!preg_match('/' . preg_quote($user, '/') . '/iS', $rv['currentuser'])) { return false; } /* We need to be logged in */ //echo "Logged in..."; // if (preg_match('/'.preg_quote('You have new messages','/').'/iS',$rv[0]['*'])) { return false; } /* Check talk page */ //if (!preg_match('/(yes|enable|true)/iS',((isset($run))?$run:$wpq->getpage('User:'******'/Run')))) { return false; } /* Check /Run page */ //echo "Ok, I'm posting."; $x = $this->forcepost($page, $data, $summery, $minor, $html, $maxlag, $maxlagkeepgoing, $bot); /* Go ahead and post. */ $this->lastpost = time(); return $x; }