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:Wikidipendenza.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="it" lang="it">
<head>
<title>Wikidipendenza.php</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>Wikidipendenza</h1><br/>
<p>Questo è un programma scritto da <a href="http://it.wikipedia.org/wiki/Utente:Filnik" title="Filnik">Filnik</a> per calcolare
in modo veloce e automatico il tuo tasso di <a href="http://it.wikipedia.org/wiki/Wikipedia:Scherzi_e_STUBidaggini/Wikidipendenza" title="Wikidipedenza">Wikidipendenza</a>.
<br/><br/>
Quanto devi fare è semplicemente spuntare le caselle se quanto viene chiesto corrisponde a verità, altrimenti basta saltare la domanda.
<br/>
Alla fine basterà cliccare su "calcola" per sapere quant'è il tuo tasso di Wikidipendenza!
<br/><br/>
<b><a href="http://botwiki.sno.cc/wiki/Php:Wikidipendenza.php" title="Sorgente">Sorgente</a></b>
<br/>
</p>
<?
class http {
private $ch;
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->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 wikidipendenza.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);
}
}
$http = new http();
$testo = $http->get("http://it.wikipedia.org/w/index.php?title=Wikipedia:Scherzi_e_STUBidaggini/Wikidipendenza§ion=1&ctype=text/javascript");
#$testo = str_replace('<a href="/wiki/', '<a href="http://it.wikipedia.org/wiki/', $testo);
#<li>Ti colleghi a wikipedia almeno una volta alla settimana? (4)</li>
$regexp = '/\<li>(.*?)\? +?\((\d*?)\)\s*?<\/li>/';
#echo "<pre>";
#echo $testo;
#echo "</pre>";
preg_match_all($regexp, $testo, $results);
#print_r($results);
if ($_REQUEST == array() or $_REQUEST['force'] == 1 or count($_REQUEST) < 3)
{
#print_r($_REQUEST);
echo "<hr />
<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
foreach($results['1'] as $num => $domanda){
echo "<input type='checkbox' value='0' id=\"checkbox-$num\" name=\"checkbox-$num\" /> $domanda? <br/>
";
}?>
<br/>
<center>
<input type='submit' value="Calcola!" accesskey="c"/>
</center>
</form>
<?
}else{
#print_r($_REQUEST);
$punteggio = 0;
foreach($_REQUEST as $res => $some){
if (stristr($res, 'checkbox')){
$checknum = str_replace('checkbox-', '', $res);
$punteggio = $punteggio + $results['2'][$checknum];
}
}?>
<center><big><b>Complimenti!</b></big><br/><br/>
Il Punteggio che hai totalizzato è: <b><?echo "$punteggio punti!</b></center>";?><br/><br/>
Lascia un commento nella pagina su Wikipedia: <a href="http://it.wikipedia.org/wiki/Wikipedia:Scherzi_e_STUBidaggini/Wikidipendenza" title="Wikipedia:Scherzi_e_STUBidaggini/Wikidipendenza">Wikipedia:Scherzi_e_STUBidaggini/Wikidipendenza</a>
<?}?>
</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>
<?
//Devo aprire il file.
$filename = "links.txt";
// copia il contenuto di un file in una stringa
//$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
if($handle)
{
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
}
?>
</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>