From 39466ce5f43aecbae05f8c65f35cf40e7b8d3ee8 Mon Sep 17 00:00:00 2001 From: ahollosi Date: Fri, 2 Jun 2000 15:59:04 +0000 Subject: [PATCH] initial commit for 1.1.4 git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@6 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- HISTORY | 37 +++++++ README | 23 ++--- index.php3 | 1 - pgsrc/AddingPages | 22 ++--- pgsrc/ConvertSpacesToTabs | 38 ++++---- pgsrc/EditText | 2 +- pgsrc/FindPage | 38 ++++---- pgsrc/FrontPage | 10 +- pgsrc/GoodStyle | 26 ++--- pgsrc/HowToUseWiki | 73 +++++++------- pgsrc/MoreAboutMechanics | 34 +++---- pgsrc/RecentChanges | 41 ++++---- pgsrc/RecentVisitors | 10 +- pgsrc/ReleaseNotes | 26 ++--- pgsrc/SteveWainstead | 14 +-- pgsrc/TextFormattingRules | 155 +++++++++++++++-------------- pgsrc/WabiSabi | 52 +++++----- pgsrc/WhatIsWikiWikiWeb | 24 ++--- wiki_config.php3 | 25 ++++- wiki_dbmlib.php3 | 89 ++++++++--------- wiki_display.php3 | 199 +------------------------------------- wiki_editlinks.php3 | 37 ++++--- wiki_editpage.php3 | 16 +-- wiki_fullsearch.php3 | 48 ++++----- wiki_savepage.php3 | 20 ++-- wiki_search.php3 | 32 +++--- wiki_setupwiki.php3 | 12 +-- wiki_stdlib.php3 | 195 +++++++++++++++++++++++++++++++------ 28 files changed, 639 insertions(+), 660 deletions(-) diff --git a/HISTORY b/HISTORY index e0cdd02fb..ff9f1a3b4 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,40 @@ +1.1.4 05/11/00: I added the new linking +scheme, which largely follows the scheme of Wikic +(http://wiki.cs.uiuc.edu/RefactoringBrowser/Wiki+Syntax). Both "classic +Wiki" linking and the new linking are supported; you can now also link +things by using square brackets, like this: + +[this is a page link] +[this is an external link | http://wcsb.org/] +[ftp://ftp.redhat.com/] + +Reference links are still supported. + +1.1.3 04/22/00: I rewrote UpdateRecentChanges completely; it's more +efficient now because it only loops over the lines once, and entries are +now newest-first instead of oldest-first. + +1.1.2 04/20/00: I finally solved the problem once and for all (I hope!) +with loading pages into a brand new wiki. Vim allows you to change the +file formats so I wrote a two line ex script to convert all the pages to +dos format. (This gives them the CR/NL, unlike Un*x). + +1.1.1 04/15/00: I changed the way Wiki markup is converted and +displayed. Before pages were rendered line by line; now it accumulates +all the HTML in a variable and does one "echo" to display the page. +While this might be a bit slower (it will use a little bit more memory) +this means PhpWiki can be modified so the HTML can be written to a file. +a whole PhpWiki site might either be served as static HTML, or +periodically exported to disk after a period of activity. This is the +secod beta (more or less) of the 1.1 release. + +1.1.0 04/10/00: Support for MySQL added. Thanks to Arno Hollosi for +his excellent work! He also provided patches to clean up the wiki_setup +procedure and fix rendering bugs with italics and bold text, amongst +others. Alister provided patches for arbitrary +numbers of reference links, fixing a rotten logic error on my part. +Removed "static" declarations to help the PHP4 porters. + 1.03 03/21/00: Refactored index.php3 and wiki_display.php3, which had dbm function calls in them. Thanks to Christian Lindig for pointing this out. This should make it diff --git a/README b/README index f50087f57..440f0befa 100644 --- a/README +++ b/README @@ -1,36 +1,29 @@ -Thanks to: -John Jorgensen http://c2.com/cgi-bin/wiki?AnotherPhpWiki, -Tim Voght http://c2.com/cgi-bin/wiki?TimVoght, -Grant Morgan http://c2.com/cgi-bin/wiki?GrantMorgan, - -and especially Clifford A. Adams: -http://c2.com/cgi-bin/wiki?CliffordAdams - -who gave invaluable feedback and patches to my little project! This web application is licensed under the Gnu Public License, which should be included in the same directory as this README. A copy can be found at http://www.gnu.org/copyleft/gpl.txt. See INSTALL for installation notes. -My test version uses a dbm file in the /tmp directory; you may wish -a more permanent place for yours, but make sure it's read/writable by -your web server! +See INSTALL.mysql for using PhpWiki with MySQL. + +The out-of-the-box version uses a dbm file in the /tmp directory; you may +wish a more permanent place for yours, but make sure it's read/writable +by your web server! +index.php3: the "main page", really a set of branching instructions wiki_config.php3: configuration options, constants, global variables wiki_dbmlib.php3: database access functions -wiki_display.php3: render a page +wiki_display.php3: display a page (this calls "wiki_transform.php3") wiki_editlinks.php3: edit the embedded links of a page wiki_editpage.php3: edit a page wiki_fullsearch.php3: full page text search -index.php3: the "main page", really a set of branching instructions wiki_savepage.php3: save a page to db, thank user wiki_search.php3: page title search wiki_setupwiki.php3: load a set of pages from ./pgsrc/ directory wiki_stdlib.php3: standard library of functions (non-db related) +wiki_transform.php3: convert wiki markup into HTML Steve Wainstead swain@wcsb.org -swain@nytimes.com http://wcsb.org/~swain/ diff --git a/index.php3 b/index.php3 index b620dbda0..dc7a25a24 100644 --- a/index.php3 +++ b/index.php3 @@ -6,7 +6,6 @@ include "wiki_config.php3"; include "wiki_stdlib.php3"; - include "wiki_dbmlib.php3"; // All requests require the database if ($copy) { diff --git a/pgsrc/AddingPages b/pgsrc/AddingPages index 0c8c6ca2a..33fe1f48c 100644 --- a/pgsrc/AddingPages +++ b/pgsrc/AddingPages @@ -1,11 +1,11 @@ -To add a new page to Wiki, all you have to do is come up with a meaningful title, capatalize all the words and StringThemTogetherLikeThis. Wiki automagically recognizes it as a hyperlink. - -Then you can go ahead and ClickTheQuestionMark at the end of your new hyperlink, and the Wiki will give you a window for making the new page. - -If you wish to add documents with complex markup to the Wiki, you might be better off providing a URL to it than trying to add the text of the document here, like so: - - PhpWiki project homepage: http://wcsb.org:8080/~swain/php/wiki/ - -The Wiki does not support HTML tags (see TextFormattingRules). They will just render like text. Wiki is meant to be as simple as possible to encourage use. - -Note that there is a feature that your system administrator can enable to allow embedded HTML, but there are security risks involved. +To add a new page to Wiki, all you have to do is come up with a meaningful title, capatalize all the words and StringThemTogetherLikeThis. Wiki automagically recognizes it as a hyperlink. + +Then you can go ahead and ClickTheQuestionMark at the end of your new hyperlink, and the Wiki will give you a window for making the new page. + +If you wish to add documents with complex markup to the Wiki, you might be better off providing a URL to it than trying to add the text of the document here, like so: + + PhpWiki project homepage: http://wcsb.org/~swain/php/wiki/ + +The Wiki does not support HTML tags (see TextFormattingRules). They will just render like text. Wiki is meant to be as simple as possible to encourage use. + +Note that there is a feature that your system administrator can enable to allow embedded HTML, but there are security risks involved. diff --git a/pgsrc/ConvertSpacesToTabs b/pgsrc/ConvertSpacesToTabs index a674e12b6..de9366c29 100644 --- a/pgsrc/ConvertSpacesToTabs +++ b/pgsrc/ConvertSpacesToTabs @@ -1,19 +1,19 @@ -VariousBrowsers have trouble with the tab character used in the TextFormattingRules. If you can't type a tab, or, if you are fixing up a page written by someone who didn't type tabs, then you should have us convert spans of spaces to tabs for you. You request space to tab conversion with the checkbox that appears near the bottom of EditText and EditCopy pages. It looks something like this... - - [ ] I can't type tabs. Please ConvertSpacesToTabs for me when I save. - -A span of spaces must be at least '''three''' spaces long to be recognized -as a tab. Use multiples of '''eight''' spaces to make multiple tabs. -Each span of eight spaces will convert to one tab. If the -last span comes up a little short, that's ok, as long as -there are at least three spaces in the last (only) span. - -'''Check your work.''' This sort of heuristic can lead to -unexpected results. ------ -[Maintenance note: This page is seen when the user clicks on the -"ConvertSpacesToTabs" link on any edit screen. It describes what happens -when you ask the system to do this, why you would want it to, and ways to -avoid the spaces-instead-of-tabs problem.] - - +VariousBrowsers have trouble with the tab character used in the TextFormattingRules. If you can't type a tab, or, if you are fixing up a page written by someone who didn't type tabs, then you should have us convert spans of spaces to tabs for you. You request space to tab conversion with the checkbox that appears near the bottom of EditText and EditCopy pages. It looks something like this... + + [ ] I can't type tabs. Please ConvertSpacesToTabs for me when I save. + +A span of spaces must be at least '''three''' spaces long to be recognized +as a tab. Use multiples of '''eight''' spaces to make multiple tabs. +Each span of eight spaces will convert to one tab. If the +last span comes up a little short, that's ok, as long as +there are at least three spaces in the last (only) span. + +'''Check your work.''' This sort of heuristic can lead to +unexpected results. +----- +[Maintenance note: This page is seen when the user clicks on the +"ConvertSpacesToTabs" link on any edit screen. It describes what happens +when you ask the system to do this, why you would want it to, and ways to +avoid the spaces-instead-of-tabs problem.] + + diff --git a/pgsrc/EditText b/pgsrc/EditText index d5f68f0cf..fa9f841c9 100644 --- a/pgsrc/EditText +++ b/pgsrc/EditText @@ -1 +1 @@ -All pages (except search results) have an EditText link at the bottom. You can edit the page you are reading by clicking that link. +All pages (except search results) have an EditText link at the bottom. You can edit the page you are reading by clicking that link. diff --git a/pgsrc/FindPage b/pgsrc/FindPage index 59901626f..5e4de34cb 100644 --- a/pgsrc/FindPage +++ b/pgsrc/FindPage @@ -1,19 +1,19 @@ -Here are some good starting points for browsing. - - * HowToUseWiki gives you the quick lowdown on Wiki markup. - * RecentChanges recorded automatically - * MoreAboutMechanics of browsing and editing on this server - - - -Here's a title search. Try something like ''wiki'' -or ''sandwich''. - -[Search] - -Use the following for a full text search. This takes a few seconds. The results will show all lines on a given page that contain a match. - -[Fullsearch] - - - +Here are some good starting points for browsing. + + * HowToUseWiki gives you the quick lowdown on Wiki markup. + * RecentChanges recorded automatically + * MoreAboutMechanics of browsing and editing on this server + + + +Here's a title search. Try something like ''wiki'' +or ''sandwich''. + +[Search] + +Use the following for a full text search. This takes a few seconds. The results will show all lines on a given page that contain a match. + +[Fullsearch] + + + diff --git a/pgsrc/FrontPage b/pgsrc/FrontPage index 6d8f90530..65d5fc075 100644 --- a/pgsrc/FrontPage +++ b/pgsrc/FrontPage @@ -1,5 +1,5 @@ - *WhatIsWikiWikiWeb? Click here to find out! - *Learn HowToUseWiki and learn about AddingPages - *Please sign your name in RecentVisitors. - *See RecentChanges for the latest page additions and changes. - + *WhatIsWikiWikiWeb? Click here to find out! + *Learn HowToUseWiki and learn about AddingPages + *Please sign your name in RecentVisitors. + *See RecentChanges for the latest page additions and changes. + diff --git a/pgsrc/GoodStyle b/pgsrc/GoodStyle index 7ea7894e0..a47649879 100644 --- a/pgsrc/GoodStyle +++ b/pgsrc/GoodStyle @@ -1,13 +1,13 @@ -"Young writers often suppose that style is a garnish for the meat of -prose, a sauce by which a dull dish is made palatable. Style has no such -separate entity; it is nondetachable, unfilterable. The beginner should -approach style warily, realizing that it is himself he is approaching, no -other; and he should begin by turning resolutely away from all devices -that are popularly believed to indicate style--all mannerisms, tricks, -adornments. The approach to style is by way of plainness, simplicity, -orderliness, sincerity." - ---Strunk and White, "The Elements of Style" - -''And thus an American textbook, typical required reading for 10th-grade English students, unknowingly extols some virtues of WabiSabi'' ---scummings +"Young writers often suppose that style is a garnish for the meat of +prose, a sauce by which a dull dish is made palatable. Style has no such +separate entity; it is nondetachable, unfilterable. The beginner should +approach style warily, realizing that it is himself he is approaching, no +other; and he should begin by turning resolutely away from all devices +that are popularly believed to indicate style--all mannerisms, tricks, +adornments. The approach to style is by way of plainness, simplicity, +orderliness, sincerity." + +--Strunk and White, "The Elements of Style" + +''And thus an American textbook, typical required reading for 10th-grade English students, unknowingly extols some virtues of WabiSabi'' +--scummings diff --git a/pgsrc/HowToUseWiki b/pgsrc/HowToUseWiki index 462cce875..23e4ee8a3 100644 --- a/pgsrc/HowToUseWiki +++ b/pgsrc/HowToUseWiki @@ -1,38 +1,35 @@ -''"Wiki wiki"'' means "quick" in Hawai'ian. - -'''All you really need to know is:''' - - * To edit any page click on the Edit Text link at the bottom of -the page. You should do that right now, and read the source code of this -page. It will make more sense. - * You get italics by surrounding words with two single quotes on -either side ''like this''. - * You get '''bold text''' by using three quotes on either side. - * And, '''''bold italics''''' with five. - * You get bullets by using a tab and an asterick * - * If you use Windows, you can't use your tab key. It's Bill -Gates's fault. But you can check the little box that says Convert Spaces -To Tabs. You can type a bunch of spaces and the Wiki will recognize them -as a tab. - * To have plain monospaced font, indent with a space: - - this is a poem - about monospacing - nothing rhymes with poem - nothing rhymes with monospacing - - * You can seperate paragraphs with an extra blank line. Example: - -I am a paragraph. - -I am a paragraph too. We're just very small paragraphs. - - - * You can get horizontal rules with four or more dashes like this: ----- - * To create hyperlinks you just capitalize the words and string them together. Let's say you want to create a page about how Steve Wainstead eats worms. All you have to do is capitalize each word and string them together like this: SteveWainsteadEatsWorms. If the page does not exist yet a question mark appears after the link, inviting you to create the page: ThisPageShouldNotExist. (And please don't ruin the example by creating one.) - * To link to pages outside the Wiki, you can just type in the URL and Wiki will link it for you: http://www.nytimes.com/ - * Now you are ready to begin AddingPages. - ----- -A WikiWikiWeb is meant to be fast and easy to edit. It has very simple markup that you can read about in TextFormattingRules. +''"Wiki wiki"'' means "quick" in Hawai'ian. + +'''All you really need to know is:''' + + * To edit any page click on the Edit Text link at the bottom of +the page. You should do that right now, and read the source code of this +page. It will make more sense. + * You get italics by surrounding words with two single quotes on +either side ''like this''. + * You get '''bold text''' by using three quotes on either side. + * And, '''''bold italics''''' with five. + * You get bullets by using a tab and an asterick * + * If you use Windows, you can't use your tab key. It's Bill Gates's fault. But you can check the little box that says Convert Spaces To Tabs. You can type a bunch of spaces and the Wiki will recognize them as a tab. + * To have plain monospaced font, indent with a space: + + this is a poem + about monospacing + nothing rhymes with poem + nothing rhymes with monospacing + + * You can seperate paragraphs with an extra blank line. Example: + +I am a paragraph. + +I am a paragraph too. We're just very small paragraphs. + + + * You can get horizontal rules with four or more dashes like this: +---- + * To create hyperlinks you just capitalize the words and string them together. Let's say you want to create a page about how Steve Wainstead eats worms. All you have to do is capitalize each word and string them together like this: SteveWainsteadEatsWorms. If the page does not exist yet a question mark appears after the link, inviting you to create the page: ThisPageShouldNotExist. (And please don't ruin the example by creating one.) + * To link to pages outside the Wiki, you can just type in the URL and Wiki will link it for you: http://www.nytimes.com/ + * Now you are ready to begin AddingPages. + +---- +A WikiWikiWeb is meant to be fast and easy to edit. It has very simple markup that you can read about in TextFormattingRules. diff --git a/pgsrc/MoreAboutMechanics b/pgsrc/MoreAboutMechanics index edbe6f69b..2a3b1dd2a 100644 --- a/pgsrc/MoreAboutMechanics +++ b/pgsrc/MoreAboutMechanics @@ -1,17 +1,17 @@ -PhpWiki is written in the server-side scripting language PHP, available from http://www.php.net/. PHP resembles C and Perl in its syntax, and functions much like ASP, EmbPerl or JSP. - -PhpWiki consists of a dozen or so files of mixed PHP and HTML. The web pages that make up a WikiWikiWeb based on PHP live in a DBM file with backup copies of previous versions of pages stored in a second DBM file. - -Every time a user hits the site the page requested is pulled from the DBM and rendered on the fly. The user only ever requests the file index.php3, which then decides which other php files to include. - -Links to pages in the wiki are automatically linked: PhpWiki. This might be the single most compelling aspect of a wiki, the ability to add pages simply by linking to them. The next most compelling thing is how easily external URL's link: - # http://www.wcsb.org/ - # ftp://ftp.redhat.com/ - # news://news.mozilla.org/ - -Combined with one namespace and a simple markup, a Wiki exhibits many of the characteristics of WabiSabi. - -PhpWiki is licensed under the Gnu General Public license, which you should be able to see here: http://www.gnu.org/copyleft/gpl.txt. - - - +PhpWiki is written in the server-side scripting language PHP, available from http://www.php.net/. PHP resembles C and Perl in its syntax, and functions much like ASP, EmbPerl or JSP. + +PhpWiki consists of a dozen or so files of mixed PHP and HTML. The web pages that make up a WikiWikiWeb based on PHP live in a DBM file with backup copies of previous versions of pages stored in a second DBM file. + +Every time a user hits the site the page requested is pulled from the DBM and rendered on the fly. The user only ever requests the file index.php3, which then decides which other php files to include. + +Links to pages in the wiki are automatically linked: PhpWiki. This might be the single most compelling aspect of a wiki, the ability to add pages simply by linking to them. The next most compelling thing is how easily external URL's link: + # http://www.wcsb.org/ + # ftp://ftp.redhat.com/ + # news://news.mozilla.org/ + +Combined with one namespace and a simple markup, a Wiki exhibits many of the characteristics of WabiSabi. + +PhpWiki is licensed under the Gnu General Public license, which you should be able to see here: http://www.gnu.org/copyleft/gpl.txt. + + + diff --git a/pgsrc/RecentChanges b/pgsrc/RecentChanges index cdb585074..7b2d7c774 100644 --- a/pgsrc/RecentChanges +++ b/pgsrc/RecentChanges @@ -1,21 +1,20 @@ -The most recently changes pages are listed below. - - -Day one: - - *WhatIsWikiWikiWeb - *HowToUseWiki - *AddingPages - *GoodStyle - *RecentVisitors - *ConvertSpacesToTabs - *SteveWainstead - *EditText - *MoreAboutMechanics - *TextFormattingRules - *FindPage - *RecentChanges - *WabiSabi - *FrontPage - *ReleaseNotes - +The most recently changes pages are listed below. + + +April 22, 2000 + *AddingPages + *ConvertSpacesToTabs + *EditText + *FindPage + *FrontPage + *GoodStyle + *HowToUseWiki + *MoreAboutMechanics + *RecentChanges + *RecentVisitors + *ReleaseNotes + *SteveWainstead + *TextFormattingRules + *WabiSabi + *WhatIsWikiWikiWeb + diff --git a/pgsrc/RecentVisitors b/pgsrc/RecentVisitors index 2e2d7637b..3ee786d09 100644 --- a/pgsrc/RecentVisitors +++ b/pgsrc/RecentVisitors @@ -1,5 +1,5 @@ -Sign and date your name below! - -SteveWainstead, Php Wiki author - - +Sign and date your name below! + +SteveWainstead, Php Wiki author + + diff --git a/pgsrc/ReleaseNotes b/pgsrc/ReleaseNotes index 280443a20..50041b1d6 100644 --- a/pgsrc/ReleaseNotes +++ b/pgsrc/ReleaseNotes @@ -1,13 +1,13 @@ -PhpWiki was written because I am so interested in WikiWikiWebs, and I haven't used PHP since version 2.0. I wanted to see how it had advanced. - -Version 1.0 is a near-perfect clone of the Portland Pattern Repository, http://c2.com/cgi-bin/wiki?WikiWikiWeb. In truth, I was using the Wiki script you can download from there as a model; that Wiki lacks a number of features the PPR has, like EditCopy. So in truth PhpWiki is a kind of hybrid of the PPR and the generic Wiki you can get from there (which is written in Perl). - -The one caveat of PhpWiki is the allowance of HTML if the line is preceded by a bar (or pipe, which is how I usually say it). (That's a '|'). It was very simple to add, and the idea came from a posting somewhere on the PPR about how AT&T had an internal Wiki clone and used the same technique. The ability to embed HTML is disabled by default for security reasons. - -Version 1.01 includes a patch that fixes a small error with rendering
lines. Thanks to Gerry Barksdale. - -See the HISTORY file for a rundown on the whole development process if that sort of thing really interests you :-) - ---SteveWainstead - - +PhpWiki was written because I am so interested in WikiWikiWebs, and I haven't used PHP since version 2.0. I wanted to see how it had advanced. + +Version 1.0 is a near-perfect clone of the Portland Pattern Repository, http://c2.com/cgi-bin/wiki?WikiWikiWeb. In truth, I was using the Wiki script you can download from there as a model; that Wiki lacks a number of features the PPR has, like EditCopy. So in truth PhpWiki is a kind of hybrid of the PPR and the generic Wiki you can get from there (which is written in Perl). + +The one caveat of PhpWiki is the allowance of HTML if the line is preceded by a bar (or pipe, which is how I usually say it). (That's a '|'). It was very simple to add, and the idea came from a posting somewhere on the PPR about how AT&T had an internal Wiki clone and used the same technique. The ability to embed HTML is disabled by default for security reasons. + +Version 1.01 includes a patch that fixes a small error with rendering
lines. Thanks to Gerry Barksdale. + +See the HISTORY file for a rundown on the whole development process if that sort of thing really interests you :-) + +--SteveWainstead + + diff --git a/pgsrc/SteveWainstead b/pgsrc/SteveWainstead index f93a14a81..869462e54 100644 --- a/pgsrc/SteveWainstead +++ b/pgsrc/SteveWainstead @@ -1,9 +1,5 @@ -Hi. I built this WikiWikiWeb. - -I work in the day at the New York Times on the Web (http://www.nytimes.com/), now part of Times Company Digital. Please report bugs to one of the email addresses below: - - *mailto:swain@wcsb.org - *mailto:swain@nytimes.com - *http://wcsb.org/~swain/ - - +Hi. I built this WikiWikiWeb. I'm at http://wcsb.org/~swain/. + +Please report bugs to mailto:swain@wcsb.org + + diff --git a/pgsrc/TextFormattingRules b/pgsrc/TextFormattingRules index 2c130a02b..200931c04 100644 --- a/pgsrc/TextFormattingRules +++ b/pgsrc/TextFormattingRules @@ -1,75 +1,80 @@ -'''Paragraphs''' - - * Don't Indent paragraphs - - * Words wrap and fill as needed - - * Use blank lines as separators - - * Four or more minus signs make a horizontal rule - - - -'''Lists''' - - * tab-* for first level - - * tab-tab-* for second level, etc. - - * Use * for bullet lists, 1. for numbered lists (mix at will) - - * tab-Term:-tab Definition for definition lists - - * One line for each item - - * Other leading whitespace signals preformatted text, changes font. - -'''Fonts''' - * Indent with one or more spaces to use a monospace font: - - This is in monospace -This is not - - - -'''Indented Paragraphs''' -''(Quotes)'' - - * tab-space-:-tab -- often used (with emphasis) for quotations. (See SimulatingQuoteBlocks) - - - -'''Emphasis''' - - * Use doubled single-quotes ('') for emphasis (usually italics) - - * Use tripled single-quotes (''') for strong emphasis (usually bold) - - * Use five single-quotes ('''''), or triples within doubles, for some other kind of emphasis (BoldItalicInWiki), but be careful about the bugs in the Wiki emphasis logic... - - * Emphasis can be used multiple times within a line, but cannot cross line boundaries - - - -'''References''' - - * JoinCapitalizedWords to make local references - - * [1], [2], [3], [4] refer to remote references. Click EditLinks on the edit form to enter URLs - - * Or precede URLs with "http:", "ftp:" or "mailto:" to create links automatically as in: http://c2.com/ - - * URLs ending with .gif are inlined ''if inserted as a remote reference'' - - -'''Mark-Up Language''' - - * Don't bother - - * < and > are themselves - - * The & characters will not work - - * If you really must use HTML, start each line with a bar (|). Note that this featured must be enabled by the system administrator. - - +'''Paragraphs''' + + * Don't Indent paragraphs + + * Words wrap and fill as needed + + * Use blank lines as separators + + * Four or more minus signs make a horizontal rule + + + +'''Lists''' + + * tab-* for first level + + * tab-tab-* for second level, etc. + + * Use * for bullet lists, 1. for numbered lists (mix at will) + + * tab-Term:-tab Definition for definition lists + + * One line for each item + + * Other leading whitespace signals preformatted text, changes font. + +'''Fonts''' + * Indent with one or more spaces to use a monospace font: + + This is in monospace +This is not + + + +'''Indented Paragraphs''' +''(Quotes)'' + + * tab-space-:-tab -- often used (with emphasis) for quotations. (See SimulatingQuoteBlocks) + + + +'''Emphasis''' + + * Use doubled single-quotes ('') for emphasis (usually italics) + + * Use tripled single-quotes (''') for strong emphasis (usually bold) + + * Use five single-quotes ('''''), or triples within doubles, for some other kind of emphasis (BoldItalicInWiki), but be careful about the bugs in the Wiki emphasis logic... + + * Emphasis can be used multiple times within a line, but cannot cross line boundaries + + + +'''References''' + * Hyperlinks to other pages within the Wiki are made by placing the page name in square brackets: [this is a page link] + + * Hyperlinks to external pages are done like this: [http://www.wcsb.org/] + + * You can name the links to the external pages by providing a name, a bar (|) and then the hyperlink: [Steve's home page | http://wcsb.org/~swain/] + + * Old Wiki linking is still supported: JoinCapitalizedWords to make local references + + * [1], [2], [3], [4] refer to remote references. Click EditLinks on the edit form to enter URLs. These differ from the newer linking scheme; references are unique to a page. + + * Also, the old way of linking URL's is still supported: precede URLs with "http:", "ftp:" or "mailto:" to create links automatically as in: http://c2.com/ + + * URLs ending with .png are inlined ''if inserted as a remote reference'' + + +'''Mark-Up Language''' + + * Don't bother + + * < and > are themselves + + * The & characters will not work + + * If you really must use HTML, start each line with a bar (|). Note that this featured must be enabled by the system administrator. + + diff --git a/pgsrc/WabiSabi b/pgsrc/WabiSabi index 97c44d939..d7c0125c4 100644 --- a/pgsrc/WabiSabi +++ b/pgsrc/WabiSabi @@ -1,26 +1,26 @@ -Since wabi-sabi represents a comprehensive Japanese world view or aesthetic system, it is difficult to explain precisely in western terms. According to Leonard Koren, wabi-sabi is the most conspicuous and characteristic feature of what we think of as traditional Japanese beauty and it "occupies roughly the same position in the Japanese pantheon of aesthetic values as do the Greek ideals of beauty and perfection in the West." - -Wabi-sabi is a beauty of things imperfect, impermanent, and incomplete. - -It is the beauty of things modest and humble. - -It is the beauty of things unconventional. - -The concepts of wabi-sabi correlate with the concepts of Zen Buddhism, as the first Japanese involved with wabi-sabi were tea masters, priests, and monks who practiced Zen. Zen Buddhism originated in India, traveled to China in the 6th century, and was first introduced in Japan around the 12th century. Zen emphasizes "direct, intuitive insight into transcendental truth beyond all intellectual conception." At the core of wabi- sabi is the importance of transcending ways of looking and thinking about things/existence. - - *All things are impermanent - *All things are imperfect - *All things are incomplete - -Material characteristics of wabi-sabi: - - *suggestion of natural process - *irregular - *intimate - *unpretentious - *earthy - *simple - -For more about wabi-sabi, see -http://www.art.unt.edu/ntieva/artcurr/japan/wabisabi.htm - +Since wabi-sabi represents a comprehensive Japanese world view or aesthetic system, it is difficult to explain precisely in western terms. According to Leonard Koren, wabi-sabi is the most conspicuous and characteristic feature of what we think of as traditional Japanese beauty and it "occupies roughly the same position in the Japanese pantheon of aesthetic values as do the Greek ideals of beauty and perfection in the West." + +Wabi-sabi is a beauty of things imperfect, impermanent, and incomplete. + +It is the beauty of things modest and humble. + +It is the beauty of things unconventional. + +The concepts of wabi-sabi correlate with the concepts of Zen Buddhism, as the first Japanese involved with wabi-sabi were tea masters, priests, and monks who practiced Zen. Zen Buddhism originated in India, traveled to China in the 6th century, and was first introduced in Japan around the 12th century. Zen emphasizes "direct, intuitive insight into transcendental truth beyond all intellectual conception." At the core of wabi- sabi is the importance of transcending ways of looking and thinking about things/existence. + + *All things are impermanent + *All things are imperfect + *All things are incomplete + +Material characteristics of wabi-sabi: + + *suggestion of natural process + *irregular + *intimate + *unpretentious + *earthy + *simple + +For more about wabi-sabi, see +http://www.art.unt.edu/ntieva/artcurr/japan/wabisabi.htm + diff --git a/pgsrc/WhatIsWikiWikiWeb b/pgsrc/WhatIsWikiWikiWeb index 223ab1af2..59fd0d8aa 100644 --- a/pgsrc/WhatIsWikiWikiWeb +++ b/pgsrc/WhatIsWikiWikiWeb @@ -1,12 +1,12 @@ -A WikiWikiWeb is a site where everyone can collaborate on the content. The most well-known and widely used Wiki is the Portland Pattern Repository at http://c2.com/cgi-bin/wiki?WikiWikiWeb. - -I found these statements there particularly relevant: - -''The point is to make the EditText form simple and the FindPage search fast.'' - -''In addition to being quick, this site also aspires to Zen ideals generally labeled WabiSabi. Zen finds beauty in the imperfect and ephemeral. When it comes down to it, that's all you need.'' - -You can say hello on RecentVisitors, or read about HowToUseWiki and AddingPages. Currently this Wiki has no "theme" for discussion, so go ahead and play with it and have fun! - ---SteveWainstead - +A WikiWikiWeb is a site where everyone can collaborate on the content. The most well-known and widely used Wiki is the Portland Pattern Repository at http://c2.com/cgi-bin/wiki?WikiWikiWeb. + +I found these statements there particularly relevant: + +''The point is to make the EditText form simple and the FindPage search fast.'' + +''In addition to being quick, this site also aspires to Zen ideals generally labeled WabiSabi. Zen finds beauty in the imperfect and ephemeral. When it comes down to it, that's all you need.'' + +You can say hello on RecentVisitors, or read about HowToUseWiki and AddingPages. Currently this Wiki has no "theme" for discussion, so go ahead and play with it and have fun! + +--SteveWainstead + diff --git a/wiki_config.php3 b/wiki_config.php3 index 767ebf61d..5c3d1f240 100644 --- a/wiki_config.php3 +++ b/wiki_config.php3 @@ -18,12 +18,33 @@ $ServerAddress = "http://$SERVER_NAME:$SERVER_PORT$REQUEST_URI"; } - $ScriptName = "index.php3"; + // if you are using MySQL instead of a DBM to store your + // Wiki pages, use wiki_mysql.php3 instead of wiki_dbmlib.php3 + // See INSTALL.mysql for details on using MySQL + + // DBM settings (default) + include "wiki_dbmlib.php3"; $WikiDataBase = "/tmp/wikidb"; // must be server-writable! $ArchiveDataBase = "/tmp/wikiarchive"; // see above! + + // MySQL settings (thanks Arno Hollosi! ) + // Comment out the lines above (for the DBM) if you use these +/* + include "wiki_mysql.php3"; + $WikiDataBase = "wiki"; + $ArchiveDataBase = "archive"; + $mysql_server = 'localhost'; + $mysql_user = 'root'; + $mysql_pwd = ''; + $mysql_db = 'wiki'; +*/ + + + $ScriptName = "index.php3"; $SignatureImg = "$ServerAddress/signature.png"; $logo = "wikibase.png"; + // you shouldn't have to edit anyting below this line $ScriptUrl = $ServerAddress . $ScriptName; @@ -39,7 +60,7 @@ // number of user-defined external links, i.e. "[1]" - define("NUM_LINKS", 4); + define("NUM_LINKS", 12); // try this many times if the dbm is unavailable define("MAX_DBM_ATTEMPTS", 20); diff --git a/wiki_dbmlib.php3 b/wiki_dbmlib.php3 index 58d3887c2..ec160de0d 100644 --- a/wiki_dbmlib.php3 +++ b/wiki_dbmlib.php3 @@ -5,20 +5,21 @@ CloseDataBase($dbi) RetrievePage($dbi, $pagename) InsertPage($dbi, $pagename, $pagehash) - UpdateRecentChanges($dbi, $pagename) IsWikiPage($dbi, $pagename) - SaveCopyToArchive($pagename, $pagehash) - PageExists($dbi, $pagename) + InitTitleSearch($dbi, $search) + TitleSearchNextMatch($dbi, &$pos) + InitFullSearch($dbi, $search) + FullSearchNextMatch($dbi, &$pos) */ // open a database and return the handle // loop until we get a handle; php has its own - // locking mechanism, thank god. This prints - // an ugly error message. Cannot prevent. + // locking mechanism, thank god. + // Suppress ugly error message with @. function OpenDataBase($dbname) { - while (($dbi = dbmopen($dbname, "c")) < 1) { + while (($dbi = @dbmopen($dbname, "c")) < 1) { if ($numattempts > MAX_DBM_ATTEMPTS) { echo "Cannot open database, giving up."; exit(); @@ -59,58 +60,52 @@ } } - // The Recent Changes file is solely handled here - function UpdateRecentChanges($dbi, $pagename) { - global $remoteuser; - $recentchanges = RetrievePage($dbi, "RecentChanges"); - - if ($recentchanges == -1) { - $recentchanges = array(); // First-time user, eh? :-) - } - - $recentchanges["text"] = preg_replace("/.*$pagename.*/", - "", - $recentchanges["text"]); + function IsWikiPage($dbi, $pagename) { + return dbmexists($dbi, $pagename); + } - $numlines = sizeof($recentchanges["text"]); - $currentdate = GetCurrentDate(); - if ($recentchanges["date"] != $currentdate) { - $recentchanges["text"][$numlines++] = "$currentdate"; - $recentchanges["text"][$numlines++] = "\n"; - $recentchanges["date"] = "$currentdate"; - } + // setup for title-search + function InitTitleSearch($dbi, $search) { + $pos['search'] = $search; + $pos['key'] = dbmfirstkey($dbi); + return $pos; + } - $recentchanges["text"][$numlines] = "\t*$pagename ..... $remoteuser"; + // iterating through database + function TitleSearchNextMatch($dbi, &$pos) { + while ($pos['key']) { + $page = $pos['key']; + $pos['key'] = dbmnextkey($dbi, $pos['key']); - // Clear out blank lines (they are size zero, not even \n) - $k = 0; - for ($i = 0; $i < ($numlines + 1); $i++) { - if (strlen($recentchanges["text"][$i]) != 0) { - $newpage[$k++] = $recentchanges["text"][$i]; + if (eregi($pos['search'], $page)) { + return $page; } } - $recentchanges["text"] = $newpage; - - InsertPage($dbi, "RecentChanges", $recentchanges); + return 0; } - - function IsWikiPage($dbi, $pagename) { - return dbmexists($dbi, $pagename); + // setup for full-text search + function InitFullSearch($dbi, $search) { + return InitTitleSearch($dbi, $search); } - - // for archiving pages to a seperate dbm - function SaveCopyToArchive($pagename, $pagehash) { - global $ArchiveDataBase; - $adbi = OpenDataBase($ArchiveDataBase); - $newpagename = $pagename; - InsertPage($adbi, $newpagename, $pagehash); - dbmclose($adbi); + //iterating through database + function FullSearchNextMatch($dbi, &$pos) { + while ($pos['key']) { + $key = $pos['key']; + $pos['key'] = dbmnextkey($dbi, $pos['key']); + + $pagedata = dbmfetch($dbi, $key); + // test the serialized data + if (eregi($pos['search'], $pagedata)) { + $page['name'] = $key; + $page['hash'] = unserialize($pagedata); + return $page; + } + } + return 0; } - - ?> diff --git a/wiki_display.php3 b/wiki_display.php3 index 2f6c627a1..65c0aec94 100644 --- a/wiki_display.php3 +++ b/wiki_display.php3 @@ -8,14 +8,7 @@ // if it wasn't this file would not have been included if ($argv[0]) { - // match pagename in GET data, or fail - if (ereg("^(([A-Z][a-z]+){2,})", $argv[0], $regs)) { - $pagename = $regs[1]; - } else { - // error, no valid page name passed in - echo "Error: invalid page name"; - exit(); - } + $pagename = rawurldecode($argv[0]); } else { $pagename = "FrontPage"; @@ -25,193 +18,9 @@ } } - WikiHeader($pagename); - - echo "

$LogoImage "; - echo "$pagename

\n"; - - $pagehash = RetrievePage($dbi, $pagename); - if (is_array($pagehash)) { - // we render the page if it's a hash, else ask the user to write - // one. - - // Set up inline links and images - for ($i = 1; $i < (NUM_LINKS + 1); $i++) { - if (! empty($pagehash["r$i"])) { - if (preg_match("/png$/i", $pagehash["r$i"])) { - // embed PNG images - $embedded[$i] = ""; - } else { - // ordinary embedded link - $embedded[$i] = "[$i]"; - } - } - } - - $numlines = count($pagehash["text"]); - - // Loop over all lines of tha page and apply transformation rules - for ($index = 0; $index < $numlines; $index++) { - $tmpline = $pagehash["text"][$index]; - - // workaround for null array elements bug - // This was affecting RecentChanges but no more - if (strlen($tmpline) == 0) { - continue; - } - - if (strlen($tmpline) == 1) { - // this is a blank line, send

- SetHTMLOutputMode("p", ZERO_DEPTH, 0); - continue; - - } -/* If your web server is not accessble to the general public, you may allow this code below, - which allows embedded HTML. If anyone can reach your web server it is highly advised that - you do not allow this. - - elseif (preg_match("/(^\|)(.*)/", $tmpline, $matches)) { - // HTML mode - SetHTMLOutputMode("", ZERO_DEPTH, 0); - echo $matches[2]; - continue; - } -*/ - // escape HTML metachars - $tmpline = ereg_replace("[&]", "&", $tmpline); - $tmpline = ereg_replace("[>]", ">", $tmpline); - $tmpline = ereg_replace("[<]", "<", $tmpline); - - // four or more dashes to


- $tmpline = ereg_replace("^-{4,}", "
", $tmpline); - - - // replace all URL's with tokens, so we don't confuse them - // with Wiki words later. Wiki words in URL's break things. - - $hasURLs = preg_match_all("/\b((http)|(ftp)|(mailto)|(news)|(file)|(gopher)):[^\s\<\>\[\]\"'\(\)]*[^\s\<\>\[\]\"'\(\)\,\.\?]/", $tmpline, $urls); - - // workaround: php can only do global search and replace which - // renders wrong when the domain appears in two consecutive URL's - // on the same line, but the second is longer i.e. - // http://c2.com followed by http://c2.com/wiki - rsort($urls[0]); - reset($urls[0]); - - for ($i = 0; $i < $hasURLs; $i++) { - $inplaceURL = preg_quote($urls[0][$i]); - $URLtoken = "${FieldSeparator}${i}${FieldSeparator}"; - $tmpline = preg_replace("|$inplaceURL|", - $URLtoken, - $tmpline); - } - - // bold italics - $tmpline = eregi_replace("(''''')(.*)(''''')", - "\\2", - $tmpline); - - // bold - $tmpline = eregi_replace("(''')(.*)(''')", - "\\2", - $tmpline); - - // italics - $tmpline = eregi_replace("('')(.*)('')", - "\\2", - $tmpline); - - // Link Wiki words - if (preg_match_all("#\b(([A-Z][a-z]+){2,})\b#", - $tmpline, - $link)) { - - // uniq the list of matches - $hash = ""; - for ($i = 0; $link[0][$i]; $i++) { - // $realfile = $link[0][$i]; - $hash[$link[0][$i]]++; - } - - reset($hash); - while (list($realfile, $val) = each($hash)) { - if (IsWikiPage($dbi, $realfile)) { - $tmpline = preg_replace("|\b$realfile\b|", - LinkExistingWikiWord($realfile), - $tmpline); - } else { - $tmpline = preg_replace("|\b$realfile\b|", - LinkUnknownWikiWord($realfile), - $tmpline); - } - } - - } - - // put URLs back, linked - for ($i = 0; $i < $hasURLs; $i++) { - $inplaceURL = ""; - $inplaceURL .= $urls[0][$i] . ""; - $URLtoken = "${FieldSeparator}${i}${FieldSeparator}"; - $tmpline = preg_replace("|$URLtoken|", - $inplaceURL, - $tmpline); - } - - - // Insert search boxes, if needed - $tmpline = ereg_replace("\[Search]", RenderQuickSearch(), $tmpline); - $tmpline = ereg_replace("\[Fullsearch]", RenderFullSearch(), $tmpline); - - // match and replace all user-defined links ([1], [2], [3]...) - preg_match_all("|\[(\d)\]|", $tmpline, $match); - if (count($match[0])) { - for ($k = 0; $k < count($match[0]); $k++) { - if (! empty($embedded[$match[1][$k]])) { - $linkpattern = preg_quote($match[0][$k]); - $tmpline = preg_replace("|$linkpattern|", - $embedded[$match[1][$k]], - $tmpline); - } - } - } - - // HTML modes: pre, unordered/ordered lists, term/def - if (preg_match("/(^\t)(.*?)(:\t)(.*$)/", $tmpline, $matches)) { - // this is a dictionary list item - SetHTMLOutputMode("dl", SINGLE_DEPTH, 1); - $tmpline = "
" . $matches[2] . "
" . $matches[4]; - - } elseif (preg_match("/(^\t+)(\*|\d|#)/", $tmpline, $matches)) { - // this is part of a list - $numtabs = strlen($matches[1]); - if ($matches[2] == "*") { - $listtag = "ul"; - } else { - $listtag = "ol"; // a rather tacit assumption. oh well. - } - $tmpline = preg_replace("/^(\t+)(\*|\d|#)/", "", $tmpline); - SetHTMLOutputMode($listtag, SINGLE_DEPTH, $numtabs); - echo "
  • "; - - } elseif (preg_match("/^\s+/", $tmpline)) { - // this is preformatted text, i.e.
    -            SetHTMLOutputMode("pre", ZERO_DEPTH, 0);
    -
    -         } else {
    -            // it's ordinary output if nothing else
    -            SetHTMLOutputMode("", ZERO_DEPTH, 0);
    -         }
    -
    -         echo "$tmpline"; // at last, emit the code
    -      }
    -
    -   } else {
    -      echo "Describe $pagename? here.\n";
    -   }
    +   // This file returns a variable $html containing all the HTML markup
    +   include("wiki_transform.php3");
    +   echo $html;
     
    -   SetHTMLOutputMode("", ZERO_DEPTH, 0);
    -   WikiToolBar();
    -   WikiFooter();
     ?>
     
    diff --git a/wiki_editlinks.php3 b/wiki_editlinks.php3
    index da0b78a6a..f02c516e5 100644
    --- a/wiki_editlinks.php3
    +++ b/wiki_editlinks.php3
    @@ -1,6 +1,15 @@
      for this code.
    +   // This allows an arbitrary number of reference links.
    +
    +   $pagename = rawurldecode($links);
    +   $pagehash = array();
        $pagehash = RetrievePage($dbi, $pagename);
    +   settype ($pagehash, 'array');
    +   for ($i = 1; $i <= NUM_LINKS; $i++)
    +   	  if (!isset($pagehash['r'.$i]))
    +   	  		$pagehash['r'.$i] = '';
    +   	  	
     ?>
     
     
    @@ -13,21 +22,21 @@
     

    Links

    -[1] -"> -
    -[2] -"> -
    -[3] -"> -
    -[4] -"> + +
    \n"; + } + +?>

    -Type the full URL (http:// ...) for each reference cited in the text.

    - +Type the full URL (http:// ...) for each reference cited in the +text.

    + + diff --git a/wiki_editpage.php3 b/wiki_editpage.php3 index 4fe71ff01..2f263d532 100644 --- a/wiki_editpage.php3 +++ b/wiki_editpage.php3 @@ -7,17 +7,17 @@ */ if ($edit) { - $pagename = $edit; + $pagename = rawurldecode($edit); $banner = "$pagename"; } elseif ($copy) { - $pagename = $copy; + $pagename = rawurldecode($copy); $banner = "Copy of $pagename"; } else { echo "No page name passed into editpage!
    \n"; exit(); } - WikiHeader($pagename); + echo WikiHeader($pagename); ?>

    "> @@ -54,20 +54,22 @@ tips for editing.
    -?links=">EditLinks +?links=">EditLinks to other web servers.
    EditCopy"; + $enc_name = rawurlencode($lastcopy); + echo "EditCopy"; echo " from previous author"; } ?> - +
    - + diff --git a/wiki_fullsearch.php3 b/wiki_fullsearch.php3 index 766f54b33..302cb2f56 100644 --- a/wiki_fullsearch.php3 +++ b/wiki_fullsearch.php3 @@ -4,44 +4,36 @@ A few too many regexps for my liking, but it works. */ - WikiHeader("Search Results"); + echo WikiHeader("Search Results"); echo "

    $LogoImage Search Results

    \n"; $found = $count = 0; // from classic wiki: $pat =~ s/[+?.*()[\]{}|\\]/\\$&/g; + // disallow _'_ and _%_ too, _\_ have to be doubled + $full = preg_replace("/[+?.*()'%[\\]{}|\\\\]/", "", $full); - $full = preg_replace("/[+?.*()[\]{}|\\\]/", "", $full); + // search matching pages + $query = InitFullSearch($dbi, $full); + while ($page = FullSearchNextMatch($dbi, $query)) { + $pagename = $page['name']; + $pagehash = $page['hash']; - // looping through all keys - $key = dbmfirstkey($dbi); - - while ($key) { - $pagedata = dbmfetch($dbi, $key); - - // test the serialized data first, before going further - if (preg_match("/$full/i", $pagedata)) { - - echo "

    ", LinkExistingWikiWord($key), "

    \n"; - $pagehash = unserialize($pagedata); + echo "

    ", LinkExistingWikiWord($pagename), "

    \n"; + $count++; - // print out all matching lines, highlighting the match - for ($j = 0; $j < (count($pagehash["text"])); $j++) { - if (preg_match("/$full/i", $pagehash["text"][$j], $pmatches)) { - $matched = preg_replace("/$full/i", "\\0", - $pagehash["text"][$j]); - $found += count($pmatches); - echo "
  • ", $matched, "
  • \n"; - } + // print out all matching lines, highlighting the match + for ($j = 0; $j < (count($pagehash["text"])); $j++) { + if (preg_match("/$full/i", $pagehash["text"][$j], $pmatches)) { + $matched = preg_replace("/$full/i", "\\0", + $pagehash["text"][$j]); + echo "
  • ", $matched, "
  • \n"; + $found += count($pmatches); } - echo "
    \n"; } - $count++; - $key = dbmnextkey($dbi, $key); + echo "
    \n"; } - echo "$found matches found out of $count pages searched.\n"; - WikiFooter(); - - + echo "$found matches found in $count pages.\n"; + echo WikiFooter(); ?> diff --git a/wiki_savepage.php3 b/wiki_savepage.php3 index e77a8ab9e..9b8df5390 100644 --- a/wiki_savepage.php3 +++ b/wiki_savepage.php3 @@ -7,7 +7,7 @@ coding it. */ - $pagename = $post; + $pagename = rawurldecode($post); $pagehash = RetrievePage($dbi, $pagename); // if this page doesn't exist yet, now's the time! @@ -38,21 +38,19 @@ } } - // Ward Cunningham has deprecated these, but I already - // implented them. You are discouraged from using them. - if (! empty($r1)) { $pagehash["r1"] = $r1; } - if (! empty($r2)) { $pagehash["r2"] = $r2; } - if (! empty($r3)) { $pagehash["r3"] = $r3; } - if (! empty($r4)) { $pagehash["r4"] = $r4; } + for ($i = 1; $i <= NUM_LINKS; $i++) { + if (! empty(${'r'.$i})) + $pagehash['r'.$i] = ${'r'.$i}; + } InsertPage($dbi, $pagename, $pagehash); UpdateRecentChanges($dbi, $pagename); - WikiHeader("Thanks for $pagename Edits"); + echo WikiHeader("Thanks for $pagename Edits"); ?> Thank you for editing $pagename
    \n"; + $enc_name = rawurlencode($pagename); + echo "$pagename
    \n"; ?> Your careful attention to detail is much appreciated.
    @@ -66,5 +64,5 @@ p.s. Be sure to Reload your old pages.
    echo "the DBM file to a permanent location or risk losing "; echo "all the pages!\n"; } - WikiFooter(); + echo WikiFooter(); ?> diff --git a/wiki_search.php3 b/wiki_search.php3 index ae75a244e..3cb0f181b 100644 --- a/wiki_search.php3 +++ b/wiki_search.php3 @@ -5,36 +5,32 @@ the logo, the title "Search Results," then a list of all Wiki pages that match seperated by five dots and the text that matched; an HR tag, and then a statement: - 32 pages found out of 94 pages searched. - where the numbers are correct. + 32 pages match your query. + where the number is correct. The online classic Wiki has both full search and title search. Title search is a good idea; it doesn't come with the script you download from c2.com. */ - WikiHeader("Search Results"); + echo WikiHeader("Search Results"); echo "

    $LogoImage Search Results

    \n"; - $found = $count = 0; + $found = 0; // from classic wiki: $pat =~ s/[+?.*()[\]{}|\\]/\\$&/g; - - $search = preg_replace("/[+?.*()[\]{}|\\\]/", "", $search); - - // looping through all keys - $key = dbmfirstkey($dbi); - while ($key) { - if (eregi("$search", $key)) { - $found++; - echo LinkExistingWikiWord($key), "
    \n"; - } - $count++; - $key = dbmnextkey($dbi, $key); + // disallow _'_ and _%_ too, _\_ have to be doubled + $search = preg_replace("/[+?.*()'%[\\]{}|\\\\]/", "", $search); + + // search matching pages + $query = InitTitleSearch($dbi, $search); + while ($page = TitleSearchNextMatch($dbi, $query)) { + $found++; + echo LinkExistingWikiWord($page), "
    \n"; } echo "
    \n"; - echo "$found pages found out of $count titles searched.\n"; - WikiFooter(); + echo "$found pages match your query.\n"; + echo WikiFooter(); ?> diff --git a/wiki_setupwiki.php3 b/wiki_setupwiki.php3 index b50ccad6d..cbc28f654 100644 --- a/wiki_setupwiki.php3 +++ b/wiki_setupwiki.php3 @@ -12,15 +12,9 @@ while ($file = readdir($handle)) { if (strlen($file) < 4) { continue; } - $page["text"] = file("pgsrc/$file"); -/* - for ($x = 0; $page["text"][$x]; $x++) { - if (strlen($page["text"][$x]) > 1) { - $page["text"][$x] = chop($page["text"][$x]); - } - } - reset($page["text"]); -*/ + $text = implode("", file("pgsrc/$file")); + $page["text"] = explode("\n", $text); + InsertPage($dbi, $file, $page); } closedir($handle); diff --git a/wiki_stdlib.php3 b/wiki_stdlib.php3 index f3ce97650..c1a888ce3 100644 --- a/wiki_stdlib.php3 +++ b/wiki_stdlib.php3 @@ -7,40 +7,43 @@ GetCurrentDate() LinkExistingWikiWord($wikiword) LinkUnknownWikiWord($wikiword) + LinkURL($url) RenderQuickSearch() RenderFullSearch() CookSpaces($pagearray) class Stack SetHTMLOutputMode($newmode, $depth) + UpdateRecentChanges($dbi, $pagename) + SaveCopyToArchive($pagename, $pagehash) + ParseAndLink($bracketlink) */ // render the Wiki toolbar at bottom of page function WikiToolBar() { global $ScriptUrl, $pagename, $pagehash; - echo "
    \n"; - echo "EditText\n"; - echo " of this page\n"; + $enc_name = rawurlencode($pagename); + + $retval = "
    \n"; + $retval .= "EditText\n"; + $retval .= " of this page\n"; if (is_array($pagehash)) { - echo " (last edited ", $pagehash["date"], ")\n"; + $retval .= " (last edited " . $pagehash["date"] . ")\n"; } - echo "
    \n"; + $retval .= "
    \n"; - echo "FindPage by browsing or searching\n"; + $retval .= "FindPage by browsing or searching\n"; + return $retval; } // top of page function WikiHeader($pagename) { global $LogoImage, $ScriptUrl; - echo "\n"; - echo "\n"; - echo "$pagename\n"; - echo "\n"; - echo "\n"; + return "\n\n$pagename\n\n\n"; } function WikiFooter() { - echo "\n\n"; + return "\n\n"; } function GetCurrentDate() { @@ -50,25 +53,32 @@ function LinkExistingWikiWord($wikiword) { global $ScriptUrl; - return "$wikiword"; + $enc_word = rawurlencode($wikiword); + return "$wikiword"; } function LinkUnknownWikiWord($wikiword) { global $ScriptUrl; - return "$wikiword?"; + $enc_word = rawurlencode($wikiword); + return "$wikiword?"; + + } + function LinkURL($url) { + global $ScriptUrl; + return "$url"; } function RenderQuickSearch() { global $value, $ScriptUrl; - static $formtext = "
    \n\n
    \n"; + $formtext = "
    \n\n
    \n"; return $formtext; } function RenderFullSearch() { global $value, $ScriptUrl; - static $formtext = "
    \n\n
    \n"; + $formtext = "
    \n\n
    \n"; return $formtext; } @@ -108,6 +118,10 @@ // end class definition + // I couldn't move this to wiki_config.php3 because it + // wasn't declared yet. + $stack = new Stack; + /* Wiki HTML output can, at any given time, be in only one mode. It will be something like Unordered List, Preformatted Text, @@ -115,13 +129,9 @@ for one mode and start tags for another. */ - // couldn't create a static version :-/ - // I couldn't move this to config.php3 because it - // wasn't declared yet. - $stack = new Stack; - function SetHTMLOutputMode($tag, $tagdepth, $tabcount) { global $stack; + $retvar = ""; if ($tagdepth == SINGLE_DEPTH) { @@ -136,17 +146,20 @@ //exit(); break; } - echo "\n"; + #echo "\n"; + $retvar .= "\n"; } - echo "<$tag>\n"; + #echo "<$tag>\n"; + $retvar .= "<$tag>\n"; $stack->push($tag); } elseif ($tabcount > $stack->cnt()) { // we add the diff to the stack // stack might be zero while ($stack->cnt() < $tabcount) { - echo "<$tag>\n"; + #echo "<$tag>\n"; + $retvar .= "<$tag>\n"; $stack->push($tag); if ($stack->cnt() > 10) { // arbitrarily limit tag nesting @@ -160,8 +173,10 @@ return; } else { $closetag = $stack->pop(); - echo "\n"; - echo "<$tag>\n"; + #echo "\n"; + #echo "<$tag>\n"; + $retvar .= "\n"; + $retvar .= "<$tag>\n"; $stack->push($tag); } } @@ -174,11 +189,13 @@ } while ($stack->cnt() > 0) { $closetag = $stack->pop(); - echo "\n"; + #echo "\n"; + $retvar .= "\n"; } if ($tag) { - echo "<$tag>\n"; + #echo "<$tag>\n"; + $retvar .= "<$tag>\n"; $stack->push($tag); } @@ -187,8 +204,128 @@ echo "Passed bad tag depth value in SetHTMLOutputMode\n"; exit(); } + + return $retvar; + } // end SetHTMLOutputMode + + // The Recent Changes file is solely handled here + function UpdateRecentChanges($dbi, $pagename) { + + global $remoteuser; // this is set in the config + + $recentchanges = RetrievePage($dbi, "RecentChanges"); + + // this shouldn't be necessary, since PhpWiki loads + // default pages if this is a new baby Wiki + if ($recentchanges == -1) { + $recentchanges = array(); + } + + $currentdate = GetCurrentDate(); + + if ($recentchanges["date"] != $currentdate) { + $isNewDay = TRUE; + $recentchanges["date"] = $currentdate; + } else { + $isNewDay = FALSE; + } + + $numlines = sizeof($recentchanges["text"]); + $newpage = array(); + $k = 0; + + // scroll through the page to the first date and break + for ($i = 0; $i < ($numlines + 1); $i++) { + if (preg_match("/^\w\w\w+ \d\d?, \d\d\d\d\r$/", + $recentchanges["text"][$i])) { + break; + } else { + $newpage[$k++] = $recentchanges["text"][$i]; + } + } + + // if it's a new date, insert it, else add the updated page's + // name to the array + + if ($isNewDay) { + $newpage[$k++] = "$currentdate\r"; + $newpage[$k++] = "\t* $pagename ..... $remoteuser\r"; + } else { + $newpage[$k++] = $recentchanges["text"][$i++]; + $newpage[$k++] = "\t* $pagename ..... $remoteuser\r"; + } + + // copy the rest of the page into the new array + for (; $i < ($numlines + 1); $i++) { + // skip previous entry for $pagename + if (preg_match("/\b$pagename\b/", $recentchanges["text"][$i])) { + continue; + } else { + $newpage[$k++] = $recentchanges["text"][$i]; + } + } + + $recentchanges["text"] = $newpage; + + InsertPage($dbi, "RecentChanges", $recentchanges); + } + + + // for archiving pages to a seperate dbm + function SaveCopyToArchive($pagename, $pagehash) { + global $ArchiveDataBase; + + $adbi = OpenDataBase($ArchiveDataBase); + $newpagename = $pagename; + InsertPage($adbi, $newpagename, $pagehash); + } + + function ParseAndLink($bracketlink) { + global $dbi; + + // $bracketlink will start and end with brackets; in between + // will be either a page name, a URL or both seperated by a pipe. + + // strip brackets and leading space + preg_match("/(\[\s*)(.+?)(\s*\])/", $bracketlink, $match); + $linkdata = $match[2]; + + // send back links that are only numbers (they are references) + if (preg_match("/^\d+$/", $linkdata)) { + return $bracketlink; + } + + // send back escaped ([[) bracket sets + if (preg_match("/^\[/", $linkdata)) { + return "$linkdata]"; + } + + // match the contents + preg_match("/([^|]+)(\|)?([^|]+)?/", $linkdata, $matches); + + if (isset($matches[3])) { + $URL = trim($matches[3]); + $linkname = trim($matches[1]); + return "$linkname"; + } + + if (isset($matches[1])) { + $linkname = trim($matches[1]); + if (IsWikiPage($dbi, $linkname)) { + return LinkExistingWikiWord($linkname); + } elseif (preg_match("#^http://|^mailto:|^ftp:|^news://|^file://|^gopher://#", $linkname)) { + return LinkURL($linkname); + } else { + return LinkUnknownWikiWord($linkname); + } + } + + return $bracketlink; + + } + ?> -- 2.45.0