r106321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106320‎ | r106321 | r106322 >
Date:14:10, 15 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Few other minor bits of cleanup
Modified paths:
  • /trunk/tools/rotatebot/login.php (modified) (history)
  • /trunk/tools/rotatebot/rotbot.php (modified) (history)
  • /trunk/tools/rotatebot/upload.php (modified) (history)

Diff [purge]

Index: trunk/tools/rotatebot/rotbot.php
@@ -101,7 +101,7 @@
102102 */
103103
104104 //noch restliche daten nachladen von api.php
105 -
 105+$urlpageids = '';
106106 foreach($contentarray['pages'] as $picture)
107107 {
108108 $urlpageids .= "|".$picture['pageid'];
@@ -173,40 +173,40 @@
174174
175175 foreach($picture['revisions'] as $key => $revisions)
176176 {
177 - if(trim($revisions['timestamp']) == $revitimestp)
178 - {
179 - $catcontent[$arraykey]['tmplsetter'] = $picture['revisions'][$key]['user'];
180 - logfile("Template by: ".$catcontent[$arraykey]['tmplsetter']);
181 - }
182 - else
183 - {
184 - logfile("set time($revitimestp) not identical with this rv, ".$revisions['timestamp'].".");
185 - //Rev's nachladen
186 - $ctxctx = file_get_contents("http://commons.wikimedia.org/w/api.php?action=query&prop=revisions&pageids=".$picture['pageid']."&rvlimit=20&rvprop=timestamp|user|comment&format=php") or suicide("api error");
187 - $totrevs = unserialize($ctxctx);
188 - logfile("ID: ".$picture['pageid']." ");
189 -
190 - if(is_array($totrevs))
 177+ if(trim($revisions['timestamp']) == $revitimestp)
191178 {
192 - foreach($totrevs['query']['pages'] as $cxxx)
 179+ $catcontent[$arraykey]['tmplsetter'] = $picture['revisions'][$key]['user'];
 180+ logfile("Template by: ".$catcontent[$arraykey]['tmplsetter']);
 181+ }
 182+ else
 183+ {
 184+ logfile("set time($revitimestp) not identical with this rv, ".$revisions['timestamp'].".");
 185+ //Rev's nachladen
 186+ $ctxctx = file_get_contents("http://commons.wikimedia.org/w/api.php?action=query&prop=revisions&pageids=".$picture['pageid']."&rvlimit=20&rvprop=timestamp|user|comment&format=php") or suicide("api error");
 187+ $totrevs = unserialize($ctxctx);
 188+ logfile("ID: ".$picture['pageid']." ");
 189+
 190+ if(is_array($totrevs))
193191 {
194 - foreach($cxxx['revisions'] as $cxxxx)
 192+ foreach($totrevs['query']['pages'] as $cxxx)
195193 {
196 - if($cxxxx['timestamp'] == $revitimestp)
 194+ foreach($cxxx['revisions'] as $cxxxx)
197195 {
198 - $catcontent[$arraykey]['tmplsetter'] = $cxxxx['user'];
199 - logfile("Older rev, template by: ".$catcontent[$arraykey]['tmplsetter']);
 196+ if($cxxxx['timestamp'] == $revitimestp)
 197+ {
 198+ $catcontent[$arraykey]['tmplsetter'] = $cxxxx['user'];
 199+ logfile("Older rev, template by: ".$catcontent[$arraykey]['tmplsetter']);
 200+ }
200201 }
201202 }
202203 }
203 - }
204 - else
205 - {
206 - logfile("API: Error: not a array!");
207 - logfile($totrevs);
208 - }
209 - }
 204+ else
 205+ {
 206+ logfile("API: Error: not a array!");
 207+ logfile($totrevs);
 208+ }
210209 }
 210+}
211211
212212
213213 //Benutzer prüfen! #########################################
@@ -227,7 +227,6 @@
228228 $a_row = $cachedbar["$wgAuthor"];
229229 }
230230
231 -
232231 $setuserid = $a_row[0];
233232 $user_registration = $a_row[2];
234233 $user_editcount = $a_row[3];
@@ -684,9 +683,9 @@
685684 //Cache leeren
686685 foreach($catcontent2 as $filename => $arraycontent)
687686 {
688 -unlink("/home/luxo/rotbot/cache/".$filename.".".$arraycontent['filetype']);
689 -unlink("/home/luxo/rotbot/cache/".$filename."_2.".$arraycontent['filetype']);
690 -unlink("/home/luxo/rotbot/cache/".$filename."_2.".$arraycontent['filetype']."_original");
 687+ unlink("/home/luxo/rotbot/cache/".$filename.".".$arraycontent['filetype']);
 688+ unlink("/home/luxo/rotbot/cache/".$filename."_2.".$arraycontent['filetype']);
 689+ unlink("/home/luxo/rotbot/cache/".$filename."_2.".$arraycontent['filetype']."_original");
691690 }
692691 logfile("cache cleared. Write log now.");
693692
@@ -745,7 +744,7 @@
746745
747746 if($nodelete[$arraycontent['title']] == 1)
748747 {
749 - $logfilew .= "<big style='color:red;text-decoration:blink;'>'''Warning:''' Template not found, file probably still in the category!!</big>\n";
 748+ $logfilew .= "<big style='color:red;text-decoration:blink;'>'''Warning:''' Template not found, file probably still in the category!!</big>\n";
750749 }
751750
752751 if($arraycontent['metadata']['Make'] and $arraycontent['metadata']['DateTimeDigitized'])
@@ -984,7 +983,7 @@
985984 $regMin = substr($tstime,10,2);
986985 $regSec = substr($tstime,12,2);
987986
988 -return mktime($regHour, $regMin, $regSec, $regMonth, $regDay, $regYear);
 987+ return mktime($regHour, $regMin, $regSec, $regMonth, $regDay, $regYear);
989988 }
990989
991990 function hexToStr($hex)
Index: trunk/tools/rotatebot/upload.php
@@ -70,7 +70,6 @@
7171
7272 function wiki_upload_file ($filename_local,$filename_wiki,$license,$desc,$wiki,$cookies)
7373 {
74 - $file1 = "";//Löschen wegen Speicherplatz
7574 $file1 = file_get_contents("/home/luxo/rotbot/cache/".$filename_local) or die("Fehler - Datei nicht gefunden! ($filename_local)");
7675
7776 $data_l = array("file.file" => $file1,
@@ -145,5 +144,4 @@
146145 fclose($fp);
147146 file_put_contents("/home/luxo/rotbot/cache/log.txt",$res);
148147 return $res;
149 - $data_l = array();
150148 }
Index: trunk/tools/rotatebot/login.php
@@ -98,7 +98,7 @@
9999
100100 //cookie-header erneut generieren
101101 $cookie = "";
102 - foreach ($cookies as $key=>$value)
 102+ foreach ($cookies as $value)
103103 {
104104 $cookie .= trim($value).";";
105105 }
@@ -291,7 +291,7 @@
292292 $data['login']['cookieprefix']."UserName" => $data['login']['cookieprefix']."UserName=".$data['login']['lgusername'],
293293 $data['login']['cookieprefix']."Token" => $data['login']['cookieprefix']."Token=".$data['login']['lgtoken']);
294294 } else {
295 - die("Login nicht erfolgreich! (".$data['login']['result'].")");
 295+ die("Login nicht erfolgreich! (".$data['login']['result'].")");
296296 }
297297
298298 curl_close($ch);

Status & tagging log