Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php |
— | — | @@ -44,13 +44,13 @@ |
45 | 45 | } |
46 | 46 | |
47 | 47 | $this->gift_id = $wgRequest->getVal( 'gift_id' ); |
48 | | - $this->initLogo($wgRequest); |
| 48 | + $this->initLogo( $wgRequest ); |
49 | 49 | $this->executeLogo(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | function initLogo( &$request ){ |
53 | 53 | $this->fileExtensions = array( 'gif', 'jpg', 'jpeg', 'png' ); |
54 | | - |
| 54 | + |
55 | 55 | if( !$request->wasPosted() ) { |
56 | 56 | # GET requests just give the main form; no data except wpDestfile. |
57 | 57 | return; |
— | — | @@ -59,12 +59,12 @@ |
60 | 60 | $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning'); |
61 | 61 | $this->mReUpload = $request->getCheck( 'wpReUpload' ); |
62 | 62 | $this->mUpload = $request->getCheck( 'wpUpload' ); |
63 | | - |
| 63 | + |
64 | 64 | $this->mUploadDescription = $request->getText( 'wpUploadDescription' ); |
65 | 65 | $this->mUploadCopyStatus = $request->getText( 'wpUploadCopyStatus' ); |
66 | 66 | $this->mUploadSource = $request->getText( 'wpUploadSource' ); |
67 | 67 | $this->mWatchthis = $request->getBool( 'wpWatchthis' ); |
68 | | - wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" ); |
| 68 | + wfDebug( __METHOD__ . ": watchthis is: '$this->mWatchthis'\n" ); |
69 | 69 | |
70 | 70 | $this->mAction = $request->getVal( 'action' ); |
71 | 71 | $this->mSessionKey = $request->getInt( 'wpSessionKey' ); |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | public function executeLogo() { |
101 | 101 | global $wgUser, $wgOut; |
102 | 102 | global $wgEnableUploads, $wgUploadDirectory; |
103 | | - $this->avatarUploadDirectory = $wgUploadDirectory . "/awards"; |
| 103 | + $this->avatarUploadDirectory = $wgUploadDirectory . '/awards'; |
104 | 104 | /** Show an error message if file upload is disabled */ |
105 | 105 | if( !$wgEnableUploads ) { |
106 | 106 | $wgOut->addWikiMsg( 'uploaddisabled' ); |
— | — | @@ -141,7 +141,7 @@ |
142 | 142 | * If there was no filename or a zero size given, give up quick. |
143 | 143 | */ |
144 | 144 | if( trim( $this->mOname ) == '' || empty( $this->mUploadSize ) ) { |
145 | | - return $this->mainUploadForm('<li>'.wfMsg( 'emptyfile' ).'</li>'); |
| 145 | + return $this->mainUploadForm( '<li>'.wfMsg( 'emptyfile' ).'</li>' ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | # Chop off any directories in the given filename |
— | — | @@ -181,9 +181,9 @@ |
182 | 182 | * probably not accept it. |
183 | 183 | */ |
184 | 184 | if( !$this->mStashed ) { |
185 | | - $veri = $this->verify($this->mUploadTempName, $finalExt); |
| 185 | + $veri = $this->verify( $this->mUploadTempName, $finalExt ); |
186 | 186 | |
187 | | - if( $veri !== true ) { //it's a wiki error... |
| 187 | + if( $veri !== true ) { // it's a wiki error... |
188 | 188 | return $this->uploadError( $veri->toString() ); |
189 | 189 | } |
190 | 190 | } |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | * Stash the file in a temporary location; the user can choose |
217 | 217 | * to let it through and we'll complete the upload then. |
218 | 218 | */ |
219 | | - return $this->uploadWarning($warning); |
| 219 | + return $this->uploadWarning( $warning ); |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
— | — | @@ -223,22 +223,22 @@ |
224 | 224 | * Try actually saving the thing... |
225 | 225 | * It will show an error form on failure. |
226 | 226 | */ |
227 | | - $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) ); |
| 227 | + $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper( $fullExt ) ); |
228 | 228 | |
229 | 229 | if( $status > 0 ) { |
230 | | - $this->showSuccess($status); |
| 230 | + $this->showSuccess( $status ); |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ){ |
235 | | - list($origWidth, $origHeight, $TypeCode) = getimagesize($imageSrc); |
| 235 | + list( $origWidth, $origHeight, $TypeCode ) = getimagesize( $imageSrc ); |
236 | 236 | |
237 | | - if($origWidth < $thumbWidth)$thumbWidth = $origWidth; |
| 237 | + if( $origWidth < $thumbWidth ) $thumbWidth = $origWidth; |
238 | 238 | $thumbHeight = ($thumbWidth * $origHeight / $origWidth); |
239 | | - if($thumbHeight < $thumbWidth)$border = " -bordercolor white -border 0x" . (($thumbWidth - $thumbHeight) / 2); |
240 | | - if($TypeCode == 2)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " -quality 100 " . $border . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".jpg"); |
241 | | - if($TypeCode == 1)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $border . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".gif"); |
242 | | - if($TypeCode == 3)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".png"); |
| 239 | + if( $thumbHeight < $thumbWidth ) $border = " -bordercolor white -border 0x" . (($thumbWidth - $thumbHeight) / 2); |
| 240 | + if( $TypeCode == 2 ) exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " -quality 100 " . $border . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".jpg"); |
| 241 | + if( $TypeCode == 1 ) exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $border . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".gif"); |
| 242 | + if( $TypeCode == 3 ) exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".png"); |
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
— | — | @@ -254,44 +254,44 @@ |
255 | 255 | * is a PHP-managed upload temporary |
256 | 256 | */ |
257 | 257 | function saveUploadedFile( $saveName, $tempName, $ext ) { |
258 | | - global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname; |
| 258 | + global $wgUploadDirectory, $wgOut, $wgUser; |
259 | 259 | |
260 | 260 | $dest = $this->avatarUploadDirectory; |
261 | 261 | |
262 | 262 | $this->mSavedFile = "{$dest}/{$saveName}"; |
263 | 263 | |
264 | | - $this->createThumbnail($tempName, $ext, $this->gift_id . "_l", 75); |
265 | | - $this->createThumbnail($tempName, $ext, $this->gift_id . "_ml", 50); |
266 | | - $this->createThumbnail($tempName, $ext, $this->gift_id . "_m", 30); |
267 | | - $this->createThumbnail($tempName, $ext, $this->gift_id . "_s", 16); |
| 264 | + $this->createThumbnail( $tempName, $ext, $this->gift_id . "_l", 75 ); |
| 265 | + $this->createThumbnail( $tempName, $ext, $this->gift_id . "_ml", 50 ); |
| 266 | + $this->createThumbnail( $tempName, $ext, $this->gift_id . "_m", 30 ); |
| 267 | + $this->createThumbnail( $tempName, $ext, $this->gift_id . "_s", 16 ); |
268 | 268 | |
269 | | - if( $ext == "JPG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ){ |
| 269 | + if( $ext == "JPG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg" ) ){ |
270 | 270 | $type = 2; |
271 | 271 | } |
272 | | - if( $ext == "GIF" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id. "_l.gif") ){ |
| 272 | + if( $ext == "GIF" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id. "_l.gif" ) ){ |
273 | 273 | $type = 1; |
274 | 274 | } |
275 | | - if( $ext == "PNG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ){ |
| 275 | + if( $ext == "PNG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png" ) ){ |
276 | 276 | $type = 3; |
277 | 277 | } |
278 | 278 | |
279 | 279 | if( $ext!= "JPG" ){ |
280 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg"); |
281 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg"); |
282 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg"); |
283 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.jpg"); |
| 280 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg" ); |
| 281 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg" ); |
| 282 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg" ); |
| 283 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.jpg" ); |
284 | 284 | } |
285 | 285 | if( $ext != "GIF" ){ |
286 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif"); |
287 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif"); |
288 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif"); |
289 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.gif"); |
| 286 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif" ); |
| 287 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif" ); |
| 288 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif" ); |
| 289 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.gif" ); |
290 | 290 | } |
291 | 291 | if( $ext != "PNG" ){ |
292 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png"); |
293 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png"); |
294 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png"); |
295 | | - if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.png"); |
| 292 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png" ); |
| 293 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png" ); |
| 294 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png" ); |
| 295 | + if( is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png" ) ) unlink( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.png" ); |
296 | 296 | } |
297 | 297 | |
298 | 298 | if( $type < 0 ){ |
— | — | @@ -334,7 +334,7 @@ |
335 | 335 | * @return int |
336 | 336 | * @access private |
337 | 337 | */ |
338 | | - function stashSession() { |
| 338 | + function stashSession() { |
339 | 339 | $stash = $this->saveTempUploadedFile( |
340 | 340 | $this->mUploadSaveName, $this->mUploadTempName ); |
341 | 341 | |
— | — | @@ -369,30 +369,45 @@ |
370 | 370 | * @access private |
371 | 371 | */ |
372 | 372 | function showSuccess( $status ) { |
373 | | - global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgUploadPath, $wgScriptPath, $wgLang; |
374 | | - wfLoadExtensionMessages('SystemGifts'); |
| 373 | + global $wgUser, $wgOut, $wgUploadPath, $wgScriptPath, $wgLang; |
| 374 | + wfLoadExtensionMessages( 'SystemGifts' ); |
375 | 375 | $ext = 'jpg'; |
376 | 376 | |
377 | | - $output = '<h2>'.wfMsg('ga-uploadsuccess').'</h2>'; |
378 | | - $output .= '<h5>'.wfMsg('ga-imagesbelow').'</h5>'; |
379 | | - if( $status == 1 ) $ext = "gif"; |
380 | | - if( $status == 2 ) $ext = "jpg"; |
381 | | - if( $status == 3 ) $ext = "png"; |
| 377 | + $output = '<h2>'.wfMsg( 'ga-uploadsuccess' ).'</h2>'; |
| 378 | + $output .= '<h5>'.wfMsg( 'ga-imagesbelow' ).'</h5>'; |
| 379 | + if( $status == 1 ) $ext = 'gif'; |
| 380 | + if( $status == 2 ) $ext = 'jpg'; |
| 381 | + if( $status == 3 ) $ext = 'png'; |
382 | 382 | |
383 | | - $output .= '<table cellspacing="0" cellpadding="5">'; |
384 | | - $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-large').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_l.' . $ext . '?ts=' . rand() . '"></td></tr>'; |
385 | | - $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-mediumlarge').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_ml.' . $ext . '?ts=' . rand() . '"></td></tr>'; |
386 | | - $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-medium').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_m.' . $ext . '?ts=' . rand() . '"></td></tr>'; |
387 | | - $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-small').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_s.' . $ext . '?ts' . rand() . '"></td></tr>'; |
388 | | - $output .= '<tr><td><input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg('ga-goback').'"></td></tr>'; |
| 383 | + $output .= '<table cellspacing="0" cellpadding="5"> |
| 384 | + <tr> |
| 385 | + <td valign="top" style="color:#666666;font-weight:800">'.wfMsg( 'ga-large' ).'</td> |
| 386 | + <td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_l.' . $ext . '?ts=' . rand() . '"></td> |
| 387 | + </tr> |
| 388 | + <tr> |
| 389 | + <td valign="top" style="color:#666666;font-weight:800">'.wfMsg( 'ga-mediumlarge' ).'</td> |
| 390 | + <td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_ml.' . $ext . '?ts=' . rand() . '"></td> |
| 391 | + </tr> |
| 392 | + <tr> |
| 393 | + <td valign="top" style="color:#666666;font-weight:800">'.wfMsg( 'ga-medium' ).'</td> |
| 394 | + <td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_m.' . $ext . '?ts=' . rand() . '"></td> |
| 395 | + </tr> |
| 396 | + <tr> |
| 397 | + <td valign="top" style="color:#666666;font-weight:800">'.wfMsg( 'ga-small' ).'</td> |
| 398 | + <td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_s.' . $ext . '?ts' . rand() . '"></td> |
| 399 | + </tr> |
| 400 | + <tr> |
| 401 | + <td> |
| 402 | + <input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg( 'ga-goback' ).'"> |
| 403 | + </td> |
| 404 | + </tr>'; |
389 | 405 | |
390 | | - // FIXME: contains very hard coded URLs |
391 | 406 | $output .= $wgLang->pipeList( array( |
392 | | - '<tr><td><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager">' . wfMsg( 'ga-back-gift-list' ) . '</a>', |
393 | | - '<a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&id=' . $this->gift_id . '">' . wfMsg( 'ga-back-edit-gift') . '</a></td></tr>' |
| 407 | + '<tr><td><a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager">' . wfMsg( 'ga-back-gift-list' ) . '</a> ', |
| 408 | + ' <a href="' . $wgScriptPath . '/index.php?title=Special:SystemGiftManager&id=' . $this->gift_id . '">' . wfMsg( 'ga-back-edit-gift') . '</a></td></tr>' |
394 | 409 | ) ); |
395 | 410 | $output .= '</table>'; |
396 | | - $wgOut->addHTML($output); |
| 411 | + $wgOut->addHTML( $output ); |
397 | 412 | } |
398 | 413 | |
399 | 414 | /** |
— | — | @@ -401,11 +416,11 @@ |
402 | 417 | */ |
403 | 418 | function uploadError( $error ) { |
404 | 419 | global $wgOut; |
405 | | - wfLoadExtensionMessages('SystemGifts'); |
| 420 | + wfLoadExtensionMessages( 'SystemGifts' ); |
406 | 421 | $sub = wfMsg( 'uploadwarning' ); |
407 | 422 | $wgOut->addHTML( "<h2>{$sub}</h2>\n" ); |
408 | 423 | $wgOut->addHTML( "<h4 class='error'>{$error}</h4>\n" ); |
409 | | - $wgOut->addHTML( '<br /><input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg('ga-goback').'">' ); |
| 424 | + $wgOut->addHTML( '<br /><input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg( 'ga-goback' ).'">' ); |
410 | 425 | } |
411 | 426 | |
412 | 427 | /** |
— | — | @@ -457,7 +472,7 @@ |
458 | 473 | {$copyright} |
459 | 474 | <table border='0'> |
460 | 475 | <tr> |
461 | | - |
| 476 | + |
462 | 477 | <tr> |
463 | 478 | <td align='right'> |
464 | 479 | <input tabindex='2' type='button' onclick=javascript:history.go(-1) value='Back' /> |
— | — | @@ -478,7 +493,7 @@ |
479 | 494 | function mainUploadForm( $msg = '' ) { |
480 | 495 | global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest; |
481 | 496 | global $wgUseCopyrightUpload; |
482 | | - wfLoadExtensionMessages('SystemGifts'); |
| 497 | + wfLoadExtensionMessages( 'SystemGifts' ); |
483 | 498 | |
484 | 499 | $cols = intval( $wgUser->getOption( 'cols' ) ); |
485 | 500 | $ew = $wgUser->getOption( 'editwidth' ); |
— | — | @@ -490,7 +505,7 @@ |
491 | 506 | $wgOut->addHTML( "<h2>{$sub}</h2>\n" . |
492 | 507 | "<h4 class='error'>{$msg}</h4>\n" ); |
493 | 508 | } |
494 | | - //$wgOut->addWikiText( wfMsg( 'uploadtext' ) ); |
| 509 | + |
495 | 510 | $sk = $wgUser->getSkin(); |
496 | 511 | |
497 | 512 | $sourcefilename = wfMsg( 'sourcefilename' ); |
— | — | @@ -509,13 +524,13 @@ |
510 | 525 | |
511 | 526 | if ( $wgUseCopyrightUpload ) { |
512 | 527 | $source = " |
513 | | - <td align='right' nowrap='nowrap'>" . wfMsg ( 'filestatus' ) . ":</td> |
| 528 | + <td align='right' nowrap='nowrap'>" . wfMsg( 'filestatus' ) . "</td> |
514 | 529 | <td><input tabindex='3' type='text' name=\"wpUploadCopyStatus\" value=\"" . |
515 | | - htmlspecialchars($this->mUploadCopyStatus). "\" size='40' /></td> |
| 530 | + htmlspecialchars( $this->mUploadCopyStatus ). "\" size='40' /></td> |
516 | 531 | </tr><tr> |
517 | | - <td align='right'>". wfMsg ( 'filesource' ) . ":</td> |
| 532 | + <td align='right'>". wfMsg( 'filesource' ) . "</td> |
518 | 533 | <td><input tabindex='4' type='text' name='wpUploadSource' value=\"" . |
519 | | - htmlspecialchars($this->mUploadSource). "\" style='width:100px' /></td> |
| 534 | + htmlspecialchars( $this->mUploadSource ). "\" style='width:100px' /></td> |
520 | 535 | "; |
521 | 536 | } |
522 | 537 | |
— | — | @@ -524,18 +539,27 @@ |
525 | 540 | : ''; |
526 | 541 | |
527 | 542 | global $wgUploadPath; |
528 | | - $gift_image = SystemGifts::getGiftImage($this->gift_id, 'l'); |
| 543 | + $gift_image = SystemGifts::getGiftImage( $this->gift_id, 'l' ); |
529 | 544 | if( $gift_image != '' ){ |
530 | | - $output = '<table><tr><td style="color:#666666;font-weight:800">'.wfMsg('ga-currentimage').'</td></tr>'; |
531 | | - $output .= '<tr><td><img src="'.$wgUploadPath.'/awards/' . $gift_image . '" border="0" alt="'.wfMsg('ga-gift').'" /></td></tr></table><br />'; |
| 545 | + $output = '<table> |
| 546 | + <tr> |
| 547 | + <td style="color:#666666;font-weight:800">'.wfMsg( 'ga-currentimage' ).'</td> |
| 548 | + </tr> |
| 549 | + <tr> |
| 550 | + <td> |
| 551 | + <img src="' . $wgUploadPath . '/awards/' . $gift_image . '" border="0" alt="'.wfMsg( 'ga-gift' ).'" /> |
| 552 | + </td> |
| 553 | + </tr> |
| 554 | + </table> |
| 555 | + <br />'; |
532 | 556 | } |
533 | | - $wgOut->addHTML($output); |
| 557 | + $wgOut->addHTML( $output ); |
534 | 558 | |
535 | 559 | $wgOut->addHTML( " |
536 | 560 | <form id='upload' method='post' enctype='multipart/form-data' action=\"\"> |
537 | 561 | <table border='0'><tr> |
538 | 562 | |
539 | | - <td style='color:#666666;font-weight:800'>".wfMsg('ga-file-instructions')."<p>".wfMsg('ga-choosefile')."<br /> |
| 563 | + <td style='color:#666666;font-weight:800'>".wfMsg( 'ga-file-instructions' ) . wfMsg( 'ga-choosefile' )."<br /> |
540 | 564 | <input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' style='width:100px' /> |
541 | 565 | </td></tr><tr> |
542 | 566 | {$source} |
— | — | @@ -598,10 +622,8 @@ |
599 | 623 | function verify( $tmpfile, $extension ) { |
600 | 624 | #magically determine mime type |
601 | 625 | $magic = & wfGetMimeMagic(); |
602 | | - $mime = $magic->guessMimeType($tmpfile, false); |
| 626 | + $mime = $magic->guessMimeType( $tmpfile, false ); |
603 | 627 | |
604 | | - $fname = "SpecialSystemGiftManagerLogo::verify"; |
605 | | - |
606 | 628 | #check mime type, if desired |
607 | 629 | global $wgVerifyMimeType; |
608 | 630 | if( $wgVerifyMimeType ) { |
— | — | @@ -613,26 +635,26 @@ |
614 | 636 | |
615 | 637 | #check mime type blacklist |
616 | 638 | global $wgMimeTypeBlacklist; |
617 | | - if( isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist) |
| 639 | + if( isset( $wgMimeTypeBlacklist ) && !is_null( $wgMimeTypeBlacklist ) |
618 | 640 | && $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) { |
619 | 641 | return new WikiErrorMsg( 'badfiletype', htmlspecialchars( $mime ) ); |
620 | 642 | } |
621 | 643 | } |
622 | 644 | |
623 | 645 | #check for htmlish code and javascript |
624 | | - if( $this->detectScript ( $tmpfile, $mime ) ) { |
| 646 | + if( $this->detectScript( $tmpfile, $mime ) ) { |
625 | 647 | return new WikiErrorMsg( 'uploadscripted' ); |
626 | 648 | } |
627 | 649 | |
628 | 650 | /** |
629 | 651 | * Scan the uploaded file for viruses |
630 | 652 | */ |
631 | | - $virus = $this->detectVirus($tmpfile); |
| 653 | + $virus = $this->detectVirus( $tmpfile ); |
632 | 654 | if ( $virus ) { |
633 | | - return new WikiErrorMsg( 'uploadvirus', htmlspecialchars($virus) ); |
| 655 | + return new WikiErrorMsg( 'uploadvirus', htmlspecialchars( $virus ) ); |
634 | 656 | } |
635 | 657 | |
636 | | - wfDebug( "$fname: all clear; passing.\n" ); |
| 658 | + wfDebug( __METHOD__ . ": all clear; passing.\n" ); |
637 | 659 | return true; |
638 | 660 | } |
639 | 661 | |
— | — | @@ -644,32 +666,28 @@ |
645 | 667 | * @return bool |
646 | 668 | */ |
647 | 669 | function verifyExtension( $mime, $extension ) { |
648 | | - $fname = 'SpecialSystemGiftManagerLogo::verifyExtension'; |
649 | | - |
650 | 670 | $magic =& wfGetMimeMagic(); |
651 | 671 | |
652 | 672 | if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) |
653 | 673 | if ( !$magic->isRecognizableExtension( $extension ) ) { |
654 | | - wfDebug( "$fname: passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" ); |
| 674 | + wfDebug( __METHOD__ . ": passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" ); |
655 | 675 | return true; |
656 | 676 | } else { |
657 | | - wfDebug( "$fname: rejecting file with unknown detected mime type; recognized extension '$extension', so probably invalid file\n" ); |
| 677 | + wfDebug( __METHOD__ . ": rejecting file with unknown detected mime type; recognized extension '$extension', so probably invalid file\n" ); |
658 | 678 | return false; |
659 | 679 | } |
660 | 680 | |
661 | 681 | $match = $magic->isMatchingExtension( $extension, $mime ); |
662 | 682 | |
663 | 683 | if( $match === NULL ) { |
664 | | - wfDebug( "$fname: no file extension known for mime type $mime, passing file\n" ); |
| 684 | + wfDebug( __METHOD__ . ": no file extension known for mime type $mime, passing file\n" ); |
665 | 685 | return true; |
666 | 686 | } elseif( $match === true ) { |
667 | | - wfDebug( "$fname: mime type $mime matches extension $extension, passing file\n" ); |
668 | | - |
| 687 | + wfDebug( __METHOD__ . ": mime type $mime matches extension $extension, passing file\n" ); |
669 | 688 | #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it! |
670 | 689 | return true; |
671 | | - |
672 | 690 | } else { |
673 | | - wfDebug( "$fname: mime type $mime mismatches file extension $extension, rejecting file\n" ); |
| 691 | + wfDebug( __METHOD__ . ": mime type $mime mismatches file extension $extension, rejecting file\n" ); |
674 | 692 | return false; |
675 | 693 | } |
676 | 694 | } |
— | — | @@ -684,11 +702,10 @@ |
685 | 703 | * @return bool true if the file contains something looking like embedded scripts |
686 | 704 | */ |
687 | 705 | function detectScript( $file, $mime ) { |
688 | | - |
689 | 706 | #ugly hack: for text files, always look at the entire file. |
690 | 707 | #For binarie field, just check the first K. |
691 | 708 | |
692 | | - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file ); |
| 709 | + if( strpos( $mime, 'text/' ) === 0 ) $chunk = file_get_contents( $file ); |
693 | 710 | else { |
694 | 711 | $fp = fopen( $file, 'rb' ); |
695 | 712 | $chunk = fread( $fp, 1024 ); |
— | — | @@ -697,23 +714,23 @@ |
698 | 715 | |
699 | 716 | $chunk = strtolower( $chunk ); |
700 | 717 | |
701 | | - if (!$chunk) return false; |
| 718 | + if( !$chunk ) return false; |
702 | 719 | |
703 | 720 | #decode from UTF-16 if needed (could be used for obfuscation). |
704 | | - if (substr($chunk,0,2)=="\xfe\xff") $enc = "UTF-16BE"; |
705 | | - elseif (substr($chunk,0,2)=="\xff\xfe") $enc = "UTF-16LE"; |
| 721 | + if( substr( $chunk, 0, 2 ) == "\xfe\xff" ) $enc = "UTF-16BE"; |
| 722 | + elseif( substr( $chunk, 0, 2 ) == "\xff\xfe" ) $enc = "UTF-16LE"; |
706 | 723 | else $enc = NULL; |
707 | 724 | |
708 | | - if ($enc) $chunk = iconv($enc, "ASCII//IGNORE", $chunk); |
| 725 | + if( $enc ) $chunk = iconv( $enc, "ASCII//IGNORE", $chunk ); |
709 | 726 | |
710 | | - $chunk = trim($chunk); |
| 727 | + $chunk = trim( $chunk ); |
711 | 728 | |
712 | 729 | #FIXME: convert from UTF-16 if necessarry! |
713 | 730 | |
714 | | - wfDebug("SpecialSystemGiftManagerLogo::detectScript: checking for embedded scripts and HTML stuff\n"); |
| 731 | + wfDebug( __METHOD__ . ": checking for embedded scripts and HTML stuff\n"); |
715 | 732 | |
716 | 733 | #check for HTML doctype |
717 | | - if (eregi("<!DOCTYPE *X?HTML", $chunk)) return true; |
| 734 | + if( eregi( "<!DOCTYPE *X?HTML", $chunk ) ) return true; |
718 | 735 | |
719 | 736 | /** |
720 | 737 | * Internet Explorer for Windows performs some really stupid file type |
— | — | @@ -756,15 +773,15 @@ |
757 | 774 | $chunk = Sanitizer::decodeCharReferences( $chunk ); |
758 | 775 | |
759 | 776 | #look for script-types |
760 | | - if( preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk) ) return true; |
| 777 | + if( preg_match( "!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk ) ) return true; |
761 | 778 | |
762 | 779 | #look for html-style script-urls |
763 | | - if( preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true; |
| 780 | + if( preg_match( "!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk ) ) return true; |
764 | 781 | |
765 | 782 | #look for css-style script-urls |
766 | | - if( preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true; |
| 783 | + if( preg_match( "!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk ) ) return true; |
767 | 784 | |
768 | | - wfDebug("SpecialSystemGiftManagerLogo::detectScript: no scripts found\n"); |
| 785 | + wfDebug( __METHOD__ . ": no scripts found\n" ); |
769 | 786 | return false; |
770 | 787 | } |
771 | 788 | |
— | — | @@ -781,16 +798,13 @@ |
782 | 799 | function detectVirus( $file ) { |
783 | 800 | global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired; |
784 | 801 | |
785 | | - $fname = "SpecialSystemGiftManagerLogo::detectVirus"; |
786 | | - |
787 | 802 | if( !$wgAntivirus ) { #disabled? |
788 | | - wfDebug("$fname: virus scanner disabled\n"); |
789 | | - |
| 803 | + wfDebug( __METHOD__ . ": virus scanner disabled\n" ); |
790 | 804 | return NULL; |
791 | 805 | } |
792 | 806 | |
793 | 807 | if( !$wgAntivirusSetup[$wgAntivirus] ) { |
794 | | - wfDebug("$fname: unknown virus scanner: $wgAntivirus\n"); |
| 808 | + wfDebug( __METHOD__ . ": unknown virus scanner: $wgAntivirus\n" ); |
795 | 809 | |
796 | 810 | $wgOut->addHTML( '<div class="error">'. wfMsg( 'virus-badscanner', $wgAntivirus ) . "\n" ); |
797 | 811 | |
— | — | @@ -804,10 +818,10 @@ |
805 | 819 | |
806 | 820 | $scanner = $virus_scanner; #copy, so we can resolve the pattern |
807 | 821 | |
808 | | - if( strpos( $scanner, "%f" ) === false ) $scanner.= " ".wfEscapeShellArg($file); #simple pattern: append file to scan |
809 | | - else $scanner = str_replace( "%f", wfEscapeShellArg($file), $scanner ); #complex pattern: replace "%f" with file to scan |
| 822 | + if( strpos( $scanner, "%f" ) === false ) $scanner.= " ".wfEscapeShellArg( $file ); #simple pattern: append file to scan |
| 823 | + else $scanner = str_replace( "%f", wfEscapeShellArg( $file ), $scanner ); #complex pattern: replace "%f" with file to scan |
810 | 824 | |
811 | | - wfDebug("$fname: running virus scan: $scanner \n"); |
| 825 | + wfDebug( __METHOD__ . ": running virus scan: $scanner \n" ); |
812 | 826 | |
813 | 827 | #execute virus scanner |
814 | 828 | $code = false; |
— | — | @@ -826,19 +840,20 @@ |
827 | 841 | } |
828 | 842 | |
829 | 843 | if( $code === AV_SCAN_FAILED ) { #scan failed (code was mapped to false by $virus_scanner_codes) |
830 | | - wfDebug("$fname: failed to scan $file (code $exit_code).\n"); |
| 844 | + wfDebug( __METHOD__ . ": failed to scan $file (code $exit_code).\n" ); |
831 | 845 | |
832 | | - if ($wgAntivirusRequired) return wfMsg( 'virus-scanfailed', $exit_code ); |
| 846 | + if( $wgAntivirusRequired ) |
| 847 | + return wfMsg( 'virus-scanfailed', $exit_code ); |
833 | 848 | else return NULL; |
834 | | - } else if( $code === AV_SCAN_ABORTED ) { #scan failed because filetype is unknown (probably imune) |
835 | | - wfDebug("$fname: unsupported file type $file (code $exit_code).\n"); |
| 849 | + } else if( $code === AV_SCAN_ABORTED ) { #scan failed because filetype is unknown (probably immune) |
| 850 | + wfDebug( __METHOD__ . ": unsupported file type $file (code $exit_code).\n" ); |
836 | 851 | return NULL; |
837 | 852 | } else if( $code === AV_NO_VIRUS ) { |
838 | | - wfDebug("$fname: file passed virus scan.\n"); |
| 853 | + wfDebug( __METHOD__ . ": file passed virus scan.\n" ); |
839 | 854 | return false; #no virus found |
840 | 855 | } else { |
841 | | - $output = join("\n", $output); |
842 | | - $output = trim($output); |
| 856 | + $output = join( "\n", $output ); |
| 857 | + $output = trim( $output ); |
843 | 858 | |
844 | 859 | if( !$output ) $output = true; #if ther's no output, return true |
845 | 860 | else if( $msg_pattern ) { |
— | — | @@ -848,7 +863,7 @@ |
849 | 864 | } |
850 | 865 | } |
851 | 866 | |
852 | | - wfDebug("$fname: FOUND VIRUS! scanner feedback: $output"); |
| 867 | + wfDebug( __METHOD__ . ": FOUND VIRUS! scanner feedback: $output" ); |
853 | 868 | return $output; |
854 | 869 | } |
855 | 870 | } |