Index: trunk/tools/rotatebot/rotbot.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | $myLockfile = $homedir."rotatebotlock"; |
21 | 21 | |
22 | 22 | ini_set('memory_limit', '100M'); //Speicher auf 100 MBytes hochsetzen |
23 | | -ini_set('user_agent', ' User:Rotatebot by Luxo on the Toolserver / PHP'); |
| 23 | +ini_set('user_agent', $useragent); |
24 | 24 | |
25 | 25 | |
26 | 26 | logfile("Starte Bot!"); |
— | — | @@ -55,7 +55,6 @@ |
56 | 56 | logfile("Verbinde zur Datenbank!"); |
57 | 57 | |
58 | 58 | $myslink = mysql_connect($databanknames, $userloginname, $databasepw) or suicide ("Can't connect to MySQL"); |
59 | | -$database = "commonswiki_p"; |
60 | 59 | mysql_select_db($database, $myslink) |
61 | 60 | or suicide ("Konnte $database nicht öffnen: ".mysql_error()); |
62 | 61 | //Datenbank verbunden |
— | — | @@ -217,7 +216,7 @@ |
218 | 217 | //Datenbank abfragen nach status |
219 | 218 | if(!$cachedbar["$wgAuthor"]) |
220 | 219 | { |
221 | | - $mysresult = mysql_query( "SELECT * FROM user WHERE user_name='".mysql_real_escape_string($wgAuthor)."'") or suicide("MySQL error"); |
| 220 | + $mysresult = mysql_query( "SELECT * FROM user WHERE user_name='".mysql_real_escape_string($wgAuthor)."'", $myslink) or suicide("MySQL error"); |
222 | 221 | $a_row = mysql_fetch_row($mysresult); |
223 | 222 | $cachedbar[$wgAuthor] = $a_row; |
224 | 223 | } |
— | — | @@ -689,7 +688,7 @@ |
690 | 689 | |
691 | 690 | //##################### LOG LOG LOG LOG LOG LOG LOG ######################### |
692 | 691 | |
693 | | -$logfilew = file_get_contents("http://commons.wikimedia.org/w/index.php?title=User:Rotatebot/Log&action=raw"); |
| 692 | +$logfilew = file_get_contents("http://commons.wikimedia.org/w/index.php?title=User:$username/Log&action=raw"); |
694 | 693 | $somanyrot = count($catcontent2); |
695 | 694 | |
696 | 695 | $logfilew = deleteold($logfilew,$somanyrot,$config['logfilesize'],$config['logheader']); |
— | — | @@ -769,7 +768,7 @@ |
770 | 769 | $msgerr = ", ".count($wrongfiles)." errors"; |
771 | 770 | } |
772 | 771 | |
773 | | - wikiedit("commons.wikimedia.org","User:Rotatebot/Log",$logfilew,"Bot: $somanyrot images rotated".$msgerr.".","1"); |
| 772 | + wikiedit("commons.wikimedia.org","User:$username/Log",$logfilew,"Bot: $somanyrot images rotated".$msgerr.".","1"); |
774 | 773 | } |
775 | 774 | |
776 | 775 | mysql_close($myslink); // TODO should/can this be moved to function suicide? - Probably not due to line 33. |
— | — | @@ -936,13 +935,15 @@ |
937 | 936 | |
938 | 937 | function botsetup() |
939 | 938 | { |
940 | | - $setupraw = file("http://commons.wikimedia.org/w/index.php?title=User:Rotatebot/config.js&action=raw"); |
| 939 | + global $username; |
| 940 | + $setupraw = file("http://commons.wikimedia.org/w/index.php?title=User:$username/config.js&action=raw"); |
941 | 941 | |
| 942 | + $array = array(); |
942 | 943 | foreach($setupraw as $line) |
943 | 944 | { |
944 | 945 | $line = trim($line); |
945 | 946 | |
946 | | - if(substr($line,0,2) != "//" AND $line != "") |
| 947 | + if(substr($line,0,2) != "//" && $line != "") |
947 | 948 | { |
948 | 949 | |
949 | 950 | $gleich = strpos($line, "="); |
— | — | @@ -956,12 +957,12 @@ |
957 | 958 | //falls vorhanden "" entfernen |
958 | 959 | if(substr($content, 0, 1) == '"') |
959 | 960 | { |
960 | | - $content = substr($content, 1); |
| 961 | + $content = substr($content, 1); |
961 | 962 | } |
962 | 963 | |
963 | 964 | if(substr($content, -1) == '"') |
964 | 965 | { |
965 | | - $content = substr($content, 0, -1); |
| 966 | + $content = substr($content, 0, -1); |
966 | 967 | } |
967 | 968 | |
968 | 969 | $content = trim($content); |
Index: trunk/tools/rotatebot/settings.php |
— | — | @@ -3,10 +3,13 @@ |
4 | 4 | $homedir = "/home/luxo/rotbot/"; |
5 | 5 | $cookies = "/home/lux/cks"; |
6 | 6 | $exiftool = "/home/luxor/rotbot/exiftool/exiftool"; |
7 | | -$useragent = "Luxo (Toolserver; php) luxo@ts.wikimedia.org"; |
| 7 | +$useragent = "Luxo (Toolserver; php) luxo@ts.wikimedia.org"; // ' User:Rotatebot by Luxo on the Toolserver / PHP' |
8 | 8 | |
9 | 9 | $databanknames = ""; // server |
| 10 | +$database = ""; // database name |
10 | 11 | |
11 | 12 | $userloginname = ""; // database username |
12 | 13 | $databasepw = ""; // database password |
13 | 14 | |
| 15 | +$username = ""; // Bot username |
| 16 | +$password = ""; // Bot password |
Index: trunk/tools/rotatebot/upload.php |
— | — | @@ -30,8 +30,7 @@ |
31 | 31 | //$cookies |
32 | 32 | if(!$cookies["commonswikiUserName"] || !$cookies["commonswikiUserID"]) |
33 | 33 | { |
34 | | - $username = "Rotatebot"; |
35 | | - $password = "**removed**"; |
| 34 | + global $username, $password; |
36 | 35 | |
37 | 36 | logfile("Login to $project!\n"); |
38 | 37 | wikilogin($username,$password,$project,$useragent); |
Index: trunk/tools/rotatebot/login.php |
— | — | @@ -23,15 +23,15 @@ |
24 | 24 | // ############### EDIT WIKIPEDIA - FUNCTION ############### |
25 | 25 | function wikiedit($project,$page,$newtext,$description,$minor) |
26 | 26 | { |
27 | | - global $cookies, $useragent; |
| 27 | + global $cookies, $useragent, $username; |
28 | 28 | logfile("Funktion gestartet..."); |
29 | 29 | logfile("Schreibe Text am ".date("r",time())." in die Seite '$page'."); |
30 | 30 | |
31 | 31 | //$cookies |
32 | 32 | if(!$cookies["commonswikiUserName"] || !$cookies["commonswikiUserID"]) |
33 | 33 | { |
34 | | - $username = "Rotatebot"; |
35 | | - $password = "**removed**"; |
| 34 | + global $password; |
| 35 | + |
36 | 36 | logfile("Login to $project!\n"); |
37 | 37 | wikilogin($username,$password,$project,$useragent); |
38 | 38 | logfile("logged in to $project!\n"); |
— | — | @@ -87,8 +87,7 @@ |
88 | 88 | //auf cookie prüfen |
89 | 89 | if(substr($linex,0,11) == "Set-Cookie:") |
90 | 90 | { |
91 | | - // FIXME: $line is undefined |
92 | | - $rawcookie = substr($line,11,strpos($line,";")-11); //Format: session=DFJ3ASD2S |
| 91 | + $rawcookie = substr($linex,11,strpos($linex,";")-11); //Format: session=DFJ3ASD2S |
93 | 92 | $cookiename = trim(substr($rawcookie,0,strpos($rawcookie,"="))); |
94 | 93 | $cookies[$cookiename] = $rawcookie; |
95 | 94 | } |
— | — | @@ -139,7 +138,7 @@ |
140 | 139 | } |
141 | 140 | logfile("Seite geladen, Anmeldung prüfen."); |
142 | 141 | |
143 | | - if(strstr($bodyy,'"wgUserName": "Rotatebot",')) |
| 142 | + if(strstr($bodyy,'"wgUserName": "' . $username . '",')) |
144 | 143 | { |
145 | 144 | logfile("Anmeldung erfolgreich!"); |
146 | 145 | |