Index: trunk/phpwiki/fpw/specialPages.php |
— | — | @@ -308,33 +308,31 @@ |
309 | 309 | function WantedPages () { |
310 | 310 | global $THESCRIPT ; |
311 | 311 | global $linkedLinks , $unlinkedLinks , $vpage ; |
312 | | - $vpage->special ( "The Most Wanted Topics" ) ; |
| 312 | + $vpage->special ( "The Most Wanted Pages" ) ; |
313 | 313 | $vpage->namespace = "" ; |
314 | 314 | $allPages = array () ; |
315 | | - $linkedLinks = array () ; |
316 | | - $unlinkedLinks = array () ; |
317 | | - $ret = "'''These articles don't exist, but other articles link to them!'''\n\n" ; |
| 315 | + $ret = "'''These articles don't exist, but other articles link to them!''' (the top 50)\n\n" ; |
318 | 316 | |
319 | 317 | $connection = getDBconnection () ; |
320 | 318 | mysql_select_db ( "wikipedia" , $connection ) ; |
321 | | - $sql = "SELECT cur_title FROM cur" ; |
| 319 | + $sql = "SELECT cur_title,cur_linked_links,cur_unlinked_links FROM cur" ; |
322 | 320 | $result = mysql_query ( $sql , $connection ) ; |
323 | | - while ( $s = mysql_fetch_object ( $result ) ) array_push ( $allPages , $s->cur_title ) ; |
| 321 | + while ( $s = mysql_fetch_object ( $result ) ) { |
| 322 | + $allPages[$s->cur_title] = -999999999999 ; # Effectively removing existing topics from list |
| 323 | + $u = explode ( "\n" , $s->cur_linked_links ) ; foreach ( $u as $x ) $allPages[$x] += 1 ; |
| 324 | + $u = explode ( "\n" , $s->cur_unlinked_links ) ; foreach ( $u as $x ) $allPages[$x] += 1 ; |
| 325 | + } |
324 | 326 | mysql_free_result ( $result ) ; |
325 | 327 | mysql_close ( $connection ) ; |
326 | 328 | |
327 | | - foreach ( $allPages as $x ) { |
328 | | - $p = new WikiPage ; |
329 | | - $p->load ( $x ) ; |
330 | | - $p->replaceInternalLinks ( $p->contents ) ; |
| 329 | + |
| 330 | + arsort ( $allPages ) ; |
| 331 | + array_shift ( $allPages ) ; # Removing blank "link" |
| 332 | + $k = array_keys ( $allPages ) ; |
| 333 | + for ( $a = 0 ; $a < 50 ; $a++ ) { |
| 334 | + $x = $k[$a] ; |
| 335 | + $ret .= "[[$x|".$vpage->getNiceTitle($x)."]] is wanted by ".$allPages[$x]." articles.<br>\n" ; |
331 | 336 | } |
332 | | - |
333 | | - arsort ( $unlinkedLinks ) ; |
334 | | - while ( count ( $unlinkedLinks ) > 20 ) array_pop ( $unlinkedLinks ) ; |
335 | | - $a = array_keys ( $unlinkedLinks ) ; |
336 | | - foreach ( $a as $x ) |
337 | | - $ret .= "[[$x]] (linked from $unlinkedLinks[$x] other topics)<br>\n" ; |
338 | | - |
339 | 337 | return $ret ; |
340 | 338 | } |
341 | 339 | |
— | — | @@ -344,35 +342,30 @@ |
345 | 343 | $vpage->special ( "The Orphans" ) ; |
346 | 344 | $vpage->namespace = "" ; |
347 | 345 | $allPages = array () ; |
348 | | - $linkedLinks = array () ; |
349 | | - $unlinkedLinks = array () ; |
350 | 346 | $ret = "'''These articles exist, but no articles link to them!'''\n\n" ; |
351 | 347 | |
352 | 348 | $connection = getDBconnection () ; |
353 | 349 | mysql_select_db ( "wikipedia" , $connection ) ; |
354 | | - $sql = "SELECT cur_title FROM cur" ; |
| 350 | + $sql = "SELECT cur_title,cur_linked_links,cur_unlinked_links FROM cur" ; |
355 | 351 | $result = mysql_query ( $sql , $connection ) ; |
356 | | - while ( $s = mysql_fetch_object ( $result ) ) array_push ( $allPages , $s->cur_title ) ; |
| 352 | + while ( $s = mysql_fetch_object ( $result ) ) { |
| 353 | + $allPages[$s->cur_title] = $allPages[$s->cur_title] * 1 ; |
| 354 | + $u = explode ( "\n" , $s->cur_linked_links ) ; foreach ( $u as $x ) $allPages[$x] += 1 ; |
| 355 | + $u = explode ( "\n" , $s->cur_unlinked_links ) ; foreach ( $u as $x ) $allPages[$x] += 1 ; |
| 356 | + } |
357 | 357 | mysql_free_result ( $result ) ; |
358 | 358 | mysql_close ( $connection ) ; |
359 | | - |
360 | | - $r = array () ; |
361 | | - foreach ( $allPages as $x ) { |
362 | | - $p = new WikiPage ; |
363 | | - $p->load ( $x ) ; |
364 | | - $r["$p->secureTitle"] = 0 ; |
365 | | - $p->replaceInternalLinks ( $p->contents ) ; |
| 359 | + |
| 360 | + $orphans = array () ; |
| 361 | + $v = array_keys ( $allPages ) ; |
| 362 | + foreach ( $v as $x ) { |
| 363 | + if ( $allPages[$x] == 0 ) |
| 364 | + array_push ( $orphans , $x ) ; |
366 | 365 | } |
367 | 366 | |
368 | | - $a = array_keys ( $linkedLinks ) ; |
369 | | - foreach ( $a as $x ) $r[$x]++ ; |
370 | | - |
371 | | - $a = array_keys ( $r ) ; |
372 | | - foreach ( $a as $x ) { |
373 | | - if ( $r[$x] == 0 ) |
374 | | - $ret .= "[[$x]]<br>\n" ; |
375 | | - } |
376 | | - |
| 367 | + asort ( $orphans ) ; |
| 368 | + foreach ( $orphans as $x ) |
| 369 | + $ret .= "[[$x|".$vpage->getNiceTitle($x)."]]<br>\n" ; |
377 | 370 | return $ret ; |
378 | 371 | } |
379 | 372 | |
— | — | @@ -487,6 +480,28 @@ |
488 | 481 | } |
489 | 482 | |
490 | 483 | function listUsers () { |
| 484 | + global $user , $vpage , $startat ; |
| 485 | + if ( !isset ( $startat ) ) $startat = 1 ; |
| 486 | + $perpage = $user->options["resultsPerPage"] ; |
| 487 | + if ( $perpage == 0 ) $perpage = 20 ; |
| 488 | + |
| 489 | + $vpage->special ( "User List" ) ; |
| 490 | + $vpage->namespace = "" ; |
| 491 | + $ret = "'''These are all wikipedia users (that have an account)!'''\n\n" ; |
| 492 | + $connection = getDBconnection () ; |
| 493 | + mysql_select_db ( "wikipedia" , $connection ) ; |
| 494 | + $sql = "SELECT * from user" ; |
| 495 | + $result = mysql_query ( $sql , $connection ) ; |
| 496 | + while ( $s = mysql_fetch_object ( $result ) ) { |
| 497 | + $ret .= "#[[user:$s->user_name|$s->user_name]]" ; |
| 498 | + if ( in_array ( "is_sysop" , $user->rights ) ) $ret .= " ($s->user_rights)" ; |
| 499 | + $ret .= "\n" ; |
| 500 | + } |
| 501 | + |
| 502 | + |
| 503 | + return $ret ; |
| 504 | + |
| 505 | +#------------------------------------------------ |
491 | 506 | global $THESCRIPT ; |
492 | 507 | global $user , $vpage , $startat ; |
493 | 508 | if ( !isset ( $startat ) ) $startat = 1 ; |
— | — | @@ -1065,15 +1080,74 @@ |
1066 | 1081 | return $ret ; |
1067 | 1082 | } |
1068 | 1083 | |
| 1084 | +function removeFromLinkList ( $item , $link ) { |
| 1085 | + $connection = getDBconnection () ; |
| 1086 | + mysql_select_db ( "wikipedia" , $connection ) ; |
| 1087 | + $sql = "SELECT cur_id FROM cur WHERE $item LIKE \"%$link%\"" ; |
| 1088 | + $result = mysql_query ( $sql , $connection ) ; |
| 1089 | + $ids = array () ; |
| 1090 | + while ( $s = mysql_fetch_object ( $result ) ) array_push ( $ids , $s->cur_id ) ; |
| 1091 | + mysql_free_result ( $result ) ; |
| 1092 | + |
| 1093 | + foreach ( $ids as $x ) { |
| 1094 | + $sql = "SELECT cur_timestamp,$item FROM cur WHERE cur_id=$x" ; |
| 1095 | + $result = mysql_query ( $sql , $connection ) ; |
| 1096 | + $s = mysql_fetch_object ( $result ) ; |
| 1097 | + mysql_free_result ( $result ) ; |
| 1098 | + $y = explode ( "\n" , $s->$item ) ; |
| 1099 | + $z = array () ; |
| 1100 | + foreach ( $y as $u ) { |
| 1101 | + if ( $u != $link ) |
| 1102 | + array_push ( $z , $u ) ; |
| 1103 | + } |
| 1104 | + $y = implode ( "\n" , $z ) ; |
| 1105 | + $sql = "UPDATE cur SET cur_timestamp=\"$s->cur_timestamp\",$item=\"$y\" WHERE cur_id=$x" ; |
| 1106 | + $result = mysql_query ( $sql , $connection ) ; |
| 1107 | + } |
| 1108 | + |
| 1109 | + mysql_close ( $connection ) ; |
| 1110 | + } |
| 1111 | + |
| 1112 | +function deletepage () { |
| 1113 | + global $THESCRIPT , $target , $user , $iamsure ; |
| 1114 | + global $vpage ; |
| 1115 | + $target = str_replace ( "\\\\" , "\\" , $target ) ; |
| 1116 | + $target = str_replace ( "\\\\" , "\\" , $target ) ; |
| 1117 | + $vpage = new WikiPage ; |
| 1118 | + $vpage->title = $title ; |
| 1119 | + $vpage->makeSecureTitle () ; |
| 1120 | + $ti = $vpage->secureTitle ; |
| 1121 | + $vpage->special ( "Deleting article '$target'" ) ; |
| 1122 | + $vpage->makeSecureTitle () ; |
| 1123 | + if ( !in_array ( "is_sysop" , $user->rights ) ) return "<h1>You are not allowed to delete this page!</h1>" ; |
| 1124 | + if ( $iamsure == "yes" ) { |
| 1125 | + $connection = getDBconnection () ; |
| 1126 | + mysql_select_db ( "wikipedia" , $connection ) ; |
| 1127 | + $sql = "DELETE FROM cur WHERE cur_title=\"$target\"" ; |
| 1128 | + $result = mysql_query ( $sql , $connection ) ; |
| 1129 | + mysql_close ( $connection ) ; |
| 1130 | + removeFromLinkList ( "cur_linked_links" , $target ) ; |
| 1131 | + removeFromLinkList ( "cur_unlinked_links" , $target ) ; |
| 1132 | + $ret = "<h2>'$target' has been removed.</h2>" ; |
| 1133 | + } else { |
| 1134 | + $ret = "<h2>You are about to delete the article \"$target\" and its complete history!<br>\n" ; |
| 1135 | + $ret .= "If you are absolutely sure you want to do this, " ; |
| 1136 | + $ret .= "<a href=\"$THESCRIPT?title=special:deletepage&target=$target&iamsure=yes\">click here</a>.</h2>" ; |
| 1137 | + } |
| 1138 | + return "<nowiki>$ret</nowiki>" ; |
| 1139 | + } |
| 1140 | + |
1069 | 1141 | # A little hack; disabled; to enable, allow function call in wikiPage->load() |
1070 | 1142 | function askSQL () { |
1071 | 1143 | global $THESCRIPT ; |
1072 | 1144 | global $Save , $question ; |
1073 | 1145 | $ret = "" ; |
1074 | 1146 | if ( isset ( $Save ) ) { |
| 1147 | + $ret .= "$question<br>" ; |
1075 | 1148 | unset ( $Save ) ; |
1076 | 1149 | $connection = getDBconnection () ; |
1077 | 1150 | mysql_select_db ( "wikipedia" , $connection ) ; |
| 1151 | + $question = str_replace ( "\\\"" , "\"" , $question ) ; |
1078 | 1152 | $result = mysql_query ( $question , $connection ) ; |
1079 | 1153 | $n = mysql_num_fields ( $result ) ; |
1080 | 1154 | $k = array () ; |
Index: trunk/phpwiki/fpw/wikiPage.php |
— | — | @@ -1,16 +1,20 @@ |
2 | 2 | <? |
3 | 3 | class WikiPage extends WikiTitle { |
4 | 4 | var $contents ; |
| 5 | + var $knownLinkedLinks , $knownUnlinkedLinks ; |
5 | 6 | |
6 | 7 | #Functions |
7 | 8 | function load ( $t , $doRedirect = true ) { |
8 | | - global $action ; |
| 9 | + global $action , $user ; |
| 10 | + $this->knownLinkedLinks = array () ; |
| 11 | + $this->knownUnlinkedLinks = array () ; |
9 | 12 | $this->title = $t ; |
10 | 13 | $this->makeSecureTitle () ; |
11 | 14 | $this->isSpecialPage = false ; |
12 | 15 | $this->revision = "current" ; |
13 | 16 | if ( $this->namespace == "special" ) { |
14 | | - $allowed = array("userlogin","userlogout","recentchanges","upload","statistics","lonelypages","wantedpages","allpages","randompage","shortpages","listusers","watchlist","special_pages","editusersettings","asksql") ; |
| 17 | + $allowed = array("userlogin","userlogout","recentchanges","upload","statistics","lonelypages","wantedpages","allpages","randompage","shortpages","listusers","watchlist","special_pages","editusersettings","deletepage"); |
| 18 | + if ( in_array ( "is_sysop" , $user->rights ) ) array_push ( $allowed , "asksql" ) ; |
15 | 19 | $call = $this->mainTitle ; |
16 | 20 | if ( !in_array ( strtolower ( $call ) , $allowed ) ) { |
17 | 21 | $this->isSpecialPage = true ; |
— | — | @@ -43,6 +47,8 @@ |
44 | 48 | $this->title=$s->cur_title ; |
45 | 49 | $this->makeSecureTitle () ; |
46 | 50 | $this->contents = $s->cur_text ; |
| 51 | + $this->knownLinkedLinks = explode ( "\n" , $s->cur_linked_links ) ; |
| 52 | + $this->knownUnlinkedLinks = explode ( "\n" , $s->cur_unlinked_links ) ; |
47 | 53 | } |
48 | 54 | else $this->contents = "Describe the new page here." ; |
49 | 55 | } |
— | — | @@ -77,7 +83,7 @@ |
78 | 84 | while ( $s = mysql_fetch_object ( $result ) ) { |
79 | 85 | $t = strstr ( $s->cur_title , "/" ) ; |
80 | 86 | $z = explode ( ":" , $t , 2 ) ; |
81 | | - $t = "[[$t]]" ; |
| 87 | + $t = "[[$t|- ".$this->getNiceTitle(substr($z[count($z)-1],1))."]]" ; |
82 | 88 | array_push ( $a , $t ) ; |
83 | 89 | } |
84 | 90 | if ( $result != "" ) mysql_free_result ( $result ) ; |
— | — | @@ -152,11 +158,18 @@ |
153 | 159 | } |
154 | 160 | function setEntry ( $text , $comment , $userID , $userName , $minorEdit ) { |
155 | 161 | $cond = "cur_title=\"$this->secureTitle\"" ; |
| 162 | + |
| 163 | + global $linkedLinks , $unlinkedLinks ; |
| 164 | + $this->parseContents ( $text ) ; |
| 165 | + $ll = implode ( "\n" , array_keys ( $linkedLinks ) ) ; |
| 166 | + $ull = implode ( "\n" , array_keys ( $unlinkedLinks ) ) ; |
| 167 | + |
156 | 168 | $connection = getDBconnection () ; |
157 | 169 | mysql_select_db ( "wikipedia" , $connection ) ; |
158 | 170 | $text = str_replace ( "\"" , "\\\"" , $text ) ; |
159 | 171 | $sql = "UPDATE cur SET cur_text=\"$text\",cur_comment=\"$comment\",cur_user=\"$userID\"," ; |
160 | | - $sql .= "cur_user_text=\"$userName\",cur_minor_edit=\"$minorEdit\" WHERE $cond" ; |
| 172 | + $sql .= "cur_user_text=\"$userName\",cur_minor_edit=\"$minorEdit\","; |
| 173 | + $sql .= "cur_linked_links=\"$ll\",cur_unlinked_links=\"$ull\" WHERE $cond" ; |
161 | 174 | mysql_query ( $sql , $connection ) ; |
162 | 175 | mysql_close ( $connection ) ; |
163 | 176 | } |
— | — | @@ -165,6 +178,7 @@ |
166 | 179 | function replaceInternalLinks ( $s ) { |
167 | 180 | global $THESCRIPT ; |
168 | 181 | global $user , $unlinkedLinks , $linkedLinks ; |
| 182 | + if ( !isset ( $this->knownLinkedLinks ) ) $this->knownLinkedLinks = array () ; |
169 | 183 | $a = explode ( "[[" , " ".$s ) ; |
170 | 184 | $s = array_shift ( $a ) ; |
171 | 185 | $s = substr ( $s , 1 ) ; |
— | — | @@ -184,7 +198,10 @@ |
185 | 199 | if ( count ( $c ) == 1 ) array_push ( $c , $topic->getMainTitle() ) ; |
186 | 200 | $text = $c[1] ; |
187 | 201 | |
188 | | - if ( $topic->doesTopicExist( $connection ) ) { |
| 202 | + if ( in_array ( $topic->secureTitle , $this->knownLinkedLinks ) ) $doesItExist = true ; |
| 203 | + else $doesItExist = $topic->doesTopicExist( $connection ) ; |
| 204 | + |
| 205 | + if ( $doesItExist ) { |
189 | 206 | $linkedLinks[$topic->secureTitle]++ ; |
190 | 207 | if ( $user->options["showHover"] == "yes" ) $hover = "title=\"$link\"" ; |
191 | 208 | $s .= "<a href=\"$THESCRIPT?title=".urlencode($link)."\" $hover>$text</a>" ; |
— | — | @@ -460,8 +477,7 @@ |
461 | 478 | $column .= "<br><a href=\"$THESCRIPT?title=special:RecentChanges\">Recent Changes</a>\n" ; |
462 | 479 | if ( $this->canEdit() ) $column .= "<br><a href=\"$THESCRIPT?action=edit&title=$this->url$editOldVersion\">Edit this page</a>\n" ; |
463 | 480 | |
464 | | -# No user management due to request of Larry |
465 | | -# if ( $this->canDelete() ) $column .= "<br><a href=\"$THESCRIPT?action=deletepage&title=$this->url\">Delete this page</a>\n" ; |
| 481 | + if ( $this->canDelete() ) $column .= "<br><a href=\"$THESCRIPT?title=special:deletepage&target=$this->url\">Delete this page</a>\n" ; |
466 | 482 | # if ( $this->canProtect() ) $column .= "<br><a href=\"$THESCRIPT?action=protectpage&title=$this->url\">Protect this page</a>\n" ; |
467 | 483 | # if ( $this->canAdvance() ) $column .= "<br><a href=\"$THESCRIPT?title=special:Advance&topic=$this->safeTitle\">Advance</a>\n" ; |
468 | 484 | |
— | — | @@ -546,9 +562,9 @@ |
547 | 563 | } |
548 | 564 | |
549 | 565 | $fc = $user->options["background"] ; |
550 | | - if ( $fc == "" ) $fc = "=white" ; |
| 566 | + if ( $fc == "" ) $fc = "=black" ; |
551 | 567 | $fc = substr ( $fc , strpos("=",$fc)+1 ) ; |
552 | | - $bc = " bordercolor=".$fc ; |
| 568 | + $bc = " bordercolor=white" ; |
553 | 569 | $fc = " color=".$fc ; |
554 | 570 | $result = mysql_query ( $sql , $connection ) ; |
555 | 571 | if ( $result != "" and $s->old_old_version != 0 ) { |
— | — | @@ -561,10 +577,10 @@ |
562 | 578 | foreach ( $a1 as $x ) if ( !in_array ( $x , $a2 ) ) array_push ( $nl , htmlentities ( $x ) ) ; |
563 | 579 | foreach ( $a2 as $x ) if ( !in_array ( $x , $a1 ) ) array_push ( $dl , htmlentities ( $x ) ) ; |
564 | 580 | # Output |
565 | | - $ret .= "<font color=#0000FF>Blue text</font> was added or changed, <font color=red>red text</font> was changed or deleted." ; |
| 581 | + $ret .= "<font color=#2AAA2A>Green text</font> was added or changed, <font color=#AAAA00>yellow text</font> was changed or deleted." ; |
566 | 582 | $ret .= "<table width=100% border=1$bc cellspacing=0 cellpadding=2>\n" ; |
567 | | - foreach ( $nl as $x ) $ret .= "<tr><td bgcolor=#0000FF><font$fc>$x</font></td></tr>\n" ; |
568 | | - foreach ( $dl as $x ) $ret .= "<tr><td bgcolor=#DD0000><font$fc>$x</font></td></tr>\n" ; |
| 583 | + foreach ( $nl as $x ) $ret .= "<tr><td bgcolor=#FFFFAF><font$fc>$x</font></td></tr>\n" ; |
| 584 | + foreach ( $dl as $x ) $ret .= "<tr><td bgcolor=#CFFFCF><font$fc>$x</font></td></tr>\n" ; |
569 | 585 | $ret .= "</table>\n" ; |
570 | 586 | } else if ( isset ( $oldID ) and $s->old_old_version == 0 ) $ret .= "This is the first version of this article. All text is new!<br>\n" ; |
571 | 587 | else if ( !isset ( $oldID ) ) $ret .= "This is the first version of this article. All text is new!<br>\n" ; |
Index: trunk/phpwiki/fpw/wikiUser.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | var $id , $name , $password , $retypePassword ; |
5 | 5 | var $isLoggedIn ; |
6 | 6 | var $options , $email ; |
| 7 | + var $rights ; |
7 | 8 | |
8 | 9 | function skin () { |
9 | 10 | if ( $this->options["skin"] == "" ) $this->skinBlank () ; |
— | — | @@ -84,6 +85,8 @@ |
85 | 86 | $b = explode ( "=" , $x ) ; |
86 | 87 | $this->options[$b[0]] = $b[1] ; |
87 | 88 | } |
| 89 | + $t = getMySQL ( "user" , "user_rights" , "user_id=".$this->id ) ; |
| 90 | + $this->rights = explode ( "," , strtolower ( $t ) ) ; |
88 | 91 | $this->password = getMySQL ( "user" , "user_password" , "user_id=".$this->id ) ; |
89 | 92 | $this->email = getMySQL ( "user" , "user_email" , "user_id=".$this->id ) ; |
90 | 93 | $this->skin () ; |
Index: trunk/phpwiki/fpw/wikiTitle.php |
— | — | @@ -19,28 +19,31 @@ |
20 | 20 | return true ; |
21 | 21 | } |
22 | 22 | function canDelete () { |
23 | | - global $action ; |
| 23 | + global $action , $user ; |
24 | 24 | global $oldID ; if ( isset ( $oldID ) ) return false ; |
25 | 25 | if ( !$this->validateTitle() ) return false ; |
26 | 26 | if ( $this->isSpecialPage ) return false ; |
27 | 27 | if ( $this->namespace == "special" ) return false ; |
28 | | - return true ; |
| 28 | + if ( in_array ( "is_sysop" , $user->rights ) ) return true ; |
| 29 | + return false ; |
29 | 30 | } |
30 | 31 | function canProtect () { |
31 | | - global $action ; |
| 32 | + global $action , $user ; |
32 | 33 | global $oldID ; if ( isset ( $oldID ) ) return false ; |
33 | 34 | if ( !$this->validateTitle() ) return false ; |
34 | 35 | if ( $this->isSpecialPage ) return false ; |
35 | 36 | if ( $this->namespace == "special" ) return false ; |
36 | | - return true ; |
| 37 | + if ( in_array ( "is_sysop" , $user->rights ) ) return true ; |
| 38 | + return false ; |
37 | 39 | } |
38 | 40 | function canAdvance () { |
39 | | - global $action ; |
| 41 | + global $action , $user ; |
40 | 42 | global $oldID ; if ( isset ( $oldID ) ) return false ; |
41 | 43 | if ( !$this->validateTitle() ) return false ; |
42 | 44 | if ( $this->isSpecialPage ) return false ; |
43 | 45 | if ( $this->namespace == "special" ) return false ; |
44 | | - return true ; |
| 46 | + if ( in_array ( "is_sysop" , $user->rights ) ) return true ; |
| 47 | + return false ; |
45 | 48 | } |
46 | 49 | |
47 | 50 | # Title functions |
Index: trunk/phpwiki/fpw/scandb.phtml |
— | — | @@ -0,0 +1,145 @@ |
| 2 | +<? |
| 3 | +$THESCRIPT = "wiki.phtml" ; |
| 4 | +#include ( "./specialPages.php" ) ; |
| 5 | +include ( "./databaseFunctions.php" ) ; |
| 6 | +include ( "./wikiTitle.php" ) ; |
| 7 | +include ( "./wikiPage.php" ) ; |
| 8 | +include ( "./wikiUser.php" ) ; |
| 9 | + |
| 10 | +function scanText2 ( $fn ) { |
| 11 | + $ret = "" ; |
| 12 | + |
| 13 | + #CONSTANTS |
| 14 | + $FS = "�" ; |
| 15 | + $FS1 = $FS."1" ; |
| 16 | + $FS2 = $FS."2" ; |
| 17 | + $FS3 = $FS."3" ; |
| 18 | + |
| 19 | + #READING FILE |
| 20 | + $t = array () ; |
| 21 | + $fd = fopen ( $fn , "r" ) ; |
| 22 | + while (!feof($fd)) { |
| 23 | + $buffer = fgets($fd, 99999); |
| 24 | + array_push ( $t , $buffer ) ; |
| 25 | + } |
| 26 | + fclose ( $fd ) ; |
| 27 | + |
| 28 | + array_pop ( $t ) ; |
| 29 | + $t = implode ( "" , $t ) ; |
| 30 | + |
| 31 | + #SPLIT PAGE |
| 32 | + $sp = explode ( $FS1 , $t ) ; |
| 33 | + |
| 34 | + $x = array_pop ( $sp ) ; |
| 35 | + $sections = explode ( $FS2 , $x ) ; |
| 36 | + foreach ( $sections as $y ) { |
| 37 | + $text = explode ( $FS3 , $y ) ; |
| 38 | + foreach ( $text as $z ) { |
| 39 | + $ret = $z ; |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + return $ret ; |
| 44 | + } |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +function scantext ( $fn ) { |
| 49 | + $fd = fopen ( $fn , "r" ) ; |
| 50 | + $leadingThree = 0 ; |
| 51 | + $n = 0 ; |
| 52 | + $t = array () ; |
| 53 | + while (!feof($fd)) { |
| 54 | + $buffer = fgets($fd, 4096); |
| 55 | + if ( substr ( $buffer , 0 , 1 ) == "�" ) $leadingThree++ ; |
| 56 | + if ( $leadingThree > 0 ) { |
| 57 | + $t[$n] = $buffer ; |
| 58 | + $n++ ; |
| 59 | + } |
| 60 | + } |
| 61 | + fclose ( $fd ) ; |
| 62 | + |
| 63 | + $c1 = $t[0] ; |
| 64 | + $t[0] = substr ( $c1 , strrpos ( $c1 , "�" ) + 2 ) ; |
| 65 | + $c1 = substr ( $c1 , 0 , strrpos ( $c1 , "�" ) + 2 ) ; |
| 66 | + |
| 67 | + $c2 = array_pop ( $t ) ; |
| 68 | + |
| 69 | + $c1 = explode ( "�" , $c1 ) ; |
| 70 | + $c2 = explode ( "�" , $c2 ) ; |
| 71 | + |
| 72 | + $ret = "" ; |
| 73 | + for ( $a = 0 ; $a < $n ; $a++ ) $ret .= $t[$a] ; |
| 74 | + return $ret ; |
| 75 | + } |
| 76 | + |
| 77 | +function getFileName ( $an ) { |
| 78 | + global $rootDir ; |
| 79 | + $ret = $rootDir ; |
| 80 | + $sd = ucfirst ( substr ( $an , 0 , 1 ) ) ; |
| 81 | + if ( $sd < "A" or $sd > "Z" ) $sd = "other" ; |
| 82 | + $ret .= "$sd/".ucfirst($an).".db" ; |
| 83 | + return $ret ; |
| 84 | + } |
| 85 | + |
| 86 | +function storeInDB ( $title , $text ) { |
| 87 | + $text = str_replace ( "\\'" , "'" , $text ) ; |
| 88 | + $text = str_replace ( "\\\"" , "\"" , $text ) ; |
| 89 | + $title = str_replace ( "\\'" , "'" , $title ) ; |
| 90 | + $title = str_replace ( "\\\"" , "\"" , $title ) ; |
| 91 | + $npage = new wikiPage ; |
| 92 | + $npage->title = $title ; |
| 93 | + $npage->makeAll () ; |
| 94 | + if ( !$npage->doesTopicExist() ) { $MinorEdit = 2 ; $npage->ensureExistence () ; } |
| 95 | + else $npage->backup() ; |
| 96 | + $npage->setEntry ( $text , "conversion" , 0 , "wikipedia conversion script" , 1 ) ; |
| 97 | + } |
| 98 | + |
| 99 | +function getTopics ( $dir ) { |
| 100 | + $ret = array () ; |
| 101 | + |
| 102 | + $mydir = opendir($dir); |
| 103 | + while ($entry = readdir($mydir)) { |
| 104 | + if ($entry != '.' && $entry != '..') { |
| 105 | + if ( is_dir ( "$dir/$entry" ) ) { |
| 106 | + $a = getTopics ( "$dir/$entry" ) ; |
| 107 | + foreach ( $a as $x ) array_push ( $ret , "$entry/$x" ) ; |
| 108 | + } else { |
| 109 | + $x = substr ( $entry , 0 , strlen ( $entry ) - 3 ) ; |
| 110 | + array_push ( $ret , $x ) ; |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + closedir($mydir); |
| 115 | + |
| 116 | + return $ret ; |
| 117 | + } |
| 118 | + |
| 119 | +function dir2DB ( $letter ) { |
| 120 | + global $rootDir ; |
| 121 | + $a = getTopics ( "$rootDir/$letter" ) ; |
| 122 | + foreach ( $a as $an ) { |
| 123 | + print "<b>$an</b><br>\n" ; |
| 124 | + $fn = getFileName ( $an ) ; |
| 125 | + $t = scantext2 ( $fn ) ; |
| 126 | + storeInDB ( $an , $t ) ; |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | +# MAIN PROGRAM |
| 131 | + global $rootDir ; |
| 132 | + $rootDir = "/home/groups/w/wi/wikipedia/htdocs/fpw/wiki-de/lib-http/db/wiki/page/" ; |
| 133 | + |
| 134 | + global $l ; |
| 135 | + if ( !isset ( $l ) ) $l = 65 ; |
| 136 | + if ( $l == "other" ) $letter = "other" ; |
| 137 | + else $letter = chr ( $l ) ; |
| 138 | + $nl = $l+1 ; |
| 139 | + if ( $letter == "Z" ) $nl = "other" ; |
| 140 | + |
| 141 | + print "<html><head></head><body>" ; |
| 142 | + dir2DB ( $letter ) ; |
| 143 | + if ( $l != "other" ) print "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=scandb.phtml?l=$nl\">" ; |
| 144 | + else print "<h1>FINISHED!</h1>" ; |
| 145 | + print "</body></html>" ; |
| 146 | +?> |
\ No newline at end of file |
Property changes on: trunk/phpwiki/fpw/scandb.phtml |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 147 | + native |
Added: svn:keywords |
2 | 148 | + Author Date Id Revision |