".getHeader("CSDF8 Comparison")."".getSideBar()."

CSDF8 Tool

"; $footer = "
"; //Wiki instance require __DIR__.'/../../classes/botclasses.php'; $wiki = new wikipedia; $wiki->url = 'http://en.wikipedia.org/w/api.php'; global $wiki; $cat = 'Category:Wikipedia files with the same name on Wikimedia Commons'; //Output the first page asking for a number of files to compare if(!isset($_GET['toget']) || !is_numeric($_GET['toget'])) { //Get a list of possible cats and write the html for the selection $cats = $wiki->categorymembers($cat,false); $selection = ""; foreach($cats as $c) { $selection .= ""; } //output the page echo $header; echo "

This tool very hackily loads $cat and compares the file version on enwiki along side the same file on commons while highlighting certain words in each files description, this allows admins to easily spot identical files with the correct permissions on both sites to be deleted from enwiki

"; echo "
Category to get files from:
Number of files to compare:
"; echo "

Files are taken from $cat

"; echo $footer; } //Output the results else { //Show what cat we are in $header .= "

".$_GET['category']."

".$footer; echo $header; $comm = new wikipedia; $comm->url = 'http://commons.wikimedia.org/w/api.php'; global $comm; $cat = $_GET['category']; $files = $wiki->categorymembers($cat,true); $counter = 0; //Content creation foreach ($files as $file) { if($counter < $_GET['toget'] && strstr($file,"Category:") == false) { $counter++; //Load the url for the images $wi = $wiki->getfilethumblocation($file,100); $ci = $comm->getfilethumblocation($file,100); //Find out who the uploader was $wu = $wiki->getfileuploader($file); $cu = $comm->getfileuploader($file); //Put the image in its tag $wimg = "$file"; $cimg = "$file"; //Get the page content of the image $wp = $wiki->getpage($file); $cp = $comm->getpage($file); //Bold and red things $wp = preg_replace("/(\{\{(cc|puf|pui(disputed)|imagevio)|PD|GFDL|self|Non|public domain|delete)/i","$0",$wp); $cp = preg_replace("/(\{\{(cc|puf|pui(disputed)|imagevio)|PD|GFDL|self|Non|$wu|public domain|User:|delete)/i","$0",$cp); $wp = preg_replace("/(\{\{(puf|pui(disputed)|imagevio))/i","$0",$wp); $cp = preg_replace("/(\{\{(puf|pui(disputed)|imagevio))/i","$0",$cp); //Find out if the two SHA1s match $filematch = false; if($wiki->getfilesha1($file) == $comm->getfilesha1($file)) {$filematch = true;} //Write the page echo "
  • Delete - "; if($filematch){echo "SHA1s of files appear to match!";} else{echo "SHA1s of files DONT MATCH!";} echo ""; echo ""; echo ""; echo "
    $wimg Wikipedia:$file by $wu$cimg Commons:$file by $cu
    ".htmlentities($wp)."".htmlentities($cp)."
    "; } } //did we actually get anything for the page? if($counter == 0) { //If the category seems empty say so and provide a link to delete echo "It appears that this category is empty...
    "; echo "Category - Delete

    The script returned...

    "; //Also just return what we found so the user can see print_r($files); } print $footer; } ?>