r76 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75‎ | r76 | r77 >
Date:21:28, 6 February 2002
Author:magnus_manske
Status:old
Tags:
Comment:
*** empty log message ***
Modified paths:
  • /trunk/phpwiki/fpw/specialPages.php (modified) (history)
  • /trunk/phpwiki/fpw/special_dohistory.php (added) (history)
  • /trunk/phpwiki/fpw/special_dosearch.php (added) (history)
  • /trunk/phpwiki/fpw/special_shortpages.php (added) (history)
  • /trunk/phpwiki/fpw/special_upload.php (added) (history)
  • /trunk/phpwiki/fpw/wikiTextEn.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/fpw/wikiTextEn.php
@@ -292,7 +292,7 @@
293293 $wikiUploadText .= "<li>You can upload as many files you like. Please don't try to crash our server, ha ha.</li>\n";
294294 $wikiUploadText .= "<li>All uploads and deletions are logged in the <a href=\"$THESCRIPT?title=Log:Uploads\">uploads log</a>.</li>\n";
295295 $wikiUploadText .= "</ul>\n";
296 -$wikiUploadAffirmText = "I hereby affirm that this file is <b>not copyrighted</b>, or that I own the copyright for this file and donate it to Wikipedia." ;
 296+$wikiUploadAffirmText = "I hereby affirm that this file is <b>not copyrighted</b>, or that I own the copyright for this file and place it under GPL licence." ;
297297 $wikiUploadButton = "Upload" ;
298298 $wikiUploadPrev = "Previously-uploaded files:" ;
299299 $wikiUploadSize = "Size (byte)" ;
Index: trunk/phpwiki/fpw/specialPages.php
@@ -27,6 +27,10 @@
2828 include_once ( "special_newpages.php" ) ;
2929 include_once ( "special_watchlist.php" ) ;
3030 include_once ( "special_statistics.php" ) ;
 31+include_once ( "special_shortpages.php" ) ;
 32+include_once ( "special_dohistory.php" ) ;
 33+include_once ( "special_upload.php" ) ;
 34+include_once ( "special_dosearch.php" ) ;
3135
3236 function userLogout () {
3337 global $user , $vpage ;
@@ -147,147 +151,7 @@
148152 return $ret ;
149153 }
150154
151 -function searchLineDisplay ( $v ) {
152 - global $search ;
153 - $v = trim(str_replace("\n","",$v)) ;
154 - $v = str_replace ( "'''" , "" , $v ) ;
155 - $v = str_replace ( "''" , "" , $v ) ;
156 - $v = ereg_replace ( "\{\{\{.*\}\}\}" , "?" , $v ) ;
157 - $v = trim ( $v ) ;
158 - while ( substr($v,0,1) == ":" ) $v = substr($v,1) ;
159 - while ( substr($v,0,1) == "*" ) $v = substr($v,1) ;
160 - while ( substr($v,0,1) == "#" ) $v = substr($v,1) ;
161 - $v = eregi_replace ( $search , "'''".$search."'''" , $v ) ;
162 - $v = "<font size=-1>$v</font>" ;
163 - return $v ;
164 - }
165155
166 -function doSearch () {
167 - global $THESCRIPT ;
168 - global $vpage , $search , $startat , $user ;
169 - global $wikiSearchTitle , $wikiSearchedVoid , $wikiNoSearchResult ;
170 - $vpage = new WikiPage ;
171 - $vpage->special ( $wikiSearchTitle ) ;
172 - $r = array () ;
173 - $s = "" ;
174 -
175 - if ( $search == "" ) $s = $wikiSearchedVoid ;
176 - else {
177 - $search = wikiRecodeInput ( $search ) ;
178 - if ( !isset ( $startat ) ) $startat = 1 ;
179 - $perpage = $user->options["resultsPerPage"] ;
180 - global $wikiSQLServer ;
181 - $connection = getDBconnection () ;
182 - mysql_select_db ( $wikiSQLServer , $connection ) ;
183 -
184 -/*
185 - # Old search algorithm
186 - $sql = "SELECT * FROM cur WHERE cur_title LIKE \"%$search%\" OR cur_text LIKE \"%$search%\" ORDER BY cur_title" ;
187 -*/
188 -
189 - # New search algorithm
190 - $totalcnt = 0 ;
191 - $s2 = str_replace ( "_" , " " , $search ) ;
192 - $s2 = ereg_replace ( "[^A-Za-z0-9 ]" , "" , $s2 ) ;
193 - $s2 = str_replace ( " " , " " , $s2 ) ;
194 - $s2 = explode ( " " , $s2 ) ;
195 -
196 - $exclude = "cur_title NOT LIKE \"%alk:%\"" ;
197 - if ( $exclude != "" ) $exclude = "($exclude) AND " ;
198 -
199 - # Phase 1
200 - $s3 = array () ;
201 - foreach ( $s2 as $x ) {
202 - $s4 = "(cur_title LIKE \"%".strtolower(substr($x,0,1)).substr($x,1)."%\" OR cur_title LIKE \"%".ucfirst($x)."%\")" ;
203 - array_push ( $s3 , $s4 ) ;
204 - }
205 - $s3 = implode ( " AND " , $s3 ) ;
206 - $sql = "SELECT * FROM cur WHERE $exclude( $s3 ) ORDER BY cur_title" ;
207 - $result = mysql_query ( $sql , $connection ) ;
208 - if ( $result != "" ) {
209 - while ( $s = mysql_fetch_object ( $result ) ) {
210 - if ( $totalcnt+1 >= $startat and count ( $r ) < $perpage )
211 - array_push ( $r , $s ) ;
212 - $totalcnt++ ;
213 - }
214 - mysql_free_result ( $result ) ;
215 - }
216 -
217 - # Phase 2
218 - $s3 = implode ( "%\" AND cur_text LIKE \"%" , $s2 ) ;
219 - $sql = "SELECT * FROM cur WHERE $exclude(cur_text LIKE \"%$s3%\" ) ORDER BY cur_title" ;
220 - $result = mysql_query ( $sql , $connection ) ;
221 - if ( $result != "" ) {
222 - while ( $s = mysql_fetch_object ( $result ) ) {
223 - if ( $totalcnt+1 >= $startat and count ( $r ) < $perpage )
224 - array_push ( $r , $s ) ;
225 - $totalcnt++ ;
226 - }
227 - mysql_free_result ( $result ) ;
228 - }
229 -
230 -
231 - #mysql_close ( $connection ) ;
232 - }
233 -
234 - if ( $s == "" and count ( $r ) == 0 ) {
235 - global $wikiUnsuccessfulSearch , $wikiUnsuccessfulSearches ;
236 - $s = "<h2>".str_replace("$1",$search,$wikiNoSearchResult)."</h2>" ;
237 - # Appending log page "wikpedia:Unsuccessful searches"
238 - $now = date ( "Y-m" , time() ) ;
239 - $logText = "*[[$search]]\n" ;
240 - makeLog ( str_replace ( "$1" , $now , $wikiUnsuccessfulSearches ) , $logText , str_replace ( "$1" , $search , $wikiUnsuccessfulSearch ) ) ;
241 -
242 - } else if ( $s == "" ) {
243 - global $wikiFoundHeading , $wikiFoundText ;
244 - $n = count ( $r ) ;
245 - $s .= "<table width=\"100%\" bgcolor=\"#FFFFCC\"><tr><td><font size=\"+1\"><b>$wikiFoundHeading</b></font><br>\n" ;
246 - $n = str_replace ( "$1" , $totalcnt , $wikiFoundText ) ;
247 - $n = str_replace ( "$2" , $search , $n ) ;
248 - $s .= "$n</td></tr></table>\n" ;
249 - $s .= "<table>" ;
250 - $realcnt = $startat ;
251 - $minlen = strlen ( $realcnt + count ( $r ) ) ;
252 - foreach ( $r as $x ) {
253 - $u = spliti ( "\n" , $x->cur_text ) ;
254 - $u = spliti ( "--" , $u[0] ) ;
255 - $y = searchLineDisplay ( array_shift ( $u ) ) ;
256 - foreach ( $u as $v ) {
257 - if ( stristr($v,$search) != false ) {
258 - $y .= "...<br>...".searchLineDisplay($v) ;
259 - break ;
260 - }
261 - }
262 -
263 - for ( $z = $realcnt ; strlen ( $z ) < $minlen ; $z = "0$z" ) ;
264 - $ct = $vpage->getNiceTitle ( $x->cur_title ) ;
265 - $s .= "<tr><td valign=top width=20 align=right><b>$z</b></td><td><font face=\"Helvetica,Arial\">'''[[$ct]]'''</font><br>" ;
266 - $s .= $y ;
267 - $s .= "</td></tr>" ;
268 - $realcnt++ ;
269 - }
270 - $s .= "</table>" ;
271 - if ( $totalcnt > $perpage ) {
272 - $s .= "<nowiki>" ;
273 - $last = $startat-$perpage ;
274 - $next = $startat+$perpage ;
275 - if ( $startat != 1 ) $s .= "<a href=\"".wikiLink("&search=$search&startat=$last")."\">&lt;&lt;</a> | ";
276 - for ( $a = 1 ; $a <= $totalcnt ; $a += $perpage ) {
277 - if ( $a != 1 ) $s .= " | " ;
278 - if ( $a != $startat ) $s .= "<a href=\"".wikiLink("&search=$search&startat=$a")."\">";
279 - $s .= "$a-" ;
280 - $s .= $a+$perpage-1 ;
281 - if ( $a != $startat ) $s .= "</a>" ;
282 - }
283 - if ( $startat != $a-$perpage ) $s .= " | <a href=\"".wikiLink("&search=$search&startat=".$next)."\">&gt;&gt;</a>";
284 - $s .= "</nowiki>" ;
285 - }
286 - }
287 -
288 - $vpage->contents = $s ;
289 - return $vpage->renderPage () ;
290 - }
291 -
292156 function listUsers () {
293157 global $user , $vpage , $startat ;
294158 if ( !isset ( $startat ) ) $startat = 1 ;
@@ -343,166 +207,8 @@
344208
345209
346210
347 -function upload () {
348 - global $THESCRIPT ;
349 - global $removeFile , $xtitle , $removeFile , $Upload , $Upload_name , $no_copyright ;
350 - global $user , $vpage , $wikiUploadTitle , $wikiUploadText , $wikiUploadDenied ;
351 - global $wikiUploadDeleted , $wikiUploadDelMsg1 , $wikiUploadDelMsg2 ;
352 - global $wikiUploadAffirm , $wikiUploadFull ;
353 - global $wikiUploadSuccess , $wikiUploadSuccess1 , $wikiUploadSuccess2 ;
354 - global $wikiUploadAffirmText , $wikiUploadButton ;
355 - $vpage->special ( $wikiUploadTitle ) ;
356 - $isSysop = in_array ( "is_sysop" , $user->rights ) ;
357 - $xtitle = $wikiUploadPage ;
358 - $ret = "<nowiki>" ;
359211
360 - $message = "" ;
361212
362 - if (isset($removeFile)) {
363 - if ( !$isSysop ) return $wikiUploadDenied ;
364 - if (is_file("./upload/$removeFile") ) unlink ("./upload/$removeFile");
365 - $message = str_replace ( "$1" , $removeFile , $wikiUploadDeleted ) ;
366 -
367 - # Appending log page "log:Uploads"
368 - $now = date ( "Y-m-d H:i:s" , time () ) ;
369 - $logText = str_replace ( "$1" , $user->name , str_replace ( "$2" , $removeFile , $wikiUploadDelMsg1 ) ) ;
370 - makeLog ( "log:Uploads" , $logText , str_replace ( "$1" , $removeFile , $wikiUploadDelMsg2 ) ) ;
371 -
372 - unset ( $removeFile ) ;
373 - } else if (isset($Upload_name) or isset($Upload)) {
374 - if ( $no_copyright != "AFFIRMED" ) return $wikiUploadAffirm ;
375 -# $Upload_name = ereg_replace(" ", "_", $Upload_name);
376 - $abc = split("\.", $Upload_name);
377 -
378 - $num = exec ("df");
379 - $readata = substr($num,(strpos($num, "%")-2),2);
380 -
381 - if ($readata > 96) {
382 - $ret .= "<body bgcolor=white>\n";
383 - $ret .= "<br><b>$wikiUploadFull</b>\n";
384 - return $ret ;
385 - }
386 -
387 - copy ( $Upload , "./upload/$Upload_name" ) ;
388 - chmod ( "./upload/$Upload_name" , 0777 ) ;
389 - $message = str_replace ( "$1" , htmlspecialchars ( $Upload_name ) , $wikiUploadSuccess ) ;
390 -
391 - # Appending log page "log:Uploads"
392 - global $REMODE_ADDR ;
393 - $now = date ( "Y-m-d H:i:s" , time () ) ;
394 - $userText = "[[user:$user->name|$user->name]]" ;
395 - if ( $user->name == "" ) $userText = $REMODE_ADDR ;
396 - $logText = str_replace ( "$1" , $now , str_replace ( "$2" , $userText , str_replace ( "$3" , htmlspecialchars ( $Upload_name ) , $wikiUploadSuccess1 ) ) ) ;
397 - makeLog ( "log:Uploads" , $logText , str_replace ( "$1" , $Upload_name , $wikiUploadSuccess2 ) ) ;
398 -
399 - unset ( $Upload_name ) ;
400 - }
401 -
402 - if ( $message != "" ) $ret .= "<font color=red>$message</font><br>\n" ;
403 - $ret .= $wikiUploadText ;
404 - $ret .= " <form enctype=\"multipart/form-data\" action=\"".wikiLink("special:upload")."\" method=post>\n";
405 - $ret .= " <input type=hidden name=max value=20096>\n";
406 - $ret .= " <input name=Upload type=\"file\"><br>\n";
407 - $ret .= " <input type=hidden name=update value=1>\n";
408 - $ret .= " <input type=hidden name=step value=$step>\n";
409 - $ret .= "<INPUT TYPE=checkbox NAME=\"no_copyright\" VALUE=\"AFFIRMED\">$wikiUploadAffirmText<br>\n" ;
410 - $ret .= " <input type=submit name=Upload value=$wikiUploadButton>\n";
411 - $ret .= "</form>\n";
412 -
413 - global $wikiUploadPrev , $wikiUploadSize , $wikiFileRemoval , $wikiUploadRemove, $THESCRIPT ;
414 -
415 - if (is_dir("upload")) {
416 - $mydir = dir("upload");
417 - while ($entry = $mydir->read()) {
418 - if ($entry != "." and $entry != "..")
419 - $file = "yes";
420 - }
421 - $mydir->close();
422 - $uploaddir = ereg_replace("[A-Za-z0-9_.]+$", "upload", $THESCRIPT);
423 -
424 - if ($file == "yes") {
425 - $ret .= "<h2>$wikiUploadPrev</h2>";
426 - $mydir = opendir("upload");
427 - $i = 0;
428 - $ret .= "<table border=1 width=\"100%\">\n";
429 - $ret .= "<tr><th>File</th><th>$wikiUploadSize</th>";
430 - if ( $isSysop )
431 - $ret .= "<th>$wikiFileRemoval</th>";
432 - $ret .= "</tr>\n" ;
433 - while ($entry = readdir($mydir)) {
434 - if ($entry != '.' && $entry != '..') {
435 - $ret .= "<tr><td align=center>" ;
436 - $ret .= "<a href=\"$uploaddir/".rawurlencode($entry)."\">".htmlspecialchars($entry)."</a></td>";
437 - $ret .= "<td align=center>".filesize("upload/$entry")." bytes</td>";
438 - if ( $isSysop ) {
439 - $ret .= "<td align=center><a href=\"".wikiLink("special:upload&removeFile=".urlencode($entry))."\">" ;
440 - $ret .= str_replace ( "$1" , $entry , $wikiUploadRemove ) ;
441 - $ret .= "</a></td>" ;
442 - }
443 - $ret .= "</tr>" ;
444 - $i++;
445 - }
446 - }
447 - $ret .= "</table>\n";
448 - closedir($mydir);
449 - }
450 - }
451 - $ret .= "</nowiki>" ;
452 - return $ret ;
453 - }
454 -
455 -function doHistory ( $title ) {
456 - global $THESCRIPT , $vpage , $wikiSQLServer , $wikiHistoryTitle , $wikiCurrentVersion , $wikiHistoryHeader ;
457 - $vpage = new WikiPage ;
458 - $vpage->SetTitle ( $title ) ;
459 - $ti = $vpage->secureTitle ;
460 - $url = $vpage->url;
461 - $vpage->special ( str_replace ( "$1" , $title , $wikiHistoryTitle ) ) ;
462 - $vpage->makeSecureTitle () ;
463 -
464 - $a = array () ;
465 - $connection = getDBconnection () ;
466 - mysql_select_db ( $wikiSQLServer , $connection ) ;
467 - $sql = "SELECT * FROM cur WHERE cur_title=\"$ti\"" ;
468 - $result = mysql_query ( $sql , $connection ) ;
469 - $s = mysql_fetch_object ( $result ) ;
470 - array_push ( $a , $s ) ;
471 - mysql_free_result ( $result ) ;
472 - $o = $s->cur_old_version ;
473 - while ( $o != 0 ) {
474 - $sql = "SELECT * FROM old WHERE old_id=$o" ;
475 - $result = mysql_query ( $sql , $connection ) ;
476 - $s = mysql_fetch_object ( $result ) ;
477 -# print "<font color=red>$s->old_timestamp:</font> ".$s->old_text."<br>" ;
478 - $s->cur_timestamp = $s->old_timestamp ;
479 - $s->cur_title = $s->old_title ;
480 - $s->cur_user = $s->old_user ;
481 - $s->cur_comment = $s->old_comment ;
482 - $s->cur_user_text = $s->old_user_text ;
483 - $s->cur_minor_edit = $s->old_minor_edit ;
484 - array_push ( $a , $s ) ;
485 - $o = $s->old_old_version ;
486 - mysql_free_result ( $result ) ;
487 - }
488 - #mysql_close ( $connection ) ;
489 -
490 - $i = count ( $a ) ;
491 - $k = array_keys ( $a ) ;
492 - foreach ( $k as $x ) {
493 - if ( $i != count ( $a ) ) $a[$x]->version = $i ;
494 - else $a[$x]->version = $wikiCurrentVersion ;
495 - $i-- ;
496 - }
497 -
498 - $t = recentChangesLayout ( $a ) ;
499 - $t = "<b>".str_replace(array("$1","$2"),array($url,$title),$wikiHistoryHeader)."</b>".$t ;
500 -
501 - $ret = $vpage->getHeader() ;
502 - $ret .= $vpage->getMiddle($t) ;
503 - $ret .= $vpage->getFooter() ;
504 - return $ret ;
505 - }
506 -
507213 function special_pages () {
508214 global $THESCRIPT , $vpage , $user , $wikiSpecialTitle , $wikiSpecialText ;
509215 $vpage->special ( $wikiSpecialTitle ) ;
@@ -525,83 +231,7 @@
526232 return $a ;
527233 }
528234
529 -function ShortPages () {
530 - global $THESCRIPT , $wikiSQLServer , $user , $vpage , $startat , $wikiStubTitle , $wikiStubText , $showLinksThere , $wikiStubShowLinks ;
531 - if ( !isset ( $startat ) ) $startat = 1 ;
532 - $perpage = $user->options["resultsPerPage"] ;
533 - if ( $perpage == 0 ) $perpage = 20 ;
534 - $vpage->special ( $wikiStubTitle ) ;
535 - $vpage->namespace = "" ;
536 - if ( $showLinksThere == "" ) $showLinksThere = 0 ;
537 - if ( $showLinksThere == 1 ) $sLT2 = 0 ;
538 - else $sLT2 = 1 ;
539 - $ret = $wikiStubText ;
540 - $ret .= str_replace ( "$1" , $sLT2 , $wikiStubShowLinks ) ;
541 - $connection = getDBconnection () ;
542 - mysql_select_db ( $wikiSQLServer , $connection ) ;
543 - $sql = "SELECT COUNT(*) AS number FROM cur WHERE cur_title NOT LIKE \"%:%\" AND cur_text NOT LIKE \"#redirect%\"" ;
544 - $result = mysql_query ( $sql , $connection ) ;
545 - $s = mysql_fetch_object ( $result ) ;
546 - $total = $s->number ;
547 - $sql = "SELECT cur_title,LENGTH(cur_text) AS len FROM cur WHERE cur_title NOT LIKE \"%:%\" AND cur_text NOT LIKE \"#redirect%\" ORDER BY LENGTH(cur_text),cur_title" ;
548 - $result = mysql_query ( $sql , $connection ) ;
549 - $cnt = 1 ;
550 - $color1 = $user->options["tabLine1"] ;
551 - $color2 = $user->options["tabLine2"] ;
552 - $color = $color1 ;
553 - $ret .= "<table width=\"100%\">\n" ;
554 - $ar = array () ;
555 - while ( $s = mysql_fetch_object ( $result ) and $cnt < $startat+$perpage ) {
556 - if ( $cnt >= $startat ) {
557 - $s->cnt = $cnt ;
558 - array_push ( $ar , $s ) ;
559 - }
560 - $cnt++ ;
561 - }
562 - mysql_free_result ( $result ) ;
563235
564 - global $wikiStubChars , $wikiStubDelete , $wikiStubLinkHere ;
565 -
566 - foreach ( $ar as $s ) {
567 - $k = new wikiTitle ;
568 - $k->setTitle ( $s->cur_title ) ;
569 - $ret .= "<tr><td$color align=right valign=top nowrap>$s->cnt</td>" ;
570 - $ret .= "<td$color align=right valign=top nowrap>(".str_replace("$1",$s->len,$wikiStubChars).")</td>\n" ;
571 - $ret .= "<td$color nowrap valign=top>[[$s->cur_title|".$k->getNiceTitle()."]]</td>\n";
572 - if ( in_array ( "is_sysop" , $user->rights ) )
573 - $ret .= "<td$color valign=top nowrap><nowiki><a href=\"".wikiLink("special:deletepage&target=$k->url")."\">$wikiStubDelete</a></nowiki></td>" ;
574 - else $ret .= "<td$color width=\"100%\" nowrap>&nbsp;</td>" ;
575 -
576 - if ( $showLinksThere == 1 ) {
577 - $lf = "" ;
578 - $lh = pagesThatLinkHere($s->cur_title,$connection);
579 - if ( count ( $lh ) <= 5 and count ( $lh ) > 0 ) {
580 - foreach ( $lh as $ll ) {
581 - if ( $lf == "" ) $lf = " <font size=-1>(" ;
582 - else $lf .= " - " ;
583 - $lf .= "[[$ll->cur_title]]" ;
584 - }
585 - $lf .= ")</font>" ;
586 - }
587 - $ret .= "<td$color width=\"100%\" valign=top>".str_replace("$1",count($lh),$wikiStubLinkHere)."$lf</td>\n";
588 - } else $ret .= "<td$color valign=top><nowiki><a href=\"".wikiLink("special:whatlinkshere&target=$k->url")."\">Show pages that link to \"".$k->getNiceTitle()."\"</a></nowiki></td>\n" ;
589 -
590 - $ret .= "</tr>" ;
591 - if ( $color == $color1 ) $color = $color2 ;
592 - else $color = $color1 ;
593 - }
594 - $ret .= "</table>\n" ;
595 -
596 - $ret .= "<nowiki>" ;
597 - $before = $startat - $perpage ; $fin = $before + $perpage - 1 ;
598 - if ( $startat > 1 ) $ret .= "<a href=\"".wikiLink("special:ShortPages&startat=$before&showLinksThere=$showLinksThere")."\">$before-$fin&lt;&lt;</a> &nbsp;";
599 - $after = $startat + $perpage ; $fin = $after+$perpage - 1 ; if ( $fin > $total ) $fin = $total ;
600 - if ( $after-1 < $total ) $ret .= "<a href=\"".wikiLink("special:ShortPages&startat=$after&showLinksThere=$showLinksThere")."\">&gt;&gt;$after-$fin</a>" ;
601 - $ret .= "</nowiki>" ;
602 - #mysql_close ( $connection ) ;
603 - return $ret ;
604 - }
605 -
606236 function removeFromLinkList ( $item , $link ) {
607237 global $wikiSQLServer ;
608238 $connection = getDBconnection () ;
Index: trunk/phpwiki/fpw/special_shortpages.php
@@ -0,0 +1,78 @@
 2+<?
 3+function ShortPages () {
 4+ global $THESCRIPT , $wikiSQLServer , $user , $vpage , $startat , $wikiStubTitle , $wikiStubText , $showLinksThere , $wikiStubShowLinks ;
 5+ if ( !isset ( $startat ) ) $startat = 1 ;
 6+ $perpage = $user->options["resultsPerPage"] ;
 7+ if ( $perpage == 0 ) $perpage = 20 ;
 8+ $vpage->special ( $wikiStubTitle ) ;
 9+ $vpage->namespace = "" ;
 10+ if ( $showLinksThere == "" ) $showLinksThere = 0 ;
 11+ if ( $showLinksThere == 1 ) $sLT2 = 0 ;
 12+ else $sLT2 = 1 ;
 13+ $ret = $wikiStubText ;
 14+ $ret .= str_replace ( "$1" , $sLT2 , $wikiStubShowLinks ) ;
 15+ $connection = getDBconnection () ;
 16+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 17+ $sql = "SELECT COUNT(*) AS number FROM cur WHERE cur_title NOT LIKE \"%:%\" AND cur_text NOT LIKE \"#redirect%\"" ;
 18+ $result = mysql_query ( $sql , $connection ) ;
 19+ $s = mysql_fetch_object ( $result ) ;
 20+ $total = $s->number ;
 21+ $sql = "SELECT cur_title,LENGTH(cur_text) AS len FROM cur WHERE cur_title NOT LIKE \"%:%\" AND cur_text NOT LIKE \"#redirect%\" ORDER BY LENGTH(cur_text),cur_title" ;
 22+ $result = mysql_query ( $sql , $connection ) ;
 23+ $cnt = 1 ;
 24+ $color1 = $user->options["tabLine1"] ;
 25+ $color2 = $user->options["tabLine2"] ;
 26+ $color = $color1 ;
 27+ $ret .= "<table width=\"100%\">\n" ;
 28+ $ar = array () ;
 29+ while ( $s = mysql_fetch_object ( $result ) and $cnt < $startat+$perpage ) {
 30+ if ( $cnt >= $startat ) {
 31+ $s->cnt = $cnt ;
 32+ array_push ( $ar , $s ) ;
 33+ }
 34+ $cnt++ ;
 35+ }
 36+ mysql_free_result ( $result ) ;
 37+
 38+ global $wikiStubChars , $wikiStubDelete , $wikiStubLinkHere ;
 39+
 40+ foreach ( $ar as $s ) {
 41+ $k = new wikiTitle ;
 42+ $k->setTitle ( $s->cur_title ) ;
 43+ $ret .= "<tr><td$color align=right valign=top nowrap>$s->cnt</td>" ;
 44+ $ret .= "<td$color align=right valign=top nowrap>(".str_replace("$1",$s->len,$wikiStubChars).")</td>\n" ;
 45+ $ret .= "<td$color nowrap valign=top>[[$s->cur_title|".$k->getNiceTitle()."]]</td>\n";
 46+ if ( in_array ( "is_sysop" , $user->rights ) )
 47+ $ret .= "<td$color valign=top nowrap><nowiki><a href=\"".wikiLink("special:deletepage&target=$k->url")."\">$wikiStubDelete</a></nowiki></td>" ;
 48+ else $ret .= "<td$color width=\"100%\" nowrap>&nbsp;</td>" ;
 49+
 50+ if ( $showLinksThere == 1 ) {
 51+ $lf = "" ;
 52+ $lh = pagesThatLinkHere($s->cur_title,$connection);
 53+ if ( count ( $lh ) <= 5 and count ( $lh ) > 0 ) {
 54+ foreach ( $lh as $ll ) {
 55+ if ( $lf == "" ) $lf = " <font size=-1>(" ;
 56+ else $lf .= " - " ;
 57+ $lf .= "[[$ll->cur_title]]" ;
 58+ }
 59+ $lf .= ")</font>" ;
 60+ }
 61+ $ret .= "<td$color width=\"100%\" valign=top>".str_replace("$1",count($lh),$wikiStubLinkHere)."$lf</td>\n";
 62+ } else $ret .= "<td$color valign=top><nowiki><a href=\"".wikiLink("special:whatlinkshere&target=$k->url")."\">Show pages that link to \"".$k->getNiceTitle()."\"</a></nowiki></td>\n" ;
 63+
 64+ $ret .= "</tr>" ;
 65+ if ( $color == $color1 ) $color = $color2 ;
 66+ else $color = $color1 ;
 67+ }
 68+ $ret .= "</table>\n" ;
 69+
 70+ $ret .= "<nowiki>" ;
 71+ $before = $startat - $perpage ; $fin = $before + $perpage - 1 ;
 72+ if ( $startat > 1 ) $ret .= "<a href=\"".wikiLink("special:ShortPages&startat=$before&showLinksThere=$showLinksThere")."\">$before-$fin&lt;&lt;</a> &nbsp;";
 73+ $after = $startat + $perpage ; $fin = $after+$perpage - 1 ; if ( $fin > $total ) $fin = $total ;
 74+ if ( $after-1 < $total ) $ret .= "<a href=\"".wikiLink("special:ShortPages&startat=$after&showLinksThere=$showLinksThere")."\">&gt;&gt;$after-$fin</a>" ;
 75+ $ret .= "</nowiki>" ;
 76+ #mysql_close ( $connection ) ;
 77+ return $ret ;
 78+ }
 79+?>
\ No newline at end of file
Property changes on: trunk/phpwiki/fpw/special_shortpages.php
___________________________________________________________________
Added: svn:eol-style
180 + native
Added: svn:keywords
281 + Author Date Id Revision
Index: trunk/phpwiki/fpw/special_upload.php
@@ -0,0 +1,110 @@
 2+<?
 3+function upload () {
 4+ global $THESCRIPT ;
 5+ global $removeFile , $xtitle , $removeFile , $Upload , $Upload_name , $no_copyright ;
 6+ global $user , $vpage , $wikiUploadTitle , $wikiUploadText , $wikiUploadDenied ;
 7+ global $wikiUploadDeleted , $wikiUploadDelMsg1 , $wikiUploadDelMsg2 ;
 8+ global $wikiUploadAffirm , $wikiUploadFull ;
 9+ global $wikiUploadSuccess , $wikiUploadSuccess1 , $wikiUploadSuccess2 ;
 10+ global $wikiUploadAffirmText , $wikiUploadButton ;
 11+ $vpage->special ( $wikiUploadTitle ) ;
 12+ $isSysop = in_array ( "is_sysop" , $user->rights ) ;
 13+ $xtitle = $wikiUploadPage ;
 14+ $ret = "<nowiki>" ;
 15+
 16+ $message = "" ;
 17+
 18+ if (isset($removeFile)) {
 19+ if ( !$isSysop ) return $wikiUploadDenied ;
 20+ if (is_file("./upload/$removeFile") ) unlink ("./upload/$removeFile");
 21+ $message = str_replace ( "$1" , $removeFile , $wikiUploadDeleted ) ;
 22+
 23+ # Appending log page "log:Uploads"
 24+ $now = date ( "Y-m-d H:i:s" , time () ) ;
 25+ $logText = str_replace ( "$1" , $user->name , str_replace ( "$2" , $removeFile , $wikiUploadDelMsg1 ) ) ;
 26+ makeLog ( "log:Uploads" , $logText , str_replace ( "$1" , $removeFile , $wikiUploadDelMsg2 ) ) ;
 27+
 28+ unset ( $removeFile ) ;
 29+ } else if (isset($Upload_name) or isset($Upload)) {
 30+ if ( $no_copyright != "AFFIRMED" ) return $wikiUploadAffirm ;
 31+# $Upload_name = ereg_replace(" ", "_", $Upload_name);
 32+ $abc = split("\.", $Upload_name);
 33+
 34+ $num = exec ("df");
 35+ $readata = substr($num,(strpos($num, "%")-2),2);
 36+
 37+ if ($readata > 96) {
 38+ $ret .= "<body bgcolor=white>\n";
 39+ $ret .= "<br><b>$wikiUploadFull</b>\n";
 40+ return $ret ;
 41+ }
 42+
 43+ copy ( $Upload , "./upload/$Upload_name" ) ;
 44+ chmod ( "./upload/$Upload_name" , 0777 ) ;
 45+ $message = str_replace ( "$1" , htmlspecialchars ( $Upload_name ) , $wikiUploadSuccess ) ;
 46+
 47+ # Appending log page "log:Uploads"
 48+ global $REMODE_ADDR ;
 49+ $now = date ( "Y-m-d H:i:s" , time () ) ;
 50+ $userText = "[[user:$user->name|$user->name]]" ;
 51+ if ( $user->name == "" ) $userText = $REMODE_ADDR ;
 52+ $logText = str_replace ( "$1" , $now , str_replace ( "$2" , $userText , str_replace ( "$3" , htmlspecialchars ( $Upload_name ) , $wikiUploadSuccess1 ) ) ) ;
 53+ makeLog ( "log:Uploads" , $logText , str_replace ( "$1" , $Upload_name , $wikiUploadSuccess2 ) ) ;
 54+
 55+ unset ( $Upload_name ) ;
 56+ }
 57+
 58+ if ( $message != "" ) $ret .= "<font color=red>$message</font><br>\n" ;
 59+ $ret .= $wikiUploadText ;
 60+ $ret .= " <form enctype=\"multipart/form-data\" action=\"".wikiLink("special:upload")."\" method=post>\n";
 61+ $ret .= " <input type=hidden name=max value=20096>\n";
 62+ $ret .= " <input name=Upload type=\"file\"><br>\n";
 63+ $ret .= " <input type=hidden name=update value=1>\n";
 64+ $ret .= " <input type=hidden name=step value=$step>\n";
 65+ $ret .= "<INPUT TYPE=checkbox NAME=\"no_copyright\" VALUE=\"AFFIRMED\">$wikiUploadAffirmText<br>\n" ;
 66+ $ret .= " <input type=submit name=Upload value=$wikiUploadButton>\n";
 67+ $ret .= "</form>\n";
 68+
 69+ global $wikiUploadPrev , $wikiUploadSize , $wikiFileRemoval , $wikiUploadRemove, $THESCRIPT ;
 70+
 71+ if (is_dir("upload")) {
 72+ $mydir = dir("upload");
 73+ while ($entry = $mydir->read()) {
 74+ if ($entry != "." and $entry != "..")
 75+ $file = "yes";
 76+ }
 77+ $mydir->close();
 78+ $uploaddir = ereg_replace("[A-Za-z0-9_.]+$", "upload", $THESCRIPT);
 79+
 80+ if ($file == "yes") {
 81+ $ret .= "<h2>$wikiUploadPrev</h2>";
 82+ $mydir = opendir("upload");
 83+ $i = 0;
 84+ $ret .= "<table border=1 width=\"100%\">\n";
 85+ $ret .= "<tr><th>File</th><th>$wikiUploadSize</th>";
 86+ if ( $isSysop )
 87+ $ret .= "<th>$wikiFileRemoval</th>";
 88+ $ret .= "</tr>\n" ;
 89+ while ($entry = readdir($mydir)) {
 90+ if ($entry != '.' && $entry != '..') {
 91+ $ret .= "<tr><td align=center>" ;
 92+ $ret .= "<a href=\"$uploaddir/".rawurlencode($entry)."\">".htmlspecialchars($entry)."</a></td>";
 93+ $ret .= "<td align=center>".filesize("upload/$entry")." bytes</td>";
 94+ if ( $isSysop ) {
 95+ $ret .= "<td align=center><a href=\"".wikiLink("special:upload&removeFile=".urlencode($entry))."\">" ;
 96+ $ret .= str_replace ( "$1" , $entry , $wikiUploadRemove ) ;
 97+ $ret .= "</a></td>" ;
 98+ }
 99+ $ret .= "</tr>" ;
 100+ $i++;
 101+ }
 102+ }
 103+ $ret .= "</table>\n";
 104+ closedir($mydir);
 105+ }
 106+ }
 107+ $ret .= "</nowiki>" ;
 108+ return $ret ;
 109+ }
 110+
 111+?>
\ No newline at end of file
Property changes on: trunk/phpwiki/fpw/special_upload.php
___________________________________________________________________
Added: svn:eol-style
1112 + native
Added: svn:keywords
2113 + Author Date Id Revision
Index: trunk/phpwiki/fpw/special_dohistory.php
@@ -0,0 +1,56 @@
 2+<?
 3+include_once ( "special_recentchangeslayout.php" ) ;
 4+
 5+function doHistory ( $title ) {
 6+ global $THESCRIPT , $vpage , $wikiSQLServer , $wikiHistoryTitle , $wikiCurrentVersion , $wikiHistoryHeader ;
 7+ $vpage = new WikiPage ;
 8+ $vpage->SetTitle ( $title ) ;
 9+ $ti = $vpage->secureTitle ;
 10+ $url = $vpage->url;
 11+ $vpage->special ( str_replace ( "$1" , $title , $wikiHistoryTitle ) ) ;
 12+ $vpage->makeSecureTitle () ;
 13+
 14+ $a = array () ;
 15+ $connection = getDBconnection () ;
 16+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 17+ $sql = "SELECT * FROM cur WHERE cur_title=\"$ti\"" ;
 18+ $result = mysql_query ( $sql , $connection ) ;
 19+ $s = mysql_fetch_object ( $result ) ;
 20+ array_push ( $a , $s ) ;
 21+ mysql_free_result ( $result ) ;
 22+ $o = $s->cur_old_version ;
 23+ while ( $o != 0 ) {
 24+ $sql = "SELECT * FROM old WHERE old_id=$o" ;
 25+ $result = mysql_query ( $sql , $connection ) ;
 26+ $s = mysql_fetch_object ( $result ) ;
 27+# print "<font color=red>$s->old_timestamp:</font> ".$s->old_text."<br>" ;
 28+ $s->cur_timestamp = $s->old_timestamp ;
 29+ $s->cur_title = $s->old_title ;
 30+ $s->cur_user = $s->old_user ;
 31+ $s->cur_comment = $s->old_comment ;
 32+ $s->cur_user_text = $s->old_user_text ;
 33+ $s->cur_minor_edit = $s->old_minor_edit ;
 34+ array_push ( $a , $s ) ;
 35+ $o = $s->old_old_version ;
 36+ mysql_free_result ( $result ) ;
 37+ }
 38+ #mysql_close ( $connection ) ;
 39+
 40+ $i = count ( $a ) ;
 41+ $k = array_keys ( $a ) ;
 42+ foreach ( $k as $x ) {
 43+ if ( $i != count ( $a ) ) $a[$x]->version = $i ;
 44+ else $a[$x]->version = $wikiCurrentVersion ;
 45+ $i-- ;
 46+ }
 47+
 48+ $t = recentChangesLayout ( $a ) ;
 49+ $t = "<b>".str_replace(array("$1","$2"),array($url,$title),$wikiHistoryHeader)."</b>".$t ;
 50+
 51+ $ret = $vpage->getHeader() ;
 52+ $ret .= $vpage->getMiddle($t) ;
 53+ $ret .= $vpage->getFooter() ;
 54+ return $ret ;
 55+ }
 56+
 57+?>
\ No newline at end of file
Property changes on: trunk/phpwiki/fpw/special_dohistory.php
___________________________________________________________________
Added: svn:eol-style
158 + native
Added: svn:keywords
259 + Author Date Id Revision
Index: trunk/phpwiki/fpw/special_dosearch.php
@@ -0,0 +1,143 @@
 2+<?
 3+function searchLineDisplay ( $v ) {
 4+ global $search ;
 5+ $v = trim(str_replace("\n","",$v)) ;
 6+ $v = str_replace ( "'''" , "" , $v ) ;
 7+ $v = str_replace ( "''" , "" , $v ) ;
 8+ $v = ereg_replace ( "\{\{\{.*\}\}\}" , "?" , $v ) ;
 9+ $v = trim ( $v ) ;
 10+ while ( substr($v,0,1) == ":" ) $v = substr($v,1) ;
 11+ while ( substr($v,0,1) == "*" ) $v = substr($v,1) ;
 12+ while ( substr($v,0,1) == "#" ) $v = substr($v,1) ;
 13+ $v = eregi_replace ( $search , "'''".$search."'''" , $v ) ;
 14+ $v = "<font size=-1>$v</font>" ;
 15+ return $v ;
 16+ }
 17+
 18+function doSearch () {
 19+ global $THESCRIPT ;
 20+ global $vpage , $search , $startat , $user ;
 21+ global $wikiSearchTitle , $wikiSearchedVoid , $wikiNoSearchResult ;
 22+ $vpage = new WikiPage ;
 23+ $vpage->special ( $wikiSearchTitle ) ;
 24+ $r = array () ;
 25+ $s = "" ;
 26+
 27+ if ( $search == "" ) $s = $wikiSearchedVoid ;
 28+ else {
 29+ $search = wikiRecodeInput ( $search ) ;
 30+ if ( !isset ( $startat ) ) $startat = 1 ;
 31+ $perpage = $user->options["resultsPerPage"] ;
 32+ global $wikiSQLServer ;
 33+ $connection = getDBconnection () ;
 34+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 35+
 36+/*
 37+ # Old search algorithm
 38+ $sql = "SELECT * FROM cur WHERE cur_title LIKE \"%$search%\" OR cur_text LIKE \"%$search%\" ORDER BY cur_title" ;
 39+*/
 40+
 41+ # New search algorithm
 42+ $totalcnt = 0 ;
 43+ $s2 = str_replace ( "_" , " " , $search ) ;
 44+ $s2 = ereg_replace ( "[^A-Za-z0-9 ]" , "" , $s2 ) ;
 45+ $s2 = str_replace ( " " , " " , $s2 ) ;
 46+ $s2 = explode ( " " , $s2 ) ;
 47+
 48+ $exclude = "cur_title NOT LIKE \"%alk:%\"" ;
 49+ if ( $exclude != "" ) $exclude = "($exclude) AND " ;
 50+
 51+ # Phase 1
 52+ $s3 = array () ;
 53+ foreach ( $s2 as $x ) {
 54+ $s4 = "(cur_title LIKE \"%".strtolower(substr($x,0,1)).substr($x,1)."%\" OR cur_title LIKE \"%".ucfirst($x)."%\")" ;
 55+ array_push ( $s3 , $s4 ) ;
 56+ }
 57+ $s3 = implode ( " AND " , $s3 ) ;
 58+ $sql = "SELECT * FROM cur WHERE $exclude( $s3 ) ORDER BY cur_title" ;
 59+ $result = mysql_query ( $sql , $connection ) ;
 60+ if ( $result != "" ) {
 61+ while ( $s = mysql_fetch_object ( $result ) ) {
 62+ if ( $totalcnt+1 >= $startat and count ( $r ) < $perpage )
 63+ array_push ( $r , $s ) ;
 64+ $totalcnt++ ;
 65+ }
 66+ mysql_free_result ( $result ) ;
 67+ }
 68+
 69+ # Phase 2
 70+ $s3 = implode ( "%\" AND cur_text LIKE \"%" , $s2 ) ;
 71+ $sql = "SELECT * FROM cur WHERE $exclude(cur_text LIKE \"%$s3%\" ) ORDER BY cur_title" ;
 72+ $result = mysql_query ( $sql , $connection ) ;
 73+ if ( $result != "" ) {
 74+ while ( $s = mysql_fetch_object ( $result ) ) {
 75+ if ( $totalcnt+1 >= $startat and count ( $r ) < $perpage )
 76+ array_push ( $r , $s ) ;
 77+ $totalcnt++ ;
 78+ }
 79+ mysql_free_result ( $result ) ;
 80+ }
 81+
 82+
 83+ #mysql_close ( $connection ) ;
 84+ }
 85+
 86+ if ( $s == "" and count ( $r ) == 0 ) {
 87+ global $wikiUnsuccessfulSearch , $wikiUnsuccessfulSearches ;
 88+ $s = "<h2>".str_replace("$1",$search,$wikiNoSearchResult)."</h2>" ;
 89+ # Appending log page "wikpedia:Unsuccessful searches"
 90+ $now = date ( "Y-m" , time() ) ;
 91+ $logText = "*[[$search]]\n" ;
 92+ makeLog ( str_replace ( "$1" , $now , $wikiUnsuccessfulSearches ) , $logText , str_replace ( "$1" , $search , $wikiUnsuccessfulSearch ) ) ;
 93+
 94+ } else if ( $s == "" ) {
 95+ global $wikiFoundHeading , $wikiFoundText ;
 96+ $n = count ( $r ) ;
 97+ $s .= "<table width=\"100%\" bgcolor=\"#FFFFCC\"><tr><td><font size=\"+1\"><b>$wikiFoundHeading</b></font><br>\n" ;
 98+ $n = str_replace ( "$1" , $totalcnt , $wikiFoundText ) ;
 99+ $n = str_replace ( "$2" , $search , $n ) ;
 100+ $s .= "$n</td></tr></table>\n" ;
 101+ $s .= "<table>" ;
 102+ $realcnt = $startat ;
 103+ $minlen = strlen ( $realcnt + count ( $r ) ) ;
 104+ foreach ( $r as $x ) {
 105+ $u = spliti ( "\n" , $x->cur_text ) ;
 106+ $u = spliti ( "--" , $u[0] ) ;
 107+ $y = searchLineDisplay ( array_shift ( $u ) ) ;
 108+ foreach ( $u as $v ) {
 109+ if ( stristr($v,$search) != false ) {
 110+ $y .= "...<br>...".searchLineDisplay($v) ;
 111+ break ;
 112+ }
 113+ }
 114+
 115+ for ( $z = $realcnt ; strlen ( $z ) < $minlen ; $z = "0$z" ) ;
 116+ $ct = $vpage->getNiceTitle ( $x->cur_title ) ;
 117+ $s .= "<tr><td valign=top width=20 align=right><b>$z</b></td><td><font face=\"Helvetica,Arial\">'''[[$ct]]'''</font><br>" ;
 118+ $s .= $y ;
 119+ $s .= "</td></tr>" ;
 120+ $realcnt++ ;
 121+ }
 122+ $s .= "</table>" ;
 123+ if ( $totalcnt > $perpage ) {
 124+ $s .= "<nowiki>" ;
 125+ $last = $startat-$perpage ;
 126+ $next = $startat+$perpage ;
 127+ if ( $startat != 1 ) $s .= "<a href=\"".wikiLink("&search=$search&startat=$last")."\">&lt;&lt;</a> | ";
 128+ for ( $a = 1 ; $a <= $totalcnt ; $a += $perpage ) {
 129+ if ( $a != 1 ) $s .= " | " ;
 130+ if ( $a != $startat ) $s .= "<a href=\"".wikiLink("&search=$search&startat=$a")."\">";
 131+ $s .= "$a-" ;
 132+ $s .= $a+$perpage-1 ;
 133+ if ( $a != $startat ) $s .= "</a>" ;
 134+ }
 135+ if ( $startat != $a-$perpage ) $s .= " | <a href=\"".wikiLink("&search=$search&startat=".$next)."\">&gt;&gt;</a>";
 136+ $s .= "</nowiki>" ;
 137+ }
 138+ }
 139+
 140+ $vpage->contents = $s ;
 141+ return $vpage->renderPage () ;
 142+ }
 143+
 144+?>
\ No newline at end of file
Property changes on: trunk/phpwiki/fpw/special_dosearch.php
___________________________________________________________________
Added: svn:eol-style
1145 + native
Added: svn:keywords
2146 + Author Date Id Revision

Status & tagging log