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:NewImages.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>Patrolling new images!</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>Patrolling the new images!</h1><br/>
<p>This is a tool written by <a href="http://it.wikipedia.org/wiki/Utente:Filnik" title="Filnik">Filnik</a> to patrol the latest images that are uploaded<br/>
on the different wikimedia projects. I'm still working on this tool, so don' judge until I've finished it :-)<br/>
If you want to go to the image's page, just click on the image.
<br/><br/>
Here you have to defain in what project you want to use that script (example: "commons.wikimedia.org").
<br /><br />
<b><a href="http://www.botwiki.sno.cc/wiki/Php:NewImages.php" title="Source">Source</a></b>
<br />
</p>
<br />
<?PHP
echo "<form method=\"get\" action=\"{$_SERVER['PHP_SELF']}\" /><input type=\"text\" name=\"domain\" value=\"it.wikipedia.org\" />";
?>
<input type="submit" value="Enter" />
<br/>
<?PHP
function resize($width, $height)
{
$number = 400;
if ($width > $height)
{
if ($width > $number){$width = $number;}
$imageInfo = '" width="' . $width . '"';
}else{
if ($height > $number){$height = $number;}
$imageInfo = '" height="' . $height . '"';
}
return $imageInfo;
}
function getPage($domain, $url, $wk = 'wiki')
{
$ch = curl_init("http://$domain/$wk/$url");
# manda l'useragent
curl_setopt ($ch, CURLOPT_USERAGENT, "'Filnik's NewImages.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($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, True); // Follow the redirects
curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Follow no more than 5 redirects
# legge il risultato
$risultato = curl_exec($ch);
curl_close($ch);
# ritorna il risultato
return $risultato;
}
if (isset($_REQUEST['domain']))
{
$domain = $_REQUEST['domain'];
if ($domain == ''){$domain = 'commons.wikimedia.org';}
#$pageSpecialLog = 'Speciale:Registri/upload';
$pageSpecialLog = 'Special:Log/upload';
if (isset($_REQUEST['offset']) or isset($_REQUEST['limit'])){
$limit = $_REQUEST['limit'];
$offset = $_REQUEST['offset'];
$pageSpecialLog = "index.php?title=Special:Log&limit=$limit&offset=$offset&type=upload&user=&page=&pattern=";
$logText = getPage($domain, $pageSpecialLog, 'w');
}else{
$logText = getPage($domain, $pageSpecialLog);
}
$offsetmin = $offset - 50;
$offsetmax = $offset + 50;
if ($offset >= 50){
echo '<p>See (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmin . '" class="mw-prevlink">previous 50</a>) ';
}else{
echo '<p>See (previous 50)';
}
echo ' (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmax . '" class="mw-prevlink">next 50</a>) </p>
<br />';
echo ' <center><h2>Image log</h2></center>
<br />';
// title="Immagine:Brumano-Stemma.png">Immagine:Brumano-Stemma.png</a>" <span class="comment">
$regex = '/title=\".*?\.(?:\w\w\w|[Jj][Pp][Ee][Gg])\">(.*?)<.a>\"\s*?/';#span class=\"comment\">/';
preg_match_all($regex, $logText, $results);
//print_r($results);
$imagesList = array_unique($results[1]);
foreach($imagesList as $image)
{
$urlimage = str_replace(' ', '_', $image);
$imageText = getPage($domain, $urlimage);
$regexImage = '/<img alt ?= ?\"' . $image . '" ?src ?= ?"(.*?)" width="(.*?)" height="(.*?)"/';
preg_match_all($regexImage, $imageText, $foulder);
$ImageDirectLink = $foulder[1][0];
$width = $foulder[2][0];
$height = $foulder[3][0];
$imageInfo = resize($width, $height);
//tipo MIME: image/jpeg)
//<!--\n/Pre-expand include size:
$regexDescription = '/(?:MIME|file size):? ?.*?\)(?:<.div>)?(.*?)(?:<!-- ?\nPre-expand include size:|<h2 id=)/s';
preg_match_all($regexDescription, $imageText, $DescriptionArray);
#print_r($DescriptionArray[1][0]);
$descriptionImage = str_replace('<a href="/w', '<a href="http://' . $domain . '/w', $DescriptionArray[1][0]);
$descriptionImage = preg_replace('/id=".*?"/', '', $descriptionImage);
$regexHistory = '/<table class="filehistory">(.*?)<.table>/s';
preg_match_all($regexHistory, $imageText, $historyArray);
$history = str_replace('<a href="/w', '<a href="http://' . $domain . '/w', $historyArray[1][0]);
//Prevent the load of deleted images...
if ($ImageDirectLink != ''){
echo '<table class="prettytable" border="1" cellpadding="3" cellspacing="0" style="margin:0 .5em .5em 0; margin-top:.5em; margin-bottom:.5em; border:1px solid #CCC; border-collapse:collapse; font-family: Arial, Frutiger 45 Light, Helvetica, Arial Unicode MS, Lucida Sans Unicode, Lucida Grande, TITUS Cyberit Basic, Code2000, MV Boli, @MS Mincho;">
<tr>
<th>' . $image . '</th>
<th colspan="3">Description</th>
</tr>
<tr>
<td><i><br />';
echo '<a href="http://' . $domain . '/wiki/' . $urlimage . '"><img alt="' . $image . '" src="' . $ImageDirectLink . $imageInfo . ' border="0" /></a>';
echo '
</i></td>
<td style="font-size: 90%">' . $descriptionImage . '</td>
</tr>
<tr><td colspan="2" style="padding: 0px">
<table class="filehistory" style="margin: 0px">' . $history . '</table>
</td></tr>
</table>
<br/><br/>';
}
}
if ($offset >= 50){
echo '<p>See (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmin . '" class="mw-prevlink">previous 50</a>) ';
}else{
echo '<p>See (previous 50)';
}
echo ' (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmax . '" class="mw-prevlink">next 50</a>) </p>
<br />';
}
?>
</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>
</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>