ویکی‌پدیا:درخواست‌های ربات/ربات واگردان

ربات واگردان
نامربات واگردان
اجازه‌نامهCC-BY-SA 3.0
تست‌شده؟بله
قابلیتواگردانی تمام ویرایش‌های یک یا چند کاربر
سازندهJavad Yousefi
زبان برنامه نویسیپی‌اچ‌پی
پی‌نوشتبرای اجرای این کد، ربات باید دسترسی واگردانی داشته باشد.
ورودینام کاربری کاربران خرابکار
خروجیواگردانی تمام ویرایش‌های کاربران خواسته شده
نمونه کار۱

این کد برای واگردانی تمامی ویرایش‌های یک یا چند کاربر است.

روش کار ویرایش

  • در ابتدا برای انجام این کد، ربات باید دسترسی واگردان داشته باشد.
  • دریافت کلاس ربات ویکی‌پدیا از اینجا .
  • ایجاد فایل rollback.php و کپی کردن کد زیر در آن.
  • اعمال تغییرات زیر در کد rollback.php.
$user = 'نام کاربری ربات';

$users = array('نام کاربری خرابکار ۲','نام کاربری خرابکار 1');
  • ساخت فایل adminpass.php و قرار دادن پسورد ربات در آن
  • اجرا روی localhost و یا بارگذاری فایل‌ها روی سرور و اجرای کد.

{{پاک‌

کد rollback.php ویرایش

<?php
/** rollback.php - Mass Revert of all a users' edits
 *  Copyright (C) 2008  Chris Grant - http://en.wikipedia.org/wiki/User:Chris_G
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc. , 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Developers (add your self here if you worked on the code):
 *  	Chris - [[User:Chris_G]] - Wrote up the main code
 *	Cobi  - [[User:Cobi]]    - Wrote some of botclasses.php
 *      Javad Yousefi  - [[:fa:User:Javadyou]    -  develop for farsi wikipedia
 **/

/* Setup my classes */
include('botclasses.php');
$wiki      = new wikipedia;
$wiki->url = 'http://fa.wikipedia.org/w/api.php';

/* All the login stuff */
$user = 'JYBot';
include('adminpass.php');
$wiki->login($user,$pass);
unset($pass);

/* The users to revert */
$users = array('Javadyou2','ss');

/* Sleep - the time to sleep between rollbacks (set to null to disable) */
$sleep = null;

/* Revert all the edits */
foreach ($users as $user_revert) {
	$contribs = $wiki->query('?action=query&format=php&list=usercontribs&ucuser='.urlencode($user_revert). '&uclimit=500&ucdir=older');
	$i = ۰;
	foreach ($contribs['query']['usercontribs'] as $c) {
		$wiki->rollback($c['title'],$user_revert);
		if ($sleep!= null) {
			sleep($sleep);
		}
		$i++;
	}
	echo "$i edits by '$user_revert' reverted. \n";
}
echo "Done\n";

?>