-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbad-image.php
97 lines (69 loc) · 3.12 KB
/
bad-image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
ini_set('memory_limit','16M');
require_once( '/home/tparis/Peachy/Init.php' );
$site = Peachy::newWiki( "TPBot" );
$site->set_runpage("User:TPBot/Run/BIL");
//START GENERATING TRANSCLUSIONS
$i = array();
$i = initPage('Template:Badimage')->embeddedin( array( 6, 7 ) );
//END GENERATING TRANSCLUSIONS
//START GENERATING BAD IMAGE LIST
$bil = initPage('MediaWiki:Bad image list')->get_text();
preg_match_all('/\*\s\[\[\:(File\:(.*?))\]\]/i', $bil, $bad_images);
$bad_images = $bad_images[1];
print_r($bad_images);
//END GENERATING BAD IMAGE LIST
//START PROCESSING EACH IMAGE
foreach( $i as $image ) {
if( in_array( str_replace('File talk','File',$image), $bad_images ) ) {
continue;
}
else {
$image_page_object = initPage($image);
$image_page = $image_page_object->get_text();
$new_image_page = str_ireplace('{{badimage}}','',$image_page);
//echo getTextDiff('unified', $image_page, $new_image_page);
if( $image_page == $new_image_page ) continue;
$image_page_object->edit($new_image_page,"Removing {{badimage}}, image is not on blacklist",true);
continue;
}
if( str_replace('File talk','File',$image) != $image ) {
$image_page_object = initPage(str_replace('File talk','File',$image));
$image_page = $image_page_object->get_text();
$image_talk_page_object = initPage($image);
$image_talk_page = $image_talk_page_object->get_text();
//START REMOVAL FROM TALK PAGE
$new_image_talk_page = str_ireplace('{{badimage}}','',$image_talk_page);
//echo getTextDiff('unified', $image_talk_page, $new_image_talk_page);
if( $image_talk_page == $new_image_talk_page ) continue;
$image_talk_page_object->edit($new_image_talk_page,"Removing {{badimage}}, moving to main image page",true);
//START ADDITION TO MAIN PAGE
if( preg_match('/\{\{badimage/i', $image_page ) ) continue;
$new_image_page = "{{badimage}}\n$image_page";
//echo getTextDiff('unified', $image_page, $new_image_page);
if( $image_page == $new_image_page ) continue;
$image_page_object->edit($new_image_page,"Adding {{badimage}}",true);
}
}
//END PROCESSING EACH IMAGE
//START GENERATING TRANSCLUSIONS
$i = array();
$i = initPage('Template:Badimage')->embeddedin( array( 6, 7 ) );
//END GENERATING TRANSCLUSIONS
//START GENERATING BAD IMAGE LIST
$bil = initPage('MediaWiki:Bad image list')->get_text();
preg_match_all('/\*\s\[\[\:(File\:(.*?))\]\]/i', $bil, $bad_images);
$bad_images = $bad_images[1];
print_r($bad_images);
//END GENERATING BAD IMAGE LIST
//START GOING THROUGH BIL
foreach( $bad_images as $bad_image ) {
$image = initPage($bad_image);
$image_page = $image->get_text();
if( preg_match('/\{\{badimage/i', $image_page ) ) continue;
$new_image_page = "{{badimage}}\n$image_page";
//echo getTextDiff('unified', $image_page, $new_image_page);
if( $image_page == $new_image_page ) continue;
$image->edit($new_image_page,"Adding {{badimage}}",true);
}
//END GOING THROUGH BIL