| Index: trunk/phpwiki/wiki.phtml | ||
| — | — | @@ -0,0 +1,98 @@ |
| 2 | +<? | |
| 3 | +function getNiceTitle ( $s ) { | |
| 4 | + $s=str_replace("_"," ",$s); | |
| 5 | + return $s ; | |
| 6 | + } | |
| 7 | + | |
| 8 | +function stripNamespace ( $s ) { | |
| 9 | + $dbpos = strpos ( " ".$s , ':' ) ; | |
| 10 | + if ( $dbpos == true ) $s = substr ( $s , $dbpos ) ; | |
| 11 | + return $s ; | |
| 12 | + } | |
| 13 | + | |
| 14 | +function getNamespace ( $s ) { | |
| 15 | + $dbpos = strpos ( " ".$s , ':' ) ; | |
| 16 | + $ret = "" ; | |
| 17 | + if ( $dbpos == true ) $ret = substr ( $s , 0 , $dbpos-1 ) ; | |
| 18 | + return $ret ; | |
| 19 | + } | |
| 20 | + | |
| 21 | +function getSecureTitle ( $s ) { | |
| 22 | + $s = trim ( $s ) ; | |
| 23 | + $s=str_replace(" ","_",$s); | |
| 24 | + $s=str_replace ( "\\'" , "'" , $s ) ; | |
| 25 | + $s=ucfirst($s); | |
| 26 | + $dbpos = strpos ( " ".$s , ':' ) ; | |
| 27 | + if ( $dbpos == true ) $s = substr ($s,0,$dbpos-1).":".ucfirst(substr($s,$dbpos)) ; | |
| 28 | + return $s ; | |
| 29 | + } | |
| 30 | + | |
| 31 | + | |
| 32 | +require ( "./essential_functions.php" ) ; # Database password! | |
| 33 | +require ( "./user_functions.php" ) ; # User management | |
| 34 | +require ( "./database_functions.php" ) ; # Article database access | |
| 35 | +require ( "./parser_functions.php" ) ; # The parser | |
| 36 | +require ( "./rights_functions.php" ) ; # User rights management | |
| 37 | +require ( "./output_functions.php" ) ; # Headers, footers | |
| 38 | +require ( "./basic_functions.php" ) ; # View, edit | |
| 39 | +require ( "./higher_functions.php" ) ; # History, statistics etc. | |
| 40 | +require ( "./upload_functions.php" ) ; # Upload page | |
| 41 | + | |
| 42 | +############################# | |
| 43 | +# MAIN PROGRAM | |
| 44 | +############################# | |
| 45 | + global $title , $action , $doSearch , $xtitle ; | |
| 46 | + | |
| 47 | + if ( $title == "" ) $title="HomePage" ; | |
| 48 | + if ( $action == "" ) $action = "view" ; | |
| 49 | + | |
| 50 | + $ltitle = strtolower ( $title ) ; | |
| 51 | + $stitle = strtolower ( getSecureTitle ( $title ) ) ; | |
| 52 | + if ( $stitle == "recent_changes" ) $ltitle = "recentchanges" ; | |
| 53 | + if ( $stitle == "page_index" ) $action = "pageindex" ; | |
| 54 | + if ( $stitle == "random_page" ) $action = "random" ; | |
| 55 | + | |
| 56 | + $action = strtolower ( $action ) ; | |
| 57 | + if ( $action == "edited" && $preview ) $action="preview" ; | |
| 58 | + unset ( $preview ) ; | |
| 59 | + if ( $action == "view_old_article" and $oid == "current" ) $action = "view" ; | |
| 60 | + if ( $action == "view_old_source" and $oid == "current" ) $action = "edit" ; | |
| 61 | + | |
| 62 | + if ( $dosearch == 1 ) $action = "search" ; | |
| 63 | + | |
| 64 | + $xtitle = "Wikipedia page" ; | |
| 65 | + if ( $title != "" ) $xtitle = getNiceTitle ( $title ) ; | |
| 66 | + | |
| 67 | + if ( $ltitle == "recentchanges" ) $ret = showRecentChanges() ; | |
| 68 | + else if ( $dosearch == 1 ) $ret = doSearch () ; | |
| 69 | + else if ( $action == "statistics" ) $ret = statistics() ; | |
| 70 | + else if ( $action == "restrictions" ) $ret = restrictions() ; | |
| 71 | + else if ( $action == "edituserrights" ) $ret = editUserRights() ; | |
| 72 | + else if ( $action == "upload" ) $ret = doUpload() ; | |
| 73 | + else if ( $action == "pageindex" ) $ret = pageIndex() ; | |
| 74 | + else if ( $action == "random" ) $ret = randomPage() ; | |
| 75 | + else if ( $action == "prefs" ) $ret = prefs() ; | |
| 76 | + else if ( $action == "login" ) $ret = login() ; | |
| 77 | + else if ( $action == "loginattempt" ) $ret = loginattempt() ; | |
| 78 | + else if ( $action == "logout" ) $ret = logout() ; | |
| 79 | + else if ( $action == "view" ) $ret = view() ; | |
| 80 | + else if ( $action == "edit" ) $ret = edit() ; | |
| 81 | + else if ( $action == "preview" ) $ret = edit() ; | |
| 82 | + else if ( $action == "edited" ) $ret = edited() ; | |
| 83 | + else if ( $action == "revisions" ) $ret = revisions() ; | |
| 84 | + else if ( $action == "view_old_article" ) $ret = view_old_article( "parsed" ) ; | |
| 85 | + else if ( $action == "view_old_source" ) $ret = view_old_article( "source" ) ; | |
| 86 | + else { # No valid action! | |
| 87 | + $ret = "<font size=\"+4\">ILLEGAL COMMAND!</font><br>\n" ; | |
| 88 | + $ret .= "Return to the <a href=\"$PHP_SELF?no\">Main Page</a>" ; | |
| 89 | + } | |
| 90 | + | |
| 91 | + # Actual page output | |
| 92 | + print "<html>\n<head>\n<title>Wikipedia : $xtitle</title>\n</head>\n<body>" ; | |
| 93 | + print $ret ; | |
| 94 | + print "</body>\n</html>" ; | |
| 95 | + unset ( $oid ) ; | |
| 96 | + unset ( $doSearch ) ; | |
| 97 | + unset ( $editusername ) ; | |
| 98 | + unset ( $countDays ) ; | |
| 99 | +?> | |
| Property changes on: trunk/phpwiki/wiki.phtml | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 100 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 101 | + native |
| Added: svn:executable | ||
| 3 | 102 | + * |
| Index: trunk/phpwiki/parser_functions.php | ||
| — | — | @@ -0,0 +1,213 @@ |
| 2 | +<? | |
| 3 | +####################################################################### PARSER FUNCTIONS | |
| 4 | + | |
| 5 | +function replaceAllEntries ( $s , $f1 , $f2 , $r1 , $r2 ) { | |
| 6 | + $quit = false ; | |
| 7 | + while ( !$quit ) { | |
| 8 | + $pieces1=spliti($f1,$s,2); | |
| 9 | + if ( count($pieces1) < 2 ) $quit = true ; | |
| 10 | + else { | |
| 11 | + $pieces2=spliti($f2,$pieces1[1],2); | |
| 12 | + if ( count ( $pieces2 ) < 2 ) $quit = true ; | |
| 13 | + else { | |
| 14 | + $middle=$pieces2[0] ; | |
| 15 | + $s=$pieces1[0].$r1.$middle.$r2.$pieces2[1]; | |
| 16 | + } | |
| 17 | + } | |
| 18 | + } | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + return $s ; | |
| 23 | + } | |
| 24 | + | |
| 25 | +# DISPLAY PARSER ; INCOMPLETE!!!! | |
| 26 | +function parseContent ( $s ) { | |
| 27 | + global $title ; | |
| 28 | + if ( $s == "" ) $s = "Describe the new page here." ; | |
| 29 | + $s = str_replace ( "\r" , "" , $s ) ; | |
| 30 | + | |
| 31 | +# Automatic /Talk page | |
| 32 | +# if ( !strpos ( $title , "/" ) and !strpos ( $s , "/Talk" ) ) $s .= "\n----\n[[/Talk]]" ; | |
| 33 | + | |
| 34 | + $namespace = "" ; | |
| 35 | + $rtitle = $title ; | |
| 36 | + $dbpos = strpos ( $title , ":" ) ; | |
| 37 | + if ( $dbpos ) { | |
| 38 | + $namespace = substr ( $title , 0 , $dbpos ) ; | |
| 39 | + $rtitle = substr ( $title , $dbpos ) ; | |
| 40 | + } | |
| 41 | + | |
| 42 | + # Replace {{{variable}}} | |
| 43 | + $var=date("m"); $s = str_replace ( "{{{CURRENTMONTH}}}" , $var , $s ) ; | |
| 44 | + $var=date("F"); $s = str_replace ( "{{{CURRENTMONTHNAME}}}" , $var , $s ) ; | |
| 45 | + $var=date("d"); $s = str_replace ( "{{{CURRENTDAY}}}" , $var , $s ) ; | |
| 46 | + $var=date("l"); $s = str_replace ( "{{{CURRENTDAYNAME}}}" , $var , $s ) ; | |
| 47 | + $var=date("Y"); $s = str_replace ( "{{{CURRENTYEAR}}}" , $var , $s ) ; | |
| 48 | + | |
| 49 | + if ( strstr ( $s , "{{{NUMBEROFARTICLES}}}" ) ) { | |
| 50 | + $connection=getDBconnection() ; | |
| 51 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 52 | + $sql = "SELECT COUNT(*) as number FROM cur WHERE cur_title NOT LIKE \"%/Talk\" AND cur_title NOT LIKE \"%ikipedia%\" AND cur_text LIKE \"%,%\"" ; | |
| 53 | + $result = mysql_query ( $sql , $connection ) ; | |
| 54 | + $var = mysql_fetch_object ( $result ) ; | |
| 55 | + $var = $var->number ; | |
| 56 | + mysql_free_result ( $result ) ; | |
| 57 | + $s = str_replace ( "{{{NUMBEROFARTICLES}}}" , $var , $s ) ; | |
| 58 | + } | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + # Replace [[ and ]] with internal links | |
| 63 | + $tag1="\[\["; | |
| 64 | + $tag2="\]\]"; | |
| 65 | + while ( eregi($tag1,$s) && eregi($tag2,$s) ) { | |
| 66 | + $pieces1=spliti($tag1,$s,2); | |
| 67 | + $pieces2=spliti($tag2,$pieces1[1],2); | |
| 68 | + $middle=$pieces2[0] ; | |
| 69 | + $original = $middle ; | |
| 70 | + $linkto=getSecureTitle($middle); | |
| 71 | + | |
| 72 | + if ( strstr ( $middle , "|" ) ) { # show left part, link to right part | |
| 73 | + $pos = strpos ( $middle , "|" ) ; | |
| 74 | + $linkto = trim ( substr ( $middle , 0 , $pos ) ) ; | |
| 75 | + $middle = trim ( substr ( $middle , $pos+1 , 9999 ) ) ; | |
| 76 | + } | |
| 77 | + | |
| 78 | + if ( substr ( $linkto , 0 , 1 ) == "/" ) { | |
| 79 | + $p=spliti("/",$rtitle,2); | |
| 80 | + $linkto = $p[0].$linkto ; | |
| 81 | + } | |
| 82 | + | |
| 83 | + # Namespace | |
| 84 | + $dbpos = strpos ( " ".$linkto , ':' ) ; | |
| 85 | + if ( $dbpos == true ) { | |
| 86 | + if ( $dbpos == 1 ) $linkto = substr ( $linkto , 1 ) ; | |
| 87 | + } else { | |
| 88 | + if ( $namespace != "" ) $linkto = $namespace.":".$linkto ; | |
| 89 | + } | |
| 90 | + | |
| 91 | + if ( substr_count ( $linkto , "/" ) < 2 ) { | |
| 92 | + $st = strtolower ( getSecureTitle ( $linkto ) ) ; | |
| 93 | + if ( $st == "random_page" or $st == "page_index" ) $exists = true ; | |
| 94 | + else $exists = doesTopicExist($linkto) ; | |
| 95 | + if ( $exists ) $middle="<a href=\"$PHP_SELF?title=$linkto&action=view\">$middle</a>" ; | |
| 96 | + else { | |
| 97 | + if ( strstr($middle," ") ) $middle="[$middle]" ; | |
| 98 | + $middle="$middle<a href=\"$PHP_SELF?title=$linkto&action=edit\">?</a>" ; | |
| 99 | + } | |
| 100 | + } else $middle = "$original" ; | |
| 101 | + $s=$pieces1[0].$middle.$pieces2[1]; | |
| 102 | + } | |
| 103 | + | |
| 104 | + # Replace ''' | |
| 105 | + $s = replaceAllEntries ( $s , "'''" , "'''" , "<b>" , "</b>" ) ; | |
| 106 | + | |
| 107 | + | |
| 108 | + # Replace '' | |
| 109 | + $s = replaceAllEntries ( $s , "''" , "''" , "<i>" , "</i>" ) ; | |
| 110 | + | |
| 111 | + # Replace * | |
| 112 | + $s = replaceAllEntries ( $s , "\n\*" , "\n" , "<ul><li>" , "</li></ul>\n" ) ; | |
| 113 | + $s = replaceAllEntries ( $s , "<ul><li>\*" , "</li></ul>" , "<ul><li><ul><li>" , "</li></ul></li></ul>\n" ) ; | |
| 114 | + $s = str_replace ( "</ul>\n" , "</ul>" , $s ) ; | |
| 115 | + while ( strstr ( $s , "</li></ul><ul><li>" ) or strstr ( $s , "</li><li><ul>" ) ) { | |
| 116 | + $s = str_replace ( "</li></ul><ul><li>" , "</li><li>" , $s ) ; | |
| 117 | + $s = str_replace ( "</li><li><ul>" , "<ul>" , $s ) ; | |
| 118 | + } | |
| 119 | + | |
| 120 | + | |
| 121 | + # Replace # | |
| 122 | + $s = replaceAllEntries ( $s , "\n\#" , "\n" , "<ol><li>" , "</li></ol>\n" ) ; | |
| 123 | + $s = replaceAllEntries ( $s , "<ol><li>\#" , "</li></ol>" , "<ol><li><ol><li>" , "</li></ol></li></ol>\n" ) ; | |
| 124 | + $s = str_replace ( "</ol>\n" , "</ol>" , $s ) ; | |
| 125 | + while ( strstr ( $s , "</li></ol><ol><li>" ) or strstr ( $s , "</li><li><ol>" ) ) { | |
| 126 | + $s = str_replace ( "</li></ol><ol><li>" , "</li><li>" , $s ) ; | |
| 127 | + $s = str_replace ( "</li><li><ol>" , "<ol>" , $s ) ; | |
| 128 | + } | |
| 129 | + | |
| 130 | + # Courier | |
| 131 | + $s = replaceAllEntries ( $s , "\n " , "\n" , "\n <font face=\"courier\">" , "</font>\n" ) ; | |
| 132 | + | |
| 133 | + | |
| 134 | + # Line by line | |
| 135 | + $arr = explode ( "\n" , $s ) ; | |
| 136 | + $narr = array () ; | |
| 137 | + | |
| 138 | + $dp = false ; | |
| 139 | + foreach ( $arr as $x ) { | |
| 140 | + $y = $x ; | |
| 141 | + | |
| 142 | + # External images | |
| 143 | + while ( strstr ( $y , "http://" ) ) { | |
| 144 | + $pieces1 = spliti("http://",$y,2); | |
| 145 | + $pieces2 = spliti(" ",$pieces1[1],2); | |
| 146 | + $thelink = $pieces2[0] ; | |
| 147 | + $thetype = strtolower ( strrchr ( $thelink , "." ) ) ; | |
| 148 | + if ( $thetype == ".gif" or $thetype == ".png" or $thetype == ".jpg" or $thetype == ".tif" ) | |
| 149 | + $y = $pieces1[0]."<img src=\"~~HTTP~~".$thelink."\">".$pieces2[1] ; | |
| 150 | + else $y = $pieces1[0]."~~HTTP~~".$thelink." ".$pieces2[1] ; | |
| 151 | + } | |
| 152 | + $y = str_replace ( "~~HTTP~~" , "http://" , $y ) ; | |
| 153 | + | |
| 154 | + if ( substr ( $y , 0 , 1 ) == ":" ) { | |
| 155 | + $y = "<dt><dd>".substr ( $y , 1 , 99999 ) ; | |
| 156 | + if ( !$dp ) $y = "<DL>".$y ; | |
| 157 | + $dp = true ; | |
| 158 | + } else if ( $dp ) { | |
| 159 | + $y .= "</DL>" ; | |
| 160 | + $dp = false ; | |
| 161 | + } | |
| 162 | + if ( substr ( $y , 0 , 4 ) == "----" ) $y = "<hr>" ; | |
| 163 | + if ( substr ( $y , 0 , 4 ) == "<hr>" ) $footnote = 1 ; | |
| 164 | + | |
| 165 | + # Outside links | |
| 166 | + $footnote = 1 ; | |
| 167 | + $tag1="\[http://"; | |
| 168 | + $tag2="\]"; | |
| 169 | + while ( eregi($tag1,$y) && eregi($tag2,$y) ) { | |
| 170 | + $pieces1=spliti($tag1,$y,2); | |
| 171 | + $pieces2=spliti($tag2,$pieces1[1],2); | |
| 172 | + $linkto=trim($pieces2[0]) ; | |
| 173 | + | |
| 174 | + if ( strpos ( $linkto , " " ) ) { | |
| 175 | + $middle = substr ( $linkto , strpos ( $linkto , " " ) + 1 , 99999 ) ; | |
| 176 | + $linkto = substr ( $linkto , 0 , strpos ( $linkto , " " ) ) ; | |
| 177 | + } else { | |
| 178 | + $middle = $footnote ; | |
| 179 | + $footnote++ ; | |
| 180 | + } | |
| 181 | + | |
| 182 | + $y=$pieces1[0]."<a href=\"http://$linkto\">[$middle]</a>".$pieces2[1]; | |
| 183 | + } | |
| 184 | + | |
| 185 | + | |
| 186 | + if ( $y == "" ) $y = "</p><p>" ; | |
| 187 | + array_push ( $narr , $y ) ; | |
| 188 | + } | |
| 189 | + | |
| 190 | + $s = implode ( "\n" , $narr ) ; | |
| 191 | + | |
| 192 | + # Final | |
| 193 | + $s = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">".$s ; # Does this do anything good? | |
| 194 | + | |
| 195 | + return $s ; | |
| 196 | + } | |
| 197 | + | |
| 198 | +function getCurrentUserText () { | |
| 199 | + global $USERNAME , $USERPASSWORD , $USERLOGGEDIN ; | |
| 200 | + global $REMOTE_ADDR ; | |
| 201 | +# if ( $USERLOGGEDIN != "YES" and $USERNAME != "" and $USERPASSWORD != "" ) { | |
| 202 | +# if ( checkUserPassword ( $USERNAME , $USERPASSWORD ) ) setcookie ( "USERLOGGEDIN" , "YES" ) ; | |
| 203 | +# $USERLOGGEDIN = "YES" ; | |
| 204 | +# } | |
| 205 | + if ( $USERLOGGEDIN != "YES" or $USERNAME == "" ) { | |
| 206 | + $u = "$REMOTE_ADDR<br>\n<a href=\"$PHP_SELF?action=login\">log in</a>" ; | |
| 207 | + } | |
| 208 | + else { | |
| 209 | + $u = "$USERNAME<br>\n<a href=\"$PHP_SELF?action=logout\">log out</a>" ; | |
| 210 | + $u .= " <a href=\"$PHP_SELF?action=prefs\">Preferences</a>" ; | |
| 211 | + } | |
| 212 | + return $u ; | |
| 213 | + } | |
| 214 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/parser_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 215 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 216 | + native |
| Added: svn:executable | ||
| 3 | 217 | + * |
| Index: trunk/phpwiki/user_functions.php | ||
| — | — | @@ -0,0 +1,77 @@ |
| 2 | +<? | |
| 3 | +####################################################################### USER FUNCTIONS | |
| 4 | + | |
| 5 | +function getCurrentUserName () { | |
| 6 | + global $USERNAME , $USERPASSWORD , $USERLOGGEDIN ; | |
| 7 | + global $REMOTE_ADDR ; | |
| 8 | + if ( $USERLOGGEDIN == "YES" ) return $USERNAME ; | |
| 9 | + else return $REMOTE_ADDR ; | |
| 10 | + } | |
| 11 | + | |
| 12 | +function doesUserExist ( $un ) { | |
| 13 | + $connection=getDBconnection() ; | |
| 14 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 15 | + $sql = "SELECT * FROM user WHERE user_name=\"$un\"" ; | |
| 16 | + $result = mysql_query ( $sql , $connection ) ; | |
| 17 | + if ( $s = mysql_fetch_object ( $result ) ) $ret = true ; | |
| 18 | + else $ret = false ; | |
| 19 | + mysql_free_result ( $result ) ; | |
| 20 | + mysql_close ( $connection ) ; | |
| 21 | + return $ret ; | |
| 22 | + } | |
| 23 | + | |
| 24 | +function getUserSetting ( $un , $s ) { | |
| 25 | + $connection=getDBconnection() ; | |
| 26 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 27 | + $sql = "SELECT * FROM user WHERE user_name=\"$un\"" ; | |
| 28 | + $result = mysql_query ( $sql , $connection ) ; | |
| 29 | + $t = mysql_fetch_object ( $result ) ; | |
| 30 | + $ret = $t->$s ; | |
| 31 | + mysql_free_result ( $result ) ; | |
| 32 | + mysql_close ( $connection ) ; | |
| 33 | + return $ret ; | |
| 34 | + } | |
| 35 | + | |
| 36 | +function changeUserSetting ( $un , $s , $v ) { | |
| 37 | + $connection=getDBconnection() ; | |
| 38 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 39 | + $sql = "UPDATE user SET $s = \"$v\" WHERE user_name = \"$un\"" ; | |
| 40 | + $result = mysql_query ( $sql , $connection ) ; | |
| 41 | + mysql_close ( $connection ) ; | |
| 42 | + } | |
| 43 | + | |
| 44 | +function checkUserPassword ( $un , $up ) { | |
| 45 | + $connection=getDBconnection() ; | |
| 46 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 47 | + $sql = "SELECT * FROM user WHERE user_name=\"$un\" AND user_password=\"$up\"" ; | |
| 48 | + $result = mysql_query ( $sql , $connection ) ; | |
| 49 | + if ( $s = mysql_fetch_object ( $result ) ) { | |
| 50 | + setcookie ( "USERID" , "$s->user_id" ) ; | |
| 51 | + $ret = true ; | |
| 52 | + } | |
| 53 | + else $ret = false ; | |
| 54 | + mysql_free_result ( $result ) ; | |
| 55 | + mysql_close ( $connection ) ; | |
| 56 | + return $ret ; | |
| 57 | + } | |
| 58 | + | |
| 59 | +function addNewUser ( $un , $up , $ur ) { | |
| 60 | + if ( doesUserExist ( $un ) ) return ; | |
| 61 | + $connection=getDBconnection() ; | |
| 62 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 63 | + $sql = "INSERT INTO user (user_name, user_password, user_rights) VALUES (\"$un\", \"$up\", \"$ur\")" ; | |
| 64 | + $result = mysql_query ( $sql , $connection ) ; | |
| 65 | + | |
| 66 | + $sql = "SELECT * FROM user WHERE user_name=\"$un\"" ; | |
| 67 | + $result = mysql_query ( $sql , $connection ) ; | |
| 68 | + $s = mysql_fetch_object ( $result ) ; | |
| 69 | + setcookie ( "USERNAME" , "$s->user_name" ) ; | |
| 70 | + setcookie ( "USERPASSWORD" , "$s->user_password" ) ; | |
| 71 | + setcookie ( "USERID" , "$s->user_id" ) ; | |
| 72 | + setcookie ( "USERLOGGEDIN" , "YES" ) ; | |
| 73 | + mysql_free_result ( $result ) ; | |
| 74 | + | |
| 75 | + mysql_close ( $connection ) ; | |
| 76 | + } | |
| 77 | + | |
| 78 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/user_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 79 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 80 | + native |
| Added: svn:executable | ||
| 3 | 81 | + * |
| Index: trunk/phpwiki/niki.phtml | ||
| — | — | @@ -0,0 +1,12 @@ |
| 2 | +<html> | |
| 3 | + | |
| 4 | +<head> | |
| 5 | +<META HTTP-EQUIV=Refresh CONTENT="2; URL=./wiki.phtml"> | |
| 6 | +</head> | |
| 7 | + | |
| 8 | +<body> | |
| 9 | +<h1>This page will forward to wiki.phtml</h1> | |
| 10 | +Please update your bookmarks! | |
| 11 | +</body> | |
| 12 | + | |
| 13 | +</html> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/niki.phtml | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 14 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 15 | + native |
| Added: svn:executable | ||
| 3 | 16 | + * |
| Index: trunk/phpwiki/output_functions.php | ||
| — | — | @@ -0,0 +1,102 @@ |
| 2 | +<? | |
| 3 | +####################################### | |
| 4 | +# OUTPUT PROCEDURES | |
| 5 | +####################################### | |
| 6 | + | |
| 7 | +function getHeaderFooterParts () { | |
| 8 | + global $title , $action , $oid , $whichOldVersion , $dosearch ; | |
| 9 | + global $USERNAME ; | |
| 10 | + | |
| 11 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 12 | + $ret = "" ; | |
| 13 | + | |
| 14 | + $special = false ; | |
| 15 | + if ( $title == "recentchanges" ) $special = true ; | |
| 16 | + if ( $action == "revisions" or $action == "statistics" or $action == "restrictions" ) $special = true ; | |
| 17 | + if ( $action == "prefs" or $action == "upload" or $action == "edituserrights" or $dosearch == 1 ) $special = true ; | |
| 18 | + | |
| 19 | + $ret .= "<a href=\"$PHP_SELF?title=HomePage&action=view\">Home page</a> | " ; | |
| 20 | + $ret .= "<a href=\"$PHP_SELF?title=recentchanges&action=view\">Recent changes</a>" ; | |
| 21 | + $ret .= " | <a href=\"$PHP_SELF?action=random\">Random page</a>" ; | |
| 22 | + if ( !$special ) $ret .= " | <a href=\"$PHP_SELF?title=$secureTitle&action=revisions\">History</a>" ; | |
| 23 | + if ( !$special and strstr ( $title , "/" ) ) { | |
| 24 | + $parent = substr($title , 0 , strrpos($title,"/")) ; | |
| 25 | + $sparent = getSecureTitle ( $parent ) ; | |
| 26 | + $ret .= " | <a href=\"$PHP_SELF?title=$sparent&action=view\">$parent</a>" ; | |
| 27 | + } | |
| 28 | + | |
| 29 | + if ( $action == "view" and !$special and canEdit($title) ) $ret .= " | <a href=\"$PHP_SELF?title=$secureTitle&action=edit\">Edit this page</a>" ; | |
| 30 | + if ( $action == "view_old_article" ) $ret .= " | <a href=\"$PHP_SELF?title=$secureTitle&action=view_old_source&oid=$oid&whichOldVersion=$whichOldVersion\">View this source</a>" ; | |
| 31 | + if ( $action == "view_old_source" ) $ret .= " | <a href=\"$PHP_SELF?title=$secureTitle&action=view_old_article&oid=$oid&whichOldVersion=$whichOldVersion\">View this article</a>" ; | |
| 32 | + $ret .= " | <a href=\"$PHP_SELF?action=upload\">Upload files</a>" ; | |
| 33 | + if ( $action != "statistics" ) $ret .= " | <a href=\"$PHP_SELF?action=statistics\">Statistics</a>" ; | |
| 34 | + | |
| 35 | + if ( !$special and canRestrict($title) ) $ret .= " | <a href=\"$PHP_SELF?title=$secureTitle&action=restrictions\">Change restrictions</a>" ; | |
| 36 | + | |
| 37 | + return $ret ; | |
| 38 | + } | |
| 39 | + | |
| 40 | +function getStandardHeader () { | |
| 41 | + global $title , $action , $oid , $whichOldVersion , $dosearch , $search ; | |
| 42 | + global $USERNAME ; | |
| 43 | + | |
| 44 | + $restrictions="" ; | |
| 45 | + if ( $action == "view" ) { | |
| 46 | + $restrictions = getTopicSetting ( $title , "cur_restrictions" ) ; | |
| 47 | + if ( $restrictions == "NOSUCHTHING" ) $restrictions = "" ; | |
| 48 | + if ( $restrictions != "" ) | |
| 49 | + $restrictions = "<font color=red>Restrictions on this page : ".$restrictions."</font>" ; | |
| 50 | + } | |
| 51 | + | |
| 52 | + $special = false ; | |
| 53 | + if ( $title == "recentchanges" ) $special = true ; | |
| 54 | + if ( $action == "revisions" or $action == "statistics" or $action == "restrictions" ) $special = true ; | |
| 55 | + if ( $action == "prefs" or $action == "upload" or $action == "edituserrights" or $dosearch == 1 ) $special = true ; | |
| 56 | + | |
| 57 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 58 | + $hversion = "" ; | |
| 59 | + if ( $action == "view_old_article" or $action == "view_old_source" ) $hversion = " (Older version #$whichOldVersion)" ; | |
| 60 | + | |
| 61 | + $userName = getCurrentUserText () ; | |
| 62 | + | |
| 63 | + $hpre = "<table width=\"100%\"><tr><td valign=top><font size=\"+3\">" ; | |
| 64 | + $hpost = "</font></td><td align=right nowrap><font color=red>User : $userName</font><br>"; | |
| 65 | + $hpost .= "</td><td rowspan=3 width=1><a href=\"$PHP_SELF/call\"><img border=0 src=\"wiki.jpg\"></a></td></tr>"; | |
| 66 | + $hpost .= "<tr><td valign=top>".getHeaderFooterParts()."<br>$restrictions</td>" ; | |
| 67 | + $hpost .= "<td valign=top align=right nowrap><FORM>Search: <INPUT TYPE=text NAME=search SIZE=20><INPUT TYPE=hidden NAME=dosearch VALUE=1></FORM></td>" ; | |
| 68 | + $hpost .= "</tr><tr><td colspan=2><hr></td>" ; | |
| 69 | + $hpost .= "</tr></table>" ; | |
| 70 | + | |
| 71 | + $ntitle = getNiceTitle ( $title ) ; | |
| 72 | + if ( $search != "" ) $asearch = "Search results for \"$search\" :" ; | |
| 73 | + else $asearch = "All pages index :" ; | |
| 74 | + | |
| 75 | + if ( $action == "view" or $action == "view_old_article" or $action == "view_old_source" or $special ) { | |
| 76 | + if ( $title == "recentchanges" ) $thebody = "Recent Changes" ; | |
| 77 | + else if ( $action == "revisions" ) $thebody = "History of $ntitle" ; | |
| 78 | + else if ( $action == "upload" ) $thebody = "Upload page" ; | |
| 79 | + else if ( $dosearch == 1 ) $thebody = $asearch ; | |
| 80 | + else if ( $action == "statistics" ) $thebody = "Statistics (".date("l, F d, Y H:i:s").", PST)" ; | |
| 81 | + else if ( $action == "edituserrights" ) $thebody = "Edit user access rights here" ; | |
| 82 | + else if ( $action == "restrictions" ) $thebody = "Restrictions of $ntitle" ; | |
| 83 | + else if ( $action == "prefs" ) $thebody = "Preferences for $USERNAME" ; | |
| 84 | + else $thebody = "<a href=\"$PHP_SELF?$action=search&search=$secureTitle&dosearch=1\">$ntitle</a>$hversion" ; | |
| 85 | + $head = $hpre.$thebody.$hpost ; | |
| 86 | + } else if ( $action == "edit" or $action == "preview" ) { | |
| 87 | + $head = $hpre."Editing $ntitle".$hpost ; | |
| 88 | + } | |
| 89 | + | |
| 90 | + return $head ; | |
| 91 | + } | |
| 92 | + | |
| 93 | +function getStandardFooter () { | |
| 94 | + global $title ; | |
| 95 | + $ret = "<hr>" ; | |
| 96 | + $ret .= getHeaderFooterParts () ; | |
| 97 | + $rtitle = stripNamespace ( $title ) ; | |
| 98 | + $namespaces = getAllNamespaces ( $rtitle ) ; | |
| 99 | + if ( $namespaces != "" ) $ret .= "<br><font color=green>Namespaces : </font>".$namespaces ; | |
| 100 | + $ret .= "<FORM>Search: <INPUT TYPE=text NAME=search SIZE=20><INPUT TYPE=hidden NAME=dosearch VALUE=1></FORM>" ; | |
| 101 | + return $ret ; | |
| 102 | + } | |
| 103 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/output_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 104 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 105 | + native |
| Added: svn:executable | ||
| 3 | 106 | + * |
| Index: trunk/phpwiki/rights_functions.php | ||
| — | — | @@ -0,0 +1,85 @@ |
| 2 | +<? | |
| 3 | +########### RIGHTS MANAGEMENT | |
| 4 | + | |
| 5 | +function canEditInNamespace ( $t ) { | |
| 6 | + $t = getSecureTitle ( $t ) ; | |
| 7 | + global $USERLOGGEDIN , $USERNAME ; | |
| 8 | + if ( $USERLOGGEDIN != "YES" ) return "You are not logged in! You have to be logged in to edit file. <a href=\"$PHP_SELF?action=login\">Log in</a> or return to the <a href=\"$PHP_SELF?no\">HomePage</a>" ; | |
| 9 | + $ret = "" ; | |
| 10 | + $rights = ",".getUserSetting ( $USERNAME , "user_rights" )."," ; | |
| 11 | + | |
| 12 | + $namespace = strtolower ( getNamespace ( $t ) ) ; | |
| 13 | + if ( $namespace == "" or $namespace == "talk" or $namespace == "wiki" or $namespace == "user" ) $ret = "" ; | |
| 14 | + else if ( doesNamespaceExist ( $namespace ) == false ) { # Trying to create a new namespace | |
| 15 | + if ( !strstr ( $rights , ",is_sysop," ) ) | |
| 16 | + $ret = "<h1>Access denied</h1>Namespace \"$namespace\" does not exist. Only sysops are authorized to create new namespaces." ; | |
| 17 | + } | |
| 18 | + else { # Any other namespace than blank, talk, wiki or user | |
| 19 | + if ( strstr ( $rights , ",is_editor," ) or strstr ( $rights , ",is_sysop," ) ) $ret = "" ; | |
| 20 | + else $ret = "<h1>Access denied</h1>You are neither an editor nor a sysop, so you cannot edit articles in namespace \"$namespace\"." ; | |
| 21 | + } | |
| 22 | + | |
| 23 | + return $ret ; | |
| 24 | + } | |
| 25 | + | |
| 26 | +function canEdit( $tt ) { | |
| 27 | + global $USERNAME , $USERLOGGEDIN , $action ; | |
| 28 | + $restrictions = getTopicSetting ( $tt , "cur_restrictions" ) ; | |
| 29 | + if ( $restrictions == "" ) return true ; # No restrictions, OK to edit for everyone | |
| 30 | + if ( $restrictions == "NOSUCHTHING" ) { | |
| 31 | + $stt = strtolower ( $tt ) ; | |
| 32 | + if ( $stt == "recentchanges" ) return false ; | |
| 33 | + if ( $action == "revisions" ) return false ; | |
| 34 | + if ( $action == "statistics" ) return false ; | |
| 35 | + if ( $action == "restrictions" ) return false ; | |
| 36 | + if ( $action == "prefs" ) return false ; | |
| 37 | + return true ; # New topic | |
| 38 | + } | |
| 39 | + if ( $USERLOGGEDIN != "YES" ) return false ; # Restrictions, but not logged in -> No edit, bad dog! | |
| 40 | + $resArr = explode ( "," , $restrictions ) ; | |
| 41 | + $rights = ",".getUserSetting ( $USERNAME , "user_rights" )."," ; | |
| 42 | + | |
| 43 | + $allowed = false ; | |
| 44 | + foreach ( $resArr as $x ) { | |
| 45 | + $y = ",is_$x," ; | |
| 46 | + if ( strstr ( $rights , $y ) ) $allowed = true ; | |
| 47 | + } | |
| 48 | + return $allowed ; | |
| 49 | + } | |
| 50 | + | |
| 51 | +function canRestrict ( $tt ) { | |
| 52 | + global $USERNAME , $USERLOGGEDIN , $dosearch ; | |
| 53 | + if ( $USERLOGGEDIN != "YES" ) return false ; # Not logged in | |
| 54 | + if ( $dosearch == 1 ) return false ; # Search page | |
| 55 | + if ( !doesTopicExist ( $tt ) ) return false ; # No such topic | |
| 56 | + $rights = ",".getUserSetting ( $USERNAME , "user_rights" )."," ; | |
| 57 | + $allowed = false ; | |
| 58 | + if ( strstr ( $rights , ",is_editor," ) ) $allowed = true ; | |
| 59 | + if ( strstr ( $rights , ",is_sysop," ) ) $allowed = true ; | |
| 60 | + return $allowed ; | |
| 61 | + } | |
| 62 | + | |
| 63 | +######## APPLY RESTRICTIONS TO AN ARTICLE | |
| 64 | +function restrictions () { | |
| 65 | + global $title , $therestrictions ; | |
| 66 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 67 | + if ( !canRestrict ( $title ) ) return "You are not allowed to restrict this article. Follow <a href=\"$PHP_SELF?title=$secureTitle\">this link</a> to go back." ; | |
| 68 | + | |
| 69 | + if ( isset ( $therestrictions ) ) { | |
| 70 | + changeTopicSetting ( $title , "cur_restrictions" , $therestrictions ) ; | |
| 71 | + $ret="<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$PHP_SELF?title=$title&action=view\">" ; | |
| 72 | + unset ( $therestrictions ) ; | |
| 73 | + } else { | |
| 74 | + $ret = "" ; | |
| 75 | + $ret .= getStandardHeader () ; | |
| 76 | + $r = getTopicSetting ( $title , "cur_restrictions" ) ; | |
| 77 | + $ret .= "<FORM action=\"$PHP_SELF?title=$title&action=restrictions\" method=post>\n" ; | |
| 78 | + $ret .= "Restrictions : <INPUT TABINDEX=1 TYPE=text NAME=therestrictions VALUE=\"$r\" SIZE=80><br>\n" ; | |
| 79 | + $ret .= "<INPUT TYPE=SUBMIT NAME=changeprefs value=\"Save new restrictions\">\n" ; | |
| 80 | + $ret .= "</FORM>\n" ; | |
| 81 | + } | |
| 82 | + | |
| 83 | + return $ret ; | |
| 84 | + } | |
| 85 | + | |
| 86 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/rights_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 87 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 88 | + native |
| Added: svn:executable | ||
| 3 | 89 | + * |
| Index: trunk/phpwiki/basic_functions.php | ||
| — | — | @@ -0,0 +1,223 @@ |
| 2 | +<? | |
| 3 | +############################################ | |
| 4 | +# BASIC FUNCTIONS | |
| 5 | +############################################ | |
| 6 | + | |
| 7 | +function view () { | |
| 8 | + global $title , $action ; | |
| 9 | + $content = acquireTopic ( $title ) ; | |
| 10 | + if ( strtolower ( substr ( $content , 0 , 9 ) ) == "#redirect" ) { | |
| 11 | + $pieces1=spliti("\[\[",$content,2); | |
| 12 | + $pieces2=spliti("\]\]",$pieces1[1],2); | |
| 13 | + $thelink=getSecureTitle($pieces2[0]) ; | |
| 14 | + $otitle = $title ; | |
| 15 | + $title = $thelink ; | |
| 16 | + $content="<font color=green>[Redirected from <b>$otitle</b>]</font><hr>".acquireTopic ( $title ) ; | |
| 17 | + } | |
| 18 | + $content = parseContent ( $content ) ; | |
| 19 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 20 | + $head = getStandardHeader () ; | |
| 21 | + $content = $head.$content."\n" ; | |
| 22 | + $content .= getStandardFooter () ; | |
| 23 | + return $content ; | |
| 24 | + } | |
| 25 | + | |
| 26 | +function view_old_article ( $mode="parsed" ) { | |
| 27 | + global $title , $action , $oid ; | |
| 28 | + if ( $oid == "" ) return "NO OID GIVEN" ; | |
| 29 | + | |
| 30 | + $content = acquireOldTopic ( $title , $oid ) ; | |
| 31 | + if ( $mode == "parsed" ) | |
| 32 | + $content = parseContent ( $content ) ; | |
| 33 | + else if ( $mode == "source" ) | |
| 34 | + $content = "<textarea name=newtext rows=20 cols=65 STYLE=\"width:100%\" wrap=virtual>$content</textarea>" ; | |
| 35 | + | |
| 36 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 37 | + $head = getStandardHeader () ; | |
| 38 | + | |
| 39 | + $content = $head.$content ; | |
| 40 | + $content .= getStandardFooter () ; | |
| 41 | + | |
| 42 | + return $content ; | |
| 43 | + } | |
| 44 | + | |
| 45 | +function edit () { | |
| 46 | + global $title , $action ; | |
| 47 | + global $newtext , $comment , $recent_edit ; | |
| 48 | + | |
| 49 | + if ( ! $comment ) $comment = "*" ; | |
| 50 | + if ( $recent_edit ) $recent_edit = "on" ; | |
| 51 | + else $recent_edit = "off" ; | |
| 52 | + | |
| 53 | + $realTitle=$title ; | |
| 54 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 55 | + | |
| 56 | + # Checking clearance | |
| 57 | + if ( !canEdit($title) ) return "You are not allowed to edit this article. Follow <a href=\"$PHP_SELF?title=$secureTitle\">this link</a> to go back." ; | |
| 58 | + | |
| 59 | + $cein = canEditInNamespace ( $title ) ; | |
| 60 | + if ( $cein != "" ) return $cein ; | |
| 61 | + | |
| 62 | + if ( $newtext ) { | |
| 63 | + $content = $newtext ; | |
| 64 | + $content = str_replace ( "\\\"" , "\"" , $content ) ; | |
| 65 | + $content = str_replace ( "\\'" , "'" , $content ) ; | |
| 66 | + } | |
| 67 | + else $content = acquireTopic ( $title ) ; | |
| 68 | + | |
| 69 | + $content = str_replace ( "\r" , "" , $content ) ; | |
| 70 | + | |
| 71 | + $source = $content ; | |
| 72 | + | |
| 73 | + $head = getStandardHeader () ; | |
| 74 | + $head .= "<form action=\"$PHP_SELF?title=$title&action=edited\" method=post>\n"; | |
| 75 | + | |
| 76 | + if ( $content == "" ) $content = "Describe the new page here.\n" ; | |
| 77 | + | |
| 78 | + $content = "<textarea name=newtext rows=20 cols=65 STYLE=\"width:100%\" wrap=virtual>$content</textarea><br>\n" ; | |
| 79 | + | |
| 80 | + $content .= "Summary:<INPUT TYPE=text NAME=comment VALUE=\"$comment\" SIZE=60 MAXLENGTH=200><br>\n" ; | |
| 81 | + $content .= "<INPUT TYPE=checkbox NAME=\"minor_edit\" VALUE=\"on\">This change is a minor edit.<br>\n" ; | |
| 82 | + $content .= "<input type=submit name=save value=\"Save changes\">\n" ; | |
| 83 | + $content .= "<input type=submit name=preview value=\"Preview changes\">\n" ; | |
| 84 | + | |
| 85 | + $content .= "</form>\n" ; | |
| 86 | + | |
| 87 | + if ( $action=="preview" ) { | |
| 88 | + $source = parseContent ( $source ) ; | |
| 89 | + $content .= "<hr>\n" ; | |
| 90 | + $content .= "<font size=\"+3\">PREVIEW</font><br><br>\n" ; | |
| 91 | + $content .= $source ; | |
| 92 | + $content .= "\n<hr><b>Remember, this is just a preview!</b>\n" ; | |
| 93 | + } | |
| 94 | + | |
| 95 | + unset ( $recent_edit ) ; | |
| 96 | + unset ( $comment ) ; | |
| 97 | + unset ( $newtext ) ; | |
| 98 | + | |
| 99 | + $content = $head.$content ; | |
| 100 | + return $content ; | |
| 101 | + } | |
| 102 | + | |
| 103 | +function edited () { | |
| 104 | + global $action , $preview , $title , $save ; | |
| 105 | + global $newtext , $comment , $minor_edit ; | |
| 106 | + | |
| 107 | + $cein = canEditInNamespace ( $title ) ; | |
| 108 | + if ( $cein != "" ) return $cein ; | |
| 109 | + | |
| 110 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 111 | + # Checking clearance | |
| 112 | + if ( !canEdit($title) ) return "You are not allowed to edit this article. Follow <a href=\"$PHP_SELF?title=$secureTitle\">this link</a> to go back." ; | |
| 113 | + | |
| 114 | + if ( doesTopicExist ( $title ) ) { | |
| 115 | + # Backup old version | |
| 116 | + backupTopic ( $title ) ; | |
| 117 | + } else { | |
| 118 | + # New topic | |
| 119 | + addPlainTopic ( $title ) ; | |
| 120 | + } | |
| 121 | + | |
| 122 | + saveTopic ( $newtext , $comment , $minor_edit ) ; | |
| 123 | + | |
| 124 | + unset ( $preview ) ; | |
| 125 | + unset ( $newtext ) ; | |
| 126 | + unset ( $save ) ; | |
| 127 | + | |
| 128 | + $action="view" ; | |
| 129 | + $ret="<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$PHP_SELF?title=$title&action=view\">" ; | |
| 130 | + return $ret ; | |
| 131 | + } | |
| 132 | + | |
| 133 | +function MySQLtimestamp ( $edit_time ) { | |
| 134 | + if ( $edit_time == "" ) return "<unknown>" ; | |
| 135 | + $qh = substr ( $edit_time , 8 , 2 ) ; | |
| 136 | + $qm = substr ( $edit_time , 10 , 2 ) ; | |
| 137 | + $qs = substr ( $edit_time , 12 , 2 ) ; | |
| 138 | + $qo = substr ( $edit_time , 4 , 2 ) ; | |
| 139 | + $qd = substr ( $edit_time , 6 , 2 ) ; | |
| 140 | + $qy = substr ( $edit_time , 0 , 4 ) ; | |
| 141 | + $edit_time = date ( "H:i:s" , mktime ( $qh , $qm , $qs , $qo , $qd , $qy ) ) ; | |
| 142 | + return $edit_time ; | |
| 143 | + } | |
| 144 | + | |
| 145 | +function MySQLdatestamp ( $edit_date ) { | |
| 146 | + if ( $edit_date == "" ) return "<unknown>" ; | |
| 147 | + $qh = substr ( $edit_date , 8 , 2 ) ; | |
| 148 | + $qm = substr ( $edit_date , 10 , 2 ) ; | |
| 149 | + $qs = substr ( $edit_date , 12 , 2 ) ; | |
| 150 | + $qo = substr ( $edit_date , 4 , 2 ) ; | |
| 151 | + $qd = substr ( $edit_date , 6 , 2 ) ; | |
| 152 | + $qy = substr ( $edit_date , 0 , 4 ) ; | |
| 153 | + $edit_date = date ( "F d, Y" , mktime ( $qh , $qm , $qs , $qo , $qd , $qy ) ) ; | |
| 154 | + return $edit_date ; | |
| 155 | + } | |
| 156 | + | |
| 157 | +function currentMySQLtime () { | |
| 158 | + return date ( "YmdHis" ) ; | |
| 159 | + } | |
| 160 | + | |
| 161 | +function login () { | |
| 162 | + global $USERNAME , $USERPASSWORD , $USERLOGGEDIN , $USER_REMEMBER_PASSWORD ; | |
| 163 | + $ret = "<font size=\"+3\">Log in</font><hr>\n" ; | |
| 164 | + if ( $USERLOGGEDIN == "YES" ) $ret .= "$USERNAME, you are already logged in!<br>\n" ; | |
| 165 | + $ret .= "<FORM action=\"$PHP_SELF?action=loginattempt\" method=post><font face=courier>\n" ; | |
| 166 | + $ret .= "Your current user name : <INPUT TABINDEX=1 TYPE=text NAME=user_name VALUE=\"$USERNAME\" SIZE=20><br>\n" ; | |
| 167 | + | |
| 168 | + $pwd = $USERPASSWORD ; | |
| 169 | + if ( !doesUserExist($USERNAME) ) $pwd = "" ; | |
| 170 | + | |
| 171 | + $ret .= "Your current password : <INPUT TABINDEX=2 TYPE=password NAME=user_password VALUE=\"$pwd\" SIZE=20><br>\n" ; | |
| 172 | + $ret .= "<INPUT TABINDEX=3 TYPE=checkbox NAME=USER_REMEMBER_PASSWORD value=$USER_REMEMBER_PASSWORD>Remember my password (as a cookie).<br>\n" ; | |
| 173 | + $ret .= "<input TABINDEX=4 type=submit name=dologin value=\"Log in\">\n" ; | |
| 174 | + $ret .= "</font></FORM>\n" ; | |
| 175 | + $ret .= "<hr>Return to the <a href=\"$PHP_SELF?no\">Main Page</a> without logging in" ; | |
| 176 | + | |
| 177 | + return $ret ; | |
| 178 | + } | |
| 179 | + | |
| 180 | +function loginattempt () { | |
| 181 | + global $user_name , $user_password , $user_remember_password , $newuser ; | |
| 182 | + global $USERNAME , $USERPASSWORD , $USERLOGGEDIN , $USER_REMEMBER_PASSWORD ; | |
| 183 | + | |
| 184 | + if ( $newuser == "YES" and !doesUserExist ( $user_name ) ) { | |
| 185 | + addNewUser ( $user_name , $user_password , "" ) ; | |
| 186 | + $ret .= "Congratulations, $user_name! You were added to the user list.<br>\n" ; | |
| 187 | + $ret .= "Check your preferences <a href=\"$PHP_SELF?action=prefs\">here</a>!<br>\n" ; | |
| 188 | + $ret .= "Or go directly to the <a href=\"$PHP_SELF?no\">Main Page</a>.\n" ; | |
| 189 | + } else if ( checkUserPassword ( $user_name , $user_password ) ) { # Correct log-in | |
| 190 | + setcookie ( "USERNAME" , $user_name ) ; | |
| 191 | + setcookie ( "USER_REMEMBER_PASSWORD" , $USER_REMEMBER_PASSWORD ) ; | |
| 192 | + if ( $user_remember_password == "on" ) setcookie ( "USERPASSWORD" , $user_password ) ; | |
| 193 | + else setcookie ( "USERPASSWORD" , "" ) ; | |
| 194 | + setcookie ( "USERLOGGEDIN" , "YES" ) ; | |
| 195 | + $USERNAME = $user_name ; | |
| 196 | + $ret .= "$USERNAME, you have been successfully logged in!<br>\n" ; | |
| 197 | + $ret .= "<hr>Return to the <a href=\"$PHP_SELF?no\">Main Page</a>" ; | |
| 198 | + } else { #Wrong log-in | |
| 199 | + $ret .= "Sorry, your login was incorrect. You can :<br>\n" ; | |
| 200 | + $ret .= "- <a href=\"$PHP_SELF?action=login\">Try again</a>.<br>\n" ; | |
| 201 | + $ret .= "- Go to the <a href=\"$PHP_SELF?no\">Main Page</a> without logging in.<br>\n" ; | |
| 202 | + if ( !doesUserExist ( $user_name ) ) { | |
| 203 | + $ret .= "- Create a new user \"$user_name\", with the password \"$user_password\"." ; | |
| 204 | + $ret .= "<FORM action=\"$PHP_SELF?action=loginattempt\" method=post>\n" ; | |
| 205 | + $ret .= "<input type=submit name=createnewuser value=\"Create user $user_name\">\n" ; | |
| 206 | + $ret .= "<INPUT TYPE=HIDDEN NAME=user_name VALUE=\"$user_name\">\n" ; | |
| 207 | + $ret .= "<INPUT TYPE=HIDDEN NAME=user_password VALUE=\"$user_password\">\n" ; | |
| 208 | + $ret .= "<INPUT TYPE=HIDDEN NAME=newuser VALUE=\"YES\">\n" ; | |
| 209 | + $ret .= "</FORM>\n" ; | |
| 210 | + } | |
| 211 | + } | |
| 212 | + | |
| 213 | + unset ( $newuser ) ; | |
| 214 | + return $ret ; | |
| 215 | + } | |
| 216 | + | |
| 217 | +function logout () { | |
| 218 | + global $USERNAME , $USERPASSWORD , $USERLOGGEDIN , $USERID ; | |
| 219 | + setcookie ( "USERLOGGEDIN" , "NO" ) ; | |
| 220 | + $ret = "<font size=\"+3\">Goodbye, $USERNAME!</font><br>\n" ; | |
| 221 | + $ret .= "Return to the <a href=\"$PHP_SELF?no\">Main Page</a>" ; | |
| 222 | + return $ret ; | |
| 223 | + } | |
| 224 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/basic_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 225 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 226 | + native |
| Added: svn:executable | ||
| 3 | 227 | + * |
| Index: trunk/phpwiki/database_functions.php | ||
| — | — | @@ -0,0 +1,202 @@ |
| 2 | +<? | |
| 3 | +####################################################################### ARTICLE DATABASE INTERFACE | |
| 4 | + | |
| 5 | +function acquireTopic ( $s ) { | |
| 6 | + global $title ; | |
| 7 | + $s=getSecureTitle($s); | |
| 8 | +# $s=strtolower($s); | |
| 9 | + $connection=getDBconnection() ; | |
| 10 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 11 | + $sql = "select * from cur where cur_title=\"$s\"" ; | |
| 12 | + $result = mysql_query ( $sql , $connection ) ; | |
| 13 | + if ( $s = mysql_fetch_object ( $result ) ) { | |
| 14 | + $title=$s->cur_title ; | |
| 15 | + $s = $s->cur_text ; | |
| 16 | + } | |
| 17 | + else { | |
| 18 | + $s = "" ; | |
| 19 | + } | |
| 20 | + mysql_free_result ( $result ) ; | |
| 21 | + mysql_close ( $connection ) ; | |
| 22 | + return $s ; | |
| 23 | + } | |
| 24 | + | |
| 25 | +function acquireOldTopic ( $s , $id ) { | |
| 26 | + global $title ; | |
| 27 | + $s=getSecureTitle($s); | |
| 28 | +# $s=strtolower($s); | |
| 29 | + $connection=getDBconnection() ; | |
| 30 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 31 | + $sql = "select * from old where old_title=\"$title\" and old_id=$id" ; | |
| 32 | + $result = mysql_query ( $sql , $connection ) ; | |
| 33 | + if ( $s = mysql_fetch_object ( $result ) ) { | |
| 34 | + $title=$s->old_title ; | |
| 35 | + $s = $s->old_text ; | |
| 36 | + } | |
| 37 | + else { | |
| 38 | + $s = "nothing available" ; | |
| 39 | + } | |
| 40 | + mysql_free_result ( $result ) ; | |
| 41 | + mysql_close ( $connection ) ; | |
| 42 | + return $s ; | |
| 43 | + } | |
| 44 | + | |
| 45 | +function saveTopic ( $txt , $com , $min ) { | |
| 46 | + global $title ; | |
| 47 | + global $USERLOGGEDIN , $USERID ; | |
| 48 | + $s=getSecureTitle($title); | |
| 49 | +# $s=strtolower($s); | |
| 50 | + $connection=getDBconnection() ; | |
| 51 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 52 | + $txt = str_replace ( "\r" , "" , $txt ) ; | |
| 53 | + | |
| 54 | + $sql = "update cur set cur_text=\"$txt\" where cur_title=\"$s\"" ; | |
| 55 | + $result = mysql_query ( $sql , $connection ) ; | |
| 56 | + | |
| 57 | + $sql = "update cur set cur_comment='$com' where cur_title=\"$s\"" ; | |
| 58 | + $result = mysql_query ( $sql , $connection ) ; | |
| 59 | + | |
| 60 | + $sql = "update cur set cur_minor_edit=1 where cur_title=\"$s\"" ; | |
| 61 | + if ( $min == "on" ) $result = mysql_query ( $sql , $connection ) ; | |
| 62 | + | |
| 63 | + $id = $USERID ; | |
| 64 | + if ( $id == "" or $USERLOGGEDIN != "YES" ) $id = "0" ; | |
| 65 | + $sql = "update cur set cur_user='$id' where cur_title=\"$s\"" ; | |
| 66 | + $result = mysql_query ( $sql , $connection ) ; | |
| 67 | + | |
| 68 | + $un = getCurrentUserName () ; | |
| 69 | + $sql = "update cur set cur_user_text='$un' where cur_title=\"$s\"" ; | |
| 70 | + $result = mysql_query ( $sql , $connection ) ; | |
| 71 | + | |
| 72 | + mysql_close ( $connection ) ; | |
| 73 | + } | |
| 74 | + | |
| 75 | +function addPlainTopic ( $t ) { | |
| 76 | + global $title ; | |
| 77 | + $s=getSecureTitle($title); | |
| 78 | +# $s=strtolower($s); | |
| 79 | + $connection=getDBconnection() ; | |
| 80 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 81 | + | |
| 82 | + $sql = "insert into cur ( cur_title, cur_text ) VALUES ( \"$s\" , \"\" )" ; | |
| 83 | + $result = mysql_query ( $sql , $connection ) ; | |
| 84 | + | |
| 85 | + mysql_close ( $connection ) ; | |
| 86 | + } | |
| 87 | + | |
| 88 | +function backupTopic ( $t ) { | |
| 89 | + global $title ; | |
| 90 | + $s=getSecureTitle($title); | |
| 91 | +# $s=strtolower($s); | |
| 92 | + $connection=getDBconnection() ; | |
| 93 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 94 | + | |
| 95 | + # Reading current version | |
| 96 | + $sql = "select * from cur where cur_title=\"$t\"" ; | |
| 97 | + $result = mysql_query ( $sql , $connection ) ; | |
| 98 | + $s = mysql_fetch_object ( $result ) ; | |
| 99 | + | |
| 100 | + $o_title = $s->cur_title ; | |
| 101 | + $o_text = $s->cur_text ; | |
| 102 | + $o_comment = $s->cur_comment ; | |
| 103 | + $o_user = $s->cur_user ; | |
| 104 | + $o_user_text = $s->cur_user_text ; | |
| 105 | + $o_old_version = $s->cur_old_version ; | |
| 106 | + $o_timestamp = $s->cur_timestamp ; | |
| 107 | + $o_minor_edit = $s->cur_minor_edit ; | |
| 108 | + | |
| 109 | + $o_text = str_replace ( '"' , '\"' , $o_text ) ; | |
| 110 | + | |
| 111 | + mysql_free_result ( $result ) ; | |
| 112 | + | |
| 113 | + # Adding data to "old" table | |
| 114 | + $sql = "insert into old ( old_title, old_text , old_comment , old_user, old_user_text , old_old_version , old_timestamp , old_minor_edit ) VALUES ( \"$o_title\" , \"$o_text\" , \"$o_comment\" , \"$o_user\" , \"$o_user_text\" , \"$o_old_version\" , \"$o_timestamp\" , \"$o_minor_edit\" )" ; | |
| 115 | + $result = mysql_query ( $sql , $connection ) ; | |
| 116 | + | |
| 117 | + # Get old id | |
| 118 | + $sql = "select * from old where old_title=\"$o_title\" and old_old_version=\"$o_old_version\"" ; | |
| 119 | + $result = mysql_query ( $sql , $connection ) ; | |
| 120 | + $s = mysql_fetch_object ( $result ) ; | |
| 121 | + $n_old_version = $s->old_id ; | |
| 122 | + mysql_free_result ( $result ) ; | |
| 123 | + | |
| 124 | + # Update current version | |
| 125 | + $sql = "update cur set cur_old_version='$n_old_version' where cur_title=\"$title\"" ; | |
| 126 | + $result = mysql_query ( $sql , $connection ) ; | |
| 127 | + | |
| 128 | + mysql_close ( $connection ) ; | |
| 129 | + } | |
| 130 | + | |
| 131 | +function doesTopicExist ( $s ) { | |
| 132 | + if ( $s == "" ) return false ; | |
| 133 | + $s=getSecureTitle($s); | |
| 134 | + $connection=getDBconnection() ; | |
| 135 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 136 | + $sql = "SELECT COUNT(*) AS number FROM cur WHERE cur_title=\"$s\"" ; | |
| 137 | + $result = mysql_query ( $sql , $connection ) ; | |
| 138 | + $s = mysql_fetch_object ( $result ) ; | |
| 139 | + if ( $s->number > 0 ) $ret = true ; | |
| 140 | + else $ret = false ; | |
| 141 | + mysql_free_result ( $result ) ; | |
| 142 | + mysql_close ( $connection ) ; | |
| 143 | + return $ret ; | |
| 144 | + } | |
| 145 | + | |
| 146 | +function doesNamespaceExist ( $ns ) { | |
| 147 | + $ns = getSecureTitle ( $ns ) ; | |
| 148 | + $connection=getDBconnection() ; | |
| 149 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 150 | + $sql = "SELECT COUNT(*) AS number FROM cur WHERE cur_title LIKE \"$ns:%\"" ; | |
| 151 | + $result = mysql_query ( $sql , $connection ) ; | |
| 152 | + $s = mysql_fetch_object ( $result ) ; | |
| 153 | + if ( $s->number > 0 ) $ret = true ; | |
| 154 | + else $ret = false ; | |
| 155 | + mysql_free_result ( $result ) ; | |
| 156 | + mysql_close ( $connection ) ; | |
| 157 | + return $ret ; | |
| 158 | + } | |
| 159 | + | |
| 160 | +function getTopicSetting ( $tt , $s ) { | |
| 161 | + $tt = getSecureTitle ( $tt ) ; | |
| 162 | + $connection=getDBconnection() ; | |
| 163 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 164 | + $sql = "SELECT * FROM cur WHERE cur_title=\"$tt\"" ; | |
| 165 | + $result = mysql_query ( $sql , $connection ) ; | |
| 166 | + if ( $t = mysql_fetch_object ( $result ) ) $ret = $t->$s ; | |
| 167 | + else $ret = "NOSUCHTHING" ; # This topic or property doesn't exist | |
| 168 | + mysql_free_result ( $result ) ; | |
| 169 | + mysql_close ( $connection ) ; | |
| 170 | + return $ret ; | |
| 171 | + } | |
| 172 | + | |
| 173 | +function changeTopicSetting ( $tt , $s , $v ) { | |
| 174 | + $secureTitle = getSecureTitle ( $tt ) ; | |
| 175 | + $connection=getDBconnection() ; | |
| 176 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 177 | + $sql = "UPDATE cur SET $s = \"$v\" WHERE cur_title = \"$secureTitle\"" ; | |
| 178 | + $result = mysql_query ( $sql , $connection ) ; | |
| 179 | + mysql_close ( $connection ) ; | |
| 180 | + } | |
| 181 | + | |
| 182 | +function getAllNamespaces ( $tt ) { | |
| 183 | + $ret = "" ; | |
| 184 | + $cnt = 0 ; | |
| 185 | + if ( doesTopicExist($tt) ) { | |
| 186 | + $ret = "<a href=\"$PHP_SELF?action=view&title=$tt\">[".getNiceTitle($tt)."]</a>" ; | |
| 187 | + $cnt++ ; | |
| 188 | + } | |
| 189 | + $connection=getDBconnection() ; | |
| 190 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 191 | + $sql = "SELECT cur_title FROM cur WHERE cur_title LIKE \"%:$tt\"" ; | |
| 192 | + $result = mysql_query ( $sql , $connection ) ; | |
| 193 | + while ( $s = mysql_fetch_object ( $result ) ) { | |
| 194 | + if ( $ret != "" ) $ret .= " " ; | |
| 195 | + $ret .= "<a href=\"$PHP_SELF?action=view&title=$s->cur_title\">[".getNiceTitle($s->cur_title)."]</a>" ; | |
| 196 | + $cnt++ ; | |
| 197 | + } | |
| 198 | + mysql_free_result ( $result ) ; | |
| 199 | + mysql_close ( $connection ) ; | |
| 200 | + if ( $cnt < 2 ) $ret = "" ; | |
| 201 | + return $ret ; | |
| 202 | + } | |
| 203 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/database_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 204 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 205 | + native |
| Added: svn:executable | ||
| 3 | 206 | + * |
| Index: trunk/phpwiki/upload_functions.php | ||
| — | — | @@ -0,0 +1,117 @@ |
| 2 | +<? | |
| 3 | +# UPLOAD FUNCTION | |
| 4 | +function doUpload () { | |
| 5 | + global $removeFile , $xtitle , $removeFile , $Upload , $Upload_name , $no_copyright ; | |
| 6 | + global $USERLOGGEDIN , $USERNAME ; | |
| 7 | + | |
| 8 | + if ( $USERLOGGEDIN != "YES" ) return "You are not logged in! You have to be logged in to upload a file. <a href=\"$PHP_SELF?action=login\">Log in</a> or return to the <a href=\"$PHP_SELF?no\">HomePage</a>" ; | |
| 9 | + | |
| 10 | + $rights = ",".getUserSetting ( $USERNAME , "user_rights" )."," ; | |
| 11 | + if ( strstr ( $rights , ",is_editor," ) or strstr ( $rights , ",is_sysop" ) ) $isEditor = true ; | |
| 12 | + else $isEditor = false ; | |
| 13 | + if ( strstr ( $rights , ",is_sysop," ) or strstr ( $rights , ",is_sysop" ) ) $isSysop = true ; | |
| 14 | + else $isSysop = false ; | |
| 15 | + | |
| 16 | + $xtitle = "File upload page"; | |
| 17 | + $ret = getStandardHeader() ; | |
| 18 | + | |
| 19 | + if (isset($removeFile)) { | |
| 20 | + if ( !$isSysop and !$isEditor ) return "You are neither an editor nor a sysop. Return to the <a href=\"$PHP_SELF?action=upload\">Upload page</a>" ; | |
| 21 | + if (is_file("upload/$removeFile") ) system ("rm -f upload/$removeFile"); | |
| 22 | + unset ( $removeFile ) ; | |
| 23 | + } else if (isset($Upload_name)) { | |
| 24 | + if ( $no_copyright != "AFFIRMED" ) return "You need to affirm that the file is not violating copygights. Return to the <a href=\"$PHP_SELF?action=upload\">Upload page</a>" ; | |
| 25 | + $Upload_name = ereg_replace(" ", "_", $Upload_name); | |
| 26 | + $abc = split("\.", $Upload_name); | |
| 27 | + | |
| 28 | + $num = exec ("df"); | |
| 29 | + $readata = substr($num,(strpos($num, "%")-2),2); | |
| 30 | + | |
| 31 | + if ($readata > 96) { | |
| 32 | + $ret .= "<body bgcolor=white>\n"; | |
| 33 | + $ret .= "<br><b>Sorry, we are almost out of disk space. We can't let you upload any files right now.</b>\n"; | |
| 34 | + return $ret ; | |
| 35 | + } | |
| 36 | + | |
| 37 | + if (!is_dir("upload") ) { | |
| 38 | + system ("mkdir upload"); | |
| 39 | + system ("chmod 777 upload"); | |
| 40 | + } | |
| 41 | + | |
| 42 | + system ("cp $Upload upload/$Upload_name"); | |
| 43 | + system ("chmod 777 upload/$Upload_name"); | |
| 44 | + | |
| 45 | + $ret .= "<script language=javascript>\n"; | |
| 46 | + $ret .= " function winclose(name){\n"; | |
| 47 | + $ret .= " str=\"Your file $Upload_name was successfully uploaded!\"\n"; | |
| 48 | + $ret .= " alert(str);\n"; | |
| 49 | + $ret .= " }\n"; | |
| 50 | + $ret .= "</script>\n"; | |
| 51 | + $ret .= "<body bgcolor=white onload=\"winclose('$name')\">\n"; | |
| 52 | + | |
| 53 | + unset ( $Upload_name ) ; | |
| 54 | + } | |
| 55 | + | |
| 56 | + $ret .= "<h2>Instructions:</h2><ul>\n"; | |
| 57 | + $ret .= "<li><strong>Use this form to upload various files</strong></li>\n"; | |
| 58 | + $ret .= "<li>To replace a previously-uploaded file (e.g., a\n"; | |
| 59 | + $ret .= "new version of the article), simply re-upload the\n"; | |
| 60 | + $ret .= "same file. But first look below and make sure you\n"; | |
| 61 | + $ret .= "haven't changed the name.</li>\n"; | |
| 62 | + $ret .= "<li><strong>Here's how to upload your file. </strong>Click\n"; | |
| 63 | + $ret .= ""Browse..." to your find the file you\n"; | |
| 64 | + $ret .= "want to upload on your hard drive. This will open\n"; | |
| 65 | + $ret .= "a "Choose file" dialogue window.</li>\n"; | |
| 66 | + $ret .= "<li>When you've found the file, click "Open."\n"; | |
| 67 | + $ret .= "This will select the file and close the "Choose\n"; | |
| 68 | + $ret .= "file" dialogue window.</li>\n"; | |
| 69 | + $ret .= "<li>Don't forget to check the copyright statement!</li>\n"; | |
| 70 | + $ret .= "<li>Then click "Upload." The file will start uploading. This may take some time, if it's\n"; | |
| 71 | + $ret .= "a big file and you have a slow Internet connection.</li>\n"; | |
| 72 | + $ret .= "<li>A message will tell you when the file has successfully uploaded.</li>\n"; | |
| 73 | + $ret .= "<li>You can upload as many files you like. Please don't try to crash our server, ha ha.</li>\n"; | |
| 74 | + $ret .= "</ul>\n"; | |
| 75 | + | |
| 76 | + $ret .= " <form enctype=\"multipart/form-data\" action=\"$PHP_SELF?action=upload\" method=post>\n"; | |
| 77 | + $ret .= " <input type=hidden name=max value=20096>\n"; | |
| 78 | + $ret .= " <input name=Upload type=\"file\"><br>\n"; | |
| 79 | + $ret .= " <input type=hidden name=update value=1>\n"; | |
| 80 | + $ret .= " <input type=hidden name=step value=$step>\n"; | |
| 81 | + $ret .= "<INPUT TYPE=checkbox NAME=\"no_copyright\" VALUE=\"AFFIRMED\">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.<br>\n" ; | |
| 82 | + $ret .= " <input type=submit value=UPLOAD>\n"; | |
| 83 | + $ret .= "</form>\n"; | |
| 84 | + | |
| 85 | + if (is_dir("upload")) { | |
| 86 | + $mydir = dir("upload"); | |
| 87 | + while ($entry = $mydir->read()) { | |
| 88 | + if ($entry != "." and $entry != "..") | |
| 89 | + $file = "yes"; | |
| 90 | + } | |
| 91 | + $mydir->close(); | |
| 92 | + | |
| 93 | + if ($file == "yes") { | |
| 94 | + $ret .= "<h2>Previously-uploaded files:</h2>"; | |
| 95 | + $mydir = opendir("upload"); | |
| 96 | + $i = 0; | |
| 97 | + $ret .= "<table border=1 width=\"100%\">\n"; | |
| 98 | + $ret .= "<tr><th>File</th><th>Size (byte)</th>"; | |
| 99 | + if ( $isSysop or $isEditor ) $ret .= "<th>File removal (editors and sysops only)</th>";" | |
| 100 | + $ret .= </tr>\n" ; | |
| 101 | + while ($entry = readdir($mydir)) { | |
| 102 | + if ($entry != '.' && $entry != '..') { | |
| 103 | + $ret .= "<tr><td align=center>" ; | |
| 104 | + $ret .= "<a href=upload/$entry>$entry</a></td>"; | |
| 105 | + $ret .= "<td align=center>".filesize("upload/$entry")." bytes</td>"; | |
| 106 | + if ( $isSysop or $isEditor ) $ret .= "<td align=center><a href=\"$PHP_SELF?action=upload&removeFile=$entry\">Click here to remove $entry.</a></td>" ; | |
| 107 | + $ret .= "</tr>" ; | |
| 108 | + $i++; | |
| 109 | + } | |
| 110 | + } | |
| 111 | + $ret .= "</table>\n"; | |
| 112 | + closedir($mydir); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + $ret .= getStandardFooter() ; | |
| 116 | + return $ret ; | |
| 117 | +} | |
| 118 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/upload_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 119 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 120 | + native |
| Added: svn:executable | ||
| 3 | 121 | + * |
| Index: trunk/phpwiki/wiki.jpg | ||
| — | — | @@ -0,0 +1,49 @@ |
| 2 | +����JFIF,,��C | |
| 3 | + | |
| 4 | + $.' ",#(7),01444'9=82<.342��C | |
| 5 | + | |
| 6 | +2!!22222222222222222222222222222222222222222222222222��nq"�� | |
| 7 | +���}!1AQa"q2���#B��R��$3br� | |
| 8 | +%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� | |
| 9 | +���w!1AQaq"2�B���� #3R�br� | |
| 10 | +$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?��(�� | |
| 11 | +BqTo� m�H-,���~B��4\�K9�u�2ǰ 2]����֯���w���s�,cV(�Wy9�U�R���B|��O���YE'�)� `8��C&���6�o%�`��[B���w�x�b���hwz�Ou��U�����܄�YcT7`·!��. ��CXӬ|,/d����b{v��ۖRq�H3�"�(��I�����!d�kv�X�W*V5�C�l | |
| 12 | +kjz*���Se�F_��ۈ�\&X�6��G'��>2���E����4fD*P�������[x���{m�{(�AK���7��H98z�@V�r�͍l2�s$�yj#uu���#n�(�<�s�_鉮h�)�;��Ue1Id��(�1&������=z��e]��@�y���RJ"X�y�$�������q���+������D�[I | |
| 13 | +�;Ƥ��n�x\�z��=��Esa��q/,|D��$����R�iQ��B�����[Ϳtl�ѝ�y}�=9ېA���ր&��(��(��WFt��^Yt�v7c����NpCS�"�H۶�$�R���}�r��!�oZ� | |
| 14 | +I��v,�.Ԕ,�$Na����d�H�G�5���� b�#n�ם���p��9z�1�QG�� | |
| 15 | +i�����t�]\��V�02n%v�;�<�<���i� �]j���cVQm�o�LP�U������o�o{��j�� .v�X�1�f<�����Fz�x.��V�ửQ4�{��틄It | |
| 16 | +���?=���x�C�kkSuM#�R �� | |
| 17 | +���@��tse��d�^�$v�.$0��8�ltKƼ�Wk�ed�l�i6㿠nO���ƻ�hIl���/�e�a�� � �?�Poxt��cb�����N0��F���+V�I�ԧ���##�����e�#v�G>��5_���o | |
| 18 | +���3�䬮�0~Q�N1�O�Wƾ��m���3ƭe.%�)o�+�eT���x�X�u��?Q�'��|RG���RU���8�dv��Q��9�}�Uּ�oʀ]�&^@6/ȇh'v�s^&����lb��w�&8aV�y����:�����yh� ���b��ːXbO�������|!.�"]i���MN��ƒ�S���-�G�Q�|Ӭ��O=�E$O�|�6R��/8�� ��Vu�Q��lo4�E�L�h��YP�1��#qa���(b�I����P$���1�Χ�;��_K����K�-��.^G | |
| 19 | +0P '�˴��1�ż����<D��@�J�8##�����(� | |
| 20 | +��V���n�Ri"�qvA�{/ `���$W/� ]鿔�R'6�[�US�������wv�ې�w:����>�j�f�9eeL��P��K���'��n��Ik���Oi�B��<Er��/A��@�-mR(����;I�;A��>T���}�=�Ep�'�<q�wv�^EZt��$Q�[�6��##���'�Wm�Gqkg"I�+GDѻ(gt\����b��#�k'�f�q��1�E�-�ݜ��䃱Y�m��8���-:�����;��-���i�/���cn�u��#�c�t��K�^!���Eq(b����D=;)�+#��1+�M�yZ�k$�"�y(� 2G�s]���MZ����,֤��AW��<;Pb���*��&�� | |
| 21 | +��%��*�P��m��pJ`��s��V2��a������XD��m�Ww|z�=���=Z��M:|�OH�dUe��ۆx��F�=��L�˥�D�y��l��4P|�v��<P�i�ھ� | |
| 22 | +��Q<�� �I&Т9�s��r�6Yn�$x<�#�X5A�d����0�zݲ���^f������yU0��2.v�<�'۽q�'�e����[�oj���076�ۇ88S�ӯ�ie�8 ���.6�$fGr��e#��K���'��:qn�?���\^,ы��%�%�t[�k��%��G8��ƚk,{��F.�*��a | |
| 23 | +ʥ����Q����Ƕ>a��^�h!�Kg�fGUf� | |
| 24 | +�ǯC����m��}J��'��Q���a� | |
| 25 | +���<�p0I��c��������u턊�����<y�C�� | |
| 26 | +�]b�?j��S\���Ɯ�ɳ,��#+����վ��ͩ5���� | |
| 27 | +�'�Nx��4袊�/�j�'�Rk�.xU��c~�Y�n�f1�7=1wN�Ɲ�_˪��+Y�7n'�8�H5$�W6�3���GFܱ�*1Ab�oa�n��u�'�7~" | |
| 28 | +k}/�<�����rAڋ���F=�����s;H�k��%&��,�8&8�}���(,u��#Ge��Y�?�&r�L@8��cX���V0�������R5ޫ��$c��Z�?�8'��$�������u%���^��ڹ��@�dgȤ��ր:?�?C��{��l�i0 q3���H�g.3��O��tˉ������338�8�I?�pv����<4�n��˵{� | |
| 29 | +�� A�A�\��q� U�d�>dsܬR^�����1�s | |
| 30 | +�, * �Z��'B�&�u����5��4���b2�q�)�� �k�k#���Y�$l�M�~�R���T_��>cjKD�ddm ���j�W> ' | |
| 31 | +V��^�Ы�,NAs����������C�\���ȅ`�$b�]{O���!x��-Ɲ'������,Jg9�1]NJ�n��G��.d[{�2X�=G��I�߳�y>�e������e�Xo����9۱�X��BH�|P�[��s�i | |
| 32 | +�FTIJ!%��A���LK��4ۏ�P���c�~�%q�コ��sF�œ��Ynuڅ��� �f2�1="1sϾEt~$��nt�k}2yЙv�$E|О[�˖Q����ЀhC���Z\[B��q�!�I$�RA=8������n Gi���/#n`[�O8�Fs�)���;����W�.��$d����� �ȭ� | |
| 33 | +�r-B��8�X�{���C6s�����(���(+W��[i���m�|&S�� �@����õ�\�7�e<:y�����;1��mI�88��&���[�d2,,^hUK4���U��i��Y־�Y�9�m�{�|�Rq$m"�J����q��@������]Ed�����.Q W$��q}�Ebx��z | |
| 34 | +|;��ܼ��i��Q�b����l瞀�<g�o | |
| 35 | +h�\-�N��C! | |
| 36 | +�<�8<�?��#�7�t�����q?�l���ZFm��$�|����;?�o�xF1����b�`.Q�7q���M��@�X�Ӵ���K��I�r�EuW�1���;����o� | |
| 37 | +�͗�停�A�`��t���]��y2Ȟn���#�J�-���\c(K�Y�x��F�9�٭���X]�B�0Hs��ǽ2����)-�X$IH�8���<d�֦�Э�F | |
| 38 | +A��$�/,yleܮ?��_�#�e�x'G�t���an,�F�䪰a��:� | |
| 39 | +K?��Z}�Szn/R��*HFe. �ѐ{�+��O���>*��<�i�$v���"���0k���&�n�"�vdi����gzG���ԩ ��g��}CX�u�� | |
| 40 | +��O9��D�]�y �*��� N���M�;(��P�-j���<E'_Oq�4����N;�y!���b�(�̈cS��$���@��$��?�$��XT�'�%r�*�=f�5_F���#:h� �/6[��]�`W�p<EA�k�q\��m���$r7��bo�8ݻp | |
| 41 | +j�js=������*�و�/Pyv���UN�ƚT#�Ϻ��m��xr�9-��O�Z:4�wV?k��H$���4�Ϳʠ�p279�� | |
| 42 | +(�� | |
| 43 | +�5���L����u�������C�7Kn��$�E(��OM���6v� ���(���/�E�l��F�jA��0܂E ���>/�wW��&�|ڣ���D��y�����|�yX�װ�4ky.�ӗV���D�Q�FfF,�+ | |
| 44 | +Ð7�e���eqw�o�tcѵĐI�x�m��|�3��@���j6Zi�Q��� | |
| 45 | +���v<���<����� ա���#70-�Op�aG��L�=�H���:�֯���Ym���������c}�A��'��O�g�x�U��'oJ�������6��K�� | |
| 46 | +�d`�j��O��A��LI��q�eRcW�t��+koY��2XژE����L� | |
| 47 | +���A��q��]��3��^[>ko�3.�d�vC���dr�������KV�9�-�ڬ���b� $3�ڀ3�<q��l��#jb�L�p�,H�p�y${�Gᑮŧ�������)c�b��&ܜ�_�%z䍘�9� ᅱ;���*1b�6�f��U�|���<C�Ad��j�E���S`v,T6$ظ��8�uw��-���ʐ��BI"U>�A��r�xg@����k��q\ݩ;b*��[��Kg����Gk�x�-��Us��4�y ���Uxf99��~a�oaoh�kq;�W7N�M�&[s�~N��@�vgNmu�ӭ��7K,������9���1�^����eg��v��,1"���%P����5b� | |
| 48 | +(�� | |
| 49 | +(��*�j6���'�'�uV�q�q^S�������#}K����q4 y��bN�$�ۈ<�wc����XY�vrY��Awk&7�<aѰr2����]2o����Z�D��#�����ڄ��}ַ��\L�Bw�dU�D��r�۸�C�l��07^����-�1K���/�������d�ui,c��x�Rγ��؛pw#�<�y'=�G�%���=��E�1�<p�n�I��Nxb�) s��Zw���f�Ѯ&�iY-���U�.� I�zn�-��ٚ�P/x�\%�?��8�~P���砤�no���-/�L�F��߲*��) ��B�d�g�M�ꚭ��~ӦD���#�A��~�N3��g �R����6W����.Rd���R�7�P�؏aۊؓJ���Eq�]��_���bf!����Cc!��/RX�Ú`�k�-�iK�����ՙ���,0[�p1��a���+K�{r!��lL(�TRL�bb�6<�vV���tV� | |
| 50 | +����`���,I,q�,I�j�QEQE�� | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/wiki.jpg | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 51 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 52 | + native |
| Added: svn:executable | ||
| 3 | 53 | + * |
| Index: trunk/phpwiki/higher_functions.php | ||
| — | — | @@ -0,0 +1,396 @@ |
| 2 | +<? | |
| 3 | +############################################ | |
| 4 | +# HIGHER BRAIN FUNCTIONS | |
| 5 | +############################################ | |
| 6 | + | |
| 7 | +function showRecentChanges () { | |
| 8 | + global $title , $countDays ; | |
| 9 | + $s=getSecureTitle($s); | |
| 10 | + $connection=getDBconnection() ; | |
| 11 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 12 | + $sql = "SELECT * FROM cur ORDER BY cur_timestamp DESC LIMIT 1000" ; | |
| 13 | + $result = mysql_query ( $sql , $connection ) ; | |
| 14 | + | |
| 15 | + $output .= getStandardHeader () ; | |
| 16 | + $last_date = "" ; | |
| 17 | + if ( $countDays != "" ) $count_days = $countDays ; | |
| 18 | + else $count_days = 2 ; | |
| 19 | + | |
| 20 | + if ( $count_days < 1 ) $count_days = 2 ; | |
| 21 | + | |
| 22 | + $output .= "<h2>Updates in the last $count_days day" ; | |
| 23 | + if ( $count_days != 1 ) $output .= "s" ; | |
| 24 | + $output .= " :</h2>\n" ; | |
| 25 | + $output .= "<a href=\"$PHP_SELF?title=recentchanges&action=view&countDays=1\">1 day</a>" ; | |
| 26 | + $output .= " | <a href=\"$PHP_SELF?title=recentchanges&action=view&countDays=3\">3 days</a>" ; | |
| 27 | + $output .= " | <a href=\"$PHP_SELF?title=recentchanges&action=view&countDays=30\">30 days</a>" ; | |
| 28 | + $output .= " | <a href=\"$PHP_SELF?title=recentchanges&action=view&countDays=90\">90 days</a><br>\n" ; | |
| 29 | + | |
| 30 | + $s = currentMySQLtime () ; | |
| 31 | + $s = MySQLdatestamp ( $s ) . ", " . MySQLtimestamp ( $s ) ; | |
| 32 | + $output .= "Now is $s" ; | |
| 33 | + | |
| 34 | + while ( $s = mysql_fetch_object ( $result ) ) { | |
| 35 | + $secureTitle=getSecureTitle($s->cur_title); | |
| 36 | + $edit_time = MySQLtimestamp ( $s->cur_timestamp ) ; | |
| 37 | + $edit_date = MySQLdatestamp ( $s->cur_timestamp ) ; | |
| 38 | + $comment=$s->cur_comment ; | |
| 39 | + if ( $comment == "*" ) $comment = "" ; | |
| 40 | + if ( $s->cur_minor_edit == 1 and $comment != "" ) $comment = "<i>edit</i> ".$comment ; | |
| 41 | + $cuser=$s->cur_user_text ; | |
| 42 | + if ( $cuser == "" ) $cuser = "<unknown>" ; | |
| 43 | + else if ( doesUserExist ( $cuser ) ) $cuser = "<a href=\"$PHP_SELF?title=user:$cuser&action=view\">$cuser</a>" ; | |
| 44 | + | |
| 45 | + $toutput = "" ; | |
| 46 | + if ( $last_date != $edit_date ) { | |
| 47 | + $count_days-- ; | |
| 48 | + $toutput .= "</ul><h3>$edit_date</h3>\n<ul>\n" ; | |
| 49 | + $last_date = $edit_date ; | |
| 50 | + } | |
| 51 | + | |
| 52 | + $toutput .= "<li><a href=\"$PHP_SELF?title=$secureTitle&action=view\">$s->cur_title</a>" ; | |
| 53 | + $toutput .= " $edit_time" ; | |
| 54 | + $toutput .= " (<a href=\"$PHP_SELF?title=$secureTitle&action=revisions\">history</a>)" ; | |
| 55 | + if ( $comment != "" ) $toutput .= " <strong>$comment</strong>" ; | |
| 56 | + $toutput .= "...... $cuser" ; | |
| 57 | + $toutput .= "</li>\n" ; | |
| 58 | + | |
| 59 | + if ( $count_days >= 0 ) $output .= $toutput ; | |
| 60 | + } | |
| 61 | + $output .= "</ul>" ; | |
| 62 | + $output .= getStandardFooter () ; | |
| 63 | + mysql_free_result ( $result ) ; | |
| 64 | +# mysql_close ( $connection ) ; | |
| 65 | + return $output ; | |
| 66 | + } | |
| 67 | + | |
| 68 | +function revisions () { | |
| 69 | + global $title ; | |
| 70 | + if ( !doesTopicExist ( $title ) ) return "There is no topic $title." ; | |
| 71 | + | |
| 72 | + $ret .= getStandardHeader () ; | |
| 73 | + | |
| 74 | + $secureTitle=getSecureTitle($title); | |
| 75 | +# $s=strtolower($secureTitle); | |
| 76 | + $stitle=$secureTitle ; | |
| 77 | + $connection=getDBconnection() ; | |
| 78 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 79 | + $sql = "select * from cur where cur_title=\"$stitle\"" ; | |
| 80 | + $result = mysql_query ( $sql , $connection ) ; | |
| 81 | + $s = mysql_fetch_object ( $result ) ; | |
| 82 | + $id = $s->cur_id ; | |
| 83 | + $next = $s->cur_old_version ; | |
| 84 | + $comment = $s->cur_comment ; | |
| 85 | + $user_text = $s->cur_user_text ; | |
| 86 | + $edit_time = $s->cur_timestamp ; | |
| 87 | + $member_id = $s->cur_user ; | |
| 88 | + $release = "current" ; | |
| 89 | + | |
| 90 | + $sql = "select * from old where old_title=\"$stitle\"" ; | |
| 91 | + $result = mysql_query ( $sql , $connection ) ; | |
| 92 | + $revs = 0 ; | |
| 93 | + while ( $s = mysql_fetch_object ( $result ) ) $revs++ ; | |
| 94 | + | |
| 95 | + $ret .= "<table width=\"100%\" border=1>\n" ; | |
| 96 | + $ret .= "<tr><th nowrap width=60><center><b>Version</b></center></th>"; | |
| 97 | + $ret .= "<th nowrap width=10><b>Source</b></th>" ; | |
| 98 | + $ret .= "<th nowrap width=10><b>User</b></th>" ; | |
| 99 | + $ret .= "<th nowrap width=10><b>Time</b></th>" ; | |
| 100 | + $ret .= "<th nowrap width=\"100%\"><b>Comment</b></th>" ; | |
| 101 | + $ret .= "</tr>\n" ; | |
| 102 | + do { | |
| 103 | + $oid = $next ; | |
| 104 | + if ( $release == "current" ) $oid = $release ; | |
| 105 | + | |
| 106 | + $edit_time = MySQLtimestamp ( $edit_time ) ; | |
| 107 | + | |
| 108 | + if ( $user_text == "" ) $user_text = "<unknown>" ; | |
| 109 | + if ( $member_id != "" ) $user_text = "<a href=\"$PHP_SELF?action=view&title=user:$user_text\">$user_text</a>" ; | |
| 110 | + | |
| 111 | + if ( $release == "current" ) $releaseText = $release ; | |
| 112 | + else $releaseText = $revs + 1 - $release ; | |
| 113 | + | |
| 114 | + $ret .= "<tr>" ; | |
| 115 | + $ret .= "<td align=center nowrap><a href=\"$PHP_SELF?title=$title&action=view_old_article&oid=$oid&whichOldVersion=$releaseText\">$releaseText</a></td>"; | |
| 116 | + $ret .= "<td align=center nowrap><a href=\"$PHP_SELF?title=$title&action=view_old_source&oid=$oid&whichOldVersion=$releaseText\">edit</a></td>"; | |
| 117 | + $ret .= "<td nowrap>$user_text</td>" ; | |
| 118 | + $ret .= "<td nowrap>$edit_time</td>" ; | |
| 119 | + $ret .= "<td>$comment</td>" ; | |
| 120 | + $ret .= "</tr>\n" ; | |
| 121 | + | |
| 122 | + if ( $release != "current" ) $next = $s->old_old_version ; | |
| 123 | + if ( $release == "current" ) $release = 0 ; | |
| 124 | + $release = $release + 1 ; | |
| 125 | + if ( $next != 0 ) { | |
| 126 | + mysql_free_result ( $result ) ; | |
| 127 | + $sql = "select * from old where old_id=$next" ; | |
| 128 | + $result = mysql_query ( $sql , $connection ) ; | |
| 129 | + $s = mysql_fetch_object ( $result ) ; | |
| 130 | + $comment = $s->old_comment ; | |
| 131 | + $member_id = $s->old_user ; | |
| 132 | + $user_text = $s->old_user_text ; | |
| 133 | + $edit_time = $s->old_timestamp ; | |
| 134 | + } | |
| 135 | + } while ( $next != 0 ) ; | |
| 136 | + $ret .= "</table>\n" ; | |
| 137 | + $ret .= getStandardFooter () ; | |
| 138 | + | |
| 139 | +# mysql_close ( $connection ) ; | |
| 140 | + return $ret ; | |
| 141 | + } | |
| 142 | + | |
| 143 | +function doSearch () { | |
| 144 | + global $search ; | |
| 145 | + | |
| 146 | + $connection=getDBconnection() ; | |
| 147 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 148 | + $sql = "SELECT * FROM cur WHERE cur_text LIKE \"%$search%\" OR cur_title LIKE \"%$search%\" ORDER BY cur_title" ; | |
| 149 | + $result = mysql_query ( $sql , $connection ) ; | |
| 150 | + | |
| 151 | + $noresult = true ; | |
| 152 | + $output = "<table border=1>\n" ; | |
| 153 | + $output .= "<tr><th nowrap>Topic</th><th nowrap>Last edit</th><th>Last comment</th></tr>"; | |
| 154 | + while ( $s = mysql_fetch_object ( $result ) ) { | |
| 155 | + $noresult = false ; | |
| 156 | + $secureTitle=getSecureTitle($s->cur_title); | |
| 157 | + $edit_time = MySQLtimestamp ( $s->cur_timestamp ) ; | |
| 158 | + $comment=$s->cur_comment ; | |
| 159 | + if ( $comment == "*" ) $comment = "" ; | |
| 160 | + if ( $s->cur_minor_edit == 1 ) $comment = "<i>edit</i> ".$comment ; | |
| 161 | + $cuser=$s->cur_user_text ; | |
| 162 | + if ( $cuser == "" ) $cuser = "<unknown>" ; | |
| 163 | + else $cuser = "<a href=\"$PHP_SELF?title=$cuser&action=view\">$cuser</a>" ; | |
| 164 | + | |
| 165 | + $output .= "<tr>" ; | |
| 166 | + $output .= "<td nowrap><a href=\"$PHP_SELF?title=$secureTitle&action=view\"><b>$s->cur_title</b></a>"; | |
| 167 | + $output .= " (<a href=\"$PHP_SELF?title=$secureTitle&action=revisions\">History</a>)</td>" ; | |
| 168 | + $output .= "<td nowrap><font color=green>$edit_time</font> by $cuser</td>" ; | |
| 169 | + $output .= "<td>$comment</td>" ; | |
| 170 | + $output .= "</tr>\n" ; | |
| 171 | + } | |
| 172 | + $output .= "</table>\n" ; | |
| 173 | + mysql_free_result ( $result ) ; | |
| 174 | + mysql_close ( $connection ) ; | |
| 175 | + | |
| 176 | + if ( $noresult ) { | |
| 177 | + $output = "<h2>Sorry, there are no matches for \"$search\" in our database.</h2>" ; | |
| 178 | + $output .= "You could write about [[$search]] yourself!" ; | |
| 179 | + $output = parseContent ( $output ) ; | |
| 180 | + } | |
| 181 | + | |
| 182 | + $output = getStandardHeader().$output.getStandardFooter () ; | |
| 183 | + return $output ; | |
| 184 | + } | |
| 185 | + | |
| 186 | +function prefs () { | |
| 187 | + global $changeprefs , $u_email , $u_password ; | |
| 188 | + global $USERNAME , $USERPASSWORD , $USERLOGGEDIN , $USERID ; | |
| 189 | + if ( $USERLOGGEDIN != "YES" ) return "You are not logged in. <a href=\"$PHP_SELF?action=login\">Log in</a> or return to the <a href=\"$PHP_SELF?no\">Main Page</a>" ; | |
| 190 | + $ret = getStandardHeader () ; | |
| 191 | + | |
| 192 | + if ( $changeprefs ) { # Save new settings | |
| 193 | + changeUserSetting ( $USERNAME , "user_email" , $u_email ) ; | |
| 194 | + changeUserSetting ( $USERNAME , "user_password" , $u_password ) ; | |
| 195 | + $ret .= "Settings are changed.<br>\n" ; | |
| 196 | + } | |
| 197 | + | |
| 198 | + $uemail = getUserSetting ( $USERNAME , "user_email" ) ; | |
| 199 | + $ur = getUserSetting ( $USERNAME , "user_rights" ) ; | |
| 200 | + $ret .= "<font face=courier>\n" ; | |
| 201 | + $ret .= "<FORM action=\"$PHP_SELF?action=prefs\" method=post>\n" ; | |
| 202 | + $ret .= "<p>Your user ID : $USERID</p>\n" ; | |
| 203 | + $ret .= "<p>Your rights : $ur</p>\n" ; | |
| 204 | + $ret .= "<p>Your email : <INPUT TABINDEX=1 TYPE=text NAME=u_email VALUE=\"$uemail\" SIZE=20></p>\n" ; | |
| 205 | + $ret .= "<p>Your password : <INPUT TABINDEX=1 TYPE=text NAME=u_password VALUE=\"$USERPASSWORD\" SIZE=20></p>\n" ; | |
| 206 | + $ret .= "<INPUT TYPE=SUBMIT NAME=changeprefs value=\"Save settings\">\n" ; | |
| 207 | + $ret .= "</FORM>\n" ; | |
| 208 | + $ret .= "</font>\n" ; | |
| 209 | + | |
| 210 | + $rights = ",".getUserSetting ( $USERNAME , "user_rights" )."," ; | |
| 211 | + if ( strstr ( $rights , ",is_editor" ) or strstr ( $rights , ",is_sysop" ) ) { | |
| 212 | + $ret .= "<hr><font color=red>You are allowed to <a href=\"$PHP_SELF?action=editUserRights\">edit user rights</a>!</font>" ; | |
| 213 | + } | |
| 214 | + | |
| 215 | + $ret .= getStandardFooter () ; | |
| 216 | + | |
| 217 | + return $ret ; | |
| 218 | + } | |
| 219 | + | |
| 220 | +######## EDIT USER RIGHTS | |
| 221 | +function editUserRights () { | |
| 222 | + global $title , $editusername , $newuserrights , $USERLOGGEDIN , $USERNAME ; | |
| 223 | + $secureTitle = getSecureTitle ( $title ) ; | |
| 224 | + if ( !$USERLOGGEDIN ) return "You are not logged in. <a href=\"$PHP_SELF?action=login\">Log in</a> or return to the <a href=\"$PHP_SELF?no\">Main Page</a>" ; | |
| 225 | + | |
| 226 | + # AUTHENTIFICATION | |
| 227 | + $rights = ",".getUserSetting ( $USERNAME , "user_rights" )."," ; | |
| 228 | + if ( strstr ( $rights , ",is_editor," ) or strstr ( $rights , ",is_sysop" ) ) $isEditor = true ; | |
| 229 | + else $isEditor = false ; | |
| 230 | + if ( strstr ( $rights , ",is_sysop," ) or strstr ( $rights , ",is_sysop" ) ) $isSysop = true ; | |
| 231 | + else $isSysop = false ; | |
| 232 | + if ( !$isSysop and !$isEditor ) return "You are neither an editor nor a sysop. Return to the <a href=\"$PHP_SELF?no\">Main Page</a>" ; | |
| 233 | + | |
| 234 | + $ret = "" ; | |
| 235 | + if ( isset ( $editusername ) ) { | |
| 236 | + if ( isset ( $newuserrights ) ) { | |
| 237 | + changeUserSetting ( $editusername , "user_rights" , $newuserrights ) ; | |
| 238 | + $ret="<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$PHP_SELF?action=prefs\">" ; | |
| 239 | + } else { | |
| 240 | + $ret .= getStandardHeader () ; | |
| 241 | + $ret .= "<font size=\"+2\">Editing rights of user $editusername</font><br>" ; | |
| 242 | + $r = getUserSetting ( $editusername , "user_rights" ) ; | |
| 243 | + $ret .= "<FORM action=\"$PHP_SELF?action=editUserRights&editusername=$editusername\" method=post>\n" ; | |
| 244 | + $ret .= "User rights : <INPUT TABINDEX=1 TYPE=text NAME=newuserrights VALUE=\"$r\" SIZE=80><br>\n" ; | |
| 245 | + $ret .= "<INPUT TYPE=SUBMIT NAME=changeprefs value=\"Save new user rights\">\n" ; | |
| 246 | + $ret .= "</FORM>\n" ; | |
| 247 | + } | |
| 248 | + unset ( $editusername ) ; | |
| 249 | + unset ( $newuserrights ) ; | |
| 250 | + } else { | |
| 251 | + $ret .= getStandardHeader () ; | |
| 252 | + $connection=getDBconnection() ; | |
| 253 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 254 | + $sql = "SELECT * FROM user" ; | |
| 255 | + if ( !$isSysop ) $sql .= " WHERE user_rights NOT LIKE \"is_sysop\"" ; | |
| 256 | + $sql .= " ORDER BY user_name" ; | |
| 257 | + $result = mysql_query ( $sql , $connection ) ; | |
| 258 | + while ( $s = mysql_fetch_object ( $result ) ) { | |
| 259 | + $t = $s->user_name ; | |
| 260 | + $t = "<a href=\"$PHP_SELF?action=editUserRights&editusername=$t\">$t</a>" ; | |
| 261 | + $ret .= "Edit the rights of $t ($s->user_rights)<br>\n" ; | |
| 262 | + } | |
| 263 | + mysql_free_result ( $result ) ; | |
| 264 | + mysql_close ( $connection ) ; | |
| 265 | + $ret .= getStandardFooter () ; | |
| 266 | + } | |
| 267 | + | |
| 268 | + return $ret ; | |
| 269 | + } | |
| 270 | + | |
| 271 | + | |
| 272 | +function statistics () { | |
| 273 | + $ret = getStandardHeader () ; | |
| 274 | + $connection=getDBconnection() ; | |
| 275 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 276 | + $ret = getStandardHeader() ; | |
| 277 | + $ret .= "<h2>Article statistics</h2><ul>" ; | |
| 278 | + | |
| 279 | + $nf1 = "<font color=red><b>" ; | |
| 280 | + $nf2 = "</b></font>" ; | |
| 281 | + | |
| 282 | + # TOTAL | |
| 283 | + $sql = "SELECT COUNT(*) AS number FROM cur" ; | |
| 284 | + $result = mysql_query ( $sql , $connection ) ; | |
| 285 | + $s = mysql_fetch_object ( $result ) ; | |
| 286 | + $totalPages = $s->number ; | |
| 287 | + $ret .= "<li>There are $nf1$totalPages$nf2 pages in the database</li>" ; | |
| 288 | + mysql_free_result ( $result ) ; | |
| 289 | + | |
| 290 | + # /TALK | |
| 291 | + $sql = "SELECT COUNT(*) as number FROM cur WHERE cur_title LIKE \"%/Talk\"" ; | |
| 292 | + $result = mysql_query ( $sql , $connection ) ; | |
| 293 | + $s = mysql_fetch_object ( $result ) ; | |
| 294 | + $talkPages = $s->number ; | |
| 295 | + $ret .= "<li>There are $nf1$talkPages$nf2 <b>/Talk</b> pages</li>" ; | |
| 296 | + mysql_free_result ( $result ) ; | |
| 297 | + | |
| 298 | + # , NOT /TALK | |
| 299 | + $sql = "SELECT COUNT(*) as number FROM cur WHERE cur_title NOT LIKE \"%/Talk\" AND cur_text LIKE \"%,%\"" ; | |
| 300 | + $result = mysql_query ( $sql , $connection ) ; | |
| 301 | + $s = mysql_fetch_object ( $result ) ; | |
| 302 | + $commaPages = $s->number ; | |
| 303 | + $ret .= "<li>There are $nf1$commaPages$nf2 with a comma that are <i>not</i> <b>/Talk</b> pages</li>" ; | |
| 304 | + mysql_free_result ( $result ) ; | |
| 305 | + | |
| 306 | + # WIKIPEDIA NOT /TALK | |
| 307 | + $sql = "SELECT COUNT(*) as number FROM cur WHERE cur_title NOT LIKE \"%/Talk\" AND cur_title LIKE \"%ikipedia%\"" ; | |
| 308 | + $result = mysql_query ( $sql , $connection ) ; | |
| 309 | + $s = mysql_fetch_object ( $result ) ; | |
| 310 | + $wikiPages = $s->number ; | |
| 311 | + $ret .= "<li>There are $nf1$wikiPages$nf2 that have \"ikipedia\" in the title and are <i>not</i> <b>/Talk</b> pages</li>" ; | |
| 312 | + mysql_free_result ( $result ) ; | |
| 313 | + | |
| 314 | + # WIKIPEDIA NOT /TALK | |
| 315 | + $sql = "SELECT COUNT(*) as number FROM cur WHERE cur_title LIKE \"%/%\"" ; | |
| 316 | + $result = mysql_query ( $sql , $connection ) ; | |
| 317 | + $s = mysql_fetch_object ( $result ) ; | |
| 318 | + $subPages = $s->number - $talkPages; | |
| 319 | + $ret .= "<li>There are $nf1$subPages$nf2 subpages that are <i>not</i> <b>/Talk</b> pages</li>" ; | |
| 320 | + mysql_free_result ( $result ) ; | |
| 321 | + | |
| 322 | + # RESULT | |
| 323 | + $x = $commaPages - $wikiPages ; # Comma (no /Talk) - wiki pages = articles, including subpages | |
| 324 | + $ret .= "<li>That means there are about $nf1$x$nf2 articles, including subpages (except <b>/Talk</b>).</li>" ; | |
| 325 | + $y = $x - $subPages ; | |
| 326 | + $ret .= "<li>Or, there are about $nf1$y$nf2 articles, not counting any subpages!</li>" ; | |
| 327 | + $z = $totalPages - $talkPages - $commaPages ; | |
| 328 | + $ret .= "<li>Finally, there are about $nf1$z$nf2 junk pages :-(</li>" ; | |
| 329 | + | |
| 330 | + # OLD PAGES | |
| 331 | + $sql = "SELECT COUNT(*) as number FROM old" ; | |
| 332 | + $result = mysql_query ( $sql , $connection ) ; | |
| 333 | + $s = mysql_fetch_object ( $result ) ; | |
| 334 | + $oldPages = $s->number - $talkPages; | |
| 335 | + $p = round ( $oldPages / $totalPages , 2 ) ; | |
| 336 | + $ret .= "<li>And, there are $nf1$oldPages$nf2 old page versions in the database, giving an average of $p old pages on every active page.</li>" ; | |
| 337 | + mysql_free_result ( $result ) ; | |
| 338 | + | |
| 339 | + | |
| 340 | + $ret .= "</ul><hr>" ; | |
| 341 | + $ret .= "<h2>User statistics</h2><ul>" ; | |
| 342 | + | |
| 343 | + # USERS | |
| 344 | + $sql = "SELECT COUNT(*) as number FROM user" ; | |
| 345 | + $result = mysql_query ( $sql , $connection ) ; | |
| 346 | + $s = mysql_fetch_object ( $result ) ; | |
| 347 | + $numUser = $s->number ; | |
| 348 | + $ret .= "<li>There are currently $nf1$numUser$nf2 users signed up.</li>" ; | |
| 349 | + mysql_free_result ( $result ) ; | |
| 350 | + | |
| 351 | + # EDITORS AND SYSOPS | |
| 352 | + $sql = "SELECT COUNT(*) as number FROM user WHERE user_rights LIKE \"%is_editor%\" OR user_rights LIKE \"%is_sysop%\"" ; | |
| 353 | + $result = mysql_query ( $sql , $connection ) ; | |
| 354 | + $s = mysql_fetch_object ( $result ) ; | |
| 355 | + $numEditors = $s->number ; | |
| 356 | + $ret .= "<li>$nf1$numEditors$nf2 of them have sysop status.</li>" ; | |
| 357 | + mysql_free_result ( $result ) ; | |
| 358 | + | |
| 359 | + mysql_close ( $connection ) ; | |
| 360 | + $ret .= "</ul>" ; | |
| 361 | + $ret .= getStandardFooter () ; | |
| 362 | + return $ret ; | |
| 363 | + } | |
| 364 | + | |
| 365 | +# RANDOM PAGE | |
| 366 | +function randomPage () { | |
| 367 | + $connection=getDBconnection() ; | |
| 368 | + mysql_select_db ( "nikipedia" , $connection ) ; | |
| 369 | + $sql = "SELECT COUNT(*) AS number FROM cur" ; | |
| 370 | + $result = mysql_query ( $sql , $connection ) ; | |
| 371 | + $s = mysql_fetch_object ( $result ) ; | |
| 372 | + mt_srand((double)microtime()*1000000); | |
| 373 | + $randval = mt_rand(0,$s->number-1); | |
| 374 | + mysql_free_result ( $result ) ; | |
| 375 | + | |
| 376 | + $sql = "SELECT * FROM cur" ; | |
| 377 | + $result = mysql_query ( $sql , $connection ) ; | |
| 378 | + while ( $randval > 0 ) { | |
| 379 | + $s = mysql_fetch_object ( $result ) ; | |
| 380 | + $randval-- ; | |
| 381 | + } | |
| 382 | + $thelink = $s->cur_title ; | |
| 383 | + $ret = "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$PHP_SELF?title=$thelink&action=view\">" ; | |
| 384 | + mysql_free_result ( $result ) ; | |
| 385 | + mysql_close ( $connection ) ; | |
| 386 | + | |
| 387 | + return $ret ; | |
| 388 | + } | |
| 389 | + | |
| 390 | +function pageIndex () { | |
| 391 | + global $search , $action , $dosearch ; | |
| 392 | + $action = "search" ; | |
| 393 | + $dosearch = 1 ; | |
| 394 | + $search = "" ; | |
| 395 | + return doSearch () ; | |
| 396 | + } | |
| 397 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/higher_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 398 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 399 | + native |
| Added: svn:executable | ||
| 3 | 400 | + * |
| Index: trunk/phpwiki/essential_functions.php | ||
| — | — | @@ -0,0 +1,9 @@ |
| 2 | +<? | |
| 3 | +function getDBconnection () { | |
| 4 | + $server="127.0.0.1" ; | |
| 5 | + $user="manske" ; | |
| 6 | + $passwd="test" ; | |
| 7 | + $connection=mysql_connect ( $server , $user , $passwd ) ; | |
| 8 | + return $connection ; | |
| 9 | + } | |
| 10 | +?> | |
| \ No newline at end of file | ||
| Property changes on: trunk/phpwiki/essential_functions.php | ||
| ___________________________________________________________________ | ||
| Added: svn:keywords | ||
| 1 | 11 | + Author Date Id Revision |
| Added: svn:eol-style | ||
| 2 | 12 | + native |
| Added: svn:executable | ||
| 3 | 13 | + * |
US