|
Home Pages Pidgin Azarennya (S|N) Mac Textanium Reference ToDo Food Local Edit Local: Hide Weather • GoWhere? • YahooMaps (mine) • GoogleMaps • Metro (map) • FairfaxConnector • GreaterGreaterWashington • DCMetrocentric • WhatsUpArlington • Restonian • BeyondDC • BaconsRebellion Language: Hide Fantasy: Hide • AnnalsOfArda • Arda • SilmarillionChronology • TolkienGateway • SciFi: Hide • CentauriDreams • ColdNavy • ConceptShips • RavenstarStudios • SkyscraperPage • StarTrek • StarTrekVsStarWars • Film: Hide IMDB • BigHollywood • DKnowsAll • Jabootu • KyleSmith Music: Hide REALbasic: Hide • Resources • Garage • University • WebRing • Forums: • REAL • ElfData • Plugins and Code: • BKeeney • DeclareSub • Einhugur • Joe • Restrepo • Tempelmann • ZAZ Coding: Hide Forums: • PowWeb • PHP • Webmaster • Coding • Walkers • Perl • Intro • Monks • PHP • JavaScript • Toolbox • UnobtrusiveJavaScript • JavaScriptCompressor • RegularExpressions (test) • JSLint • SQL • Cocoa • CocoaBuilder • CocoaDev • CocoaLab • AppleScript • BBS • Userland • Faqintosh • FileMaker • FileMakerTips • FileMakerWorld • FileMakerPlugins Science: Hide DarwinCentral • PhysOrg • PandasThumb • TalkOrigins • TalkRational • AstronomyDailyPics • Curmudgeon • SmallThings • ArchaeoBlog • AntiEvolution.org • SkepticsGuide • EvC • BadAstronomer • PhysicsForum • SlashdotScience • JunkScience • Engadget • Thunderbolts • Icecap • CentauriDreams • NewScientist • Gizmodo • CO2Science • ClimateDebate • ScienceDaily • Nrich • Math • TalkOrigins • GoodMathBadMath • Magazines • AmericanScientist • NationalGeographic • Space.com History: Hide • 1421 News/Politics: Hide WideAwakes • Anchoress • Lucianne • Strata • AceOfSpades • BigLizards • BlackAndRight • Cannonfire • DrSanity • FloppingAces • GatewayPundit • HillBuzz • HotAir • Husaria • JawaReport • JimTreacher • JsCafeNette • LittleGreenFootballs • MyVRWC • Newsbusters • Pal2Pal • PinkFlamingo • PowerLine • RachelLucas • RogerLSimon • SisterToldjah • StolenThunder • SultanKnish • TCSDaily • UppityWoman • Wizbang • NewsGroper • NewsRightNow • OriginalSignal • Blogs... Cults/Crime: Hide Miscellaneous: Hide Fun: Agony ICanHas? ObSkills Snopes Pix: Deviant Places Renderosity Blender Artists X86: OSX86 ArsTech OSNews TUAW Tools: Calculator AsciiArt XMLVal FunStuff: Pictures: Photobucket (eg Dubai) Videos: YouTube Subtitler InterestingThings: LibraryThing FlashCards GoogleDocs Wowio Bubbl.us Colemak Audible PodioBooks WonderfulInfo BooksOnline AboutUs.org |
Wiki /
InspirationTigerWikiWebsite: chabel.org
<?php
// TigerWiki 2 (Version 2.19 - 2006-11-02)
// Copyleft (C) Arsenic 2005-2006, licence GNU/GPL (disponible sur www.gnu.org)
// http://chabel.org/ - root chez chabel point org
$WIKI_VERSION = "TigerWiki 2.19";
include("_config.php");
// SET THE TITLE OF THE PAGE
if (! $PAGE_TITLE = stripslashes($_GET["page"])) {
if ($_GET["action"] == "search") {
if ($_GET["query"] != "") {
$PAGE_TITLE = "$SEARCH_RESULTS \"$_GET[query]\"";
} else {
$PAGE_TITLE = $LIST . " (" . count(glob("$PAGES_DIR/*.*")) . ")";
}
} elseif ($_GET["action"] == "recent") {
$PAGE_TITLE = "$RECENT_CHANGES";
} else {
$PAGE_TITLE = "$START_PAGE";
}
}
$action = $_GET["action"];
if (isset($_GET["time"]))
$gtime = $_GET["time"];
$datetw = date("Y/m/d H:i", mktime(date("H") + $LOCAL_HOUR));
// PREVENT HACKER ATTACKS ON THE SERVER FILESYSTEM
if (preg_match("/\//", $PAGE_TITLE)) {
$PAGE_TITLE = $START_PAGE;
}
if (preg_match("/\//", $gtime)) {
$gtime = '';
}
// SAVE MODIFICATIONS IF NEEDED
if ($_POST["content"] != "") {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (
$_POST["sc"] == $PASSWORD ||
$_COOKIE['AutorisationTigerWiki'] == md5($PASSWORD)
) {
setcookie(
'AutorisationTigerWiki',
md5($PASSWORD),
time() + 365*24*3600
);
if (! $file = @fopen(
$PAGES_DIR . stripslashes($_POST["page"]) . ".txt", "w")
) {
die("Could not write page!");
}
if (get_magic_quotes_gpc()) {
fputs($file, trim(stripslashes($_POST["content"])));
} else {
fputs($file, trim($_POST["content"]));
}
fclose($file);
if ($BACKUP_DIR <> '') {
$complete_dir_s = $BACKUP_DIR . $_POST["page"] . "/";
if (! $dir = @opendir($complete_dir_s)) {
mkdir($complete_dir_s);
chmod($complete_dir_s, 0777);
}
if (! $file = @fopen(
$complete_dir_s . date("Ymd-Hi", mktime(
date("H") + $LOCAL_HOUR
)) . ".bak", "a"
)) {
die("Could not write backup of page!");
}
fputs(
$file,
"\n// " . $datetw . " / " . " "
. $_SERVER['REMOTE_ADDR'] . "\n"
);
if (get_magic_quotes_gpc()) {
fputs($file, trim(stripslashes($_POST["content"])));
} else {
fputs($file, trim($_POST["content"]) . "\n\n");
}
fclose($file);
}
header("location: ./?page=" . urlencode(stripslashes($_POST[page])));
} else {
header("location: ./?page=" . $_POST[page]."&action=edit&error=1");
}
}
} elseif (isset($_POST["content"]) && $_POST["content"] == "") {
if ($_POST["sc"] == $PASSWORD || $_COOKIE['AutorisationTigerWiki'] == md5($PASSWORD)) {
setcookie('AutorisationTigerWiki', md5($PASSWORD), time() + 365*24*3600);
unlink($PAGES_DIR . stripslashes($_POST["page"]) . ".txt");
} else {
header("location: ./?page=".$_POST["page"]."&action=edit&error=1");
}
}
// READ THE TEMPLATE FILE INTO MEMORY
if (! $file = @fopen("template.html", "r")) {
die("'template.html' is missing!");
}
$template = fread($file, filesize("template.html"));
fclose($file);
// READ PAGE CONTENT AND ITS LAST-MODIFIED DATE
if (($file = @fopen($PAGES_DIR . $PAGE_TITLE . ".txt", "r")) || $action <> "") {
if (file_exists($PAGES_DIR . $PAGE_TITLE . ".txt")) {
$TIME = date("Y/m/d H:i", @filemtime(
$PAGES_DIR . $PAGE_TITLE . ".txt"
) + $LOCAL_HOUR * 3600);
}
$CONTENT = "\n" . @fread($file, @filesize($PAGES_DIR . $PAGE_TITLE . ".txt")) . "\n";
// Restore a page.
if (isset($_GET["page"]) && isset($gtime) && $_GET["restore"] == 1) {
if ($file = @fopen($BACKUP_DIR . $PAGE_TITLE . "/" . $gtime, "r")) {
$CONTENT = "\n" . @fread($file, @filesize(
$BACKUP_DIR . $PAGE_TITLE . "/" . $gtime
)) . "\n";
}
}
@fclose($file);
$CONTENT = preg_replace("/\\$/Umsi", "$", $CONTENT); // dollar sign
$CONTENT = preg_replace("/\\\/Umsi", "\", $CONTENT); // backslash
} else {
if (!file_exists($PAGES_DIR . $PAGE_TITLE . ".txt")) {
$CONTENT = "\n" . $DEFAULT_CONTENT;
} else {
$action = "edit";
}
}
// HANDLE "EDIT" AND "RECENT CHANGES" LINKS DEPENDING ON PAGE ACCESS REQUESTED
if ($action == "edit" || $action == "search" || $action == "recent") {
$html = preg_replace(
'/{EDIT}/',
$EDIT_BUTTON,
$template
);
} elseif (
is_writable($PAGES_DIR . $PAGE_TITLE . ".txt")
|| !file_exists($PAGES_DIR . $PAGE_TITLE . ".txt")
) {
$html = preg_replace(
'/{EDIT}/',
"<a href=\"./?page=".$PAGE_TITLE."&action=edit\" accesskey=\"5\">$EDIT_BUTTON</a>",
$template
);
} else {
$html = preg_replace(
'/{EDIT}/',
$PROTECTED_BUTTON,
$template
);
}
if ($action == "recent") {
$html = preg_replace(
'/{RECENT_CHANGES}/',
$RECENT_CHANGES,
$html
);
} else {
$html = preg_replace(
'/{RECENT_CHANGES}/',
"<a href=\"./?action=recent\" accesskey=\"3\">$RECENT_CHANGES</a>",
$html
);
}
// REPLACE VARIABLES WITHIN THE TEMPLATE WITH ACTUAL TEXT
$html = preg_replace(
'/{PAGE_TITLE_BRUT}/',
$PAGE_TITLE,
$html
);
if ($action != "" && $action != "recent" && $action != "search") {
$html = preg_replace(
'/{PAGE_TITLE}/',
"<a href=\"./?page=".$PAGE_TITLE."\">".$PAGE_TITLE."</a>",
$html
);
} else {
$html = preg_replace(
'/{PAGE_TITLE}/',
$PAGE_TITLE,
$html
);
}
if ($PAGE_TITLE == $START_PAGE && $action <> "search") {
$html = preg_replace(
'/{HOME}/',
$HOME_BUTTON,
$html
);
} else {
$html = preg_replace(
'/{HOME}/',
"<a href=\"./?page=".$START_PAGE."\" accesskey=\"1\">$HOME_BUTTON</a>",
$html
);
}
$html = preg_replace('/{WIKI_TITLE}/', $WIKI_TITLE, $html);
$html = preg_replace('/{LAST_CHANGE}/', $LAST_CHANGES." :", $html);
if ($action != "edit") {
$html = preg_replace(
'/{HELP}/',
"",
$html
);
} else {
$html = preg_replace(
'/{HELP}/',
"(<a href=\"./?page=$HELP_BUTTON\" accesskey=\"2\">$HELP_BUTTON</a>)",
$html
);
}
$html = preg_replace(
'/{SEARCH}/',
"<form method=\"get\" action=\"./?page=".$_GET[page]."\"><div>" .
"<input type=\"hidden\" name=\"action\" value=\"search\" />" .
"<input type=\"text\" name=\"query\" value=\"$_GET[query]\" /> " .
"<input type=\"submit\" value=\"$SEARCH_BUTTON\" accesskey=\"q\" />" .
"</div></form>",
$html
);
if ($action == "edit") {
$html = preg_replace(
'/{HISTORY}/',
"/ <a href=\"?page=" . $PAGE_TITLE . "&action=history\" accesskey=\"6\">" .
$HISTORY_BUTTON . "</a><br />",
$html
);
$CONTENT = "<form method=\"post\" action=\"./\">" .
"<textarea name=\"content\" cols=\"83\" rows=\"30\" style=\"width: 100%;\">" .
"$CONTENT</textarea><input type=\"hidden\" name=\"page\" value=\"" .
$PAGE_TITLE . "\" /><br /><p align=\"right\">";
if ($PASSWORD != "" && $_COOKIE['AutorisationTigerWiki'] != md5($PASSWORD)) {
$CONTENT .= $MDP . " : <input type=\"password\" name=\"sc\" />";
}
$CONTENT .= " <input type=\"submit\" value=\"$DONE_BUTTON\" accesskey=\"s\" /></p></div></form>";
} elseif ($action != "history") {
$html = preg_replace('/{HISTORY}/', "", $html);
}
// IF "HISTORY" REQUESTED, GET PREVIOUS VERSIONS OF THE PAGE...
if ($action == "history" && !isset($gtime)) {
$html = preg_replace('/{HISTORY}/', "/ ".$HISTORY_BUTTON, $html);
$complete_dir = $BACKUP_DIR . $_GET["page"] . "/";
if ($opening_dir = @opendir($complete_dir)) {
while (false !== ($filename = @readdir($opening_dir))) {
$files[] = $filename;
}
sort ($files);
for($cptfiles = 2; $files[$cptfiles] != ''; $cptfiles++) {
$affichage = $affichage . "<a href=\"?page=" . $_GET["page"]
. "&action=history&time=" . $files[$cptfiles]
. "\">" . $files[$cptfiles] . "</a><br />";
}
$html = preg_replace('/{CONTENT}/', $affichage, $html);
} else {
$html = preg_replace('/{CONTENT}/', $NO_HISTORY, $html);
}
}
// ...AND ADD THEM TO THE HTML.
if ($action == "history" && isset($gtime)) {
$complete_dir = $BACKUP_DIR . $PAGE_TITLE . "/";
if ($file = @fopen($BACKUP_DIR . $PAGE_TITLE . "/" . $gtime, "r")) {
$html = preg_replace(
'/{HISTORY}/',
"/ <a href=\"?page=" . $PAGE_TITLE . "&action=history\">"
. $HISTORY_BUTTON."</a> (<a href=\"?page=" . $PAGE_TITLE
. "&action=edit&time=" . $gtime . "&restore=1\">"
. $RESTORE . "</a>)",
$html
);
$CONTENT = @fread($file, @filesize($complete_dir . $gtime)) . "\n";
} else {
$html = preg_replace(
'/{HISTORY}/',
"/ <a href=\"?page=" . $PAGE_TITLE . "&action=history\">"
. $HISTORY_BUTTON."</a> (-)",
$html
);
}
}
// IF THE PASSWORD IS WRONG, ADD THE ERROR TEXT.
if ($_GET['error'] == 1) {
$html = preg_replace('/{ERROR}/', $ERROR, $html);
} else {
$html = preg_replace('/{ERROR}/', "", $html);
}
// (Erasing a cookie)
if ($_GET['erasecookie'] == 1) {
setcookie('AutorisationTigerWiki');
}
// IF "SEARCH" REQUESTED, GENERATE HTML FOR A SEARCH PAGE.
if ($action == "search") {
$dir = opendir(getcwd() . "/$PAGES_DIR");
while ($file = readdir($dir)) {
if (preg_match("/.txt/", $file)) {
$handle = fopen($PAGES_DIR . $file, "r");
@$content = fread($handle, filesize($PAGES_DIR . $file));
fclose($handle);
if (preg_match("/$_GET[query]/i", $content)
|| preg_match("/$_GET[query]/i", "$PAGES_DIR/$file")
) {
$file = substr($file, 0, strlen($file) - 4);
$CONTENT .= "<a href=\"./?page=$file\">$file</a><br />";
}
}
}
}
// IF "RECENT" REQUESTED, ADD RECENT CHANGES TO THE HTML.
elseif ($action == "recent") {
$dir = opendir(getcwd() . "/$PAGES_DIR");
while ($file = readdir($dir)) {
if (preg_match("/.txt/", $file)) {
$filetime[$file] = filemtime($PAGES_DIR . $file);
}
}
arsort($filetime);
$filetime = array_slice($filetime, 0, 10);
foreach ($filetime as $filename => $timestamp) {
$filename = substr($filename, 0, strlen($filename) - 4);
$CONTENT .= "<a href=\"./?page=$filename\">$filename</a> ("
. strftime("$TIME_FORMAT", $timestamp + $LOCAL_HOUR * 3600) . ")<br />";
}
}
// IF "EDIT" REQUESTED, CONVERT HTML TO WIKI SYNTAX AND DISPLAY EDITOR.
elseif ($action <> "edit") {
if (preg_match("/%html%\s/", $CONTENT)) {
$CONTENT = preg_replace("/%html%\s/", "", $CONTENT);
} else {
$CONTENT = htmlentities($CONTENT);
$CONTENT = preg_replace("/&#036;/Umsi", "$", $CONTENT);
$CONTENT = preg_replace("/&#092;/Umsi", "\", $CONTENT);
$CONTENT = preg_replace("/\^(.)/Umsie", "'&#'.ord('\\1').';'", $CONTENT);
// Links and images (from URLs in the text)
$CONTENT = preg_replace(
'#\[(.+)\|([0-9a-zA-Z\.\'\s\#/~\-_%=\?\&,\+]*)\]#U',
'<a href="$2" class="url">$1</a>',
$CONTENT
);
$CONTENT = preg_replace(
'#\[(.+)\|h(ttps?://[0-9a-zA-Z\.\#/~\-_%=\?\&,\+]*)\]#U',
'<a href="xx$2" class="url">$1</a>',
$CONTENT
);
$CONTENT = preg_replace(
'#\[h(ttps?://[0-9a-zA-Z\.\&\#\:/~\-_%=?]*\.(jpg|gif|png))\]#i',
'<img src="xx$1" />',
$CONTENT
);
$CONTENT = preg_replace(
'#\[([0-9a-zA-Z\.\&\#\:/~\-_%=?]*\.(jpg|gif|png))\]#i',
'<img src="$1" />',
$CONTENT
);
$CONTENT = preg_replace(
'#(https?://[0-9a-zA-Z\.\&\#\:/~\-_%=?]*)#i',
'<a href="$0" class="url">$1</a>',
$CONTENT
);
$CONTENT = preg_replace('#xxttp#', 'http', $CONTENT);
// Convert embedded page titles to links
preg_match_all("/\[([^\/]+)\]/U", $CONTENT, $matches, PREG_PATTERN_ORDER);
//Pour bloquer les liens accentués : "/\[([0-9a-zA-Z\- :\.,\(\)\']+)\]/U"
foreach ($matches[1] as $match) {
if (file_exists(html_entity_decode($PAGES_DIR."$match.txt"))) {
$CONTENT = str_replace(
"[$match]",
"<a href=\"./?page=".$match."\">$match</a>",
$CONTENT
);
} else {
$CONTENT = str_replace(
"[$match]",
"<a class=\"pending\" href=\"./?page=".$match."\">$match</a>",
$CONTENT
);
}
}
$CONTENT = preg_replace(
'#(\[\?(.+)\]*)#i',
'<a href="http://en.wikipedia.org/wiki/$0" class="url">$0</a>',
$CONTENT
);
$CONTENT = preg_replace(
'#([0-9a-zA-Z\./~\-_]+@[0-9a-z\./~\-_]+)#i',
'<a href="mailto:$0">$0</a>',
$CONTENT
);
// Lists
$CONTENT = preg_replace(
'/^\*\*\*(.*)(\n)/Um',
"<ul><ul><ul><li>$1</li></ul></ul></ul>$2",
$CONTENT
);
$CONTENT = preg_replace('/^\*\*(.*)(\n)/Um', "<ul><ul><li>$1</li></ul></ul>$2", $CONTENT);
$CONTENT = preg_replace('/^\*(.*)(\n)/Um', "<ul><li>$1</li></ul>$2", $CONTENT);
$CONTENT = preg_replace(
'/^\#\#\#(.*)(\n)/Um',
"<ol><ol><ol><li>$1</li></ol></ol></ol>$2",
$CONTENT
);
$CONTENT = preg_replace(
'/^\#\#(.*)(\n)/Um',
"<ol><ol><li>$1</li></ol></ol>$2",
$CONTENT
);
$CONTENT = preg_replace('/^\#(.*)(\n)/Um', "<ol><li>$1</li></ol>$2", $CONTENT);
$CONTENT = preg_replace('/(<\/ol>\n*<ol>|<\/ul>\n*<ul>)/', "", $CONTENT);
$CONTENT = preg_replace('/(<\/ol>\n*<ol>|<\/ul>\n*<ul>)/', "", $CONTENT);
$CONTENT = preg_replace('/(<\/ol>\n*<ol>|<\/ul>\n*<ul>)/', "", $CONTENT);
// Headers
$CONTENT = preg_replace('/^!!!(.*)(\n)/Um', '<h1>$1</h1>$2', $CONTENT);
$CONTENT = preg_replace('/^!!(.*)(\n)/Um', '<h2>$1</h2>$2', $CONTENT);
$CONTENT = preg_replace('/^!(.*)(\n)/Um', '<h3>$1</h3>$2', $CONTENT);
while (preg_match('/^ /Um', $CONTENT)) {
$CONTENT = preg_replace(
'/^( +) ([^ ])/Um',
'$1 $2',
$CONTENT
);
}
$CONTENT = preg_replace('/^ /Um', ' ', $CONTENT);
// Horizontal lines
$CONTENT = preg_replace('/----*(\r\n|\r|\n)/m', '<hr />', $CONTENT);
// Line breaks
$CONTENT = preg_replace('/\n/', '<br />', $CONTENT);
// Lists
$CONTENT = preg_replace('#</ul>(<br />)*#', "</ul>", $CONTENT);
$CONTENT = preg_replace('#</ol>(<br />)*#', "</ol>", $CONTENT);
$CONTENT = preg_replace('#</li><ul><li>*#', "<ul><li>", $CONTENT);
$CONTENT = preg_replace('#</ul></ul>*#', "</ul></li></ul>", $CONTENT);
$CONTENT = preg_replace('#</ul></ul>*#', "</ul></li></ul>", $CONTENT);
$CONTENT = preg_replace('#</li></ul><li>*#', "</li></ul></li><li>", $CONTENT);
$CONTENT = preg_replace('#</li><ol><li>*#', "<ol><li>", $CONTENT);
$CONTENT = preg_replace('#</ol></ol>*#', "</ol></li></ol>", $CONTENT);
$CONTENT = preg_replace('#</ol></ol>*#', "</ol></li></ol>", $CONTENT);
$CONTENT = preg_replace('#</li></ol><li>*#', "</li></ol></li><li>", $CONTENT);
// Headers
$CONTENT = preg_replace('#(</h[123]>)<br />#', "$1", $CONTENT);
$CONTENT = preg_replace(
"/{(.+)}/Ue",
// "'<pre><code>' . preg_replace('#<br />#', '', '\\1') . '</code></pre>'",
"preg_replace('#<br />#', '', '\\1')",
$CONTENT
);
// Bold and italic
$CONTENT = preg_replace(
"/'''''(.*)'''''/Um",
'<strong><em>$1</em></strong>',
$CONTENT
);
$CONTENT = preg_replace("/'''(.*)'''/Um", '<strong>$1</strong>', $CONTENT);
$CONTENT = preg_replace("/''(.*)''/Um", '<em>$1</em>', $CONTENT);
$CONTENT = substr($CONTENT, 6, strlen($CONTENT) - 6);
$CONTENT = html_entity_decode($CONTENT);
}
}
if ($action != "" && $action != "edit" || (!file_exists($PAGES_DIR . $PAGE_TITLE . ".txt"))) {
$TIME = "-";
}
$html = preg_replace("/{CONTENT}/", $CONTENT, $html);
$html = preg_replace("/{LANG}/", $LANG, $html);
$html = preg_replace("/{WIKI_VERSION}/", $WIKI_VERSION, $html);
$html = preg_replace("/{CHARSET}/", $CHARSET, $html);
$html = preg_replace('/{TIME}/', $TIME, $html);
$html = preg_replace('/{DATE}/', $datetw, $html);
$html = preg_replace('/{IP}/', $_SERVER['REMOTE_ADDR'], $html);
if ($_COOKIE['AutorisationTigerWiki'] != "") {
$html = preg_replace(
'/{COOKIE}/',
'-- <a href="./?page='.$PAGE_TITLE.'&erasecookie=1">'.$ERASE_COOKIE.'</a>',
$html
);
} else {
$html = preg_replace(
'/{COOKIE}/',
'',
$html
);
}
// OUTPUT THE HTML AT LAST.
echo $html;
?>
|