Registration has been disabled and the moderation extension has been turned off.
Contact an admin on Discord or EDF if you want an account. Also fuck bots.

User:Weasel/big report/PHP

From Encyclopedia Dramatica
Jump to navigation Jump to search

I know this is inefficient but it gets the job done. The script scans files in the same directory with the .txt extension. File contents are a list of articles delimited by \n.

Source

<?php
$report = array ();
$types = array ();
$scandir = scandir (dirname (__FILE__));
foreach ($scandir as $file) {
	if (strpos ($file, ".txt")) {
		$contents = file_get_contents ($file);
		$file = str_replace (".txt", "", $file);
		if (!isset ($types[$file])) {
			$types[] = $file;
		}
		foreach (explode ("\n", $contents) as $article) {
			if (!strpos ($article, ":")) {
				$report[$article][$file]=true;
			}
		}
	}
}
ksort ($report);
print "<pre>";
print "{| class=\"wikitable sortable\"\n|-\n!Article\n";
foreach ($types as $key => $value) {
	print ("!$value\n");
}
print "\n";
foreach ($report as $article => $links_here) {
	print "|-\n|[[$article]]\n";
	foreach ($types as $type) {
		if (isset ($links_here[$type])) {
			print "| \n";
		} else {
			print "|$type Missing\n";
		}
	}
}
print "|}\n";
?>

Example

Possible file names include Category.txt and Portal.txt or whatever you want.

Blackfrost
Blackwingdragon
Blaze Arctic
Blazger
Blu Aardvark
Bludshot the Hedgehog
BlueshineWolf
Bucky Bunny
Burned Fur
Cakepony
CaliHusky
Can't let you do that, StarFox!