r106243 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106242‎ | r106243 | r106244 >
Date:21:24, 14 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Bit more indenting


Fixup some possibly undefined variables
Modified paths:
  • /trunk/tools/rotatebot/login.php (modified) (history)
  • /trunk/tools/rotatebot/upload.php (modified) (history)

Diff [purge]

Index: trunk/tools/rotatebot/upload.php
@@ -21,45 +21,47 @@
2222 // ############### EDIT WIKIPEDIA - FUNCTION ###############
2323 function wikiupload($project,$filename_local,$filename_wiki,$license,$desc)
2424 {
25 -global $cookies;
26 -$username = "Rotatebot";
27 -$password = "**removed**";
28 -
29 -logfile("Lade Bild '$filename_wiki' hoch am ".date("r",time()).".");
30 -
31 -//$cookies
32 -if(!$cookies["commonswikiUserName"] OR !$cookies["commonswikiUserID"])
33 -{
 25+ global $cookies;
3426 $username = "Rotatebot";
3527 $password = "**removed**";
36 - logfile("Login to $project!\n");
37 - wikilogin($username,$password,$project,$useragent);
38 - logfile("logged in to $project!\n");
39 - print_r($cookies);
40 -}
41 -else
42 -{
43 - logfile("already logged in to $project for upload\n");
44 -}
4528
 29+ logfile("Lade Bild '$filename_wiki' hoch am ".date("r",time()).".");
4630
47 -if($cookies) {
48 - logfile("Angemeldet in $project!\n");
49 -} else {
50 - die("Keine Cookies! Abbruch\n$header\n");
51 -}
 31+ //$cookies
 32+ if(!$cookies["commonswikiUserName"] || !$cookies["commonswikiUserID"])
 33+ {
 34+ $username = "Rotatebot";
 35+ $password = "**removed**";
 36+ $useragent = "Luxo (toolserver; php) luxo@ts.wikimedia.org";
 37+ logfile("Login to $project!\n");
 38+ wikilogin($username,$password,$project,$useragent);
 39+ logfile("logged in to $project!\n");
 40+ print_r($cookies);
 41+ }
 42+ else
 43+ {
 44+ logfile("already logged in to $project for upload\n");
 45+ }
5246
53 -//Angemeldet, Cookies formatieren**************
 47+ $header = '';
 48+ if($cookies) {
 49+ logfile("Angemeldet in $project!\n");
 50+ } else {
 51+ die("Keine Cookies! Abbruch\n$header\n");
 52+ }
5453
55 -foreach ($cookies as $key=>$value)
56 -{
57 - $cookie .= trim($value).";";
58 -}
59 -$cookie = substr($cookie,0,-1);
 54+ //Angemeldet, Cookies formatieren**************
6055
61 -//************ BILD HOCHLADEN ****************
62 -wiki_upload_file ($filename_local,$filename_wiki,$license,$desc,$project,$cookie);
 56+ $cookie = '';
 57+ foreach ($cookies as $key=>$value)
 58+ {
 59+ $cookie .= trim($value).";";
 60+ }
 61+ $cookie = substr($cookie,0,-1);
6362
 63+ //************ BILD HOCHLADEN ****************
 64+ wiki_upload_file ($filename_local,$filename_wiki,$license,$desc,$project,$cookie);
 65+
6466 }
6567
6668 /* ###########################################
Index: trunk/tools/rotatebot/login.php
@@ -29,7 +29,7 @@
3030 $useragent = "Luxo (toolserver; php) luxo@ts.wikimedia.org";
3131
3232 //$cookies
33 - if(!$cookies["commonswikiUserName"] OR !$cookies["commonswikiUserID"])
 33+ if(!$cookies["commonswikiUserName"] || !$cookies["commonswikiUserID"])
3434 {
3535 $username = "Rotatebot";
3636 $password = "**removed**";
@@ -51,9 +51,8 @@
5252 $bodyw.=$linew;
5353 }
5454 echo $bodyw;*/
55 - $header = "";
 55+ $accept = "";
5656
57 -
5857 //Angemeldet, Cookies ausgelesen, editieren kann beginnen**************
5958 $fpb = fsockopen ($project, 80, $errno, $errstr, 30);
6059
@@ -65,13 +64,13 @@
6665 fputs($fpb, "Accept: $accept\n");
6766 fputs($fpb, "Accept-Language: de\n");
6867
69 - foreach ($cookies as $key=>$value)
 68+ $cookie = '';
 69+ foreach ($cookies as $value)
7070 {
7171 $cookie .= trim($value).";";
7272 }
7373 $cookie = substr($cookie,0,-1);
7474
75 -
7675 logfile("Lade Seite; Cookies: $cookie\n");
7776
7877 fputs($fpb, "Cookie: ".$cookie."\n");
@@ -79,6 +78,7 @@
8079 fputs($fpb, "Connection: close\n");
8180 fputs($fpb, "\n");
8281
 82+ $headerrx = '';
8383
8484 //Response Header auslesen forallem cooke********************
8585 do {
@@ -88,9 +88,10 @@
8989 //auf cookie prüfen
9090 if(substr($linex,0,11) == "Set-Cookie:")
9191 {
 92+ // FIXME: $line is undefined
9293 $rawcookie = substr($line,11,strpos($line,";")-11); //Format: session=DFJ3ASD2S
9394 $cookiename = trim(substr($rawcookie,0,strpos($rawcookie,"=")));
94 - $cookies[$cookiename] = $rawcookie;
 95+ $cookies[$cookiename] = $rawcookie;
9596 }
9697
9798 } while (trim($linex)!="");
@@ -103,7 +104,7 @@
104105 }
105106 $cookie = substr($cookie,0,-1);
106107
107 -
 108+ $bodyy = '';
108109 logfile("Neue Cookies: $cookie\n");
109110
110111 //echo $headerrx."\n\n";

Status & tagging log