function InsertPage($dbi, $pagename, $pagehash) { global $WikiPageStore; // ugly hack if ($dbi['table'] == $WikiPageStore) { // HACK $linklist = ExtractWikiPageLinks($pagehash['content']); SetWikiPageLinks($dbi, $pagename, $linklist); } $pagehash = MakeDBHash($pagename, $pagehash); // record the time of modification $pagehash["lastmodified"] = time(); if (IsWikiPage($dbi, $pagename)) { $PAIRS = "author='{$pagehash['author']}'," . "content='{$pagehash['content']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}"; $query = "UPDATE {$dbi['table']} SET {$PAIRS} WHERE pagename='{$pagename}'"; } else { // do an insert // build up the column names and values for the query $COLUMNS = "author, content, created, flags, lastmodified, " . "pagename, refs, version"; $VALUES = "'{$pagehash['author']}', '{$pagehash['content']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}"; $query = "INSERT INTO {$dbi['table']} ({$COLUMNS}) VALUES({$VALUES})"; } //echo "<p>Insert/Update Query: $query<p>\n"; $retval = mssql_query($query); if ($retval == false) { printf(gettext("Insert/Update failed: %s <br>\n"), mssql_get_last_message()); } }
function InsertPage($dbi, $pagename, $pagehash) { // update the wikilinks table $linklist = ExtractWikiPageLinks($pagehash['content']); SetWikiPageLinks($dbi, $pagename, $linklist); // prepare the content for storage if (!isset($pagehash["pagename"])) { $pagehash["pagename"] = $pagename; } if (!isset($pagehash["flags"])) { $pagehash["flags"] = 0; } $pagehash["author"] = addslashes($pagehash["author"]); $pagehash["content"] = implode("\n", $pagehash["content"]); $pagehash["content"] = addslashes($pagehash["content"]); $pagehash["pagename"] = addslashes($pagehash["pagename"]); $pagehash["refs"] = serialize($pagehash["refs"]); // Check for empty variables which can cause a sql error if (empty($pagehash["created"])) { $pagehash["created"] = time(); } if (empty($pagehash["version"])) { $pagehash["version"] = 1; } // record the time of modification $pagehash["lastmodified"] = time(); if (IsWikiPage($dbi, $pagename)) { $PAIRS = "author='{$pagehash['author']}'," . "content='{$pagehash['content']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}"; $query = "UPDATE {$dbi['table']} SET {$PAIRS} WHERE pagename='{$pagename}'"; } else { // do an insert // build up the column names and values for the query $COLUMNS = "author, content, created, flags, " . "lastmodified, pagename, refs, version"; $VALUES = "'{$pagehash['author']}', '{$pagehash['content']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}"; $query = "INSERT INTO {$dbi['table']} ({$COLUMNS}) VALUES({$VALUES})"; } // echo "<p>Query: $query<p>\n"; $retval = pg_exec($dbi['dbc'], $query); if ($retval == false) { echo "Insert/update failed: " . pg_errormessage($dbi['dbc']); } }
$replacements[$oldn] = substr($replacements[$oldn], 1); } else { $replacements[$oldn] = LinkURL($replacements[$oldn]); } $oldn++; } ////////////////////////////////////////////////////////// // Link Wiki words // Wikiwords preceeded by a '!' are not linked $oldn = $ntokens; $tmpline = tokenize($tmpline, "!?{$WikiNameRegexp}", $replacements, $ntokens); while ($oldn < $ntokens) { $old = $replacements[$oldn]; if ($old[0] == '!') { $replacements[$oldn] = substr($old, 1); } elseif (IsWikiPage($dbi, $old)) { $replacements[$oldn] = LinkExistingWikiWord($old); } else { $replacements[$oldn] = LinkUnknownWikiWord($old); } $oldn++; } ////////////////////////////////////////////////////////// // escape HTML metachars $tmpline = str_replace('&', '&', $tmpline); $tmpline = str_replace('>', '>', $tmpline); $tmpline = str_replace('<', '<', $tmpline); // Gilles Casse (2003-01-21) for the Oralux website // The PhpWiki features are lowered: // - first because today we do not need them // - second to have a page which can be validated as xhtml 1.0 strict
<?php // Backlinks: returns pages which link to a given page. rcs_id('$Id: backlinks.php,v 1.1 2004/09/28 21:48:44 gcasse Exp $'); if (get_magic_quotes_gpc()) { $refs = stripslashes($refs); } $pagename = $refs; // No HTML markup allowed in $title. $title = sprintf(gettext("Pages which link to %s"), htmlspecialchars($pagename)); if (IsWikiPage($dbi, $pagename)) { $pagelink = LinkExistingWikiWord($pagename); } else { $pagelink = LinkUnknownWikiWord($pagename); } $html = "<p><b>" . sprintf(gettext("Pages which link to %s") . " .....", $pagelink) . "</b></p>\n<ul>\n"; // search matching pages $query = InitBackLinkSearch($dbi, $pagename); $found = 0; while ($page = BackLinkSearchNextMatch($dbi, $query)) { $found++; $html .= "<li>" . LinkExistingWikiWord($page) . "<br>\n"; } $html .= "</ul>\n<hr noshade>\n" . sprintf(gettext("%d pages link to %s."), $found, $pagelink) . "\n"; GeneratePage('MESSAGE', $html, $title, 0);
function InsertPage($dbi, $pagename, $pagehash) { $pagehash = MakeDBHash($pagename, $pagehash); // $pagehash["content"] is now an array of strings // of MSQL_MAX_LINE_LENGTH // record the time of modification $pagehash["lastmodified"] = time(); if (IsWikiPage($dbi, $pagename)) { $PAIRS = "author='{$pagehash['author']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}"; $query = "UPDATE {$dbi['table']} SET {$PAIRS} WHERE pagename='{$pagename}'"; } else { // do an insert // build up the column names and values for the query $COLUMNS = "author, created, flags, lastmodified, " . "pagename, refs, version"; $VALUES = "'{$pagehash['author']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}"; $query = "INSERT INTO {$dbi['table']} ({$COLUMNS}) VALUES({$VALUES})"; } // echo "<p>Query: $query<p>\n"; // first, insert the metadata $retval = msql_query($query, $dbi['dbc']); if ($retval == false) { printf(gettext("Insert/update to table 'wiki' failed: %s"), msql_error()); print "<br>\n"; } // second, insert the page data // remove old data from page_table $query = "delete from {$dbi['page_table']} where pagename='{$pagename}'"; // echo "Delete query: $query<br>\n"; $retval = msql_query($query, $dbi['dbc']); if ($retval == false) { printf(gettext("Delete on %s failed: %s"), $dbi[page_table], msql_error()); print "<br>\n"; } // insert the new lines reset($pagehash["content"]); for ($x = 0; $x < count($pagehash["content"]); $x++) { $line = addslashes($pagehash["content"][$x]); if ($line == '') { continue; } // why do we always have 127 lines? $esc_pagename = addslashes($pagename); $query = "INSERT INTO {$dbi['page_table']} " . "(pagename, lineno, line) " . "VALUES('{$esc_pagename}', {$x}, '{$line}')"; //echo "Page line insert query: $query<br>\n"; $retval = msql_query($query, $dbi['dbc']); if ($retval == false) { printf(gettext("Insert into %s failed: %s"), $dbi[page_table], msql_error()); print "<br>\n"; } } }
function LinkRelatedPages($dbi, $pagename) { // currently not supported everywhere if (!function_exists('GetWikiPageLinks')) { return ''; } $links = GetWikiPageLinks($dbi, $pagename); $txt = "<b>"; $txt .= sprintf(gettext("%d best incoming links:"), NUM_RELATED_PAGES); $txt .= "</b>\n"; for ($i = 0; $i < NUM_RELATED_PAGES; $i++) { if (isset($links['in'][$i])) { list($name, $score) = $links['in'][$i]; if ($i > 0) { $txt .= ", "; } $txt .= LinkExistingWikiWord($name) . " ({$score})"; } } $txt .= "\n<br><b>"; $txt .= sprintf(gettext("%d best outgoing links:"), NUM_RELATED_PAGES); $txt .= "</b>\n"; for ($i = 0; $i < NUM_RELATED_PAGES; $i++) { if (isset($links['out'][$i])) { list($name, $score) = $links['out'][$i]; if (IsWikiPage($dbi, $name)) { if ($i > 0) { $txt .= ", "; } } $txt .= LinkExistingWikiWord($name) . " ({$score})"; } } $txt .= "\n<br><b>"; $txt .= sprintf(gettext("%d most popular nearby:"), NUM_RELATED_PAGES); $txt .= "</b>\n"; for ($i = 0; $i < NUM_RELATED_PAGES; $i++) { if (isset($links['popular'][$i])) { list($name, $score) = $links['popular'][$i]; if ($i > 0) { $txt .= ", "; } $txt .= LinkExistingWikiWord($name) . " ({$score})"; } } return $txt; }