Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.
UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.
Php:Watchlist parser.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Watchlist parser.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- <meta name="robots" content="noindex,nofollow"> -->
<style type="text/css" media="screen,projection">/*<![CDATA[*/
@import "http://en.wikipedia.org/skins-1.5/common/shared.css?80";
@import "http://en.wikipedia.org/skins-1.5/monobook/main.css?80";
@import "../misza.css";
/*]]>*/</style>
</head>
<body class="mediawiki">
<div id="globalWrapper">
<div id="column-content">
<div id="content">
<h1>Watchlist parser.</h1><br/>
<p>This is a tool written by <a href="http://it.wikipedia.org/wiki/Utente:Filnik" title="Filnik">Filnik</a> to parse the watchlist to make it
more readable for the users.
<br/><br/>
Here you have to defain in what project you want to use that script (example: "commons.wikimedia.org") and your NickName and Passoword on this
project (as you can see in the source, the script won't same any data that you post)
<br/><br/>
Although I won't store any data posted, I <b>won't guarantee anything</b> because I don't want to have Problems.<br/>
If you trust me, good. Enjoy and make me know what do you think about this tool :-)
<br/><br/>
If it's the first time that you use this script, try it with a minor account (like your account on a language where you have few pages in watchlist)
<br/>so you won't make big Mistakes.
<br/><br/>
<b><a href="http://botwiki.sno.cc/wiki/Php:Watchlist_parser.php" title="Source">Source</a></b>
<br />
</p>
<?PHP
$domain = $_REQUEST['domain'];
if ($domain == ''){$domain = 'commons.wikimedia.org';}
echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" />
<label for='domain'>Domain: </label><input type=\"text\" name=\"domain\" id=\"domain\" value=\"$domain\" />";
if ($_REQUEST['nickname'] == '' or $_REQUEST['password'] == ''){
echo "
<label for='nickname'>Nickname: </label><input type='text' class='loginText' name=\"nickname\" id=\"nickname\" value=\"\" size='20' />
<label for='password'>Password: </label>
<input type='password' class='loginPassword' name=\"password\" id=\"password\" value=\"\" size='20' />";
}else{
?>
<input type='hidden' class='loginText' name="nickname" id="nickname" value="<?=$_REQUEST['nickname']?>" />
<input type='hidden' class='loginPassword' name="password" id="password" value="<?=$_REQUEST['password']?>" />
<?
?>
<br/>
<br/>
<input type="submit" value="Enter" />
<br/>
<ul>
<script type="text/javascript">
function CheckAll(formName) {
var form = document.getElementsById(formName)
for (var i=0;i<form.elements.length;i++) {
if( form.elements[i].type == 'checkbox'){
form.elements[i].checked = true;
}
}
}
</script>
<?PHP
class http {
private $ch;
private $uid;
function data_encode($data, $keyprefix = "", $keypostfix = "") {
assert( is_array($data) );
$vars=null;
foreach($data as $key=>$value) {
if(is_array($value)) $vars .= $this->data_encode($value, $keyprefix.$key.$keypostfix.urlencode("["), urlencode("]"));
else $vars .= $keyprefix.$key.$keypostfix."=".urlencode($value)."&";
}
return $vars;
}
function __construct(){
$this->ch = curl_init();
$this->uid = dechex(rand(0,99999999));
$this->cookie_file = 'cookie.txt';
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cookie_file);
curl_setopt($this->ch, CURLOPT_USERAGENT, "'Filnik's Watchlist.php");
#"Mozilla/5.0 (X11; U; Linux i686; it; rv:1.8.1.3) Gecko/20060601 Firefox/2.0.0.4 (Ubuntu-edgy)");
curl_setopt($this->ch,CURLOPT_MAXCONNECTS,100);
curl_setopt($this->ch,CURLOPT_CLOSEPOLICY,CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
}
function post($url,$data) {
curl_setopt($this->ch,CURLOPT_URL,$url);
curl_setopt($this->ch,CURLOPT_FOLLOWLOCATION,True);
curl_setopt($this->ch,CURLOPT_MAXREDIRS,10);
curl_setopt($this->ch,CURLOPT_HEADER,0);
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->ch,CURLOPT_TIMEOUT,30);
curl_setopt($this->ch,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($this->ch,CURLOPT_POST,True);
curl_setopt($this->ch,CURLOPT_POSTFIELDS, substr($this->data_encode($data), 0, -1) );
return curl_exec($this->ch);
}
function get($url){
curl_setopt($this->ch,CURLOPT_URL,$url);
curl_setopt($this->ch,CURLOPT_FOLLOWLOCATION,True);
curl_setopt($this->ch,CURLOPT_MAXREDIRS,10);
curl_setopt($this->ch,CURLOPT_HEADER,0);
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->ch,CURLOPT_TIMEOUT,30);
curl_setopt($this->ch,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($this->ch,CURLOPT_HTTPGET,1);
return curl_exec($this->ch);
}
function __destruct(){
curl_close($this->ch);
@unlink($this->$cookie_file);
}
}
function wikiUrl($page, $domain){
return "http://$domain/wiki/$page";
}
function logged($data, $UserNickName){
if (stristr($data, "var wgUserName = \"$UserNickName\";")){
return True;
}else{
return False;
}
}
if (isset($_REQUEST['domain']) and isset($_REQUEST['nickname']) and $_REQUEST['nickname'] != '' and $_REQUEST['password'] != '')
{
$password = $_REQUEST['password'];
$UserNickName = $_REQUEST['nickname'];
$domain = $_REQUEST['domain'];
$pageWatchlist = 'Special:Watchlist';
$pageLogIn = 'Special:Userlogin';
$data["wpName"] = $UserNickName;
$data["wpPassword"] = $password;
$data["wpLoginattempt"] = "Aanmelden & Inschrijven"; # dutch button label seems to work for all wikis
$data["wpRemember"] = 1;
$http = new http();
$LogPage = $http->post(wikiUrl($pageLogIn, $domain),$data);
#echo "<br/><br/><br/><br/><br/><br/><br/><br/>";
#print_r($LogPage);
$watchData = $http->get(wikiUrl($pageWatchlist, $domain));
if (logged($LogPage, $UserNickName) and logged($watchData, $UserNickName)){
$xlksdo = 1;# Do nothing ---echo "logged";
}else{
echo "<center><big>Problem with logging!</big></center>";
}
# </ul>
# <h4>16 nov 2007</h4>
# <ul class="special"><li>(<a href="
$regex = "/(<h4>.*?<\/h4>)\n(<ul class=\"special\">.*?<\/ul>)/s";
preg_match_all($regex, $watchData, $results);
#print_r($results['0']);
$textBox = "<input type='checkbox' name=\"checkbox-";
$textBox2 = "\" value=\"1\" id=\"checkbox-";
$textBox3 = "\"/>";
$cronText = '';
$num = 0;
foreach($results['2'] as $res){
$res = str_replace('<a href="/w', '<a href="http://' . $domain . '/w', $res);
$regex2 = "/(<li>.*?<\/li>)/s";
$results2 = array();
preg_match_all($regex2, $res, $results2);
$cronText = $cronText . $results['1'][$num] . '
';
$num = $num + 1;
foreach($results2['0'] as $minires){
$minires = preg_replace('/<li>\(<a href="(.*?)\/w\/index.php\?title=(.*?)&/',
'<li> '. $textBox . html_entity_decode('\\2') .$textBox2 . html_entity_decode('\\2') . $textBox3 . ' (<a href="\1/w/index.php?title=\\2&',
$minires);
$cronText = $cronText . $minires . '
';
}
}
echo $cronText;
foreach($_REQUEST as $nome => $valore){
if (stristr($nome, 'checkbox-') and $valore == '1'){
$page = str_replace('checkbox-', '', $nome);
$unwatchURL = "http://$domain/w/index.php?action=unwatch&title=$page";
$http->get($unwatchURL);
echo "
<br/>
Deleted: $page";
}
}
}
?>
</ul>
</form>
</div><!--content-->
</div><!--column-content-->
<div id="column-one">
<div id="p-logo" class="portlet">
<a title="Hosted by the Wikimedia Toolserver" href="/" style="background-image: url(toolserv.png);"></a>
</div><!--p-logo-->
<div id="p-navigation" class="portlet">
<h5>Navigation</h5>
<div class="pBody">
<ul>
<li><a href="index.php">Main</a></li>
<li><a href="cancellazioni.php">Logs</a></li>
<li><a href="newimages.php">New Images.php</a></li>
</ul>
</div>
</div><!--p-navigation-->
</div><!--column-one-->
<div class="visualClear" />
<div id="footer">
<a href="http://tools.wikimedia.de/"><img
src="http://tools.wikimedia.de/wikimedia-toolserver-button.png"
alt="Hosted on the Toolserver" /></a>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10-blue"
alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
</div><!--footer-->
</div><!--globalWrapper-->
</body>
</html>