Index: trunk/phpwiki/fpw/specialPages.php |
— | — | @@ -20,15 +20,16 @@ |
21 | 21 | $text = $EditBox ; |
22 | 22 | $text = str_replace ( "\\'" , "'" , $text ) ; |
23 | 23 | $text = str_replace ( "\\\"" , "\"" , $text ) ; |
24 | | - if ( $user->isLoggedIn ) |
25 | | - $text = str_replace ( "~~~" , "[[user:$user->name|$user->name]]" , $text ) ; |
| 24 | + if ( $user->isLoggedIn ) $text = str_replace ( "~~~" , "[[user:$user->name|$user->name]]" , $text ) ; |
| 25 | + else $text = str_replace ( "~~~" , $user->getLink() , $text ) ; |
26 | 26 | $title = str_replace ( "\\'" , "'" , $title ) ; |
27 | 27 | $title = str_replace ( "\\\"" , "\"" , $title ) ; |
28 | 28 | $npage->title = $title ; |
29 | 29 | $npage->makeAll () ; |
30 | 30 | if ( $npage->doesTopicExist() ) $npage->backup() ; |
31 | 31 | else { $MinorEdit = 2 ; $npage->ensureExistence () ; } |
32 | | - $npage->setEntry ( $text , $CommentBox , $user->id , $user->name , $MinorEdit*1 ) ; |
| 32 | + if ( !$user->isLoggedIn ) $npage->setEntry ( $text , $CommentBox , 0 , $user->getLink() , $MinorEdit*1 ) ; |
| 33 | + else $npage->setEntry ( $text , $CommentBox , $user->id , $user->name , $MinorEdit*1 ) ; |
33 | 34 | global $wasSaved ; |
34 | 35 | $wasSaved = true ; |
35 | 36 | return "" ; |
— | — | @@ -94,14 +95,14 @@ |
95 | 96 | function userLogout () { |
96 | 97 | global $user , $vpage ; |
97 | 98 | $vpage->title = "User logout" ; |
98 | | - setcookie ( "WikiLoggedIn" , "" ) ; |
99 | | - if ( $user->options["rememberPassword"] != "on" ) setcookie ( "WikiUserPassword" , "" ) ; |
| 99 | + setcookie ( "WikiLoggedIn" , "" , time()-3600 ) ; |
| 100 | + if ( $user->options["rememberPassword"] != "on" ) setcookie ( "WikiUserPassword" , "" , time()-3600 ) ; |
100 | 101 | $user->isLoggedIn = false ; |
101 | 102 | return "<h1>Goodbye, $user->name!</h1>" ; |
102 | 103 | } |
103 | 104 | |
104 | 105 | function userLogin () { |
105 | | - global $loginattempt , $user , $vpage , $WikiUserID ; |
| 106 | + global $loginattempt , $user , $vpage , $WikiUserID , $expiration ; |
106 | 107 | $vpage->title = "User login" ; |
107 | 108 | |
108 | 109 | if ( isset ( $loginattempt ) ) { |
— | — | @@ -118,18 +119,18 @@ |
119 | 120 | if ( $nu->isLoggedIn ) { |
120 | 121 | $user = new WikiUser ; |
121 | 122 | $user = $nu ; |
122 | | - setcookie ( "WikiUserID" , $user->id ) ; |
123 | | - setcookie ( "WikiLoggedIn" , "yes" ) ; |
124 | | - setcookie ( "WikiUserPassword" , $user->password ) ; |
| 123 | + setcookie ( "WikiUserID" , $user->id , $expiration ) ; |
| 124 | + setcookie ( "WikiLoggedIn" , "yes" , $expiration ) ; |
| 125 | + setcookie ( "WikiUserPassword" , $user->password , $expiration ) ; |
125 | 126 | $user->options["rememberPassword"] = $REMEMBERPASSWORD ; |
126 | 127 | $user->saveSettings() ; |
127 | 128 | } else if ( $USERPASSWORD == $RETYPE and !($nu->doesUserExist()) ) { |
128 | 129 | $nu->addToDatabase () ; |
129 | 130 | $user = $nu ; |
130 | 131 | $s = "<h1>Welcome, $user->name!</h1><font color=red>Don't forget to personalize your wikipedia perferences!</font>" ; |
131 | | - setcookie ( "WikiLoggedIn" , "yes" ) ; |
132 | | - setcookie ( "WikiUserID" , $user->id ) ; |
133 | | - if ( $user->options["rememberPassword"] == "on" ) setcookie ( "WikiUserPassword" , $user->password ) ; |
| 132 | + setcookie ( "WikiLoggedIn" , "yes" , $expiration ) ; |
| 133 | + setcookie ( "WikiUserID" , $user->id , $expiration ) ; |
| 134 | + if ( $user->options["rememberPassword"] == "on" ) setcookie ( "WikiUserPassword" , $user->password , $expiration ) ; |
134 | 135 | $user->options["rememberPassword"] = $REMEMBERPASSWORD ; |
135 | 136 | $user->saveSettings() ; |
136 | 137 | } else { |
— | — | @@ -379,7 +380,7 @@ |
380 | 381 | $v = trim(str_replace("\n","",$v)) ; |
381 | 382 | $v = str_replace ( "'''" , "" , $v ) ; |
382 | 383 | $v = str_replace ( "''" , "" , $v ) ; |
383 | | - $v = ereg_replace ( "{{{.*}}}" , "?" , $v ) ; |
| 384 | + $v = ereg_replace ( "\{\{\{.*\}\}\}" , "?" , $v ) ; |
384 | 385 | $v = trim ( $v ) ; |
385 | 386 | while ( substr($v,0,1) == ":" ) $v = substr($v,1) ; |
386 | 387 | while ( substr($v,0,1) == "*" ) $v = substr($v,1) ; |
— | — | @@ -467,6 +468,53 @@ |
468 | 469 | return $vpage->renderPage () ; |
469 | 470 | } |
470 | 471 | |
| 472 | +function listUsers () { |
| 473 | + global $user , $vpage , $startat ; |
| 474 | + if ( !isset ( $startat ) ) $startat = 1 ; |
| 475 | + $perpage = $user->options["resultsPerPage"] ; |
| 476 | + if ( $perpage == 0 ) $perpage = 20 ; |
| 477 | + |
| 478 | + $vpage->special ( "User List" ) ; |
| 479 | + $vpage->namespace = "" ; |
| 480 | + $ret = "'''These are all wikipedia users (that have an account)!'''\n\n" ; |
| 481 | + $connection = getDBconnection () ; |
| 482 | + mysql_select_db ( "wikipedia" , $connection ) ; |
| 483 | + $sql = "SELECT COUNT(*) AS number FROM cur WHERE cur_title LIKE \"User:%\"" ; |
| 484 | + $result = mysql_query ( $sql , $connection ) ; |
| 485 | + $s = mysql_fetch_object ( $result ) ; |
| 486 | + $total = $s->number ; |
| 487 | + $sql = "SELECT * FROM cur WHERE cur_title LIKE \"User:%\" ORDER BY cur_title" ; |
| 488 | + $result = mysql_query ( $sql , $connection ) ; |
| 489 | + $cnt = 1 ; |
| 490 | + $color1 = $user->options["tabLine1"] ; |
| 491 | + $color2 = $user->options["tabLine2"] ; |
| 492 | + $color = $color1 ; |
| 493 | + $ret .= "<table width=100%>\n" ; |
| 494 | + while ( $s = mysql_fetch_object ( $result ) and $cnt < $startat+$perpage ) { |
| 495 | + if ( $cnt >= $startat ) { |
| 496 | + $u = $s->cur_title ; |
| 497 | + $u = substr ( strstr ( $u , ":" ) , 1 ) ; |
| 498 | + $u = $vpage->getNiceTitle ( $u ) ; |
| 499 | + $ret .= "<tr><td$color align=right nowrap>$cnt</td>" ; |
| 500 | + $ret .= "<td$color width=100% valign=top>[[$s->cur_title|$u]]</td></tr>\n"; |
| 501 | + if ( $color == $color1 ) $color = $color2 ; |
| 502 | + else $color = $color1 ; |
| 503 | + } |
| 504 | + $cnt++ ; |
| 505 | + } |
| 506 | + $ret .= "</table>\n" ; |
| 507 | + |
| 508 | + $ret .= "<nowiki>" ; |
| 509 | + $before = $startat - $perpage ; $fin = $before + $perpage - 1 ; |
| 510 | + if ( $startat > 1 ) $ret .= "<a href=\"$PHP_SELF?title=special:UserList&startat=$before\">$before-$fin<<</a> " ; |
| 511 | + $after = $startat + $perpage ; $fin = $after+$perpage - 1 ; if ( $fin > $total ) $fin = $total ; |
| 512 | + if ( $after-1 < $total ) $ret .= "<a href=\"$PHP_SELF?title=special:UserList&startat=$after\">>>$after-$fin</a>" ; |
| 513 | + $ret .= "</nowiki>" ; |
| 514 | + mysql_free_result ( $result ) ; |
| 515 | + mysql_close ( $connection ) ; |
| 516 | + return $ret ; |
| 517 | + } |
| 518 | + |
471 | 519 | function randompage () { |
472 | 520 | global $vpage ; |
473 | 521 | $connection=getDBconnection() ; |
— | — | @@ -892,4 +940,49 @@ |
893 | 941 | $ret .= $vpage->getQuickBar () ; |
894 | 942 | return $ret ; |
895 | 943 | } |
| 944 | + |
| 945 | +function ShortPages () { |
| 946 | + global $user , $vpage , $startat ; |
| 947 | + if ( !isset ( $startat ) ) $startat = 1 ; |
| 948 | + $perpage = $user->options["resultsPerPage"] ; |
| 949 | + if ( $perpage == 0 ) $perpage = 20 ; |
| 950 | + |
| 951 | + $vpage->special ( "Short 'stub' articles" ) ; |
| 952 | + $vpage->namespace = "" ; |
| 953 | + $ret = "'''These are all the articles in the database, sorted by length!'''\n\n" ; |
| 954 | + $connection = getDBconnection () ; |
| 955 | + mysql_select_db ( "wikipedia" , $connection ) ; |
| 956 | + $sql = "SELECT COUNT(*) AS number FROM cur" ; |
| 957 | + $result = mysql_query ( $sql , $connection ) ; |
| 958 | + $s = mysql_fetch_object ( $result ) ; |
| 959 | + $total = $s->number ; |
| 960 | + $sql = "SELECT * FROM cur ORDER BY LENGTH(cur_text)" ; |
| 961 | + $result = mysql_query ( $sql , $connection ) ; |
| 962 | + $cnt = 1 ; |
| 963 | + $color1 = $user->options["tabLine1"] ; |
| 964 | + $color2 = $user->options["tabLine2"] ; |
| 965 | + $color = $color1 ; |
| 966 | + $ret .= "<table width=100%>\n" ; |
| 967 | + while ( $s = mysql_fetch_object ( $result ) and $cnt < $startat+$perpage ) { |
| 968 | + if ( $cnt >= $startat ) { |
| 969 | + $ret .= "<tr><td$color align=right nowrap>$cnt</td>" ; |
| 970 | + $ret .= "<td$color align=right nowrap>(".strlen($s->cur_text)." chars)</td>\n" ; |
| 971 | + $ret .= "<td$color width=100% valign=top>[[$s->cur_title]]</td></tr>\n"; |
| 972 | + if ( $color == $color1 ) $color = $color2 ; |
| 973 | + else $color = $color1 ; |
| 974 | + } |
| 975 | + $cnt++ ; |
| 976 | + } |
| 977 | + $ret .= "</table>\n" ; |
| 978 | + |
| 979 | + $ret .= "<nowiki>" ; |
| 980 | + $before = $startat - $perpage ; $fin = $before + $perpage - 1 ; |
| 981 | + if ( $startat > 1 ) $ret .= "<a href=\"$PHP_SELF?title=special:ShortPages&startat=$before\">$before-$fin<<</a> " ; |
| 982 | + $after = $startat + $perpage ; $fin = $after+$perpage - 1 ; if ( $fin > $total ) $fin = $total ; |
| 983 | + if ( $after-1 < $total ) $ret .= "<a href=\"$PHP_SELF?title=special:ShortPages&startat=$after\">>>$after-$fin</a>" ; |
| 984 | + $ret .= "</nowiki>" ; |
| 985 | + mysql_free_result ( $result ) ; |
| 986 | + mysql_close ( $connection ) ; |
| 987 | + return $ret ; |
| 988 | + } |
896 | 989 | ?> |
\ No newline at end of file |
Index: trunk/phpwiki/fpw/wiki.phtml |
— | — | @@ -7,13 +7,19 @@ |
8 | 8 | |
9 | 9 | # Main program |
10 | 10 | global $action , $title , $pageTitle ; |
11 | | - global $user , $search ; |
| 11 | + global $user , $search , $expiration ; |
| 12 | + $expiration = time()+315360000 ; # Cookies set will expire in ten years from now |
12 | 13 | $pageTitle = "" ; |
13 | 14 | $user = new WikiUser ; |
14 | 15 | $user->scanCookies () ; |
15 | 16 | if ( $action == "" ) $action = "view" ; |
16 | 17 | if ( $title == "" ) $title = "HomePage" ; |
17 | 18 | |
| 19 | + $theTitle = new wikiTitle ; |
| 20 | + $theTitle->title = urldecode ( $title ) ; |
| 21 | + $theTitle->makeSecureTitle () ; |
| 22 | + $title = $theTitle->secureTitle ; |
| 23 | + |
18 | 24 | $action = strtolower ( trim ( $action ) ) ; |
19 | 25 | $title = urldecode ( $title ) ; |
20 | 26 | |
Index: trunk/phpwiki/fpw/wikiPage.php |
— | — | @@ -133,15 +133,17 @@ |
134 | 134 | if ( count($b) < 2 ) $s .= "Illegal link : ?$b[0]?" ; |
135 | 135 | else { |
136 | 136 | $c = explode ( "|" , $b[0] , 2 ) ; |
137 | | - if ( count ( $c ) == 1 ) array_push ( $c , $c[0] ) ; |
138 | 137 | $link = $c[0] ; |
139 | | - $text = $c[1] ; |
140 | 138 | |
141 | 139 | $topic = new WikiTitle ; |
142 | 140 | $topic->setTitle ( $link ) ; |
143 | 141 | $link = $this->getLinkTo ( $topic ) ; |
144 | 142 | $topic->setTitle ( $link ) ; |
145 | 143 | |
| 144 | + if ( count ( $c ) == 1 ) array_push ( $c , $topic->getNiceTitle($topic->secureTitle) ) ; |
| 145 | + $text = $c[1] ; |
| 146 | + |
| 147 | + |
146 | 148 | if ( $topic->doesTopicExist() ) { |
147 | 149 | $linkedLinks[$topic->secureTitle]++ ; |
148 | 150 | if ( $user->options["showHover"] == "yes" ) $hover = "title=\"$link\"" ; |
— | — | @@ -206,7 +208,7 @@ |
207 | 209 | function replaceVariables ( $s ) { |
208 | 210 | $var=date("m"); $s = str_replace ( "{{{CURRENTMONTH}}}" , $var , $s ) ; |
209 | 211 | $var=date("F"); $s = str_replace ( "{{{CURRENTMONTHNAME}}}" , $var , $s ) ; |
210 | | - $var=date("d"); $s = str_replace ( "{{{CURRENTDAY}}}" , $var , $s ) ; |
| 212 | + $var=date("j"); $s = str_replace ( "{{{CURRENTDAY}}}" , $var , $s ) ; |
211 | 213 | $var=date("l"); $s = str_replace ( "{{{CURRENTDAYNAME}}}" , $var , $s ) ; |
212 | 214 | $var=date("Y"); $s = str_replace ( "{{{CURRENTYEAR}}}" , $var , $s ) ; |
213 | 215 | if ( strstr ( $s , "{{{NUMBEROFARTICLES}}}" ) ) { |
— | — | @@ -250,7 +252,11 @@ |
251 | 253 | foreach ( $a as $x ) { |
252 | 254 | $b = spliti ( "</nowiki>" , $x , 2 ) ; |
253 | 255 | $s .= $b[0] ; |
254 | | - if ( count ( $b ) == 2 ) $s .= $this->subParseContents ( $b[1] ) ; |
| 256 | + if ( count ( $b ) == 2 ) { |
| 257 | + $sub = $this->subParseContents ( $b[1] ) ; |
| 258 | + $sub = substr ( strstr ( $sub , ">" ) , 1 ) ; |
| 259 | + $s .= $sub ; |
| 260 | + } |
255 | 261 | } |
256 | 262 | return $s ; |
257 | 263 | } |
— | — | @@ -361,7 +367,7 @@ |
362 | 368 | } |
363 | 369 | function getHeader () { |
364 | 370 | global $user , $action ; |
365 | | - $t = $this->title ; |
| 371 | + $t = $this->getNiceTitle ( $this->title ) ; |
366 | 372 | if ( substr_count ( $t , ":" ) > 0 ) $t = ucfirst ( $t ) ; |
367 | 373 | $ret = "<table ".$user->options["quickBarBackground"]." width=100% border=1 frame=below rules=none bordercolor=black cellspacing=0>\n<tr>" ; |
368 | 374 | if ( $user->options["leftImage"] != "" ) |
— | — | @@ -406,6 +412,8 @@ |
407 | 413 | $column .= "<br>\n<a href=\"$PHP_SELF?title=special:WantedPages\">Most wanted</a>" ; |
408 | 414 | $column .= "<br>\n<a href=\"$PHP_SELF?title=special:AllPages\">All pages</a>" ; |
409 | 415 | $column .= "<br>\n<a href=\"$PHP_SELF?title=special:RandomPage\">Random Page</a>" ; |
| 416 | + $column .= "<br>\n<a href=\"$PHP_SELF?title=special:ShortPages\">Stub articles</a>" ; |
| 417 | + $column .= "<br>\n<a href=\"$PHP_SELF?title=special:ListUsers\">List users</a>" ; |
410 | 418 | if ( $user->isLoggedIn ) { |
411 | 419 | $column .= "<br>\n<a href=\"$PHP_SELF?title=special:WatchList\">My watchlist</a>" ; |
412 | 420 | } |
Index: trunk/phpwiki/fpw/wikiUser.php |
— | — | @@ -88,6 +88,7 @@ |
89 | 89 | $this->skin () ; |
90 | 90 | } |
91 | 91 | function saveSettings () { |
| 92 | + global $expiration ; |
92 | 93 | if ( !$this->isLoggedIn ) return ; |
93 | 94 | $t = "" ; |
94 | 95 | $a = array_keys ( $this->options ) ; |
— | — | @@ -100,15 +101,15 @@ |
101 | 102 | setMySQL ( "user" , "user_options" , urlencode ( $t ) , "user_id=".$this->id ) ; |
102 | 103 | setMySQL ( "user" , "user_password" , $this->password , "user_id=".$this->id ) ; |
103 | 104 | setMySQL ( "user" , "user_email" , $this->email , "user_id=".$this->id ) ; |
104 | | - if ( $this->options["rememberPassword"] == "on" ) setcookie ( "WikiUserPassword" , $this->password ) ; |
| 105 | + if ( $this->options["rememberPassword"] == "on" ) setcookie ( "WikiUserPassword" , $this->password , $expiration ) ; |
105 | 106 | } |
106 | 107 | function getLink () { |
107 | 108 | global $REMOTE_ADDR ; |
108 | 109 | if ( $this->isLoggedIn ) { |
109 | 110 | $s = new WikiPage ; |
110 | | - $s->setTitle ( "user:$this->name" ) ; |
111 | | - $s = $s->parseContents ( "[[$this->name]]" ) ; |
112 | | - $s = str_replace ( "<p>" , "" , $s ) ; |
| 111 | +# $s->setTitle ( "user:$this->name" ) ; |
| 112 | + $s = $s->parseContents ( "[[user:$this->name|$this->name]]" ) ; |
| 113 | + $s = substr ( strstr ( $s , ">" ) , 1 ) ; |
113 | 114 | $s = str_replace ( "</p>" , "" , $s ) ; |
114 | 115 | return $s ; |
115 | 116 | } |
Index: trunk/phpwiki/fpw/wikiTitle.php |
— | — | @@ -45,11 +45,12 @@ |
46 | 46 | if ( $s != "" ) $s .= ":" ; |
47 | 47 | $s .= ucfirst ( trim ( $this->mainTitle ) ) ; |
48 | 48 | if ( trim ( $this->subpageTitle ) != "" ) $s .= "/".trim($this->subpageTitle) ; |
49 | | - $s = str_replace ( "\"" , "_" , $s ) ; |
| 49 | + $s = str_replace ( "\\\"" , "" , $s ) ; |
| 50 | + $s = str_replace ( "\"" , "" , $s ) ; |
50 | 51 | $s = str_replace ( "\\'" , "'" , $s ) ; |
51 | 52 | |
52 | 53 | # Make it compatible with old wiki |
53 | | - $s = str_replace ( "'" , "" , $s ) ; |
| 54 | +# $s = str_replace ( "'" , "" , $s ) ; |
54 | 55 | $s = str_replace ( " " , "_" , $s ) ; |
55 | 56 | |
56 | 57 | $this->secureTitle = $s ; |
— | — | @@ -61,7 +62,7 @@ |
62 | 63 | if ( !isset ( $s ) ) $s = $this->secureTitle ; |
63 | 64 | $s = str_replace ( "_" , " " , $s ) ; |
64 | 65 | $s = str_replace ( "\\'" , "'" , $s ) ; |
65 | | - $s = str_replace ( "\\\"" , "\"" , $s ) ; |
| 66 | + $s = str_replace ( "\\\\" , "\\" , $s ) ; |
66 | 67 | return ucfirst ( $s ) ; |
67 | 68 | } |
68 | 69 | function splitTitle () { |