Add "longdesc" attribute to all (non-external) images, containing
[lhc/web/wiklou.git] / includes / EditPage.php
1 <?php
2 /**
3 * Contain the EditPage class
4 * @package MediaWiki
5 * @version $Id$
6 */
7
8 /**
9 * Splitting edit page/HTML interface from Article...
10 * The actual database and text munging is still in Article,
11 * but it should get easier to call those from alternate
12 * interfaces.
13 *
14 * @package MediaWiki
15 */
16
17 class EditPage {
18 var $mArticle;
19 var $mTitle;
20
21 # Form values
22 var $save = false, $preview = false;
23 var $minoredit = false, $watchthis = false;
24 var $textbox1 = '', $textbox2 = '', $summary = '';
25 var $edittime = '', $section = '';
26 var $oldid = 0;
27
28 /**
29 * @todo document
30 * @param $article
31 */
32 function EditPage( $article ) {
33 $this->mArticle =& $article;
34 global $wgTitle;
35 $this->mTitle =& $wgTitle;
36 }
37
38 /**
39 * This is the function that gets called for "action=edit".
40 */
41 function edit() {
42 global $wgOut, $wgUser, $wgWhitelistEdit, $wgRequest;
43 // this is not an article
44 $wgOut->setArticleFlag(false);
45
46 $this->importFormData( $wgRequest );
47
48 if ( ! $this->mTitle->userCanEdit() ) {
49 $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
50 return;
51 }
52 if ( $wgUser->isBlocked() ) {
53 $this->blockedIPpage();
54 return;
55 }
56 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
57 $this->userNotLoggedInPage();
58 return;
59 }
60 if ( wfReadOnly() ) {
61 if( $this->save || $this->preview ) {
62 $this->editForm( 'preview' );
63 } else {
64 $wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
65 }
66 return;
67 }
68 if ( $this->save ) {
69 $this->editForm( 'save' );
70 } else if ( $this->preview or $wgUser->getOption('previewonfirst')) {
71 $this->editForm( 'preview' );
72 } else { # First time through
73 $this->editForm( 'initial' );
74 }
75 }
76
77 /**
78 * @todo document
79 */
80 function importFormData( &$request ) {
81 # These fields need to be checked for encoding.
82 # Also remove trailing whitespace, but don't remove _initial_
83 # whitespace from the text boxes. This may be significant formatting.
84 $this->textbox1 = rtrim( $request->getText( 'wpTextbox1' ) );
85 $this->textbox2 = rtrim( $request->getText( 'wpTextbox2' ) );
86 $this->summary = trim( $request->getText( 'wpSummary' ) );
87
88 $this->edittime = $request->getVal( 'wpEdittime' );
89 if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = '';
90
91 $this->preview = $request->getCheck( 'wpPreview' );
92 $this->save = $request->wasPosted() && !$this->preview;
93 $this->minoredit = $request->getCheck( 'wpMinoredit' );
94 $this->watchthis = $request->getCheck( 'wpWatchthis' );
95
96 $this->oldid = $request->getInt( 'oldid' );
97
98 # Section edit can come from either the form or a link
99 $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
100 }
101
102 /**
103 * Since there is only one text field on the edit form,
104 * pressing <enter> will cause the form to be submitted, but
105 * the submit button value won't appear in the query, so we
106 * Fake it here before going back to edit(). This is kind of
107 * ugly, but it helps some old URLs to still work.
108 */
109 function submit() {
110 if( !$this->preview ) $this->save = true;
111
112 $this->edit();
113 }
114
115 /**
116 * The edit form is self-submitting, so that when things like
117 * preview and edit conflicts occur, we get the same form back
118 * with the extra stuff added. Only when the final submission
119 * is made and all is well do we actually save and redirect to
120 * the newly-edited page.
121 *
122 * @param string $formtype Type of form either : save, initial or preview
123 */
124 function editForm( $formtype ) {
125 global $wgOut, $wgUser;
126 global $wgLang, $wgContLang, $wgParser, $wgTitle;
127 global $wgAllowAnonymousMinor;
128 global $wgWhitelistEdit;
129 global $wgSpamRegex, $wgFilterCallback;
130 global $wgUseLatin1;
131
132 $sk = $wgUser->getSkin();
133 $isConflict = false;
134 // css / js subpages of user pages get a special treatment
135 $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
136
137 if(!$this->mTitle->getArticleID()) { # new article
138 $wgOut->addWikiText(wfmsg('newarticletext'));
139 }
140
141 if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) {
142 $wgOut->addWikiText(wfmsg('talkpagetext'));
143 }
144
145 # Attempt submission here. This will check for edit conflicts,
146 # and redundantly check for locked database, blocked IPs, etc.
147 # that edit() already checked just in case someone tries to sneak
148 # in the back door with a hand-edited submission URL.
149
150 if ( 'save' == $formtype ) {
151 # Check for spam
152 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
153 $this->spamPage ( $matches );
154 return;
155 }
156 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
157 # Error messages or other handling should be performed by the filter function
158 return;
159 }
160 if ( $wgUser->isBlocked() ) {
161 $this->blockedIPpage();
162 return;
163 }
164 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
165 $this->userNotLoggedInPage();
166 return;
167 }
168 if ( wfReadOnly() ) {
169 $wgOut->readOnlyPage();
170 return;
171 }
172
173 # If article is new, insert it.
174 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
175 if ( 0 == $aid ) {
176 # Don't save a new article if it's blank.
177 if ( ( '' == $this->textbox1 ) ||
178 ( wfMsg( 'newarticletext' ) == $this->textbox1 ) ) {
179 $wgOut->redirect( $this->mTitle->getFullURL() );
180 return;
181 }
182 $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, $this->minoredit, $this->watchthis );
183 return;
184 }
185
186 # Article exists. Check for edit conflict.
187
188 $this->mArticle->clear(); # Force reload of dates, etc.
189 $this->mArticle->forUpdate( true ); # Lock the article
190
191 if( ( $this->section != 'new' ) &&
192 ($this->mArticle->getTimestamp() != $this->edittime ) ) {
193 $isConflict = true;
194 }
195 $userid = $wgUser->getID();
196
197 if ( $isConflict) {
198 $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
199 $this->section, $this->textbox1, $this->summary, $this->edittime);
200 }
201 else {
202 $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
203 $this->section, $this->textbox1, $this->summary);
204 }
205 # Suppress edit conflict with self
206
207 if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
208 $isConflict = false;
209 } else {
210 # switch from section editing to normal editing in edit conflict
211 if($isConflict) {
212 # Attempt merge
213 if( $this->mergeChangesInto( $text ) ){
214 // Successful merge! Maybe we should tell the user the good news?
215 $isConflict = false;
216 } else {
217 $this->section = '';
218 $this->textbox1 = $text;
219 }
220 }
221 }
222 if ( ! $isConflict ) {
223 # All's well
224 $sectionanchor = '';
225 if( $this->section != '' ) {
226 # Try to get a section anchor from the section source, redirect to edited section if header found
227 # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
228 # for duplicate heading checking and maybe parsing
229 $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches );
230 # we can't deal with anchors, includes, html etc in the header for now,
231 # headline would need to be parsed to improve this
232 #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
233 if($hasmatch and strlen($matches[2]) > 0) {
234 global $wgInputEncoding;
235 $headline = do_html_entity_decode( $matches[2], ENT_COMPAT, $wgInputEncoding );
236 # strip out HTML
237 $headline = preg_replace( "/<.*?" . ">/","",$headline );
238 $headline = trim( $headline );
239 $sectionanchor = '#'.urlencode( str_replace(' ', '_', $headline ) );
240 $replacearray = array(
241 '%3A' => ':',
242 '%' => '.'
243 );
244 $sectionanchor = str_replace(array_keys($replacearray),array_values($replacearray),$sectionanchor);
245 }
246 }
247
248 # update the article here
249 if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, $this->watchthis, '', $sectionanchor ))
250 return;
251 else
252 $isConflict = true;
253 }
254 }
255 # First time through: get contents, set time for conflict
256 # checking, etc.
257
258 if ( 'initial' == $formtype ) {
259 $this->edittime = $this->mArticle->getTimestamp();
260 $this->textbox1 = $this->mArticle->getContent( true );
261 $this->summary = '';
262 $this->proxyCheck();
263 }
264 $wgOut->setRobotpolicy( 'noindex,nofollow' );
265
266 # Enabled article-related sidebar, toplinks, etc.
267 $wgOut->setArticleRelated( true );
268
269 if ( $isConflict ) {
270 $s = wfMsg( 'editconflict', $this->mTitle->getPrefixedText() );
271 $wgOut->setPageTitle( $s );
272 $wgOut->addHTML( wfMsg( 'explainconflict' ) );
273
274 $this->textbox2 = $this->textbox1;
275 $this->textbox1 = $this->mArticle->getContent( true );
276 $this->edittime = $this->mArticle->getTimestamp();
277 } else {
278 $s = wfMsg( 'editing', $this->mTitle->getPrefixedText() );
279
280 if( $this->section != '' ) {
281 if( $this->section == 'new' ) {
282 $s.=wfMsg('commentedit');
283 } else {
284 $s.=wfMsg('sectionedit');
285 }
286 if(!$this->preview) {
287 $sectitle=preg_match("/^=+(.*?)=+/mi",
288 $this->textbox1,
289 $matches);
290 if( !empty( $matches[1] ) ) {
291 $this->summary = "/* ". trim($matches[1])." */ ";
292 }
293 }
294 }
295 $wgOut->setPageTitle( $s );
296 if ( !$wgUseLatin1 && !$this->checkUnicodeCompliantBrowser() ) {
297 $this->mArticle->setOldSubtitle();
298 $wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );
299 }
300 if ( $this->oldid ) {
301 $this->mArticle->setOldSubtitle();
302 $wgOut->addHTML( wfMsg( 'editingold' ) );
303 }
304 }
305
306 if( wfReadOnly() ) {
307 $wgOut->addHTML( '<strong>' .
308 wfMsg( 'readonlywarning' ) .
309 "</strong>" );
310 } else if ( $isCssJsSubpage and 'preview' != $formtype) {
311 $wgOut->addHTML( wfMsg( 'usercssjsyoucanpreview' ));
312 }
313 if( $this->mTitle->isProtected() ) {
314 $wgOut->addHTML( '<strong>' . wfMsg( 'protectedpagewarning' ) .
315 "</strong><br />\n" );
316 }
317
318 $kblength = (int)(strlen( $this->textbox1 ) / 1024);
319 if( $kblength > 29 ) {
320 $wgOut->addHTML( '<strong>' .
321 wfMsg( 'longpagewarning', $wgLang->formatNum( $kblength ) )
322 . '</strong>' );
323 }
324
325 $rows = $wgUser->getOption( 'rows' );
326 $cols = $wgUser->getOption( 'cols' );
327
328 $ew = $wgUser->getOption( 'editwidth' );
329 if ( $ew ) $ew = " style=\"width:100%\"";
330 else $ew = '';
331
332 $q = 'action=submit';
333 #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
334 $action = $this->mTitle->escapeLocalURL( $q );
335
336 $summary = wfMsg('summary');
337 $subject = wfMsg('subject');
338 $minor = wfMsg('minoredit');
339 $watchthis = wfMsg ('watchthis');
340 $save = wfMsg('savearticle');
341 $prev = wfMsg('showpreview');
342
343 $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(),
344 wfMsg('cancel') );
345 $edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
346 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
347 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
348 htmlspecialchars( wfMsg( 'newwindow' ) );
349
350 global $wgRightsText;
351 $copywarn = "<div id=\"editpage-copywarn\">\n" .
352 wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2',
353 '[[' . wfMsg( 'copyrightpage' ) . ']]',
354 $wgRightsText ) . "\n</div>";
355
356 if( $wgUser->getOption('showtoolbar') and !$isCssJsSubpage ) {
357 # prepare toolbar for edit buttons
358 $toolbar = $sk->getEditToolbar();
359 } else {
360 $toolbar = '';
361 }
362
363 // activate checkboxes if user wants them to be always active
364 if( !$this->preview ) {
365 if( $wgUser->getOption( 'watchdefault' ) ) $this->watchthis = true;
366 if( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
367
368 // activate checkbox also if user is already watching the page,
369 // require wpWatchthis to be unset so that second condition is not
370 // checked unnecessarily
371 if( !$this->watchthis && $this->mTitle->userIsWatching() ) $this->watchthis = true;
372 }
373
374 $minoredithtml = '';
375
376 if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) {
377 $minoredithtml =
378 "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?" checked='checked'":"").
379 " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />".
380 "<label for='wpMinoredit' title='".wfMsg('tooltip-minoredit')."'>{$minor}</label>";
381 }
382
383 $watchhtml = '';
384
385 if ( 0 != $wgUser->getID() ) {
386 $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?" checked='checked'":"").
387 " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis' />".
388 "<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
389 }
390
391 $checkboxhtml = $minoredithtml . $watchhtml . '<br />';
392
393 if ( 'preview' == $formtype) {
394 $previewhead='<h2>' . wfMsg( 'preview' ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
395 wfMsg( 'note' ) . wfMsg( 'previewnote' ) . "</font></center></p>\n";
396 if ( $isConflict ) {
397 $previewhead.='<h2>' . wfMsg( 'previewconflict' ) .
398 "</h2>\n";
399 }
400
401 $parserOptions = ParserOptions::newFromUser( $wgUser );
402 $parserOptions->setEditSection( false );
403 $parserOptions->setEditSectionOnRightClick( false );
404
405 # don't parse user css/js, show message about preview
406 # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
407
408 if ( $isCssJsSubpage ) {
409 if(preg_match("/\\.css$/", $wgTitle->getText() ) ) {
410 $previewtext = wfMsg('usercsspreview');
411 } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) {
412 $previewtext = wfMsg('userjspreview');
413 }
414 $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
415 $wgOut->addHTML( $parserOutput->mText );
416 } else {
417 # if user want to see preview when he edit an article
418 if( $wgUser->getOption('previewonfirst') and ($this->textbox1 == '')) {
419 $this->textbox1 = $this->mArticle->getContent(true);
420 }
421
422 $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $this->textbox1 ) ."\n\n",
423 $wgTitle, $parserOptions );
424
425 $previewHTML = $parserOutput->mText;
426
427 if($wgUser->getOption('previewontop')) {
428 $wgOut->addHTML($previewhead);
429 $wgOut->addHTML($previewHTML);
430 }
431 $wgOut->addCategoryLinks($parserOutput->getCategoryLinks());
432 $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
433 $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
434 }
435 }
436
437 # if this is a comment, show a subject line at the top, which is also the edit summary.
438 # Otherwise, show a summary field at the bottom
439 $summarytext = htmlspecialchars( $wgContLang->recodeForEdit( $this->summary ) ); # FIXME
440 if( $this->section == 'new' ) {
441 $commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
442 $editsummary = '';
443 } else {
444 $commentsubject = '';
445 $editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
446 }
447
448 if( !$this->preview ) {
449 # Don't select the edit box on preview; this interferes with seeing what's going on.
450 $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
451 }
452 # Prepare a list of templates used by this page
453 $db =& wfGetDB( DB_SLAVE );
454 $cur = $db->tableName( 'cur' );
455 $links = $db->tableName( 'links' );
456 $id = $this->mTitle->getArticleID();
457 $sql = "SELECT cur_namespace,cur_title,cur_id ".
458 "FROM $cur,$links WHERE l_to=cur_id AND l_from={$id} and cur_namespace=".NS_TEMPLATE;
459 $res = $db->query( $sql, "EditPage::editform" );
460
461 if ( $db->numRows( $res ) ) {
462 $templates = '<br />'. wfMsg( 'templatesused' ) . '<ul>';
463 while ( $row = $db->fetchObject( $res ) ) {
464 if ( $titleObj = Title::makeTitle( $row->cur_namespace, $row->cur_title ) ) {
465 $templates .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
466 }
467 }
468 $templates .= '</ul>';
469 } else {
470 $templates = '';
471 }
472 $wgOut->addHTML( "
473 {$toolbar}
474 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
475 enctype=\"application/x-www-form-urlencoded\">
476 {$commentsubject}
477 <textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
478 cols='{$cols}'{$ew}>" .
479 htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
480 "
481 </textarea>
482 <br />{$editsummary}
483 {$checkboxhtml}
484 <input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
485 " title=\"".wfMsg('tooltip-save')."\"/>
486 <input tabindex='6' id='wpPreview' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
487 " title=\"".wfMsg('tooltip-preview')."\"/>
488 <em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}" );
489 $wgOut->addWikiText( $copywarn );
490 $wgOut->addHTML( "
491 <input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" />
492 <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n" );
493
494 if ( $isConflict ) {
495 require_once( "DifferenceEngine.php" );
496 $wgOut->addHTML( "<h2>" . wfMsg( "yourdiff" ) . "</h2>\n" );
497 DifferenceEngine::showDiff( $this->textbox2, $this->textbox1,
498 wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
499
500 $wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
501 <textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
502 . htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox2 ) ) .
503 "
504 </textarea>" );
505 }
506 $wgOut->addHTML( "</form>\n" );
507 if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
508 $wgOut->addHTML($previewhead);
509 $wgOut->addHTML($previewHTML);
510 }
511 }
512
513 /**
514 * @todo document
515 */
516 function blockedIPpage() {
517 global $wgOut, $wgUser, $wgContLang, $wgIP;
518
519 $wgOut->setPageTitle( wfMsg( 'blockedtitle' ) );
520 $wgOut->setRobotpolicy( 'noindex,nofollow' );
521 $wgOut->setArticleRelated( false );
522
523 $id = $wgUser->blockedBy();
524 $reason = $wgUser->blockedFor();
525 $ip = $wgIP;
526
527 if ( is_numeric( $id ) ) {
528 $name = User::whoIs( $id );
529 } else {
530 $name = $id;
531 }
532 $link = '[[' . $wgContLang->getNsText( Namespace::getUser() ) .
533 ":{$name}|{$name}]]";
534
535 $wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
536 $wgOut->returnToMain( false );
537 }
538
539 /**
540 * @todo document
541 */
542 function userNotLoggedInPage() {
543 global $wgOut, $wgUser;
544
545 $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
546 $wgOut->setRobotpolicy( 'noindex,nofollow' );
547 $wgOut->setArticleRelated( false );
548
549 $wgOut->addWikiText( wfMsg( 'whitelistedittext' ) );
550 $wgOut->returnToMain( false );
551 }
552
553 /**
554 * @todo document
555 */
556 function spamPage ( $matches = array() )
557 {
558 global $wgOut;
559 $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
560 $wgOut->setRobotpolicy( 'noindex,nofollow' );
561 $wgOut->setArticleRelated( false );
562
563 $wgOut->addWikiText( wfMsg( 'spamprotectiontext' ) );
564 if ( isset ( $matches[0] ) ) {
565 $wgOut->addWikiText( wfMsg( 'spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>" ) );
566 }
567 $wgOut->returnToMain( false );
568 }
569
570 /**
571 * Forks processes to scan the originating IP for an open proxy server
572 * MemCached can be used to skip IPs that have already been scanned
573 */
574 function proxyCheck() {
575 global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
576 global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
577
578 if ( !$wgBlockOpenProxies ) {
579 return;
580 }
581
582 # Get MemCached key
583 $skip = false;
584 if ( $wgUseMemCached ) {
585 $mcKey = $wgDBname.':proxy:ip:'.$wgIP;
586 $mcValue = $wgMemc->get( $mcKey );
587 if ( $mcValue ) {
588 $skip = true;
589 }
590 }
591
592 # Fork the processes
593 if ( !$skip ) {
594 $title = Title::makeTitle( NS_SPECIAL, 'Blockme' );
595 $iphash = md5( $wgIP . $wgProxyKey );
596 $url = $title->getFullURL( 'ip='.$iphash );
597
598 foreach ( $wgProxyPorts as $port ) {
599 $params = implode( ' ', array(
600 escapeshellarg( $wgProxyScriptPath ),
601 escapeshellarg( $wgIP ),
602 escapeshellarg( $port ),
603 escapeshellarg( $url )
604 ));
605 exec( "php $params &>/dev/null &" );
606 }
607 # Set MemCached key
608 if ( $wgUseMemCached ) {
609 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
610 }
611 }
612 }
613
614 /**
615 * @access private
616 * @todo document
617 */
618 function mergeChangesInto( &$text ){
619 $fname = 'EditPage::mergeChangesInto';
620 $oldDate = $this->edittime;
621 $dbw =& wfGetDB( DB_MASTER );
622 $obj = $dbw->getArray( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle->getArticleID() ),
623 $fname, 'FOR UPDATE' );
624
625 $yourtext = $obj->cur_text;
626 $ns = $this->mTitle->getNamespace();
627 $title = $this->mTitle->getDBkey();
628 $obj = $dbw->getArray( 'old',
629 array( 'old_text','old_flags'),
630 array( 'old_namespace' => $ns, 'old_title' => $title,
631 'old_timestamp' => $dbw->timestamp($oldDate)),
632 $fname );
633 $oldText = Article::getRevisionText( $obj );
634
635 if(wfMerge($oldText, $text, $yourtext, $result)){
636 $text = $result;
637 return true;
638 } else {
639 return false;
640 }
641 }
642
643
644 function checkUnicodeCompliantBrowser() {
645 global $wgBrowserBlackList;
646 $currentbrowser = $_SERVER["HTTP_USER_AGENT"];
647 foreach ( $wgBrowserBlackList as $browser ) {
648 if ( preg_match($browser, $currentbrowser) ) {
649 return false;
650 }
651 }
652 return true;
653 }
654
655 }
656
657 ?>