Index: trunk/tools/rotatebot/upload.php |
— | — | @@ -21,45 +21,47 @@ |
22 | 22 | // ############### EDIT WIKIPEDIA - FUNCTION ############### |
23 | 23 | function wikiupload($project,$filename_local,$filename_wiki,$license,$desc) |
24 | 24 | { |
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; |
34 | 26 | $username = "Rotatebot"; |
35 | 27 | $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 | | -} |
45 | 28 | |
| 29 | + logfile("Lade Bild '$filename_wiki' hoch am ".date("r",time())."."); |
46 | 30 | |
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 | + } |
52 | 46 | |
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 | + } |
54 | 53 | |
55 | | -foreach ($cookies as $key=>$value) |
56 | | -{ |
57 | | - $cookie .= trim($value).";"; |
58 | | -} |
59 | | -$cookie = substr($cookie,0,-1); |
| 54 | + //Angemeldet, Cookies formatieren************** |
60 | 55 | |
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); |
63 | 62 | |
| 63 | + //************ BILD HOCHLADEN **************** |
| 64 | + wiki_upload_file ($filename_local,$filename_wiki,$license,$desc,$project,$cookie); |
| 65 | + |
64 | 66 | } |
65 | 67 | |
66 | 68 | /* ########################################### |
Index: trunk/tools/rotatebot/login.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | $useragent = "Luxo (toolserver; php) luxo@ts.wikimedia.org"; |
31 | 31 | |
32 | 32 | //$cookies |
33 | | - if(!$cookies["commonswikiUserName"] OR !$cookies["commonswikiUserID"]) |
| 33 | + if(!$cookies["commonswikiUserName"] || !$cookies["commonswikiUserID"]) |
34 | 34 | { |
35 | 35 | $username = "Rotatebot"; |
36 | 36 | $password = "**removed**"; |
— | — | @@ -51,9 +51,8 @@ |
52 | 52 | $bodyw.=$linew; |
53 | 53 | } |
54 | 54 | echo $bodyw;*/ |
55 | | - $header = ""; |
| 55 | + $accept = ""; |
56 | 56 | |
57 | | - |
58 | 57 | //Angemeldet, Cookies ausgelesen, editieren kann beginnen************** |
59 | 58 | $fpb = fsockopen ($project, 80, $errno, $errstr, 30); |
60 | 59 | |
— | — | @@ -65,13 +64,13 @@ |
66 | 65 | fputs($fpb, "Accept: $accept\n"); |
67 | 66 | fputs($fpb, "Accept-Language: de\n"); |
68 | 67 | |
69 | | - foreach ($cookies as $key=>$value) |
| 68 | + $cookie = ''; |
| 69 | + foreach ($cookies as $value) |
70 | 70 | { |
71 | 71 | $cookie .= trim($value).";"; |
72 | 72 | } |
73 | 73 | $cookie = substr($cookie,0,-1); |
74 | 74 | |
75 | | - |
76 | 75 | logfile("Lade Seite; Cookies: $cookie\n"); |
77 | 76 | |
78 | 77 | fputs($fpb, "Cookie: ".$cookie."\n"); |
— | — | @@ -79,6 +78,7 @@ |
80 | 79 | fputs($fpb, "Connection: close\n"); |
81 | 80 | fputs($fpb, "\n"); |
82 | 81 | |
| 82 | + $headerrx = ''; |
83 | 83 | |
84 | 84 | //Response Header auslesen forallem cooke******************** |
85 | 85 | do { |
— | — | @@ -88,9 +88,10 @@ |
89 | 89 | //auf cookie prüfen |
90 | 90 | if(substr($linex,0,11) == "Set-Cookie:") |
91 | 91 | { |
| 92 | + // FIXME: $line is undefined |
92 | 93 | $rawcookie = substr($line,11,strpos($line,";")-11); //Format: session=DFJ3ASD2S |
93 | 94 | $cookiename = trim(substr($rawcookie,0,strpos($rawcookie,"="))); |
94 | | - $cookies[$cookiename] = $rawcookie; |
| 95 | + $cookies[$cookiename] = $rawcookie; |
95 | 96 | } |
96 | 97 | |
97 | 98 | } while (trim($linex)!=""); |
— | — | @@ -103,7 +104,7 @@ |
104 | 105 | } |
105 | 106 | $cookie = substr($cookie,0,-1); |
106 | 107 | |
107 | | - |
| 108 | + $bodyy = ''; |
108 | 109 | logfile("Neue Cookies: $cookie\n"); |
109 | 110 | |
110 | 111 | //echo $headerrx."\n\n"; |