| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 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 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
break; |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
$res; |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
adeiGroupList($props) { |
|---|
| 139 |
$res = ""; |
|---|
| 140 |
|
|---|
| 141 |
$req = new REQUEST($tmp = array()); |
|---|
| 142 |
$sources = $req->GetSources(REQUEST::SKIP_UNCACHED|REQUEST::LIST_ALL); |
|---|
| 143 |
$sources as $sreq) { |
|---|
| 144 |
$title = $sreq->GetSourceTitle(); |
|---|
| 145 |
|
|---|
| 146 |
$groupinfo = $sreq->GetGroupList(); |
|---|
| 147 |
$groups = $sreq->GetGroups(NULL, REQUEST::SKIP_UNCACHED); |
|---|
| 148 |
$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 |
$res; |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
ErrorHandler { |
|---|
| 162 |
reportError($error) { |
|---|
| 163 |
'<b>Error:</b> '.$error.'<br/>'; |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
CodeInterpreter { |
|---|
| 168 |
$instance; |
|---|
| 169 |
$wiki; |
|---|
| 170 |
|
|---|
| 171 |
__construct($wiki) { |
|---|
| 172 |
$this->wiki = $wiki; |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
getInstance($wiki) { |
|---|
| 176 |
$instance) || $instance == null) { |
|---|
| 177 |
$instance = new CodeInterpreter($wiki); |
|---|
| 178 |
|
|---|
| 179 |
$instance); |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
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 |
$string); |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
compileTable($string) { |
|---|
| 203 |
$string = preg_replace( |
|---|
| 204 |
|
|---|
| 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 |
$string); |
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
compileNewLine($string) { |
|---|
| 220 |
$string = preg_replace("/^[ \t]*\r?\n?$/m","<br/>",$string); |
|---|
| 221 |
$string = eregi_replace("\[(br|hr)\]","<\\1/>",$string); |
|---|
| 222 |
$string); |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
compileVersion($string) { |
|---|
| 226 |
preg_replace_callback( |
|---|
| 227 |
"/\[\s*version\s*\]/", |
|---|
| 228 |
create_function('$matches', ' |
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
), |
|---|
| 241 |
$string |
|---|
| 242 |
); |
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
compileChannelList($string) { |
|---|
| 247 |
preg_replace_callback( |
|---|
| 248 |
"/\[\s*(channels_by_group|channels_by_name)\s*(\(([^\)\]]+)\))?\s*\]/", |
|---|
| 249 |
create_function('$matches', ' |
|---|
| 250 |
|
|---|
| 251 |
), |
|---|
| 252 |
$string |
|---|
| 253 |
); |
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
compileGroupList($string) { |
|---|
| 257 |
preg_replace_callback( |
|---|
| 258 |
"/\[\s*grouplist\s*(\(([^\)\]]+)\))?\s*\]/", |
|---|
| 259 |
create_function('$matches', ' |
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
), |
|---|
| 265 |
$string |
|---|
| 266 |
); |
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
compilePreview($string) { |
|---|
| 270 |
preg_replace_callback( |
|---|
| 271 |
"/\[\s*preview\s*\(([^\)\]]+)\)(\s*,\s*link\s*(\(([^\]\)]+)\))?)?\s*\]/", |
|---|
| 272 |
create_function('$matches', ' |
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
), |
|---|
| 300 |
$string |
|---|
| 301 |
); |
|---|
| 302 |
|
|---|
| 303 |
|
|---|
| 304 |
resolveAdeiLink($string) { |
|---|
| 305 |
preg_replace_callback( |
|---|
| 306 |
"/\[\s*link\s*=?\s*(\(|\")([^\]]+)(\)|\")\s*\]([^\[]+)\[\s*\/link\s*\]/", |
|---|
| 307 |
create_function('$matches', ' |
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
), |
|---|
| 322 |
$string |
|---|
| 323 |
); |
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
resolveInternalLink($string) { |
|---|
| 327 |
$AJAX_MODE; |
|---|
| 328 |
$ADEI_SETUP; |
|---|
| 329 |
|
|---|
| 330 |
preg_match_all('/\[\[[\w\s\d_-]*\]\]/', $string, $hits); |
|---|
| 331 |
$hits[0] as $hit) { |
|---|
| 332 |
$title = preg_replace('/\[\[/', '', $hit); |
|---|
| 333 |
$title = preg_replace('/\]\]/', '', $title); |
|---|
| 334 |
$this->wiki->getPage($title)->getContent() == '...') { $class = 'newpagelink';} |
|---|
| 335 |
$class = 'link';} |
|---|
| 336 |
$AJAX_MODE) { |
|---|
| 337 |
$string = preg_replace("/\[\[$title\]\]/", |
|---|
| 338 |
'<a class="'.$class.'" href="javascript:wiki.SetID('.$this->wiki->getPage($title)->getId().')">'.$title.'</a>',$string); |
|---|
| 339 |
|
|---|
| 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 |
$string); |
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
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 |
$string); |
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
compileExternalCustomLink($string) { |
|---|
| 357 |
$string=eregi_replace('\[url=\\\"','[url="',$string); |
|---|
| 358 |
$string=eregi_replace('\\\"\]','"]',$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 |
$string); |
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 |
compileMailTo($string) { |
|---|
| 368 |
$string = eregi_replace("\[mail\]([^\[]+)\[/mail\]","<a href=\"mailto:\\1\">\\1</a>",$string); |
|---|
| 369 |
$string); |
|---|
| 370 |
|
|---|
| 371 |
|
|---|
| 372 |
compileImage($string) { |
|---|
| 373 |
$string = eregi_replace("\[img\]([^\[]+)\[/img\]","<img src=\"\\1\" border=\"0\"/>",$string); |
|---|
| 374 |
$string); |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
compileBoldText($string) { |
|---|
| 378 |
$string = eregi_replace("\[b\]([^\[]+)\[/b\]","<b>\\1</b>",$string); |
|---|
| 379 |
$string); |
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
compileItalicText($string) { |
|---|
| 383 |
$string = eregi_replace("\[i\]([^\[]+)\[/i\]","<i>\\1</i>",$string); |
|---|
| 384 |
$string); |
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
compileUnderlineText($string) { |
|---|
| 388 |
$string = eregi_replace("\[u\]([^\[]+)\[/u\]","<u>\\1</u>",$string); |
|---|
| 389 |
$string); |
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 |
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 |
$string); |
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
Page { |
|---|
| 400 |
$id; |
|---|
| 401 |
$title; |
|---|
| 402 |
$content; |
|---|
| 403 |
$wiki; |
|---|
| 404 |
|
|---|
| 405 |
__construct($id, $title, $content, $wiki) { |
|---|
| 406 |
$this->id = $id; |
|---|
| 407 |
$this->title = $title; |
|---|
| 408 |
$this->content = $content; |
|---|
| 409 |
$this->wiki = $wiki; |
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 |
getId() { return($this->id); } |
|---|
| 413 |
getTitle() { return($this->title); } |
|---|
| 414 |
getContent() { return($this->content); } |
|---|
| 415 |
|
|---|
| 416 |
includeHTMLContent($m) { |
|---|
| 417 |
$page = $this->wiki->getPage($m[1]); |
|---|
| 418 |
|
|---|
| 419 |
$page) return $page->getHTMLContent(1); |
|---|
| 420 |
""; |
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 |
getHTMLContent() { |
|---|
| 424 |
$string = CodeInterpreter::getInstance($this->wiki)->parseCode($this->content); |
|---|
| 425 |
|
|---|
| 426 |
$string = preg_replace_callback("/\[include\(([^)]+)\)\]/i", array($this, "includeHTMLContent"), $string); |
|---|
| 427 |
$string; |
|---|
| 428 |
|
|---|
| 429 |
setTitle($title) { $this->title = htmlspecialchars($title); } |
|---|
| 430 |
setContent($content) { $this->content = htmlspecialchars($content); } |
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
Wiki { |
|---|
| 435 |
$fileName; |
|---|
| 436 |
$data; |
|---|
| 437 |
$xmlString; |
|---|
| 438 |
$pages = array(); |
|---|
| 439 |
|
|---|
| 440 |
__construct($fileName) { |
|---|
| 441 |
$this->fileName = $fileName; |
|---|
| 442 |
$this->readDataFromFile(); |
|---|
| 443 |
$this->extractXMLStringFromData(); |
|---|
| 444 |
$this->createPagesFromXML(); |
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
getPage($pageidentifier) { |
|---|
| 448 |
is_integer($pageidentifier)) { |
|---|
| 449 |
if(!isset($this->pages[$pageidentifier])) { |
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
return; |
|---|
| 454 |
|
|---|
| 455 |
$this->pages[$pageidentifier]); |
|---|
| 456 |
is_string($pageidentifier)) { |
|---|
| 457 |
foreach($this->pages as $page) { |
|---|
| 458 |
$page->getTitle() == $pageidentifier) { |
|---|
| 459 |
$page); |
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 |
$i = 1; true; $i++) { |
|---|
| 463 |
array_key_exists($i, $this->pages)) { |
|---|
| 464 |
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
$this->pages[$i] = new Page($i, $pageidentifier, '...', $this); |
|---|
| 468 |
$this->saveWikiToFile(); |
|---|
| 469 |
$this->pages[$i]); |
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
|
|---|
| 473 |
readDataFromFile() { |
|---|
| 474 |
$this->data = ""; |
|---|
| 475 |
is_file($this->fileName))&&(filesize($this->fileName)>0)) { |
|---|
| 476 |
$handle = fopen ($this->fileName, "r"); |
|---|
| 477 |
feof($handle)) { |
|---|
| 478 |
$this->data .= fgets($handle, 4096); |
|---|
| 479 |
|
|---|
| 480 |
fclose ($handle); |
|---|
| 481 |
is_file($_SERVER['SCRIPT_FILENAME'])) { |
|---|
| 482 |
$handle = fopen ($_SERVER['SCRIPT_FILENAME'], "r"); |
|---|
| 483 |
feof($handle)) { |
|---|
| 484 |
$this->data .= fgets($handle, 4096); |
|---|
| 485 |
|
|---|
| 486 |
fclose ($handle); |
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 |
findXMLStartPosition() { |
|---|
| 491 |
$i = 0; |
|---|
| 492 |
$i < strlen($this->data)) { |
|---|
| 493 |
$i = strpos ($this->data, '<<' , $i); |
|---|
| 494 |
substr($this->data, $i+2, 2) == '>>') { |
|---|
| 495 |
$i+4); |
|---|
| 496 |
|
|---|
| 497 |
$i++; |
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
findXMLStopPosition() { |
|---|
| 502 |
$i = strlen($this->data); |
|---|
| 503 |
$i >= 0) { |
|---|
| 504 |
$schrumpf = substr($this->data, 0, $i); |
|---|
| 505 |
substr($schrumpf, $i-2, 2) == '>>') { |
|---|
| 506 |
substr($schrumpf, $i-4, 2) == '<<') { |
|---|
| 507 |
$i-4); |
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
$i--; |
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 |
extractXMLStringFromData() { |
|---|
| 515 |
$this->xmlString = substr($this->data, $this->findXMLStartPosition(), |
|---|
| 516 |
$this->findXMLStopPosition() - $this->findXMLStartPosition()); |
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 |
extractXMLStringFromMemory() { |
|---|
| 520 |
$xmlstr = '<!--<<'; |
|---|
| 521 |
$xmlstr .= ">>"; |
|---|
| 522 |
$xmlstr .= "<pages>\n"; |
|---|
| 523 |
$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 |
$xmlstr); |
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 |
createPagesFromXML() { |
|---|
| 534 |
$xml = new SimpleXMLElement($this->xmlString); |
|---|
| 535 |
$xml->page as $page) { |
|---|
| 536 |
$this->pages[(int)$page['id']] = new Page($page['id'], $page['title'], $page, $this); |
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
saveWikiToFile() { |
|---|
| 541 |
$ADEI_SETUP; |
|---|
| 542 |
$ADEI_ROOTDIR; |
|---|
| 543 |
$WIKI_FILENAME; |
|---|
| 544 |
|
|---|
| 545 |
$stringToWrite = |
|---|
| 546 |
$this->extractXMLStringFromMemory(); |
|---|
| 547 |
is_writable($WIKI_FILENAME)) { |
|---|
| 548 |
$handle = fopen($WIKI_FILENAME, "w+"); |
|---|
| 549 |
$handle) { |
|---|
| 550 |
fwrite($handle, $stringToWrite); |
|---|
| 551 |
fclose($handle); |
|---|
| 552 |
ErrorHandler::reportError($WIKI_FILENAME.' not writable');} |
|---|
| 553 |
ErrorHandler::reportError($WIKI_FILENAME.' not writable');} |
|---|
| 554 |
is_writable($ADEI_ROOTDIR . '/tmp/')) { |
|---|
| 555 |
is_dir($ADEI_ROOTDIR . '/tmp/wiki')) { |
|---|
| 556 |
mkdir($ADEI_ROOTDIR . '/tmp/wiki'); |
|---|
| 557 |
|
|---|
| 558 |
is_dir($ADEI_ROOTDIR . '/tmp/wiki')) { |
|---|
| 559 |
$handle = fopen($ADEI_ROOTDIR . '/tmp/wiki/'.$ADEI_SETUP.'-'.date('YmdTHis').'.xml', "w+"); |
|---|
| 560 |
$handle) { |
|---|
| 561 |
fwrite($handle, $stringToWrite); |
|---|
| 562 |
fclose($handle); |
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
} |
|---|
| 567 |
|
|---|
| 568 |
editPage($id, $title, $content) { |
|---|
| 569 |
$this->pages as $page) { |
|---|
| 570 |
$page->getTitle() == $title && $page->getId() != $id) { |
|---|
| 571 |
ErrorHandler::reportError("this pagetitle is already used by another page!"); |
|---|
| 572 |
|
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 |
$this->pages[$id]->setTitle($title); |
|---|
| 576 |
$this->pages[$id]->setContent($content); |
|---|
| 577 |
$this->saveWikiToFile(); |
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
|
|---|
| 582 |
$ADEI_SETUP)) { |
|---|
| 583 |
file_exists("adei.php")) require("adei.php"); |
|---|
| 584 |
"../adei.php"); |
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
file_exists("$ADEI_ROOTDIR/setups/$ADEI_SETUP/wiki.xml")) { |
|---|
| 588 |
$WIKI_FILENAME = "$ADEI_ROOTDIR/setups/$ADEI_SETUP/wiki.xml"; |
|---|
| 589 |
|
|---|
| 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 |
|
|---|
| 713 |
|
|---|
| 714 |
|
|---|
| 715 |
|
|---|
| 716 |
|
|---|
| 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=\&quot;http://www.pburkhalter.net\&quot;]external[/url] link to the same destination |
|---|
| 825 |
An [url=\&quot;http://www.pburkhalter.net\&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 |
<<>>--> |
|---|