root/trunk/wiki.php

Revision trunk,165, 25.3 kB (checked in by Suren A. Chilingaryan <csa@dside.dyndns.org>, 1 year ago)

Respect ADEI setup in WiKi? editor

Line 
1 <?php
2 #################################################################################
3 #                                                                               #
4 #   This program is free software; you can redistribute it and/or modify        #
5 #   it under the terms of the GNU General Public License as published by        #
6 #   the Free Software Foundation; either version 2 of the License, or           #
7 #   (at your option) any later version.                                         #
8 #                                                                               #
9 #   This program is distributed in the hope that it will be useful,             #
10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of              #
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
12 #   GNU General Public License for more details.                                #
13 #                                                                               #
14 #   You should have received a copy of the GNU General Public License           #
15 #   along with this program; if not, write to the Free Software                 #
16 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   #
17 #                                                                               #
18 #################################################################################
19
20 // Installation Instructions:
21 //
22 // Just save wiki.phps as wiki.php in your web directory and make sure that
23 // your web server is able to read and write the file. If you want a backup
24 // functionality, create a folder named 'history' at the place where wiki.php
25 // lives. Don't forget to give proper write rights to this folder.
26 //
27 // If you work with htacces, you can define an array named AUTHORS with a
28 // list of persons which are allowed to modify this wiki:
29 //   - when no array named AUTHORS is defined, everybody can write. This is default.
30 //   - when an array named AUTHORS is defined but empty, nobody can write
31 //
32 // examples:
33 //   $AUTHORS = array('buck','jack');  // only buck and jack bauer can modify the wiki
34 //   $AUTHORS = array();               // nobody can edit the wiki, mr. nobody can't also :-)
35 //   //$AUTHORS = array();             // everybody can edit the wiki
36 //   $FREE4ALL = array('public site'); // in order to enable a page which is editable by everyone,
37                                        // you can define this array which containing a string with the page title
38
39 global $ADEI;
40 global $ADEI_SETUP;
41 global $ADEI_ROOTDIR;
42 global $WIKI_FILENAME;
43 global $AJAX_MODE;
44 global $REQ;
45
46
47 function adeiChannels($type, $props) {
48     $bygroup = false;
49     
50     switch($type) {
51      case "channels_by_group":
52     $bygroup = true;   
53      break;
54      case "channels_by_name":
55     $channels = array();
56      break;
57     }
58
59     $res = "";
60
61     $req = new REQUEST($tmp = array());
62     $sources = $req->GetSources(REQUEST::SKIP_UNCACHED|REQUEST::LIST_ALL);
63     foreach ($sources as $sreq) {
64     $title = $sreq->GetSourceTitle();
65     
66     $groupinfo = $sreq->GetGroupList();
67     $groups = $sreq->GetGroups(NULL, REQUEST::SKIP_UNCACHED);
68
69     foreach ($groups as $gid => $greq) {
70         $gtitle = $title . " -- " . $groupinfo[$gid]["name"];
71         $gquery = $greq->GetGroupQueryString($props);
72         
73         $masklist = $greq->GetMaskList(REQUEST::NEED_INFO);
74         $defaultmask = array_shift($masklist);
75         $defaultmask = $defaultmask['mask'];
76         unset($masklist);
77         
78         $glink = $gquery . "&db_mask=$defaultmask";
79         
80         $list = $greq->GetItemList();
81         if ($bygroup) {
82         $first = true;
83         
84         foreach ($list as &$item) {
85             if (isset($item["uid"])) {
86             if ($first) {
87                 $first = false;
88                 $res .= "!!$gtitle ([link($glink)]" . _("View") . "[/link])[br]\n";
89             }
90             $link = $gquery . "&db_mask=" . $item['id'];
91             
92             $res .= "[link($link)]{$item['uid']}[/link] - " . xml_escape($item['name']) ."[br]\n";
93             }
94         }
95         
96         if (!$first) $res .= "[br][br]\n";
97         } else {
98         foreach ($list as &$item) {
99             if (isset($item["uid"])) {
100             $link = $gquery . "&db_mask=" . $item['id'];
101             array_push($channels, array(
102                 'uid' => $item["uid"],
103                 'link' => $link,
104                 'name' => xml_escape($item["name"]),
105                 'glink' => $glink,
106                 'gname' => xml_escape($gtitle)
107             ));
108             }
109         }
110         }
111     }
112     }
113
114     switch($type) {
115      case "channels_by_name":
116         usort($channels, create_function('$a, $b', '
117         return strcmp($a["uid"], $b["uid"]);
118     '));
119
120     $res .= "{| border=\"1px\"\n";
121     $res .= "UID || Group || Description\n|-\n";
122     foreach ($channels as &$item) {
123         $res .= "[link({$item['link']})]{$item['uid']}[/link] || [link({$item['glink']})]{$item['gname']}[/link]) || {$item['name']}\n|-\n";
124     }
125     $res .= "|}\n";
126
127 /*   
128     foreach ($channels as &$item) {
129         $res .= "[link({$item['link']})]{$item['uid']}[/link] (Group: [link({$item['glink']})]{$item['gname']}[/link]) - {$item['name']}[br]\n";
130     }
131 */
132      break;
133     }
134     
135     return $res;
136 }
137
138 function adeiGroupList($props) {
139     $res = "";
140         
141     $req = new REQUEST($tmp = array());
142     $sources = $req->GetSources(REQUEST::SKIP_UNCACHED|REQUEST::LIST_ALL);
143     foreach ($sources as $sreq) {
144     $title = $sreq->GetSourceTitle();
145     
146     $groupinfo = $sreq->GetGroupList();
147     $groups = $sreq->GetGroups(NULL, REQUEST::SKIP_UNCACHED);
148     foreach ($groups as $gid=>$greq) {
149         $res .= "!!" . xml_escape($title . " -- " . $groupinfo[$gid]["name"]) . "[br]\n";
150         $res .= "[preview(" .
151             $greq->GetGroupQueryString($props) .
152             "), link]";
153         $res .= "[br][br][br]\n";
154     }
155     }
156     
157     return $res;
158 }
159
160
161 class ErrorHandler {
162     public static function reportError($error) {
163         print '<b>Error:</b> '.$error.'<br/>';
164     }
165 }
166
167 class CodeInterpreter {
168     private static $instance;
169     private $wiki;
170
171     private function __construct($wiki) {
172         $this->wiki = $wiki;
173     }
174
175     public static function getInstance($wiki) {
176         if(!isset($instance) || $instance == null) {
177             $instance = new CodeInterpreter($wiki);
178         }
179         return($instance);
180     }
181
182     public function parseCode($string) {
183         $string = $this->compileVersion($string);
184         $string = $this->compileChannelList($string);
185         $string = $this->compileGroupList($string);
186         $string = $this->compilePreview($string);
187         $string = $this->resolveAdeiLink($string);
188         $string = $this->resolveInternalLink($string);
189         $string = $this->compileImage($string);
190         $string = $this->compileExternalLink($string);
191         $string = $this->compileExternalCustomLink($string);
192         $string = $this->compileMailTo($string);
193         $string = $this->compileBoldText($string);
194         $string = $this->compileItalicText($string);
195         $string = $this->compileUnderlineText($string);
196         $string = $this->compileHeader($string);
197         $string = $this->compileTable($string);
198         $string = $this->compileNewLine($string);
199         return($string);
200     }
201
202     private function compileTable($string) {
203         $string = preg_replace(
204             array(
205             "/^[ \t]*\{\|([^\r\n]*)/m",
206             "/^[ \t]*\|\}/m",
207             "/^[ \t]*\|-/m",
208             "/\|\|/m"
209             ), array(
210             '<table\\1><tr><td>',
211             '</td></tr></table>',
212             '</td></tr><tr><td>',
213             '</td><td>'
214             ), $string);
215             
216         return($string);
217     }
218     
219     private function compileNewLine($string) {
220         $string = preg_replace("/^[ \t]*\r?\n?$/m","<br/>",$string);
221         $string = eregi_replace("\[(br|hr)\]","<\\1/>",$string);
222         return($string);
223     }
224     
225     private function compileVersion($string) {
226         return preg_replace_callback(
227         "/\[\s*version\s*\]/",
228         create_function('$matches', '
229             if (file_exists("VERSION")) {
230             $stat = stat("VERSION");
231             $date = date("r", $stat["mtime"]);
232             
233             $version = file_get_contents("VERSION");
234             if (preg_match("/^\s*([\d.]+)/", $version, $m)) $version = $m[1];
235             
236             return "Version: $version from $date";
237             } else {
238             return "";
239             }
240         '),
241         $string
242         );
243
244     }
245     
246     private function compileChannelList($string) {
247         return preg_replace_callback(
248         "/\[\s*(channels_by_group|channels_by_name)\s*(\(([^\)\]]+)\))?\s*\]/",
249         create_function('$matches', '
250             return adeiChannels($matches[1], $matches[3]);
251         '),
252         $string
253         );
254     }
255     
256     private function compileGroupList($string) {
257         return preg_replace_callback(
258         "/\[\s*grouplist\s*(\(([^\)\]]+)\))?\s*\]/",
259         create_function('$matches', '
260             global $AJAX_MODE;
261
262             if (1||$AJAX_MODE) return adeiGroupList($matches[2]);
263             else return "[b] --- Group list would be displayed here --- [/b][br]\n";
264         '),
265         $string
266         );
267     }
268     
269     private function compilePreview($string) {
270         return preg_replace_callback(
271         "/\[\s*preview\s*\(([^\)\]]+)\)(\s*,\s*link\s*(\(([^\]\)]+)\))?)?\s*\]/",
272         create_function('$matches', '
273             global $REQ;
274             global $AJAX_MODE;
275             /* We can get here in problems due to overriding masks, etc. */
276             $zreq = new REQUEST($props = array());
277             //$zreq = $REQ; // enable to get some props from
278             
279             $img = "[img]services/getimage.php?" . $zreq->GetQueryString($matches[1], array(
280             "precision" => "LOW",
281             "hide_axes" => 1
282             )) . "[/img]";
283             if (($AJAX_MODE)&&($matches[2])) {
284             if ($matches[4]) {
285                 $query = $zreq->GetQueryString($matches[4], array(
286                 "module" => "graph"
287                 ));
288             } else {
289                 $query = $zreq->GetQueryString($matches[1], array(
290                 "module" => "graph"
291                 ));
292             }
293             $query = preg_replace("/&/", "&amp;", $query);
294             $img = preg_replace("/&/", "&amp;", $img);
295             return \'[url="javascript:wiki.SetConfiguration(\\\'\' . $query . \'\\\')"]\' . $img . \'[/url]\';
296             } else {
297             return $img;
298             }
299         '),
300         $string
301         );
302     }
303     
304     private function resolveAdeiLink($string) {
305         return preg_replace_callback(
306         "/\[\s*link\s*=?\s*(\(|\")([^\]]+)(\)|\")\s*\]([^\[]+)\[\s*\/link\s*\]/",
307         create_function('$matches', '
308             global $AJAX_MODE;
309             global $ADEI_SETUP;
310
311             $req = new REQUEST($props = array());
312             $query = $req->GetQueryString($matches[2], array(
313             "module" => "graph"
314             ));
315             $query = preg_replace("/&/", "&amp;", $query);
316             if ($AJAX_MODE) {
317             return \'[url="javascript:wiki.SetConfiguration(\\\'\' . $query . \'\\\')"]\' . $matches[4] . \'[/url]\';
318             } else {
319             return \'[url="index.php?setup=\' . $ADEI_SETUP . \'#\' . $query . \'"]\' . $matches[4] . \'[/url]\';
320             }
321         '),
322         $string
323         );
324     }
325
326     private function resolveInternalLink($string) {
327         global $AJAX_MODE;
328         global $ADEI_SETUP;
329         
330         preg_match_all('/\[\[[\w\s\d_-]*\]\]/', $string, $hits);
331         foreach($hits[0] as $hit) {
332             $title = preg_replace('/\[\[/', '', $hit);
333             $title = preg_replace('/\]\]/', '', $title);
334             if($this->wiki->getPage($title)->getContent() == '...') { $class = 'newpagelink';}
335             else {$class = 'link';}
336             if ($AJAX_MODE) {
337                 $string = preg_replace("/\[\[$title\]\]/",
338                     '<a class="'.$class.'" href="javascript:wiki.SetID('.$this->wiki->getPage($title)->getId().')">'.$title.'</a>',$string);
339             } else {
340                 $string = preg_replace("/\[\[$title\]\]/",
341                     '<a class="'.$class.'" href="?setup='.$ADEI_SETUP.'&pageid='.$this->wiki->getPage($title)->getId().'">'.$title.'</a>',$string);
342             }
343         }
344         return($string);
345     }
346
347     private function compileExternalLink($string) {
348         $string=eregi_replace("\[url\](javascript:[^\[]+)\[/url\]",
349                 "<a class=\"external\" href=\"\\1\">\\1</a>",$string);
350
351         $string=eregi_replace("\[url\]([^\[]+)\[/url\]",
352                 "<a class=\"external\" href=\"\\1\" target=\"_blank\">\\1</a>",$string);
353         return($string);
354     }
355
356     private function compileExternalCustomLink($string) {
357         $string=eregi_replace('\[url=\\\&quot;','[url="',$string);
358         $string=eregi_replace('\\\&quot;\]','"]',$string);
359
360         $string=eregi_replace('\[url="(javascript:[^\"]+)"]([^\[]+)\[/url\]',
361                 "<a class=\"external\" href=\"\\1\">\\2</a>",$string);
362         $string=eregi_replace('\[url="([^\"]+)"]([^\[]+)\[/url\]',
363                 "<a class=\"external\" href=\"\\1\" target=\"_blank\">\\2</a>",$string);
364         return($string);
365     }
366
367     private function compileMailTo($string) {
368         $string = eregi_replace("\[mail\]([^\[]+)\[/mail\]","<a href=\"mailto:\\1\">\\1</a>",$string);
369         return($string);
370     }
371
372     private function compileImage($string) {
373         $string = eregi_replace("\[img\]([^\[]+)\[/img\]","<img src=\"\\1\" border=\"0\"/>",$string);
374         return($string);
375     }
376
377     private function compileBoldText($string) {
378         $string = eregi_replace("\[b\]([^\[]+)\[/b\]","<b>\\1</b>",$string);
379         return($string);
380     }
381
382     private function compileItalicText($string) {
383         $string = eregi_replace("\[i\]([^\[]+)\[/i\]","<i>\\1</i>",$string);
384         return($string);
385     }
386
387     private function compileUnderlineText($string) {
388         $string = eregi_replace("\[u\]([^\[]+)\[/u\]","<u>\\1</u>",$string);
389         return($string);
390     }
391
392     private function compileHeader($string) {
393         $string = preg_replace('/\!\![^\ ].*\\n/e', "'<p class=\"wiki_header2\">'.substr('$0', 2).'</p>'", $string);
394         $string = preg_replace('/\![^\ ].*\\n/e', "'<p class=\"wiki_header\">'.substr('$0', 1).'</p>'", $string);
395         return($string);
396     }
397 }
398
399 class Page {
400     private $id;
401     private $title;
402     private $content;
403     private $wiki;
404
405     public function __construct($id, $title, $content, $wiki) {
406         $this->id = $id;
407         $this->title = $title;
408         $this->content = $content;
409         $this->wiki = $wiki;
410     }
411
412     public function getId() { return($this->id); }
413     public function getTitle() { return($this->title); }
414     public function getContent() { return($this->content); }
415     
416     public function includeHTMLContent($m) {
417         $page = $this->wiki->getPage($m[1]);
418         
419         if ($page) return $page->getHTMLContent(1);
420         return "";
421     }
422     
423     public function getHTMLContent() {
424         $string = CodeInterpreter::getInstance($this->wiki)->parseCode($this->content);
425         // $string = nl2br($string);
426         $string = preg_replace_callback("/\[include\(([^)]+)\)\]/i", array($this, "includeHTMLContent"), $string);
427         return $string;
428     }
429     public function setTitle($title) { $this->title = htmlspecialchars($title); }
430     public function setContent($content) { $this->content = htmlspecialchars($content); }
431 }
432
433
434 class Wiki {
435     private $fileName;
436     private $data;
437     private $xmlString;
438     private $pages = array();
439
440     public function __construct($fileName) {
441         $this->fileName = $fileName;
442         $this->readDataFromFile();
443         $this->extractXMLStringFromData();
444         $this->createPagesFromXML();
445     }
446
447     public function getPage($pageidentifier) {
448         if(is_integer($pageidentifier)) { // search with id
449             if(!isset($this->pages[$pageidentifier])) {
450                 // this feature is dangerous, return null
451                 //$this->pages[(int) $pageidentifier] = new Page((int)$pageidentifier, 'New Site', '...', $this);
452                 //$this->saveWikiToFile();
453                 return;
454             }
455             return($this->pages[$pageidentifier]);
456         } elseif(is_string($pageidentifier)) { //search with title
457             foreach($this->pages as $page) {
458                 if($page->getTitle() == $pageidentifier) {
459                     return($page);
460                 }
461             }
462             for($i = 1; true; $i++) {
463                 if(!array_key_exists($i, $this->pages)) {
464                     break;
465                 }
466             }
467             $this->pages[$i] = new Page($i, $pageidentifier, '...', $this);
468             $this->saveWikiToFile();
469             return($this->pages[$i]);
470         }
471     }
472
473     public function readDataFromFile() {
474         $this->data = "";
475         if((is_file($this->fileName))&&(filesize($this->fileName)>0)) {
476             $handle = fopen ($this->fileName, "r");
477             while (!feof($handle)) {
478                 $this->data .= fgets($handle, 4096);
479             }
480             fclose ($handle);
481         } else if (is_file($_SERVER['SCRIPT_FILENAME'])) {
482             $handle = fopen ($_SERVER['SCRIPT_FILENAME'], "r");
483             while (!feof($handle)) {
484                 $this->data .= fgets($handle, 4096);
485             }
486             fclose ($handle);
487         }
488     }
489
490     public function findXMLStartPosition() {
491         $i = 0;
492         while($i < strlen($this->data)) {
493             $i = strpos ($this->data, '<<' , $i);
494             if(substr($this->data, $i+2, 2) == '>>') {
495                 return($i+4);
496             }
497             $i++;
498         }
499     }
500
501     public function findXMLStopPosition() {
502         $i = strlen($this->data);
503         while($i >= 0) {
504             $schrumpf = substr($this->data, 0, $i);
505             if(substr($schrumpf, $i-2, 2) == '>>') {
506                 if(substr($schrumpf, $i-4, 2) == '<<') {
507                     return($i-4);
508                 }
509             }
510             $i--;
511         }
512     }
513
514     public function extractXMLStringFromData() {
515         $this->xmlString = substr($this->data, $this->findXMLStartPosition(),
516                 $this->findXMLStopPosition() - $this->findXMLStartPosition());   
517     }
518
519     public function extractXMLStringFromMemory() {
520         $xmlstr = '<!--<<';
521         $xmlstr .= ">>";
522         $xmlstr .= "<pages>\n";
523         foreach($this->pages as $page) {
524             $xmlstr .= '<page id="'.$page->getId().'" title="'.htmlspecialchars($page->getTitle()).'">'
525                 . htmlspecialchars($page->getContent())."</page>\n";
526         }
527         $xmlstr .= "</pages>\n";
528         $xmlstr .= '<<';
529         $xmlstr .= '>>-->';
530         return($xmlstr);
531     }
532
533     public function createPagesFromXML() {
534         $xml = new SimpleXMLElement($this->xmlString);
535         foreach($xml->page as $page) {
536             $this->pages[(int)$page['id']] = new Page($page['id'], $page['title'], $page, $this);
537         }
538     }
539
540     public function saveWikiToFile() {
541         global $ADEI_SETUP;
542         global $ADEI_ROOTDIR;
543         global $WIKI_FILENAME;
544         
545         $stringToWrite =/* substr($this->data,0,
546                 $this->findXMLStartPosition()-8) .*/ $this->extractXMLStringFromMemory();
547         if (is_writable($WIKI_FILENAME)) {
548             $handle = fopen($WIKI_FILENAME, "w+");
549             if ($handle) {
550                 fwrite($handle, $stringToWrite);
551                 fclose($handle);
552             } else {ErrorHandler::reportError($WIKI_FILENAME.' not writable');}
553         } else {ErrorHandler::reportError($WIKI_FILENAME.' not writable');}
554         if (is_writable($ADEI_ROOTDIR . '/tmp/')) {
555             if (!is_dir($ADEI_ROOTDIR . '/tmp/wiki')) {
556                 @mkdir($ADEI_ROOTDIR . '/tmp/wiki');
557             }
558             if (is_dir($ADEI_ROOTDIR . '/tmp/wiki')) {
559                 $handle = fopen($ADEI_ROOTDIR . '/tmp/wiki/'.$ADEI_SETUP.'-'.date('YmdTHis').'.xml', "w+");
560                 if ($handle) {
561                 fwrite($handle, $stringToWrite);
562                 fclose($handle);
563                 }
564             }
565         } //else {ErrorHandler::reportError($ADEI_ROOTdIR.'/tmp/wiki'.' not writable');}
566     }
567
568     public function editPage($id, $title, $content) {
569         foreach($this->pages as $page) {
570             if($page->getTitle() == $title && $page->getId() != $id) {
571                 ErrorHandler::reportError("this pagetitle is already used by another page!");
572                 return;
573             }
574         }
575         $this->pages[$id]->setTitle($title);
576         $this->pages[$id]->setContent($content);
577         $this->saveWikiToFile();
578     }
579 }
580
581
582 if (!isset($ADEI_SETUP)) {
583     if (file_exists("adei.php")) require("adei.php");
584     else require("../adei.php");
585 }
586
587 if (file_exists("$ADEI_ROOTDIR/setups/$ADEI_SETUP/wiki.xml")) {
588     $WIKI_FILENAME = "$ADEI_ROOTDIR/setups/$ADEI_SETUP/wiki.xml";
589 } else {
590     $WIKI_FILENAME = "$ADEI_ROOTDIR/wiki.xml";
591 }
592
593 $REQ = new REQUEST($_GET);
594 $GET_ID = $REQ->GetProp('pageid', 1);
595
596 $wiki = new Wiki($WIKI_FILENAME);
597 if($GET_ID <= 0 || $wiki->getPage((int)$GET_ID) == null) {
598     $GET_ID = 1;
599 }
600
601 if (preg_match("/services\\/[^\\\]+.php$/", $_SERVER['SCRIPT_FILENAME'])) {
602     $AJAX_MODE = true;
603     $error = false;
604
605     header("Content-type: text/xml");
606
607     $xslt = $REQ->GetProp('xslt');
608     if ($xslt) {
609     $temp_file = tempnam(sys_get_temp_dir(), 'adei_wiki.');
610     $out = @fopen($temp_file, "w");
611     if (!$out) $error = translate("I'm not able to create temporary file \"%s\"", $temp_file);
612     } else {
613     $out = fopen("php://output", "w");
614     }
615     
616     if ($out) {
617     fwrite($out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
618     fwrite($out, "<div>" . stripslashes($wiki->getPage((int)$GET_ID)->getHTMLContent(1)) . "</div>");
619     fclose($out);
620     }
621
622     if (($xslt)&&(!$error)) {
623     try {
624         echo $ADEI->TransformXML($xslt, $temp_file);
625     } catch (ADEIException $ex) {
626         $ex->logInfo(NULL, $reader?$reader:$req);
627         $error = $ADEI->EscapeForXML($ex->getInfo());
628     }
629     @unlink($temp_file);
630     }
631     
632     if ($error) {
633         echo "<div>$error</div>";
634     }
635     
636     exit;
637 } else {
638     header("Content-type: text/html");
639 }
640
641 ?>
642
643 <html>
644 <head>
645     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
646     <title>Yada Yada Yada Wiki</title>
647     <style type="text/css">
648
649         body {
650             background-color: #f3f3f3;
651             color: black;
652             font-style: normal;
653             font-size: 12px;
654             line-height: 16px;
655             font-family: sans-serif, arial;
656             margin:0px;
657         }
658         td {
659             color: black;
660             font-style: normal;
661             font-size: 12px;
662             font-family: sans-serif, arial;
663         }
664         .footer {
665             color: gray;
666             clear:left;
667             margin-top:1em;
668             margin-right:20px;
669             text-align:right;
670             font-size: 12px;
671         }
672         .outertable {
673             background-color: #f3f3f3; border-width: 0px; border-color: #999999; border-style: solid;
674         }
675         .innertable {
676             background-color: white; border-width: 1px; border-color: #9f9f9f; border-style: solid;
677         }
678         .title {
679             border-bottom: 1px; border-color: #999999; border-style: solid;
680             border-top: none; border-left: none; border-right: none;
681             padding-bottom: 5px; font-size: 30px; font-weight:bold;
682         }
683         .edit {
684             padding: 0px; font-size: 30px; font-weight:bold;
685         }
686         .niceformelement {
687             border: 1px solid gray; width:80px;
688         }
689         .shyline {
690             border-bottom: 1px; border-color: #999999; border-style: dotted;
691             border-top: none; border-left: none; border-right: none;
692         }
693         a:link { color: blue; text-decoration:none; }
694         a:visited { color: blue; text-decoration:none;}
695         a:hover { color: blue; text-decoration:none;}
696         a:active { color: blue; text-decoration:none;}
697         a.newpagelink:link { color: red; text-decoration:none; }
698         a.newpagelink:visited { color: red; text-decoration:none;}
699         a.newpagelink:hover { color: red; text-decoration:none;}
700         a.newpagelink:active { color: red; text-decoration:none;}
701         a.external:link { color: blue; text-decoration:underline; }
702         a.external:visited { color: blue; text-decoration:underline;}
703         a.external:hover { color: blue; text-decoration:underline;}
704         a.external:active { color: blue; text-decoration:underline;}
705         .wiki_header{font-size: 18px; font-weight:bold; margin-bottom: 18px; margin-top: 0px;}
706         .wiki_header2{font-size: 12px; font-weight:bold; margin-bottom: 12px; margin-top: 0px;}
707        
708     </style>
709 </head>
710 <body>
711 <?
712 /*foreach($_GET as $key => $value) {
713     print "GET: $key => $value <br/>";
714 }
715 foreach($_POST as $key => $value) {
716     print "POST: $key => $value <br/>";
717 }*/
718
719 if($_POST['edit'] == 'true') {
720     $wiki->editPage($_POST['id'], $_POST['title'], $_POST['content']);
721 }
722 if($_POST['editmenu'] == 'true') {
723     $wiki->editPage(0, $_POST['title'], $_POST['content']);
724 }
725 ?>
726
727 <table width="100%" class="outertable" cellspacing="20px" cellpadding="0px">
728     <tr>
729         <td class="title" colspan="2">
730             <?print $wiki->getPage((int)$GET_ID)->getTitle();?>
731         </td>
732     </tr>
733     <tr>
734         <td valign="top" width="150px">
735             <table width="100%" class="innertable" cellspacing="0px" cellpadding="10px">
736             <tr>
737             <td>
738             <?
739                 if($_POST['modifymenu'] == 'true') {
740                     print '<form method="post">';
741                     print '<input type="hidden" name="editmenu" value="true" />';
742                     print '<input type="hidden" name="modifymenu" value="false" />';
743                     print '<input type="hidden" name="id" value="'.$wiki->getPage(0)->getId().'" />';
744                     print '<textarea class="text" cols="18" rows="10" name="content" WRAP="PHYSICAL" />';
745                     print stripslashes($wiki->getPage(0)->getContent());
746                     print '</textarea>';
747                     print "<br/>";
748                     print '<input type="submit" value="save" class="niceformelement" />';
749                     print "</form>";
750                 } else {
751                     print stripslashes($wiki->getPage(0)->getHTMLContent());
752                     if(((isset($AUTHORS) && in_array(getenv('REMOTE_USER'), $AUTHORS) || !isset($AUTHORS)))
753                             || (isset($FREE4ALL) && in_array($wiki->getPage((int)$GET_ID)->getTitle(),$FREE4ALL)))
754                     {
755                         print '<form style="text-align:left" method="post">';
756                         print '<p class="shyline"></p>';
757                         print '<input type="hidden" name="modifymenu" value="true"/>';
758                         print '<input type="submit" value="edit" class="niceformelement"/>';
759                         print '</form>';
760                     }
761                 }
762             ?>
763             </td>
764             </tr>
765             </table>
766         </td>
767         <td colspan="1" valign="top">
768             <table width="100%" class="innertable" cellspacing="0px" cellpadding="10px">
769             <tr>
770             <td>
771             <?
772                 if($_POST['modify'] == 'true') {
773                     print '<form method="post">';
774                     print '<input type="hidden" name="edit" value="true"/>';
775                     print '<input type="hidden" name="modify" value="false"/>';
776                     print '<input type="hidden" name="id" value="'.$wiki->getPage((int)$GET_ID)->getId().'"/>';
777                     print '<input type="text" name="title" value="'.$wiki->getPage((int)$GET_ID)->getTitle().'"/>';
778                     print "<br/>";
779                     print '<textarea class="text" cols="100" rows="15" name="content" WRAP="PHYSICAL">';
780                     print stripslashes($wiki->getPage((int)$GET_ID)->getContent());
781                     print '</textarea>';
782                     print "<br/>";
783                     print '<input type="submit" value="save" class="niceformelement"/>';
784                     print "</form>";
785                 } else {
786                     print stripslashes($wiki->getPage((int)$GET_ID)->getHTMLContent());
787                     if((isset($AUTHORS) && in_array(getenv('REMOTE_USER'), $AUTHORS) || !isset($AUTHORS))) {
788                         print '<form style="text-align:left;" method="post">';
789                         print '<p class="shyline"></p>';
790                         print '<input type="hidden" name="modify" value="true"/>';
791                         print '<input type="submit" value="edit" class="niceformelement"/>';
792                         print '</form>';
793                     }
794                 }
795             ?>
796             </td>
797             </tr>
798             </table>
799         </td>
800     </tr>
801 </table>
802 <div class="footer">
803 <!--<a href="<? print basename($WIKI_FILENAME).'s'?>">Yada Yada Yada Wiki</a> -->
804 <a href="http://www.pburkhalter.net/yadawiki.php">Yada Yada Yada Wiki 0.0.5</a>
805 </div>
806 </body>
807 </html>
808
809 <!--<<>><pages>
810 <page id="0" title="">[[Help]]
811 </page>
812 <page id="2" title="Help">!This is a Header
813 !!Images
814 [img]http://www.rosalux.de/cms/uploads/pics/gnu.png[/img]
815
816 !!Links
817 An internal link to this Wiki: [[New Page]]
818 (a red link means site is empty, but created)
819
820 An internal link to this Wiki: [[Help]]
821 (a blue link means site is not empty and created)
822
823 An external link [url]http://www.pburkhalter.net[/url]
824 A [url=\&amp;quot;http://www.pburkhalter.net\&amp;quot;]external[/url] link to the same destination
825 An [url=\&amp;quot;http://www.pburkhalter.net\&amp;quot;][img]http://www.pburkhalter.net/images/external_image_link.png[/img][/url] to the same destination
826
827 !!Formating
828 [b]Bold[/b]
829 [i]Italic[/i]
830 [u]Underlined[/u]
831 </page>
832 </pages>
833 <<>>-->
Note: See TracBrowser for help on using the browser.