Zack
Zack

Reputation: 2497

Script to get list of unprotected pages

I am looking for a way to get a list of all pages that are NOT protected on my wiki. There are special pages in MediaWiki for viewing a list of all pages and for viewing a list of protected pages. Is there a way to write a script that will basically just compare the two lists and output those pages which are not protected?

Note: I should also mention that while I have C++, C, Java and Python experience, I have NEVER written in PHP before...

Upvotes: 0

Views: 106

Answers (2)

Tgr
Tgr

Reputation: 28160

If its your wiki, why bother with the special pages? You can just look at the database and do something like this:

SELECT page_namespace, page_title 
FROM page p JOIN page_restrictions pr ON p.page_id = pr.page_id;

Upvotes: 0

ashiina
ashiina

Reputation: 1006

Easiest way is like this. (Populate the list of $allPages and $protectedPages by yourself)

$allPages = array('url1', 'url2', 'url3');
$protectedPages = array('url2');

// this array_diff() will give you the an array of the difference in each array
$unprotectedPages = array_diff($allPages, $protectedPages);
print_r($unprotectedPages);

Upvotes: 1

Related Questions