Mediawiki - Removendo Spam

De Pontão Nós Digitais

O seguinte documentação funciona da seguinte forma:

grupos e permissões

  • Crie as regras de restrições de edição e criando grupo no MediaWiki, adicionando em LocalSettings.php
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['human']['edit'] = true;
$wgGroupPermissions['sysop']['edit'] = true;

adicionando usuário no grupo

  • Adicionar os usuários humanos no grupo "human". Há duas formas de fazer, via interface administratica web do MediaWiki, indo emPáginas especiais > Gestão de privilégios de usuários > Localize o usuário > acrescente no grupo "human"

ou pela linha de comando no MySQL:

INSERT INTO mw_user_groups ( ug_user, ug_group ) VALUES ( 3, "human");

queries de remoção

Depois um conjunto queries que identificará tudo criado por usuário que não está no grupo human e removerá esse conteúdo e depois os usuários.


As queries usados foram:


remove o conteúdo de mw_categorylinks

delete
from mw_categorylinks
where cl_from in (select pg.page_id 
  from mw_page pg 
  where pg.page_id in (select rev_page
   from `mw_revision`
   where `rev_user` not in(select ug_user from mw_user_groups)
   and `rev_timestamp` in (select MIN(`rev_timestamp`) from `mw_revision` group by rev_page)
   )
);


remove o conteúdo de mw_pagelinks

delete
from mw_pagelinks
where pl_from in (select pg.page_id 
  from mw_page pg 
  where pg.page_id in (select rev_page
   from `mw_revision`
   where `rev_user` not in(select ug_user from mw_user_groups)
   and `rev_timestamp` in (select MIN(`rev_timestamp`) from `mw_revision` group by rev_page)
  )
);


remove o conteúdo de mw_externallinks

delete
from mw_externallinks
where el_from in (select pg.page_id 
 from mw_page pg 
 where pg.page_id in (select rev_page
   from `mw_revision`
   where `rev_user` not in(select ug_user from mw_user_groups)
   and `rev_timestamp` in (select MIN(`rev_timestamp`) from `mw_revision` group by rev_page)
  )
);


remove o conteúdo de mw_imagelinks

delete
from mw_imagelinks
where il_from in (select pg.page_id 
 from mw_page pg 
 where pg.page_id in (select rev_page
  from `mw_revision`
  where `rev_user` not in(select ug_user from mw_user_groups)
  and `rev_timestamp` in (select MIN(`rev_timestamp`) from `mw_revision` group by rev_page)
 )
);


remove o conteúdo de mw_user

delete
from mw_user 
where user_id not in(select ug_user from mw_user_groups)


remove o conteúdo de mw_recentchanges

delete
from mw_recentchanges 
where rc_user not in(select ug_user from mw_user_groups)


remove o conteúdo de mw_oldimage

delete
from mw_oldimage 
where oi_user not in(select ug_user from mw_user_groups)


remove o conteúdo de mw_logging

delete
from mw_logging 
where log_user not in(select ug_user from mw_user_groups)


remove o conteúdo de mw_image

delete
from mw_image 
where img_user not in(select ug_user from mw_user_groups)


remove o conteúdo de mw_archive

delete
from mw_archive 
where ar_user not in(select ug_user from mw_user_groups)


remove o conteúdo de page

delete
from mw_page
where page_id in (select rev_page
 from `mw_revision`
 where `rev_user` not in(select ug_user from mw_user_groups)
 and `rev_timestamp` in (select MIN(`rev_timestamp`) from `mw_revision` group by rev_page)
)


Referências

Conteúdo liberado sob a licença Gnu-fdl.png GNU Free Documentation License 1.2