From 07e45ed574df0142acd5b0c5bd03baf56a128d26 Mon Sep 17 00:00:00 2001 From: rurban Date: Fri, 7 Jan 2005 14:00:00 +0000 Subject: [PATCH] 2004-11-28 19:19 rurban Release 1.2.5 * admin.php, index.php, lib/config.php(global, compute_default_scripturl): import _SERVER and _GET/_POST to support register_globals=off * admin.php: on (un)lock=pagename display the (un)lock'ed page not FrontPage * lib/pgsql.php, lib/config.php: add pg_user and pg_pass (patch #1001339 by Jack Twilley) * lib/dbalib.php, lib/dbmlib.php, lib/db_filesystem: fix GetAllWikiPagenames() using $dbi['wiki']. This fixes zip and dumpserial on dba, dbm and file. * lib/msql.php: typo in GetAllWikiPageNames(). This fixes zip and dumpserial on msql. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/branches/release-1_2-branch@4360 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- admin.php | 11 +- admin/.htaccess | 3 + index.php | 7 +- lib/.htaccess | 2 +- lib/backlinks.php | 4 +- lib/db_filesystem.php | 6 +- lib/dbmlib.php | 8 +- lib/diff.php | 4 +- lib/display.php | 4 +- lib/editlinks.php | 4 +- lib/editpage.php | 4 +- lib/fullsearch.php | 4 +- lib/msql.php | 6 +- lib/mssql.php | 798 +++++++++++++++++++++--------------------- lib/mysql.php | 4 +- lib/pgsql.php | 12 +- lib/search.php | 4 +- lib/setupwiki.php | 4 +- lib/transform.php | 4 +- locale/.htaccess | 2 +- pgsrc/RecentVisitors | 10 +- schemas/.htaccess | 2 +- templates/.htaccess | 3 + 23 files changed, 464 insertions(+), 446 deletions(-) create mode 100755 admin/.htaccess create mode 100644 templates/.htaccess diff --git a/admin.php b/admin.php index a1f9a21e7..ca218226f 100644 --- a/admin.php +++ b/admin.php @@ -1,11 +1,17 @@ - +?> \ No newline at end of file diff --git a/admin/.htaccess b/admin/.htaccess new file mode 100755 index 000000000..f282d1689 --- /dev/null +++ b/admin/.htaccess @@ -0,0 +1,3 @@ +# $Id: .htaccess,v 1.1.2.1 2005-01-07 13:59:57 rurban Exp $ +order allow,deny +Deny from all diff --git a/index.php b/index.php index 784d7f592..6643b38f0 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ - + +?> \ No newline at end of file diff --git a/lib/.htaccess b/lib/.htaccess index 145f82df8..773b9ee17 100644 --- a/lib/.htaccess +++ b/lib/.htaccess @@ -1,3 +1,3 @@ -# $Id: .htaccess,v 1.2 2001-11-08 16:35:05 dairiki Exp $ +# $Id: .htaccess,v 1.2.2.1 2005-01-07 13:59:58 rurban Exp $ order allow,deny Deny from all diff --git a/lib/backlinks.php b/lib/backlinks.php index 5386c5656..8035a549b 100644 --- a/lib/backlinks.php +++ b/lib/backlinks.php @@ -1,6 +1,6 @@ +?> \ No newline at end of file diff --git a/lib/db_filesystem.php b/lib/db_filesystem.php index 6035c1168..f9fce1889 100644 --- a/lib/db_filesystem.php +++ b/lib/db_filesystem.php @@ -1,4 +1,4 @@ - +?> \ No newline at end of file diff --git a/lib/dbmlib.php b/lib/dbmlib.php index f5efd1eea..57ce04024 100644 --- a/lib/dbmlib.php +++ b/lib/dbmlib.php @@ -1,6 +1,6 @@ +?> \ No newline at end of file diff --git a/lib/diff.php b/lib/diff.php index bcc6aea68..5353fa1c5 100644 --- a/lib/diff.php +++ b/lib/diff.php @@ -1,4 +1,4 @@ - + +?> \ No newline at end of file diff --git a/lib/display.php b/lib/display.php index 846867e8c..e97f7d96b 100644 --- a/lib/display.php +++ b/lib/display.php @@ -1,7 +1,7 @@ +?> \ No newline at end of file diff --git a/lib/editlinks.php b/lib/editlinks.php index ad2fd79d9..168ba017b 100644 --- a/lib/editlinks.php +++ b/lib/editlinks.php @@ -1,4 +1,4 @@ - + for this code. // This allows an arbitrary number of reference links. @@ -11,4 +11,4 @@ settype ($pagehash, 'array'); GeneratePage('EDITLINKS', "", $pagename, $pagehash); -?> +?> \ No newline at end of file diff --git a/lib/editpage.php b/lib/editpage.php index 9ea5c889b..f65a70cf9 100644 --- a/lib/editpage.php +++ b/lib/editpage.php @@ -1,4 +1,4 @@ - + +?> \ No newline at end of file diff --git a/lib/fullsearch.php b/lib/fullsearch.php index 1be5086c2..c8301c396 100644 --- a/lib/fullsearch.php +++ b/lib/fullsearch.php @@ -1,6 +1,6 @@ +?> \ No newline at end of file diff --git a/lib/msql.php b/lib/msql.php index 8ec38835f..a3011fdf9 100644 --- a/lib/msql.php +++ b/lib/msql.php @@ -1,4 +1,4 @@ - +?> \ No newline at end of file diff --git a/lib/mssql.php b/lib/mssql.php index aff64c29a..0cc941b89 100644 --- a/lib/mssql.php +++ b/lib/mssql.php @@ -1,399 +1,399 @@ -"; - $msg .= sprintf(gettext ("MSSQL error: %s"), mssql_get_last_message()); - ExitWiki($msg); - } - // flush message - mssql_get_last_message(); - - if (!mssql_select_db($mssql_db, $dbc)) { - $msg = sprintf(gettext ("Cannot open database %s, giving up."), $mssql_db); - $msg .= "
"; - $msg .= sprintf(gettext ("MSSQL error: %s"), mssql_get_last_message()); - ExitWiki($msg); - } - // flush message - mssql_get_last_message(); - - $dbi['dbc'] = $dbc; - $dbi['table'] = $dbname; - return $dbi; - } - - - function CloseDataBase($dbi) { - // NOP function - // mssql connections are established as persistant - // they cannot be closed through mssql_close() - } - - - // prepare $pagehash for storing in mssql - function MakeDBHash($pagename, $pagehash) - { - $pagehash["pagename"] = addslashes($pagename); - if (!isset($pagehash["flags"])) - $pagehash["flags"] = 0; - $pagehash["author"] = addslashes($pagehash["author"]); - $pagehash["content"] = implode("\n", $pagehash["content"]); - $pagehash["content"] = addslashes($pagehash["content"]); - if (!isset($pagehash["refs"])) - $pagehash["refs"] = array(); - $pagehash["refs"] = serialize($pagehash["refs"]); - - return $pagehash; - } - - - // convert mssql result $dbhash to $pagehash - function MakePageHash($dbhash) - { - // unserialize/explode content - $dbhash['refs'] = unserialize($dbhash['refs']); - $dbhash['content'] = explode("\n", $dbhash['content']); - return $dbhash; - } - - - // Return hash of page + attributes or default - function RetrievePage($dbi, $pagename, $pagestore) { - $pagename = addslashes($pagename); - if ($res = mssql_query("select * from $pagestore where pagename='$pagename'", $dbi['dbc'])) { - if ($dbhash = mssql_fetch_array($res)) { - return MakePageHash($dbhash); - } - } - return -1; - } - - - // Either insert or replace a key/value (a page) - 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 "

Insert/Update Query: $query

\n"; - - $retval = mssql_query($query); - if ($retval == false) { - printf(gettext ("Insert/Update failed: %s
\n"), mssql_get_last_message()); - } - } - - - // for archiving pages to a seperate dbm - function SaveCopyToArchive($dbi, $pagename, $pagehash) { - global $ArchivePageStore; - $adbi = OpenDataBase($ArchivePageStore); - InsertPage($adbi, $pagename, $pagehash); - } - - - function IsWikiPage($dbi, $pagename) { - $pagename = addslashes($pagename); - if ($res = mssql_query("select count(*) from $dbi[table] where pagename='$pagename'", $dbi['dbc'])) { - return(mssql_result($res, 0, 0)); - } - return 0; - } - - function IsInArchive($dbi, $pagename) { - global $ArchivePageStore; - - $pagename = addslashes($pagename); - if ($res = mssql_query("select count(*) from $ArchivePageStore where pagename='$pagename'", $dbi['dbc'])) { - return(mssql_result($res, 0, 0)); - } - return 0; - } - - - function RemovePage($dbi, $pagename) { - global $WikiPageStore, $ArchivePageStore; - global $WikiLinksStore, $HitCountStore, $WikiScoreStore; - - $pagename = addslashes($pagename); - $msg = gettext ("Cannot delete '%s' from table '%s'"); - $msg .= "
\n"; - $msg .= gettext ("MSSQL error: %s"); - - if (!mssql_query("delete from $WikiPageStore where pagename='$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $WikiPageStore, mssql_get_last_message())); - - if (!mssql_query("delete from $ArchivePageStore where pagename='$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $ArchivePageStore, mssql_get_last_message())); - - if (!mssql_query("delete from $WikiLinksStore where frompage='$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $WikiLinksStore, mssql_get_last_message())); - - if (!mssql_query("delete from $HitCountStore where pagename='$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $HitCountStore, mssql_get_last_message())); - - if (!mssql_query("delete from $WikiScoreStore where pagename='$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $WikiScoreStore, mssql_get_last_message())); - } - - - function IncreaseHitCount($dbi, $pagename) - { - global $HitCountStore; - - $qpagename = addslashes($pagename); - $rowexists = 0; - if ($res = mssql_query("select count(*) from $dbi[table] where pagename='$qpagename'", $dbi['dbc'])) { - $rowexists = (mssql_result($res, 0, 0)); - } - - if ($rowexists) - $res = mssql_query("update $HitCountStore set hits=hits+1 where pagename='$qpagename'", $dbi['dbc']); - else - $res = mssql_query("insert into $HitCountStore (pagename, hits) values ('$qpagename', 1)", $dbi['dbc']); - - return $res; - } - - function GetHitCount($dbi, $pagename) - { - global $HitCountStore; - - $qpagename = addslashes($pagename); - $res = mssql_query("select hits from $HitCountStore where pagename='$qpagename'", $dbi['dbc']); - if (mssql_num_rows($res)) - $hits = mssql_result($res, 0, 0); - else - $hits = "0"; - - return $hits; - } - - function MakeSQLSearchClause($search, $column) - { - $search = preg_replace("/\s+/", " ", trim($search)); - $search = preg_replace('/(?=[%_\\\\])/', "\\", $search); - $search = addslashes($search); - - $term = strtok($search, ' '); - $clause = ''; - while($term) { - $word = "$term"; - if ($word[0] == '-') { - $word = substr($word, 1); - $clause .= "not ($column like '%$word%') "; - } else { - $clause .= "($column like '%$word%') "; - } - if ($term = strtok(' ')) - $clause .= 'and '; - } - return $clause; - } - - // setup for title-search - function InitTitleSearch($dbi, $search) { - $clause = MakeSQLSearchClause($search, 'pagename'); - $res = mssql_query("select pagename from $dbi[table] where $clause order by pagename", $dbi["dbc"]); - - return $res; - } - - - // iterating through database - function TitleSearchNextMatch($dbi, $res) { - if($o = mssql_fetch_object($res)) { - return $o->pagename; - } - else { - return 0; - } - } - - - // setup for full-text search - function InitFullSearch($dbi, $search) { - $clause = MakeSQLSearchClause($search, 'content'); - $res = mssql_query("select * from $dbi[table] where $clause", $dbi["dbc"]); - - return $res; - } - - // iterating through database - function FullSearchNextMatch($dbi, $res) { - if($hash = mssql_fetch_array($res)) { - return MakePageHash($hash); - } - else { - return 0; - } - } - - function InitMostPopular($dbi, $limit) { - global $HitCountStore; - $res = mssql_query("select top $limit * from $HitCountStore order by hits desc, pagename", $dbi["dbc"]); - - return $res; - } - - function MostPopularNextMatch($dbi, $res) { - if ($hits = mssql_fetch_array($res)) - return $hits; - else - return 0; - } - - function GetAllWikiPageNames($dbi) { - global $WikiPageStore; - $res = mssql_query("select pagename from $WikiPageStore", $dbi["dbc"]); - $rows = mssql_num_rows($res); - for ($i = 0; $i < $rows; $i++) { - $pages[$i] = mssql_result($res, $i, 0); - } - return $pages; - } - - - //////////////////////////////////////// - // functionality for the wikilinks table - - // takes a page name, returns array of scored incoming and outgoing links - function GetWikiPageLinks($dbi, $pagename) { - global $WikiLinksStore, $WikiScoreStore, $HitCountStore; - - $pagename = addslashes($pagename); - $res = mssql_query("select topage, score from $WikiLinksStore, $WikiScoreStore where topage=pagename and frompage='$pagename' order by score desc, topage"); - $rows = mssql_num_rows($res); - for ($i = 0; $i < $rows; $i++) { - $out = mssql_fetch_array($res); - $links['out'][] = array($out['topage'], $out['score']); - } - - $res = mssql_query("select frompage, score from $WikiLinksStore, $WikiScoreStore where frompage=pagename and topage='$pagename' order by score desc, frompage"); - $rows = mssql_num_rows($res); - for ($i = 0; $i < $rows; $i++) { - $out = mssql_fetch_array($res); - $links['in'][] = array($out['frompage'], $out['score']); - } - - $res = mssql_query("select distinct pagename, hits from $WikiLinksStore, $HitCountStore where (frompage=pagename and topage='$pagename') or (topage=pagename and frompage='$pagename') order by hits desc, pagename"); - $rows = mssql_num_rows($res); - for ($i = 0; $i < $rows; $i++) { - $out = mssql_fetch_array($res); - $links['popular'][] = array($out['pagename'], $out['hits']); - } - - return $links; - } - - - // takes page name, list of links it contains - // the $linklist is an array where the keys are the page names - function SetWikiPageLinks($dbi, $pagename, $linklist) { - global $WikiLinksStore, $WikiScoreStore; - - $frompage = addslashes($pagename); - - // first delete the old list of links - mssql_query("delete from $WikiLinksStore where frompage='$frompage'", - $dbi["dbc"]); - - // the page may not have links, return if not - if (! count($linklist)) - return; - // now insert the new list of links - while (list($topage, $count) = each($linklist)) { - $topage = addslashes($topage); - if($topage != $frompage) { - mssql_query("insert into $WikiLinksStore (frompage, topage) " . - "values ('$frompage', '$topage')", $dbi["dbc"]); - } - } - - // update pagescore - mssql_query("delete from $WikiScoreStore", $dbi["dbc"]); - mssql_query("insert into $WikiScoreStore select w1.topage, count(*) from $WikiLinksStore as w1, $WikiLinksStore as w2 where w2.topage=w1.frompage group by w1.topage", $dbi["dbc"]); - } - -/* more mssql queries: - -orphans: -select pagename from wiki left join wikilinks on pagename=topage where topage is NULL; -*/ -?> +"; + $msg .= sprintf(gettext ("MSSQL error: %s"), mssql_get_last_message()); + ExitWiki($msg); + } + // flush message + mssql_get_last_message(); + + if (!mssql_select_db($mssql_db, $dbc)) { + $msg = sprintf(gettext ("Cannot open database %s, giving up."), $mssql_db); + $msg .= "
"; + $msg .= sprintf(gettext ("MSSQL error: %s"), mssql_get_last_message()); + ExitWiki($msg); + } + // flush message + mssql_get_last_message(); + + $dbi['dbc'] = $dbc; + $dbi['table'] = $dbname; + return $dbi; + } + + + function CloseDataBase($dbi) { + // NOP function + // mssql connections are established as persistant + // they cannot be closed through mssql_close() + } + + + // prepare $pagehash for storing in mssql + function MakeDBHash($pagename, $pagehash) + { + $pagehash["pagename"] = addslashes($pagename); + if (!isset($pagehash["flags"])) + $pagehash["flags"] = 0; + $pagehash["author"] = addslashes($pagehash["author"]); + $pagehash["content"] = implode("\n", $pagehash["content"]); + $pagehash["content"] = addslashes($pagehash["content"]); + if (!isset($pagehash["refs"])) + $pagehash["refs"] = array(); + $pagehash["refs"] = serialize($pagehash["refs"]); + + return $pagehash; + } + + + // convert mssql result $dbhash to $pagehash + function MakePageHash($dbhash) + { + // unserialize/explode content + $dbhash['refs'] = unserialize($dbhash['refs']); + $dbhash['content'] = explode("\n", $dbhash['content']); + return $dbhash; + } + + + // Return hash of page + attributes or default + function RetrievePage($dbi, $pagename, $pagestore) { + $pagename = addslashes($pagename); + if ($res = mssql_query("select * from $pagestore where pagename='$pagename'", $dbi['dbc'])) { + if ($dbhash = mssql_fetch_array($res)) { + return MakePageHash($dbhash); + } + } + return -1; + } + + + // Either insert or replace a key/value (a page) + 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 "

Insert/Update Query: $query

\n"; + + $retval = mssql_query($query); + if ($retval == false) { + printf(gettext ("Insert/Update failed: %s
\n"), mssql_get_last_message()); + } + } + + + // for archiving pages to a seperate dbm + function SaveCopyToArchive($dbi, $pagename, $pagehash) { + global $ArchivePageStore; + $adbi = OpenDataBase($ArchivePageStore); + InsertPage($adbi, $pagename, $pagehash); + } + + + function IsWikiPage($dbi, $pagename) { + $pagename = addslashes($pagename); + if ($res = mssql_query("select count(*) from $dbi[table] where pagename='$pagename'", $dbi['dbc'])) { + return(mssql_result($res, 0, 0)); + } + return 0; + } + + function IsInArchive($dbi, $pagename) { + global $ArchivePageStore; + + $pagename = addslashes($pagename); + if ($res = mssql_query("select count(*) from $ArchivePageStore where pagename='$pagename'", $dbi['dbc'])) { + return(mssql_result($res, 0, 0)); + } + return 0; + } + + + function RemovePage($dbi, $pagename) { + global $WikiPageStore, $ArchivePageStore; + global $WikiLinksStore, $HitCountStore, $WikiScoreStore; + + $pagename = addslashes($pagename); + $msg = gettext ("Cannot delete '%s' from table '%s'"); + $msg .= "
\n"; + $msg .= gettext ("MSSQL error: %s"); + + if (!mssql_query("delete from $WikiPageStore where pagename='$pagename'", $dbi['dbc'])) + ExitWiki(sprintf($msg, $pagename, $WikiPageStore, mssql_get_last_message())); + + if (!mssql_query("delete from $ArchivePageStore where pagename='$pagename'", $dbi['dbc'])) + ExitWiki(sprintf($msg, $pagename, $ArchivePageStore, mssql_get_last_message())); + + if (!mssql_query("delete from $WikiLinksStore where frompage='$pagename'", $dbi['dbc'])) + ExitWiki(sprintf($msg, $pagename, $WikiLinksStore, mssql_get_last_message())); + + if (!mssql_query("delete from $HitCountStore where pagename='$pagename'", $dbi['dbc'])) + ExitWiki(sprintf($msg, $pagename, $HitCountStore, mssql_get_last_message())); + + if (!mssql_query("delete from $WikiScoreStore where pagename='$pagename'", $dbi['dbc'])) + ExitWiki(sprintf($msg, $pagename, $WikiScoreStore, mssql_get_last_message())); + } + + + function IncreaseHitCount($dbi, $pagename) + { + global $HitCountStore; + + $qpagename = addslashes($pagename); + $rowexists = 0; + if ($res = mssql_query("select count(*) from $dbi[table] where pagename='$qpagename'", $dbi['dbc'])) { + $rowexists = (mssql_result($res, 0, 0)); + } + + if ($rowexists) + $res = mssql_query("update $HitCountStore set hits=hits+1 where pagename='$qpagename'", $dbi['dbc']); + else + $res = mssql_query("insert into $HitCountStore (pagename, hits) values ('$qpagename', 1)", $dbi['dbc']); + + return $res; + } + + function GetHitCount($dbi, $pagename) + { + global $HitCountStore; + + $qpagename = addslashes($pagename); + $res = mssql_query("select hits from $HitCountStore where pagename='$qpagename'", $dbi['dbc']); + if (mssql_num_rows($res)) + $hits = mssql_result($res, 0, 0); + else + $hits = "0"; + + return $hits; + } + + function MakeSQLSearchClause($search, $column) + { + $search = preg_replace("/\s+/", " ", trim($search)); + $search = preg_replace('/(?=[%_\\\\])/', "\\", $search); + $search = addslashes($search); + + $term = strtok($search, ' '); + $clause = ''; + while($term) { + $word = "$term"; + if ($word[0] == '-') { + $word = substr($word, 1); + $clause .= "not ($column like '%$word%') "; + } else { + $clause .= "($column like '%$word%') "; + } + if ($term = strtok(' ')) + $clause .= 'and '; + } + return $clause; + } + + // setup for title-search + function InitTitleSearch($dbi, $search) { + $clause = MakeSQLSearchClause($search, 'pagename'); + $res = mssql_query("select pagename from $dbi[table] where $clause order by pagename", $dbi["dbc"]); + + return $res; + } + + + // iterating through database + function TitleSearchNextMatch($dbi, $res) { + if($o = mssql_fetch_object($res)) { + return $o->pagename; + } + else { + return 0; + } + } + + + // setup for full-text search + function InitFullSearch($dbi, $search) { + $clause = MakeSQLSearchClause($search, 'content'); + $res = mssql_query("select * from $dbi[table] where $clause", $dbi["dbc"]); + + return $res; + } + + // iterating through database + function FullSearchNextMatch($dbi, $res) { + if($hash = mssql_fetch_array($res)) { + return MakePageHash($hash); + } + else { + return 0; + } + } + + function InitMostPopular($dbi, $limit) { + global $HitCountStore; + $res = mssql_query("select top $limit * from $HitCountStore order by hits desc, pagename", $dbi["dbc"]); + + return $res; + } + + function MostPopularNextMatch($dbi, $res) { + if ($hits = mssql_fetch_array($res)) + return $hits; + else + return 0; + } + + function GetAllWikiPageNames($dbi) { + global $WikiPageStore; + $res = mssql_query("select pagename from $WikiPageStore", $dbi["dbc"]); + $rows = mssql_num_rows($res); + for ($i = 0; $i < $rows; $i++) { + $pages[$i] = mssql_result($res, $i, 0); + } + return $pages; + } + + + //////////////////////////////////////// + // functionality for the wikilinks table + + // takes a page name, returns array of scored incoming and outgoing links + function GetWikiPageLinks($dbi, $pagename) { + global $WikiLinksStore, $WikiScoreStore, $HitCountStore; + + $pagename = addslashes($pagename); + $res = mssql_query("select topage, score from $WikiLinksStore, $WikiScoreStore where topage=pagename and frompage='$pagename' order by score desc, topage"); + $rows = mssql_num_rows($res); + for ($i = 0; $i < $rows; $i++) { + $out = mssql_fetch_array($res); + $links['out'][] = array($out['topage'], $out['score']); + } + + $res = mssql_query("select frompage, score from $WikiLinksStore, $WikiScoreStore where frompage=pagename and topage='$pagename' order by score desc, frompage"); + $rows = mssql_num_rows($res); + for ($i = 0; $i < $rows; $i++) { + $out = mssql_fetch_array($res); + $links['in'][] = array($out['frompage'], $out['score']); + } + + $res = mssql_query("select distinct pagename, hits from $WikiLinksStore, $HitCountStore where (frompage=pagename and topage='$pagename') or (topage=pagename and frompage='$pagename') order by hits desc, pagename"); + $rows = mssql_num_rows($res); + for ($i = 0; $i < $rows; $i++) { + $out = mssql_fetch_array($res); + $links['popular'][] = array($out['pagename'], $out['hits']); + } + + return $links; + } + + + // takes page name, list of links it contains + // the $linklist is an array where the keys are the page names + function SetWikiPageLinks($dbi, $pagename, $linklist) { + global $WikiLinksStore, $WikiScoreStore; + + $frompage = addslashes($pagename); + + // first delete the old list of links + mssql_query("delete from $WikiLinksStore where frompage='$frompage'", + $dbi["dbc"]); + + // the page may not have links, return if not + if (! count($linklist)) + return; + // now insert the new list of links + while (list($topage, $count) = each($linklist)) { + $topage = addslashes($topage); + if($topage != $frompage) { + mssql_query("insert into $WikiLinksStore (frompage, topage) " . + "values ('$frompage', '$topage')", $dbi["dbc"]); + } + } + + // update pagescore + mssql_query("delete from $WikiScoreStore", $dbi["dbc"]); + mssql_query("insert into $WikiScoreStore select w1.topage, count(*) from $WikiLinksStore as w1, $WikiLinksStore as w2 where w2.topage=w1.frompage group by w1.topage", $dbi["dbc"]); + } + +/* more mssql queries: + +orphans: +select pagename from wiki left join wikilinks on pagename=topage where topage is NULL; +*/ +?> \ No newline at end of file diff --git a/lib/mysql.php b/lib/mysql.php index 9523951a5..66ab6e680 100644 --- a/lib/mysql.php +++ b/lib/mysql.php @@ -1,4 +1,4 @@ - +?> \ No newline at end of file diff --git a/lib/pgsql.php b/lib/pgsql.php index 6b5d449f9..369ac5f3f 100644 --- a/lib/pgsql.php +++ b/lib/pgsql.php @@ -1,4 +1,4 @@ - +?> \ No newline at end of file diff --git a/lib/search.php b/lib/search.php index 13fa3e003..19d76a64e 100644 --- a/lib/search.php +++ b/lib/search.php @@ -1,6 +1,6 @@ +?> \ No newline at end of file diff --git a/lib/setupwiki.php b/lib/setupwiki.php index 71e0a98a1..a3b4b49de 100644 --- a/lib/setupwiki.php +++ b/lib/setupwiki.php @@ -1,4 +1,4 @@ - + +?> \ No newline at end of file diff --git a/lib/transform.php b/lib/transform.php index 7c39c6e53..a6dd7f3c3 100644 --- a/lib/transform.php +++ b/lib/transform.php @@ -1,4 +1,4 @@ - +?> \ No newline at end of file diff --git a/locale/.htaccess b/locale/.htaccess index 145f82df8..551ed186d 100644 --- a/locale/.htaccess +++ b/locale/.htaccess @@ -1,3 +1,3 @@ -# $Id: .htaccess,v 1.2 2001-11-08 16:35:05 dairiki Exp $ +# $Id: .htaccess,v 1.2.2.1 2005-01-07 13:59:59 rurban Exp $ order allow,deny Deny from all diff --git a/pgsrc/RecentVisitors b/pgsrc/RecentVisitors index cf612c285..9dd4ed067 100644 --- a/pgsrc/RecentVisitors +++ b/pgsrc/RecentVisitors @@ -1,5 +1,5 @@ -Sign and date your name below! - -Arno Hollosi, Aredridel Stauck, Jeff Dairiki, Steve Wainstead, the PhpWiki authors. - - +Sign and date your name below! + +Arno Hollosi, Aredridel Stauck, Jeff Dairiki, Steve Wainstead, Reini Urban, the PhpWiki authors. + + diff --git a/schemas/.htaccess b/schemas/.htaccess index 145f82df8..5c5761e29 100644 --- a/schemas/.htaccess +++ b/schemas/.htaccess @@ -1,3 +1,3 @@ -# $Id: .htaccess,v 1.2 2001-11-08 16:35:05 dairiki Exp $ +# $Id: .htaccess,v 1.2.2.1 2005-01-07 14:00:00 rurban Exp $ order allow,deny Deny from all diff --git a/templates/.htaccess b/templates/.htaccess new file mode 100644 index 000000000..8b3198825 --- /dev/null +++ b/templates/.htaccess @@ -0,0 +1,3 @@ +# $Id: .htaccess,v 1.3.2.1 2005-01-07 14:00:00 rurban Exp $ +order allow,deny +Deny from all -- 2.45.0