You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(43) |
Nov
(73) |
Dec
(10) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(34) |
Feb
(110) |
Mar
(24) |
Apr
(44) |
May
(37) |
Jun
(22) |
Jul
(20) |
Aug
(28) |
Sep
(50) |
Oct
(11) |
Nov
(132) |
Dec
(595) |
2002 |
Jan
(1099) |
Feb
(579) |
Mar
(63) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(125) |
Sep
(101) |
Oct
(25) |
Nov
(34) |
Dec
(47) |
2003 |
Jan
(82) |
Feb
(182) |
Mar
(71) |
Apr
(3) |
May
(1) |
Jun
(3) |
Jul
|
Aug
|
Sep
(14) |
Oct
(6) |
Nov
(124) |
Dec
(68) |
2004 |
Jan
(64) |
Feb
(191) |
Mar
(199) |
Apr
(298) |
May
(252) |
Jun
(426) |
Jul
(134) |
Aug
(13) |
Sep
(96) |
Oct
(75) |
Nov
(232) |
Dec
(171) |
2005 |
Jan
(205) |
Feb
(165) |
Mar
(8) |
Apr
(74) |
May
(21) |
Jun
(19) |
Jul
(37) |
Aug
(69) |
Sep
(141) |
Oct
(118) |
Nov
(31) |
Dec
(7) |
2006 |
Jan
(5) |
Feb
(10) |
Mar
(35) |
Apr
(24) |
May
(34) |
Jun
(29) |
Jul
(5) |
Aug
(38) |
Sep
(30) |
Oct
(37) |
Nov
(30) |
Dec
(86) |
2007 |
Jan
(414) |
Feb
(40) |
Mar
(18) |
Apr
(10) |
May
(66) |
Jun
(60) |
Jul
(105) |
Aug
(55) |
Sep
(64) |
Oct
(7) |
Nov
(11) |
Dec
(5) |
2008 |
Jan
(26) |
Feb
(28) |
Mar
(79) |
Apr
(34) |
May
(61) |
Jun
(24) |
Jul
(29) |
Aug
(160) |
Sep
(62) |
Oct
(70) |
Nov
(32) |
Dec
(14) |
2009 |
Jan
(140) |
Feb
(135) |
Mar
(153) |
Apr
(53) |
May
(24) |
Jun
(138) |
Jul
(90) |
Aug
(46) |
Sep
(72) |
Oct
(84) |
Nov
(32) |
Dec
(4) |
2010 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(55) |
May
(89) |
Jun
(131) |
Jul
(41) |
Aug
(38) |
Sep
(42) |
Oct
(11) |
Nov
(27) |
Dec
(54) |
2011 |
Jan
(127) |
Feb
(16) |
Mar
(71) |
Apr
(52) |
May
(32) |
Jun
(31) |
Jul
(4) |
Aug
|
Sep
(45) |
Oct
(26) |
Nov
(36) |
Dec
(10) |
2012 |
Jan
(23) |
Feb
(6) |
Mar
(13) |
Apr
(18) |
May
(1) |
Jun
(4) |
Jul
(3) |
Aug
(12) |
Sep
(57) |
Oct
(96) |
Nov
(163) |
Dec
(124) |
2013 |
Jan
(11) |
Feb
(17) |
Mar
(7) |
Apr
(48) |
May
(15) |
Jun
(29) |
Jul
(12) |
Aug
|
Sep
(9) |
Oct
|
Nov
|
Dec
(3) |
2014 |
Jan
(4) |
Feb
(1) |
Mar
(2) |
Apr
(1) |
May
(8) |
Jun
(90) |
Jul
(104) |
Aug
(12) |
Sep
(81) |
Oct
(139) |
Nov
(111) |
Dec
(64) |
2015 |
Jan
(46) |
Feb
(74) |
Mar
(56) |
Apr
(61) |
May
(3) |
Jun
(7) |
Jul
(11) |
Aug
(5) |
Sep
(15) |
Oct
(1) |
Nov
(1) |
Dec
(15) |
2016 |
Jan
(25) |
Feb
(33) |
Mar
(24) |
Apr
(4) |
May
(24) |
Jun
(3) |
Jul
(75) |
Aug
|
Sep
(2) |
Oct
(38) |
Nov
(4) |
Dec
(18) |
2017 |
Jan
(8) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(14) |
Jun
|
Jul
(5) |
Aug
(9) |
Sep
|
Oct
(23) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
(9) |
Apr
(60) |
May
(1) |
Jun
|
Jul
(13) |
Aug
|
Sep
(11) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
(15) |
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(47) |
2021 |
Jan
(24) |
Feb
(33) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(64) |
Jul
(71) |
Aug
(114) |
Sep
(82) |
Oct
(32) |
Nov
(76) |
Dec
(86) |
2022 |
Jan
(162) |
Feb
(41) |
Mar
(11) |
Apr
(9) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(7) |
2023 |
Jan
|
Feb
(1) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(25) |
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
|
2024 |
Jan
(7) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
|
Feb
(90) |
Mar
(19) |
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Steve W. <wai...@us...> - 2001-11-02 05:17:11
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv15216 Modified Files: Tag: release-1_2-branch mssql.php Log Message: Newer version fixes a bug in InsertPage(). Index: mssql.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/mssql.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -r1.1.2.1 -r1.1.2.2 *** mssql.php 2001/11/02 05:07:52 1.1.2.1 --- mssql.php 2001/11/02 05:17:08 1.1.2.2 *************** *** 111,114 **** --- 111,121 ---- 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); |
From: Steve W. <wai...@us...> - 2001-11-02 05:15:08
|
Update of /cvsroot/phpwiki/phpwiki In directory usw-pr-cvs1:/tmp/cvs-serv14877 Modified Files: Tag: release-1_2-branch INSTALL.mssql Log Message: Cleaned it up and added some hints. Index: INSTALL.mssql =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/Attic/INSTALL.mssql,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -r1.1.2.1 -r1.1.2.2 *** INSTALL.mssql 2001/11/02 05:07:52 1.1.2.1 --- INSTALL.mssql 2001/11/02 05:15:05 1.1.2.2 *************** *** 1,35 **** ! From sw...@pa... Tue May 1 11:28:09 2001 -0400 ! Return-Path: <And...@ba...> ! Received: from avon0.barclayscapital.com (hermes.barclayscapital.com [141.228.4.66]) ! by mail3.panix.com (Postfix) with SMTP id B1954983BC ! for <sw...@pa...>; Tue, 1 May 2001 11:28:05 -0400 (EDT) ! Received: from hermes.barclayscapital.com ([141.228.4.66]) by avon0.barclayscapital.com ! via smtpd (for mail3.panix.com [166.84.0.167]) with SMTP; 1 May 2001 15:28:06 UT ! Received: from avon1.barclayscapital.com (localhost [127.0.0.1]) ! by hermes.barclayscapital.com with SMTP id QAA23136 ! for <sw...@pa...>; Tue, 1 May 2001 16:31:29 +0100 (BST) From: And...@ba... - Received: from exlpseg011.ldn.bzwint.com by avon1.barclayscapital.com - via smtpd (for hermesint.barclayscapital.com [141.228.4.34]) with SMTP; 1 May 2001 15:26:56 UT - Received: (private information removed) - Received: (private information removed) - Message-ID: <07F...@ex...> To: sw...@pa... Cc: php...@li... Subject: PHPWiki with Microsoft SQL-Server Date: Tue, 1 May 2001 16:26:50 +0100 ! MIME-Version: 1.0 ! X-Mailer: Internet Mail Service (5.5.2448.0) ! Content-Type: multipart/mixed ; boundary="----_=_NextPart_000_01C0D253.2568B8F4" ! X-Eagle-Notice: Sender not 8-bit clean in '\tby hermes.barclayscapital.com with SMTP\234 id QAA23136' ! Status: RO ! X-Status: A ! ! This message is in MIME format. Since your mail reader does not understand ! this format, some or all of this message may not be legible. ! ! ------_=_NextPart_000_01C0D253.2568B8F4 ! Content-Type: text/plain; ! charset="iso-8859-1" --- 1,20 ---- ! Note: this is the email I got when the files were contributed. I cannot test ! the code, since I don't have access to mssql, so ymmv. The files referenced ! here are at: ! ! lib/mssql.php ! admin/translate_mysql.pl (you probably won't need this) ! ! The code for lib/config.php has already been added. ! ! ~swain ! ! From: And...@ba... To: sw...@pa... Cc: php...@li... Subject: PHPWiki with Microsoft SQL-Server Date: Tue, 1 May 2001 16:26:50 +0100 ! *************** *** 98,574 **** -------------------------------------------------------------------------------------- - - ------_=_NextPart_000_01C0D253.2568B8F4 - Content-Type: application/octet-stream; - name="mssql.php" - Content-Transfer-Encoding: quoted-printable - Content-Disposition: attachment; - filename="mssql.php" - - <?php=20 - - /* Microsoft SQL-Server library for PHPWiki - Author: Andrew K. Pearson - Date: 01 May 2001 - */ - - /* - Database functions: - OpenDataBase($dbname) - CloseDataBase($dbi) - MakeDBHash($pagename, $pagehash) - MakePageHash($dbhash) - RetrievePage($dbi, $pagename, $pagestore) - InsertPage($dbi, $pagename, $pagehash) - SaveCopyToArchive($dbi, $pagename, $pagehash) - IsWikiPage($dbi, $pagename) - IsInArchive($dbi, $pagename) - RemovePage($dbi, $pagename) - IncreaseHitCount($dbi, $pagename) - GetHitCount($dbi, $pagename) - MakeSQLSearchClause($search, $column) - InitTitleSearch($dbi, $search) - TitleSearchNextMatch($dbi, $res) - InitFullSearch($dbi, $search) - FullSearchNextMatch($dbi, $res) - InitMostPopular($dbi, $limit) - MostPopularNextMatch($dbi, $res) - GetAllWikiPageNames($dbi) - GetWikiPageLinks($dbi, $pagename) - SetWikiPageLinks($dbi, $pagename, $linklist) - */ - - // open a database and return the handle - // ignores MAX_DBM_ATTEMPTS - - function OpenDataBase($dbname) { - global $mssql_server, $mssql_user, $mssql_pwd, $mssql_db; - - if (!($dbc =3D mssql_pconnect($mssql_server, $mssql_user, = - $mssql_pwd))) { - $msg =3D gettext ("Cannot establish connection to database, = - giving up."); - $msg .=3D "<BR>"; - $msg .=3D 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 =3D sprintf(gettext ("Cannot open database %s, giving = - up."), $mssql_db); - $msg .=3D "<BR>"; - $msg .=3D sprintf(gettext ("MSSQL error: %s"), = - mssql_get_last_message()); - ExitWiki($msg); - } - // flush message - mssql_get_last_message(); - - $dbi['dbc'] =3D $dbc; - $dbi['table'] =3D $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"] =3D addslashes($pagename); - if (!isset($pagehash["flags"])) - $pagehash["flags"] =3D 0; - $pagehash["author"] =3D addslashes($pagehash["author"]); - $pagehash["content"] =3D implode("\n", $pagehash["content"]); - $pagehash["content"] =3D addslashes($pagehash["content"]); - if (!isset($pagehash["refs"])) - $pagehash["refs"] =3D array(); - $pagehash["refs"] =3D serialize($pagehash["refs"]); - =20 - return $pagehash; - } - - - // convert mssql result $dbhash to $pagehash - function MakePageHash($dbhash) - { - // unserialize/explode content - $dbhash['refs'] =3D unserialize($dbhash['refs']); - $dbhash['content'] =3D explode("\n", $dbhash['content']); - return $dbhash; - } - - - // Return hash of page + attributes or default - function RetrievePage($dbi, $pagename, $pagestore) { - $pagename =3D addslashes($pagename); - if ($res =3D mssql_query("select * from $pagestore where = - pagename=3D'$pagename'", $dbi['dbc'])) { - if ($dbhash =3D mssql_fetch_array($res)) { - return MakePageHash($dbhash); - } - } - return -1; - } - - - // Either insert or replace a key/value (a page) - function InsertPage($dbi, $pagename, $pagehash) { - - $pagehash =3D MakeDBHash($pagename, $pagehash); - - // record the time of modification - $pagehash["lastmodified"] =3D time(); - - if (IsWikiPage($dbi, $pagename)) { - - $PAIRS =3D "author=3D'$pagehash[author]'," . - "content=3D'$pagehash[content]'," . - "created=3D$pagehash[created]," . - "flags=3D$pagehash[flags]," . - "lastmodified=3D$pagehash[lastmodified]," . - "pagename=3D'$pagehash[pagename]'," . - "refs=3D'$pagehash[refs]'," . - "version=3D$pagehash[version]"; - - $query =3D "UPDATE $dbi[table] SET $PAIRS WHERE = - pagename=3D'$pagename'"; - - } else { - // do an insert - // build up the column names and values for the query - - $COLUMNS =3D "author, content, created, flags, lastmodified, " = - . - "pagename, refs, version"; - - $VALUES =3D "'$pagehash[author]', '$pagehash[content]', " . - "$pagehash[created], $pagehash[flags], " . - "$pagehash[lastmodified], '$pagehash[pagename]', " = - . - "'$pagehash[refs]', $pagehash[version]"; - - - $query =3D "INSERT INTO $dbi[table] ($COLUMNS) = - VALUES($VALUES)"; - } - - //echo "<p>Insert/Update Query: $query<p>\n"; - - $retval =3D mssql_query($query); - if ($retval =3D=3D false) { - printf(gettext ("Insert/Update failed: %s <br>\n"), = - mssql_get_last_message()); - } - } - - - // for archiving pages to a seperate dbm - function SaveCopyToArchive($dbi, $pagename, $pagehash) { - global $ArchivePageStore; - $adbi =3D OpenDataBase($ArchivePageStore); - InsertPage($adbi, $pagename, $pagehash); - } - - - function IsWikiPage($dbi, $pagename) { - $pagename =3D addslashes($pagename); - if ($res =3D mssql_query("select count(*) from $dbi[table] where = - pagename=3D'$pagename'", $dbi['dbc'])) { - return(mssql_result($res, 0, 0)); - } - return 0; - } - - function IsInArchive($dbi, $pagename) { - global $ArchivePageStore; - - $pagename =3D addslashes($pagename); - if ($res =3D mssql_query("select count(*) from $ArchivePageStore = - where pagename=3D'$pagename'", $dbi['dbc'])) { - return(mssql_result($res, 0, 0)); - } - return 0; - } - - - function RemovePage($dbi, $pagename) { - global $WikiPageStore, $ArchivePageStore; - global $WikiLinksStore, $HitCountStore, $WikiScoreStore; - - $pagename =3D addslashes($pagename); - $msg =3D gettext ("Cannot delete '%s' from table '%s'"); - $msg .=3D "<br>\n"; - $msg .=3D gettext ("MSSQL error: %s"); - - if (!mssql_query("delete from $WikiPageStore where = - pagename=3D'$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $WikiPageStore, = - mssql_get_last_message())); - - if (!mssql_query("delete from $ArchivePageStore where = - pagename=3D'$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $ArchivePageStore, = - mssql_get_last_message())); - - if (!mssql_query("delete from $WikiLinksStore where = - frompage=3D'$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $WikiLinksStore, = - mssql_get_last_message())); - - if (!mssql_query("delete from $HitCountStore where = - pagename=3D'$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $HitCountStore, = - mssql_get_last_message())); - - if (!mssql_query("delete from $WikiScoreStore where = - pagename=3D'$pagename'", $dbi['dbc'])) - ExitWiki(sprintf($msg, $pagename, $WikiScoreStore, = - mssql_get_last_message())); - } - - - function IncreaseHitCount($dbi, $pagename) - { - global $HitCountStore; - - $rowexists =3D 0; - if ($res =3D mssql_query("select count(*) from $dbi[table] where = - pagename=3D'$pagename'", $dbi['dbc'])) { - $rowexists =3D (mssql_result($res, 0, 0)); - } - - if ($rowexists) - $res =3D mssql_query("update $HitCountStore set hits=3Dhits+1 = - where pagename=3D'$pagename'", $dbi['dbc']); - else - $res =3D mssql_query("insert into $HitCountStore (pagename, hits) = - values ('$pagename', 1)", $dbi['dbc']); - - return $res; - } - - function GetHitCount($dbi, $pagename) - { - global $HitCountStore; - - $res =3D mssql_query("select hits from $HitCountStore where = - pagename=3D'$pagename'", $dbi['dbc']); - if (mssql_num_rows($res)) - $hits =3D mssql_result($res, 0, 0); - else - $hits =3D "0"; - - return $hits; - } - - function MakeSQLSearchClause($search, $column) - { - $search =3D addslashes(preg_replace("/\s+/", " ", $search)); - $term =3D strtok($search, ' '); - $clause =3D ''; - while($term) { - $word =3D "$term"; - if ($word[0] =3D=3D '-') { - $word =3D substr($word, 1); - $clause .=3D "not ($column like '%$word%') "; - } else { - $clause .=3D "($column like '%$word%') "; - } - if ($term =3D strtok(' ')) - $clause .=3D 'and '; - } - return $clause; - } - - // setup for title-search - function InitTitleSearch($dbi, $search) { - $clause =3D MakeSQLSearchClause($search, 'pagename'); - $res =3D 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 =3D mssql_fetch_object($res)) { - return $o->pagename; - } - else { - return 0; - } - } - - - // setup for full-text search - function InitFullSearch($dbi, $search) { - $clause =3D MakeSQLSearchClause($search, 'content'); - $res =3D mssql_query("select * from $dbi[table] where $clause", = - $dbi["dbc"]); - - return $res; - } - - // iterating through database - function FullSearchNextMatch($dbi, $res) { - if($hash =3D mssql_fetch_array($res)) { - return MakePageHash($hash); - } - else { - return 0; - } - } - - function InitMostPopular($dbi, $limit) { - global $HitCountStore; - $res =3D mssql_query("select top $limit * from $HitCountStore = - order by hits desc, pagename", $dbi["dbc"]); - =20 - return $res; - } - - function MostPopularNextMatch($dbi, $res) { - if ($hits =3D mssql_fetch_array($res)) - return $hits; - else - return 0; - } - - function GetAllWikiPageNames($dbi) { - global $WikiPageStore; - $res =3D mssql_query("select pagename from $WikiPageStore", = - $dbi["dbc"]); - $rows =3D mssql_num_rows($res); - for ($i =3D 0; $i < $rows; $i++) { - $pages[$i] =3D mssql_result($res, $i, 0); - } - return $pages; - } - =20 - =20 - //////////////////////////////////////// - // 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 =3D addslashes($pagename); - $res =3D mssql_query("select topage, score from $WikiLinksStore, = - $WikiScoreStore where topage=3Dpagename and frompage=3D'$pagename' = - order by score desc, topage"); - $rows =3D mssql_num_rows($res); - for ($i =3D 0; $i < $rows; $i++) { - $out =3D mssql_fetch_array($res); - $links['out'][] =3D array($out['topage'], $out['score']); - } - - $res =3D mssql_query("select frompage, score from = - $WikiLinksStore, $WikiScoreStore where frompage=3Dpagename and = - topage=3D'$pagename' order by score desc, frompage"); - $rows =3D mssql_num_rows($res); - for ($i =3D 0; $i < $rows; $i++) { - $out =3D mssql_fetch_array($res); - $links['in'][] =3D array($out['frompage'], $out['score']); - } - - $res =3D mssql_query("select distinct pagename, hits from = - $WikiLinksStore, $HitCountStore where (frompage=3Dpagename and = - topage=3D'$pagename') or (topage=3Dpagename and frompage=3D'$pagename') = - order by hits desc, pagename"); - $rows =3D mssql_num_rows($res); - for ($i =3D 0; $i < $rows; $i++) { - $out =3D mssql_fetch_array($res); - $links['popular'][] =3D 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 =3D addslashes($pagename); - - // first delete the old list of links - mssql_query("delete from $WikiLinksStore where = - frompage=3D'$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) =3D each($linklist)) { - $topage =3D addslashes($topage); - if($topage !=3D $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=3Dw1.frompage group by w1.topage", $dbi["dbc"]); - } - - /* more mssql queries: - - orphans: - select pagename from wiki left join wikilinks on pagename=3Dtopage = - where topage is NULL; - */ - ?> - - ------_=_NextPart_000_01C0D253.2568B8F4 - Content-Type: application/octet-stream; - name="translate_mysql.pl" - Content-Disposition: attachment; - filename="translate_mysql.pl" - - - # Convert MySQL wiki database dump to a Microsoft SQL-Server compatible SQL script - # NB This is not a general-purpose MySQL->SQL-Server conversion script - - # Author: Andrew K. Pearson - # Date: 01 May 2001 - - # Example usage: perl translate_mysql.pl dump.sql > dump2.sql - - # NB I did not use sed because the version I have is limited to input lines of <1K in size - - while (<>) - { - $newvalue = $_; - - $newvalue =~ s/\\\"/\'\'/g; - $newvalue =~ s/\\\'/\'\'/g; - $newvalue =~ s/\\n/\'+char(10)+\'/g; - $newvalue =~ s/TYPE=MyISAM;//g; - $newvalue =~ s/int\(.+\)/int/g; - $newvalue =~ s/mediumtext/text/g; - $newvalue =~ s/^#/--/g; - - print $newvalue; - } - - - ------_=_NextPart_000_01C0D253.2568B8F4-- --- 83,85 ---- |
From: Steve W. <wai...@us...> - 2001-11-02 05:11:19
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv14230/lib Modified Files: Tag: release-1_2-branch config.php Log Message: Added config code contributed by Andrew Pearson for support for MS SQL Server. Untested. Index: config.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v retrieving revision 1.24.2.2 retrieving revision 1.24.2.3 diff -C2 -r1.24.2.2 -r1.24.2.3 *** config.php 2001/05/21 16:06:50 1.24.2.2 --- config.php 2001/11/02 05:11:16 1.24.2.3 *************** *** 45,49 **** $WhichDatabase = 'default'; // use one of "dbm", "dba", "mysql", ! // "pgsql", "msql", or "file" // DBM and DBA settings (default) --- 45,49 ---- $WhichDatabase = 'default'; // use one of "dbm", "dba", "mysql", ! // "pgsql", "msql", "mssql", or "file" // DBM and DBA settings (default) *************** *** 126,130 **** include "lib/db_filesystem.php"; ! } else die("Invalid '\$WhichDatabase' in lib/config.php"); --- 126,143 ---- include "lib/db_filesystem.php"; ! // MS SQLServer settings ! } elseif ($WhichDatabase == 'mssql') { ! $WikiPageStore = "wiki"; ! $ArchivePageStore = "archive"; ! $WikiLinksStore = "wikilinks"; ! $WikiScoreStore = "wikiscore"; ! $HitCountStore = "hitcount"; ! $mssql_server = 'servername'; ! $mssql_user = ''; ! $mssql_pwd = ''; ! $mssql_db = ''; ! include "lib/mssql.php"; ! ! } else die("Invalid '\$WhichDatabase' in lib/config.php"); |
From: Steve W. <wai...@us...> - 2001-11-02 05:07:56
|
Update of /cvsroot/phpwiki/phpwiki/admin In directory usw-pr-cvs1:/tmp/cvs-serv13508/admin Added Files: Tag: release-1_2-branch translate_mysql.pl Log Message: Missed these but they will be in the 1.2.2 release. Code for Microsoft SQL Server. --- NEW FILE --- # Convert MySQL wiki database dump to a Microsoft SQL-Server compatible SQL script # NB This is not a general-purpose MySQL->SQL-Server conversion script # Author: Andrew K. Pearson # Date: 01 May 2001 # Example usage: perl translate_mysql.pl dump.sql > dump2.sql # NB I did not use sed because the version I have is limited to input lines of <1K in size while (<>) { $newvalue = $_; $newvalue =~ s/\\\"/\'\'/g; $newvalue =~ s/\\\'/\'\'/g; $newvalue =~ s/\\n/\'+char(10)+\'/g; $newvalue =~ s/TYPE=MyISAM;//g; $newvalue =~ s/int\(.+\)/int/g; $newvalue =~ s/mediumtext/text/g; $newvalue =~ s/^#/--/g; print $newvalue; } |
From: Steve W. <wai...@us...> - 2001-11-02 05:07:55
|
Update of /cvsroot/phpwiki/phpwiki In directory usw-pr-cvs1:/tmp/cvs-serv13508 Added Files: Tag: release-1_2-branch INSTALL.mssql Log Message: Missed these but they will be in the 1.2.2 release. Code for Microsoft SQL Server. --- NEW FILE --- From sw...@pa... Tue May 1 11:28:09 2001 -0400 Return-Path: <And...@ba...> Received: from avon0.barclayscapital.com (hermes.barclayscapital.com [141.228.4.66]) by mail3.panix.com (Postfix) with SMTP id B1954983BC for <sw...@pa...>; Tue, 1 May 2001 11:28:05 -0400 (EDT) Received: from hermes.barclayscapital.com ([141.228.4.66]) by avon0.barclayscapital.com via smtpd (for mail3.panix.com [166.84.0.167]) with SMTP; 1 May 2001 15:28:06 UT Received: from avon1.barclayscapital.com (localhost [127.0.0.1]) by hermes.barclayscapital.com with SMTP id QAA23136 for <sw...@pa...>; Tue, 1 May 2001 16:31:29 +0100 (BST) From: And...@ba... Received: from exlpseg011.ldn.bzwint.com by avon1.barclayscapital.com via smtpd (for hermesint.barclayscapital.com [141.228.4.34]) with SMTP; 1 May 2001 15:26:56 UT Received: (private information removed) Received: (private information removed) Message-ID: <07F...@ex...> To: sw...@pa... Cc: php...@li... Subject: PHPWiki with Microsoft SQL-Server Date: Tue, 1 May 2001 16:26:50 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: multipart/mixed ; boundary="----_=_NextPart_000_01C0D253.2568B8F4" X-Eagle-Notice: Sender not 8-bit clean in '\tby hermes.barclayscapital.com with SMTP\234 id QAA23136' Status: RO X-Status: A This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C0D253.2568B8F4 Content-Type: text/plain; charset="iso-8859-1" My colleague John Clayton set up PHPWiki for our development team using Apache and MySQL on Windows NT 4. He then left, and I was asked to port this to IIS and SQLServer. Please note this is not a reflection of the Apache and MySQL products, which were performing the task admirably, but had more to do with consistency of our environment. Since PHP does work with SQL-Server, the whole migration took about a day. Here are the steps I carried out: 1. Wrote a sql-server library called mssql.php to reside in wiki\lib. <<mssql.php>> 2. Added the following clause to wiki\lib\config.php // MS SQLServer settings } elseif ($WhichDatabase == 'mssql') { $WikiPageStore = "wiki"; $ArchivePageStore = "archive"; $WikiLinksStore = "wikilinks"; $WikiScoreStore = "wikiscore"; $HitCountStore = "hitcount"; $mssql_server = 'servername'; $mssql_user = 'wikiweb'; $mssql_pwd = 'wikiweb'; $mssql_db = 'wiki'; include "lib/mssql.php"; } 3. Set $WhichDatabase='mssql' in config.php 4. Dumped out the mysql wiki database (mysqldump --user=john --host=localhost wiki) and wrote the following perl script to convert to sql-server compatible sql <<translate_mysql.pl>> 5. Loaded the translated db script into SQL-Server and granted relevant permissions/logins etc. 6. Set "magic_quotes_sybase=On" in php.ini to handle embedded quote characters in strings. This is because SQL-Server, like Sybase, uses '' instead of \' within strings to cope with embedded quotes. We had some problems initially with the PHP extension dll for sql-server, but I installed a newer version from http://www.mm4.de. In fact I unpacked their whole php4.0.5-rc1 distribution. I make no claims about all this working 100%, but our existing site seems to work okay in its new IIS/SQL-Server home :-) Andrew Pearson Barclays Capital, UK -------------------------------------------------------------------------------------- For more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group unless otherwise specifically stated. -------------------------------------------------------------------------------------- ------_=_NextPart_000_01C0D253.2568B8F4 Content-Type: application/octet-stream; name="mssql.php" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="mssql.php" <?php=20 /* Microsoft SQL-Server library for PHPWiki Author: Andrew K. Pearson Date: 01 May 2001 */ /* Database functions: OpenDataBase($dbname) CloseDataBase($dbi) MakeDBHash($pagename, $pagehash) MakePageHash($dbhash) RetrievePage($dbi, $pagename, $pagestore) InsertPage($dbi, $pagename, $pagehash) SaveCopyToArchive($dbi, $pagename, $pagehash) IsWikiPage($dbi, $pagename) IsInArchive($dbi, $pagename) RemovePage($dbi, $pagename) IncreaseHitCount($dbi, $pagename) GetHitCount($dbi, $pagename) MakeSQLSearchClause($search, $column) InitTitleSearch($dbi, $search) TitleSearchNextMatch($dbi, $res) InitFullSearch($dbi, $search) FullSearchNextMatch($dbi, $res) InitMostPopular($dbi, $limit) MostPopularNextMatch($dbi, $res) GetAllWikiPageNames($dbi) GetWikiPageLinks($dbi, $pagename) SetWikiPageLinks($dbi, $pagename, $linklist) */ // open a database and return the handle // ignores MAX_DBM_ATTEMPTS function OpenDataBase($dbname) { global $mssql_server, $mssql_user, $mssql_pwd, $mssql_db; if (!($dbc =3D mssql_pconnect($mssql_server, $mssql_user, = $mssql_pwd))) { $msg =3D gettext ("Cannot establish connection to database, = giving up."); $msg .=3D "<BR>"; $msg .=3D 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 =3D sprintf(gettext ("Cannot open database %s, giving = up."), $mssql_db); $msg .=3D "<BR>"; $msg .=3D sprintf(gettext ("MSSQL error: %s"), = mssql_get_last_message()); ExitWiki($msg); } // flush message mssql_get_last_message(); $dbi['dbc'] =3D $dbc; $dbi['table'] =3D $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"] =3D addslashes($pagename); if (!isset($pagehash["flags"])) $pagehash["flags"] =3D 0; $pagehash["author"] =3D addslashes($pagehash["author"]); $pagehash["content"] =3D implode("\n", $pagehash["content"]); $pagehash["content"] =3D addslashes($pagehash["content"]); if (!isset($pagehash["refs"])) $pagehash["refs"] =3D array(); $pagehash["refs"] =3D serialize($pagehash["refs"]); =20 return $pagehash; } // convert mssql result $dbhash to $pagehash function MakePageHash($dbhash) { // unserialize/explode content $dbhash['refs'] =3D unserialize($dbhash['refs']); $dbhash['content'] =3D explode("\n", $dbhash['content']); return $dbhash; } // Return hash of page + attributes or default function RetrievePage($dbi, $pagename, $pagestore) { $pagename =3D addslashes($pagename); if ($res =3D mssql_query("select * from $pagestore where = pagename=3D'$pagename'", $dbi['dbc'])) { if ($dbhash =3D mssql_fetch_array($res)) { return MakePageHash($dbhash); } } return -1; } // Either insert or replace a key/value (a page) function InsertPage($dbi, $pagename, $pagehash) { $pagehash =3D MakeDBHash($pagename, $pagehash); // record the time of modification $pagehash["lastmodified"] =3D time(); if (IsWikiPage($dbi, $pagename)) { $PAIRS =3D "author=3D'$pagehash[author]'," . "content=3D'$pagehash[content]'," . "created=3D$pagehash[created]," . "flags=3D$pagehash[flags]," . "lastmodified=3D$pagehash[lastmodified]," . "pagename=3D'$pagehash[pagename]'," . "refs=3D'$pagehash[refs]'," . "version=3D$pagehash[version]"; $query =3D "UPDATE $dbi[table] SET $PAIRS WHERE = pagename=3D'$pagename'"; } else { // do an insert // build up the column names and values for the query $COLUMNS =3D "author, content, created, flags, lastmodified, " = . "pagename, refs, version"; $VALUES =3D "'$pagehash[author]', '$pagehash[content]', " . "$pagehash[created], $pagehash[flags], " . "$pagehash[lastmodified], '$pagehash[pagename]', " = . "'$pagehash[refs]', $pagehash[version]"; $query =3D "INSERT INTO $dbi[table] ($COLUMNS) = VALUES($VALUES)"; } //echo "<p>Insert/Update Query: $query<p>\n"; $retval =3D mssql_query($query); if ($retval =3D=3D false) { printf(gettext ("Insert/Update failed: %s <br>\n"), = mssql_get_last_message()); } } // for archiving pages to a seperate dbm function SaveCopyToArchive($dbi, $pagename, $pagehash) { global $ArchivePageStore; $adbi =3D OpenDataBase($ArchivePageStore); InsertPage($adbi, $pagename, $pagehash); } function IsWikiPage($dbi, $pagename) { $pagename =3D addslashes($pagename); if ($res =3D mssql_query("select count(*) from $dbi[table] where = pagename=3D'$pagename'", $dbi['dbc'])) { return(mssql_result($res, 0, 0)); } return 0; } function IsInArchive($dbi, $pagename) { global $ArchivePageStore; $pagename =3D addslashes($pagename); if ($res =3D mssql_query("select count(*) from $ArchivePageStore = where pagename=3D'$pagename'", $dbi['dbc'])) { return(mssql_result($res, 0, 0)); } return 0; } function RemovePage($dbi, $pagename) { global $WikiPageStore, $ArchivePageStore; global $WikiLinksStore, $HitCountStore, $WikiScoreStore; $pagename =3D addslashes($pagename); $msg =3D gettext ("Cannot delete '%s' from table '%s'"); $msg .=3D "<br>\n"; $msg .=3D gettext ("MSSQL error: %s"); if (!mssql_query("delete from $WikiPageStore where = pagename=3D'$pagename'", $dbi['dbc'])) ExitWiki(sprintf($msg, $pagename, $WikiPageStore, = mssql_get_last_message())); if (!mssql_query("delete from $ArchivePageStore where = pagename=3D'$pagename'", $dbi['dbc'])) ExitWiki(sprintf($msg, $pagename, $ArchivePageStore, = mssql_get_last_message())); if (!mssql_query("delete from $WikiLinksStore where = frompage=3D'$pagename'", $dbi['dbc'])) ExitWiki(sprintf($msg, $pagename, $WikiLinksStore, = mssql_get_last_message())); if (!mssql_query("delete from $HitCountStore where = pagename=3D'$pagename'", $dbi['dbc'])) ExitWiki(sprintf($msg, $pagename, $HitCountStore, = mssql_get_last_message())); if (!mssql_query("delete from $WikiScoreStore where = pagename=3D'$pagename'", $dbi['dbc'])) ExitWiki(sprintf($msg, $pagename, $WikiScoreStore, = mssql_get_last_message())); } function IncreaseHitCount($dbi, $pagename) { global $HitCountStore; $rowexists =3D 0; if ($res =3D mssql_query("select count(*) from $dbi[table] where = pagename=3D'$pagename'", $dbi['dbc'])) { $rowexists =3D (mssql_result($res, 0, 0)); } if ($rowexists) $res =3D mssql_query("update $HitCountStore set hits=3Dhits+1 = where pagename=3D'$pagename'", $dbi['dbc']); else $res =3D mssql_query("insert into $HitCountStore (pagename, hits) = values ('$pagename', 1)", $dbi['dbc']); return $res; } function GetHitCount($dbi, $pagename) { global $HitCountStore; $res =3D mssql_query("select hits from $HitCountStore where = pagename=3D'$pagename'", $dbi['dbc']); if (mssql_num_rows($res)) $hits =3D mssql_result($res, 0, 0); else $hits =3D "0"; return $hits; } function MakeSQLSearchClause($search, $column) { $search =3D addslashes(preg_replace("/\s+/", " ", $search)); $term =3D strtok($search, ' '); $clause =3D ''; while($term) { $word =3D "$term"; if ($word[0] =3D=3D '-') { $word =3D substr($word, 1); $clause .=3D "not ($column like '%$word%') "; } else { $clause .=3D "($column like '%$word%') "; } if ($term =3D strtok(' ')) $clause .=3D 'and '; } return $clause; } // setup for title-search function InitTitleSearch($dbi, $search) { $clause =3D MakeSQLSearchClause($search, 'pagename'); $res =3D 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 =3D mssql_fetch_object($res)) { return $o->pagename; } else { return 0; } } // setup for full-text search function InitFullSearch($dbi, $search) { $clause =3D MakeSQLSearchClause($search, 'content'); $res =3D mssql_query("select * from $dbi[table] where $clause", = $dbi["dbc"]); return $res; } // iterating through database function FullSearchNextMatch($dbi, $res) { if($hash =3D mssql_fetch_array($res)) { return MakePageHash($hash); } else { return 0; } } function InitMostPopular($dbi, $limit) { global $HitCountStore; $res =3D mssql_query("select top $limit * from $HitCountStore = order by hits desc, pagename", $dbi["dbc"]); =20 return $res; } function MostPopularNextMatch($dbi, $res) { if ($hits =3D mssql_fetch_array($res)) return $hits; else return 0; } function GetAllWikiPageNames($dbi) { global $WikiPageStore; $res =3D mssql_query("select pagename from $WikiPageStore", = $dbi["dbc"]); $rows =3D mssql_num_rows($res); for ($i =3D 0; $i < $rows; $i++) { $pages[$i] =3D mssql_result($res, $i, 0); } return $pages; } =20 =20 //////////////////////////////////////// // 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 =3D addslashes($pagename); $res =3D mssql_query("select topage, score from $WikiLinksStore, = $WikiScoreStore where topage=3Dpagename and frompage=3D'$pagename' = order by score desc, topage"); $rows =3D mssql_num_rows($res); for ($i =3D 0; $i < $rows; $i++) { $out =3D mssql_fetch_array($res); $links['out'][] =3D array($out['topage'], $out['score']); } $res =3D mssql_query("select frompage, score from = $WikiLinksStore, $WikiScoreStore where frompage=3Dpagename and = topage=3D'$pagename' order by score desc, frompage"); $rows =3D mssql_num_rows($res); for ($i =3D 0; $i < $rows; $i++) { $out =3D mssql_fetch_array($res); $links['in'][] =3D array($out['frompage'], $out['score']); } $res =3D mssql_query("select distinct pagename, hits from = $WikiLinksStore, $HitCountStore where (frompage=3Dpagename and = topage=3D'$pagename') or (topage=3Dpagename and frompage=3D'$pagename') = order by hits desc, pagename"); $rows =3D mssql_num_rows($res); for ($i =3D 0; $i < $rows; $i++) { $out =3D mssql_fetch_array($res); $links['popular'][] =3D 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 =3D addslashes($pagename); // first delete the old list of links mssql_query("delete from $WikiLinksStore where = frompage=3D'$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) =3D each($linklist)) { $topage =3D addslashes($topage); if($topage !=3D $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=3Dw1.frompage group by w1.topage", $dbi["dbc"]); } /* more mssql queries: orphans: select pagename from wiki left join wikilinks on pagename=3Dtopage = where topage is NULL; */ ?> ------_=_NextPart_000_01C0D253.2568B8F4 Content-Type: application/octet-stream; name="translate_mysql.pl" Content-Disposition: attachment; filename="translate_mysql.pl" # Convert MySQL wiki database dump to a Microsoft SQL-Server compatible SQL script # NB This is not a general-purpose MySQL->SQL-Server conversion script # Author: Andrew K. Pearson # Date: 01 May 2001 # Example usage: perl translate_mysql.pl dump.sql > dump2.sql # NB I did not use sed because the version I have is limited to input lines of <1K in size while (<>) { $newvalue = $_; $newvalue =~ s/\\\"/\'\'/g; $newvalue =~ s/\\\'/\'\'/g; $newvalue =~ s/\\n/\'+char(10)+\'/g; $newvalue =~ s/TYPE=MyISAM;//g; $newvalue =~ s/int\(.+\)/int/g; $newvalue =~ s/mediumtext/text/g; $newvalue =~ s/^#/--/g; print $newvalue; } ------_=_NextPart_000_01C0D253.2568B8F4-- |
From: Steve W. <wai...@us...> - 2001-11-02 05:07:55
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv13508/lib Added Files: Tag: release-1_2-branch mssql.php Log Message: Missed these but they will be in the 1.2.2 release. Code for Microsoft SQL Server. --- NEW FILE --- <?php /* Microsoft SQL-Server library for PHPWiki Author: Andrew K. Pearson Date: 01 May 2001 */ /* Database functions: OpenDataBase($dbname) CloseDataBase($dbi) MakeDBHash($pagename, $pagehash) MakePageHash($dbhash) RetrievePage($dbi, $pagename, $pagestore) InsertPage($dbi, $pagename, $pagehash) SaveCopyToArchive($dbi, $pagename, $pagehash) IsWikiPage($dbi, $pagename) IsInArchive($dbi, $pagename) RemovePage($dbi, $pagename) IncreaseHitCount($dbi, $pagename) GetHitCount($dbi, $pagename) MakeSQLSearchClause($search, $column) InitTitleSearch($dbi, $search) TitleSearchNextMatch($dbi, $res) InitFullSearch($dbi, $search) FullSearchNextMatch($dbi, $res) InitMostPopular($dbi, $limit) MostPopularNextMatch($dbi, $res) GetAllWikiPageNames($dbi) GetWikiPageLinks($dbi, $pagename) SetWikiPageLinks($dbi, $pagename, $linklist) */ // open a database and return the handle // ignores MAX_DBM_ATTEMPTS function OpenDataBase($dbname) { global $mssql_server, $mssql_user, $mssql_pwd, $mssql_db; if (!($dbc = mssql_pconnect($mssql_server, $mssql_user, $mssql_pwd))) { $msg = gettext ("Cannot establish connection to database, giving up."); $msg .= "<BR>"; $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 .= "<BR>"; $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) { $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()); } } // 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 .= "<br>\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; $rowexists = 0; if ($res = mssql_query("select count(*) from $dbi[table] where pagename='$pagename'", $dbi['dbc'])) { $rowexists = (mssql_result($res, 0, 0)); } if ($rowexists) $res = mssql_query("update $HitCountStore set hits=hits+1 where pagename='$pagename'", $dbi['dbc']); else $res = mssql_query("insert into $HitCountStore (pagename, hits) values ('$pagename', 1)", $dbi['dbc']); return $res; } function GetHitCount($dbi, $pagename) { global $HitCountStore; $res = mssql_query("select hits from $HitCountStore where pagename='$pagename'", $dbi['dbc']); if (mssql_num_rows($res)) $hits = mssql_result($res, 0, 0); else $hits = "0"; return $hits; } function MakeSQLSearchClause($search, $column) { $search = addslashes(preg_replace("/\s+/", " ", $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; */ ?> |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 21:08:11
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv21829/lib Modified Files: config.php Log Message: Fixes based on SF Patch #471014. Detect when protocol is https rather than http, and adjust SERVER_URL appropriately. Index: config.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** config.php 2001/09/19 19:16:27 1.43 --- config.php 2001/10/29 21:08:09 1.44 *************** *** 145,152 **** if (!defined('SERVER_NAME')) define('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME']); if (!defined('SERVER_PORT')) define('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT']); if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', $HTTP_SERVER_VARS['SCRIPT_NAME']); ! if (!defined('DATA_PATH')) ! define('DATA_PATH', dirname(SCRIPT_NAME)); ! if (!defined('USE_PATH_INFO')) { /* --- 145,160 ---- if (!defined('SERVER_NAME')) define('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME']); if (!defined('SERVER_PORT')) define('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT']); + if (!defined('SERVER_PROTOCOL')) { + if (empty($HTTP_SERVER_VARS['HTTPS']) || $HTTP_SERVER_VARS['HTTPS'] == 'off') + define('SERVER_PROTOCOL', 'http'); + else + define('SERVER_PROTOCOL', 'https'); + } + if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', $HTTP_SERVER_VARS['SCRIPT_NAME']); ! ! if (!defined('DATA_PATH')) define('DATA_PATH', dirname(SCRIPT_NAME)); ! ! if (!defined('USE_PATH_INFO')) { /* *************** *** 218,227 **** } ! if (SERVER_PORT && SERVER_PORT != 80) ! define('SERVER_URL', ! "http://" . SERVER_NAME . ':' . SERVER_PORT); ! else ! define('SERVER_URL', ! "http://" . SERVER_NAME); if (VIRTUAL_PATH != SCRIPT_NAME) --- 226,238 ---- } ! if (SERVER_PORT ! && SERVER_PORT != (SERVER_PROTOCOL == 'https' ? 443 : 80)) { ! define('SERVER_URL', ! SERVER_PROTOCOL . "://" . SERVER_NAME . ':' . SERVER_PORT); ! } ! else { ! define('SERVER_URL', ! SERVER_PROTOCOL . "://" . SERVER_NAME); ! } if (VIRTUAL_PATH != SCRIPT_NAME) |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 20:43:20
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv6817/lib Modified Files: FileFinder.php Log Message: (Slightly modified) SF Patch #473466 by <ax...@co...>. Fixes to work on windows systems where the path separator is ';' rather than ':'. Index: FileFinder.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/FileFinder.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** FileFinder.php 2001/09/20 18:26:14 1.2 --- FileFinder.php 2001/10/29 20:43:18 1.3 *************** *** 101,104 **** --- 101,115 ---- /** + * The system-dependent path-separator character. On UNIX systems, + * this character is ':'; on Win32 systems it is ';'. + * + * @access private + * @return string path_separator. + */ + function _get_path_separator () { + return preg_match('/^Windows/', php_uname()) ? ';' : ':'; + } + + /** * Get the value of PHP's include_path. * *************** *** 110,114 **** if (empty($path)) $path = '.'; ! return explode(':', $path); } --- 121,125 ---- if (empty($path)) $path = '.'; ! return explode($this->_get_path_separator(), $path); } *************** *** 139,143 **** * but we put it here, as it seems to work-around the bug. */ ! ini_set('include_path', implode(':', $path)); } } --- 150,154 ---- * but we put it here, as it seems to work-around the bug. */ ! ini_set('include_path', implode($this->_get_path_separator(), $path)); } } |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 19:34:29
|
Update of /cvsroot/phpwiki/phpwiki/pgsrc In directory usw-pr-cvs1:/tmp/cvs-serv8051/pgsrc Modified Files: TitleSearch Log Message: Explicitly set auto_redirect=0 in TitleSearch form. Index: TitleSearch =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/pgsrc/TitleSearch,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TitleSearch 2001/09/18 19:16:23 1.1 --- TitleSearch 2001/10/29 19:34:27 1.2 *************** *** 12,15 **** ---- Search Again: ! <?plugin-form TitleSearch?> <?plugin-form FullTextSearch?> --- 12,15 ---- ---- Search Again: ! <?plugin-form TitleSearch auto_redirect=0?> <?plugin-form FullTextSearch?> |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 19:31:13
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv7542/lib Removed Files: search.php fullsearch.php Log Message: Title and full-text searches are now handled by plug-ins. --- search.php DELETED --- --- fullsearch.php DELETED --- |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 18:41:14
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv26125/lib Modified Files: stdlib.php Log Message: Fix SF bug #473493: Need to include lib/template.php before calling GeneratePage(). (Patch from Steven Murdoch.) Index: stdlib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** stdlib.php 2001/09/18 19:16:23 1.42 --- stdlib.php 2001/10/29 18:41:11 1.43 *************** *** 498,501 **** --- 498,503 ---- $version, htmlspecialchars($page->getName())); $html .= "\n"; + + include_once('lib/Template.php'); echo GeneratePage('MESSAGE', $html, gettext("Bad Version")); ExitWiki (""); |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 18:24:28
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv22762/lib Modified Files: pageinfo.php Log Message: Fix SF Bug #473499: Diff from page history always diffs HomePage when USE_PATH_INFO is false. (Patch from Steven Murdoch.) Index: pageinfo.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/pageinfo.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** pageinfo.php 2001/09/18 19:16:23 1.11 --- pageinfo.php 2001/10/29 18:24:26 1.12 *************** *** 68,76 **** $table = ("\n" ! . Element('table', join("\n", $rows)) . "\n" ! . Element('input', array('type' => 'hidden', ! 'name' => 'action', ! 'value' => 'diff')) . "\n" ! . Element('input', array('type' => 'submit', 'value' => 'Run Diff')) . "\n"); $formargs['action'] = USE_PATH_INFO ? WikiURL($pagename) : SCRIPT_NAME; --- 68,79 ---- $table = ("\n" ! . Element('table', join("\n", $rows)) . "\n" ! . Element('input', array('type' => 'hidden', ! 'name' => 'action', ! 'value' => 'diff')) . "\n" ! . Element('input', array('type' => 'hidden', ! 'name' => 'pagename', ! 'value' => $pagename)) . "\n" ! . Element('input', array('type' => 'submit', 'value' => 'Run Diff')) . "\n"); $formargs['action'] = USE_PATH_INFO ? WikiURL($pagename) : SCRIPT_NAME; |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 17:58:40
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv14462/lib Modified Files: WikiDB.php Log Message: Fix SF bug #468595: Can not unlock pages. Index: WikiDB.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** WikiDB.php 2001/09/18 19:16:23 1.1 --- WikiDB.php 2001/10/29 17:58:37 1.2 *************** *** 684,696 **** if (!empty($data[$key]) && $data[$key] == $newval) return; // values identical, skip update. - $data[$key] = $newval; } else { if (empty($data[$key])) return; // values identical, skip update. - unset($data[$key]); } ! $cache->update_pagedata($pagename, $data, array($key => $newval)); } --- 684,694 ---- if (!empty($data[$key]) && $data[$key] == $newval) return; // values identical, skip update. } else { if (empty($data[$key])) return; // values identical, skip update. } ! $cache->update_pagedata($pagename, array($key => $newval)); } |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 17:57:26
|
Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend In directory usw-pr-cvs1:/tmp/cvs-serv14137/lib/WikiDB/backend Modified Files: PearDB.php Log Message: Cleanup to get rid of PHP warning. Index: PearDB.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend/PearDB.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** PearDB.php 2001/09/21 14:41:33 1.6 --- PearDB.php 2001/10/29 17:57:24 1.7 *************** *** 372,383 **** $dbh->query("DELETE FROM $link_tbl WHERE linkfrom=$pageid"); ! foreach($links as $link) { ! if (isset($linkseen[$link])) ! continue; ! $linkseen[$link] = true; ! $linkid = $this->_get_pageid($link, true); ! $dbh->query("INSERT INTO $link_tbl (linkfrom, linkto)" ! . " VALUES ($pageid, $linkid)"); ! } $this->unlock(); } --- 372,385 ---- $dbh->query("DELETE FROM $link_tbl WHERE linkfrom=$pageid"); ! if ($links) { ! foreach($links as $link) { ! if (isset($linkseen[$link])) ! continue; ! $linkseen[$link] = true; ! $linkid = $this->_get_pageid($link, true); ! $dbh->query("INSERT INTO $link_tbl (linkfrom, linkto)" ! . " VALUES ($pageid, $linkid)"); ! } ! } $this->unlock(); } |
From: Geoffrey T. D. <da...@us...> - 2001-10-29 17:56:16
|
Update of /cvsroot/phpwiki/phpwiki/admin In directory usw-pr-cvs1:/tmp/cvs-serv13667/admin Modified Files: removepage.php Log Message: Fix SF bug #475757: Can not remove pages. (Patch by Steven Murdoch). Index: removepage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/admin/removepage.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** removepage.php 2001/09/19 03:24:36 1.5 --- removepage.php 2001/10/29 17:56:13 1.6 *************** *** 2,6 **** rcs_id('$Id$'); ! if (empty($verify) || $verify != 'okay') { $html = sprintf(gettext ("You are about to remove '%s' permanently!"), htmlspecialchars($pagename)); --- 2,6 ---- rcs_id('$Id$'); ! if ($request->getArg('verify') != 'okay') { $html = sprintf(gettext ("You are about to remove '%s' permanently!"), htmlspecialchars($pagename)); *************** *** 17,21 **** htmlspecialchars($pagename)); } ! require_once('lib/template.php'); echo GeneratePage('MESSAGE', $html, gettext("Remove page")); --- 17,21 ---- htmlspecialchars($pagename)); } ! require_once('lib/Template.php'); echo GeneratePage('MESSAGE', $html, gettext("Remove page")); |
From: Gerrit R. <ri...@us...> - 2001-10-01 21:58:35
|
Update of /cvsroot/phpwiki/phpwiki/tests In directory usw-pr-cvs1:/tmp/cvs-serv27292 Added Files: unit_test_backend_cvs.php Log Message: unit test for the cvs backend class --- NEW FILE --- <?php /** * Unit tests the 'lib/WikiDB/backend/cvs.php' file and with it * the class WikiDB_backend_cvs * * Author: Gerrit Riessen, ger...@op... */ // need to set this to be something sensible .... ini_set('include_path', '/www/development/phpwiki' ); function rcs_id() { } if ( $USER == "root" ) { // root user can't check in to a CVS repository print( "can not be run as root\n" ); exit(1); } // set to false if something went wrong $REMOVE_DEBUG = true; require_once( 'lib/WikiDB/backend/cvs.php' ); $db_params = array(); /** * These are the parameters required by the backend. */ $db_params[CVS_PAGE_SOURCE] = "/www/development/phpwiki/pgsrc"; $db_params[CVS_CHECK_FOR_REPOSITORY] = true; // the following three are removed if the test succeeds. $db_params[CVS_DOC_DIR] = "/tmp/wiki_docs"; $db_params[CVS_REPOSITORY] = "/tmp/wiki_repository"; $db_params[CVS_DEBUG_FILE] = "/tmp/php_cvs.log"; // // Check the creation of a new CVS repository and the importing of // the default pages. // $cvsdb = new WikiDB_backend_cvs( $db_params ); // check that all files contained in page source where checked in. $allPageNames = array(); $d = opendir( $db_params[CVS_PAGE_SOURCE] ); while ( $entry = readdir( $d ) ) { exec( "grep 'Checking in $entry' " . $db_params[CVS_DEBUG_FILE], $cmdOutput, $cmdRetval ); if ( !is_dir( $db_params[CVS_PAGE_SOURCE] . "/" . $entry )) { $allPageNames[] = $entry; if ( $cmdRetval ) { print "*** Error: [$entry] was not checked in -- view " . $db_params[CVS_DEBUG_FILE] . " for details\n"; $REMOVE_DEBUG = false; } } } closedir( $d ); // // Check that the meta data files were created // function get_pagedata( $item, $key, $cvsdb ) { global $REMOVE_DEBUG; $pageHash = $cvsdb->get_pagedata( $item ); if ( $pageHash[CMD_VERSION] != "2" ) { print "*** Error: [$item] version wrong (". $pageHash[CMD_VERSION] .")\n"; $REMOVE_DEBUG = false; } } array_walk( $allPageNames, 'get_pagedata', $cvsdb ); // // clean up after ourselves // if ( $REMOVE_DEBUG ) { exec( "rm -fr " . $db_params[CVS_DOC_DIR], $cmdout, $retval ); exec( "rm -fr " . $db_params[CVS_REPOSITORY], $cmdout, $retval ); exec( "rm -f " . $db_params[CVS_DEBUG_FILE], $cmdout, $retval ); } else { print "It appears something went wrong, nothing being removed\n"; } ?> |
From: Gerrit R. <ri...@us...> - 2001-10-01 21:56:01
|
Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend In directory usw-pr-cvs1:/tmp/cvs-serv26479 Modified Files: cvs.php Log Message: initial implementation of a cvs backend ... Index: cvs.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend/cvs.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cvs.php 2001/09/28 14:28:22 1.1 --- cvs.php 2001/10/01 21:55:54 1.2 *************** *** 4,82 **** * Backend for handling CVS repository. * ! * This code assumes that cvs and grep are in the path of the program ! * which uses this code. * * Author: Gerrit Riessen, ger...@op... */ require_once('lib/WikiDB/backend.php'); class WikiDB_backend_cvs extends WikiDB_backend { ! function get_pagedata($pagename) { ! } ! function update_pagedata($pagename, $newdata) { } ! function get_latest_version($pagename) { } ! function get_previous_version($pagename, $version) { } ! function get_versiondata($pagename, $version, $want_content = false) { } ! function delete_page($pagename) { } ! function delete_versiondata($pagename, $version) { } ! function set_versiondata($pagename, $version, $data) { } ! function update_versiondata($pagename, $version, $newdata) { } ! function set_links($pagename, $links) { } ! function get_links($pagename, $reversed) { } ! function get_all_revisions($pagename) { } ! function get_all_pages($include_defaulted) { } ! function text_search($search = '', $fullsearch = false) { } ! function most_popular($limit) { } ! function most_recent($params) { } ! function lock($write_lock = true) { } ! function unlock($force = false) { } ! function close () { } ! function sync() { } ! function optimize() { } ! function check() { } ! function rebuild() { } // // The rest are all internal methods, not to be used // directly. // /** ! * Return a list of currently existing Wiki pages. */ ! function _GetAllWikiPageNames($dirName) { ! $namelist = array(); ! $d = opendir( $dirName ); ! $curr = 0; ! while ( $entry = readdir( $d ) ) { ! $namelist[$curr++] = $entry; ! } ! ! // TODO: do we need to do something similar to a closedir ??? ! return $namelist; } --- 4,486 ---- * Backend for handling CVS repository. * ! * ASSUMES: that the shell commands 'cvs', 'grep', 'rm', are all located ! * ASSUMES: in the path of the server calling this script. * * Author: Gerrit Riessen, ger...@op... */ + require_once('lib/WikiDB/backend.php'); + require_once('lib/ErrorManager.php'); + + /** + * Constants used by the CVS backend + **/ + // these are the parameters defined in db_params + define( 'CVS_DOC_DIR', 'doc_dir' ); + define( 'CVS_REPOSITORY', 'repository' ); + define( 'CVS_CHECK_FOR_REPOSITORY', 'check_for_repository' ); + define( 'CVS_DEBUG_FILE', 'debug_file' ); + define( 'CVS_PAGE_SOURCE', 'pgsrc' ); + define( 'CVS_MODULE_NAME', 'module_name' ); + + // these are the things that are defined in the page hash + // CMD == Cvs Meta Data + define( 'CMD_LAST_MODIFIED', 'lastmodified' ); + define( 'CMD_CONTENT', '%content'); + define( 'CMD_CREATED', 'created'); + define( 'CMD_VERSION', 'version'); + define( 'CMD_AUTHOR', 'author'); + class WikiDB_backend_cvs extends WikiDB_backend { ! var $_docDir; ! var $_repository; ! var $_module_name; ! var $_debug_file; ! ! /** ! * In the following parameters should be defined in dbparam: ! * . wiki ==> directory where the pages should be stored ! * this is not the CVS repository location ! * . repository ==> local directory where the repository should be ! * created. This can also be a :pserver: but then ! * set check_for_repository to false and checkout ! * the documents beforehand. (This is basically CVSROOT) ! * . check_for_repository ==> boolean flag to indicate whether the ! * repository should be created, this only ! * applies to local directories, for pserver ! * set this to false and check out the ! * document base beforehand ! * . debug_file ==> file name where debug information should be set. ! * If file doesn't exist then it's created, if this ! * is empty, then no debugging is done. ! * . pgsrc ==> directory name where the default wiki pages are stored. ! * This is only required if the backend is to create a ! * new CVS repository. ! * ! * The class also adds a parameter 'module_name' to indicate the name ! * of the cvs module that is being used to version the documents. The ! * module_name is assumed to be the base name of directory given in ! * wiki, e.g. if wiki == '/some/path/to/documents' then module_name ! * becomes 'documents' and this module will be created in the CVS ! * repository or assumed to exist. If on the other hand the parameter ! * already exists, then it is not overwritten. ! */ ! function WikiDB_backend_cvs( $dbparam ) ! { ! // setup all the instance values. ! $this->_docDir = $dbparam{CVS_DOC_DIR}; ! $this->_repository = $dbparam{CVS_REPOSITORY}; ! if ( ! $dbparam{CVS_MODULE_NAME} ) { ! $this->_module_name = basename( $this->_docDir ); ! $dbparam{CVS_MODULE_NAME} = $this->_module_name; ! } else { ! $this->_module_name = $dbparam{CVS_MODULE_NAME}; ! } ! $this->_debug_file = $dbparam{CVS_DEBUG_FILE}; ! ! if ( !($dbparam{CVS_CHECK_FOR_REPOSITORY} ! && is_dir( $this->_repository ) ! && is_dir( $this->_repository . "/CVSROOT" ) ! && is_dir( $this->_repository . "/" . $this->_module_name ))) { ! ! $this->_cvsDebug( "Creating new repository [$this->_repository]" ); ! ! // doesn't exist, need to create it and the replace the wiki ! // document directory. ! $this->_mkdir( $this->_repository, 0775 ); ! ! // assume that the repository is a local directory, prefix :local: ! if ( !ereg( "^:local:", $this->_repository ) ) { ! $this->_repository = ":local:" . $this->_repository; ! } ! ! $cmdLine = sprintf( "cvs -d \"%s\" init", $this->_repository); ! $this->_execCommand( $cmdLine, $cmdOutput, true ); ! ! $this->_mkdir( $this->_docDir, 0775 ); ! $cmdLine = sprintf("cd %s; cvs -d \"%s\" import -m no_message " ! ."%s V R", $this->_docDir, $this->_repository, ! $this->_module_name ); ! $this->_execCommand( $cmdLine, $cmdOutput, true ); ! ! // remove the wiki directory and check it out from the ! // CVS repository ! $cmdLine = sprintf( "rm -fr %s; cd %s; cvs -d \"%s\" co %s", ! $this->_docDir, dirname($this->_docDir), ! $this->_repository, $this->_module_name); ! $this->_execCommand( $cmdLine, $cmdOutput, true ); ! ! // add the default pages using the update_pagedata ! $metaData = array(); ! $metaData[$AUTHOR] = "PhpWiki -- CVS Backend"; ! ! if ( is_dir( $dbparam[CVS_PAGE_SOURCE] ) ) { ! $d = opendir( $dbparam[CVS_PAGE_SOURCE] ); ! while ( $entry = readdir( $d ) ) { ! $filename = $dbparam[CVS_PAGE_SOURCE] . "/" . $entry; ! $this->_cvsDebug("Found [$entry] in [" ! . $dbparam[CVS_PAGE_SOURCE]."]"); ! ! if ( is_file( $filename ) ) { ! $metaData[CMD_CONTENT] = join('',file($filename)); ! $this->update_pagedata( $entry, $metaData ); ! } ! } ! closedir( $d ); ! } ! ! // ensure that the results of the is_dir are cleared ! clearstatcache(); ! } } ! ! /** ! * Return: metadata about page ! */ ! function get_pagedata($pagename) ! { ! // the metadata information about a page is stored in the ! // CVS directory of the document root in serialized form. The ! // file always has the name _$pagename. ! $metaFile = $this->_docDir . "/CVS/_" . $pagename; ! ! if ( $fd = @fopen( $metaFile, "r" ) ) { ! ! $locked = flock( $fd, 1 ); // read lock ! if ( !$locked ) { ! fclose( $fd ); ! $this->_cvsError( "Unable to obtain read lock.",__LINE__); ! } ! ! $pagehash = unserialize( join( '', file($metaFile) )); ! // need to strip off the new lines at the end of each line ! // hmmmm, content expects an array of lines where each line ! // has it's newline stripped off. Unfortunately because i don't ! // want to store the files in serialize or wiki specific format, ! // i need to add newlines when storing but need to strip them ! // off again when i retrieve the file because file() doesn't remove ! // newlines! ! // $pagehash['content'] = file($filename); ! // array_walk( $pagehash['content'], '_strip_newlines' ); ! // reset( $pagehash['content'] ); ! ! fclose( $fd ); ! return $pagehash; ! } ! ! return false; } ! ! /** ! * This will create a new page if page being requested does not ! * exist. ! */ ! function update_pagedata($pagename, $newdata) ! { ! // retrieve the meta data ! $metaData = $this->get_pagedata( $pagename ); ! ! if ( ! $metaData ) { ! $this->_cvsDebug( "update_pagedata: no meta data found" ); ! // this means that the page does not exist, we need to create ! // it. ! $metaData = array(); ! ! $metaData[CMD_CREATED] = time(); ! $metaData[CMD_VERSION] = "1"; ! ! if ( ! isset($newdata[$CONTENT])) { ! $metaData[CMD_CONTENT] = ""; ! } else { ! $metaData[CMD_CONTENT] = $newdata[CMD_CONTENT]; ! } ! ! // create an empty page ... ! $this->_writePage( $pagename, $metaData[CMD_CONTENT] ); ! $this->_addPage( $pagename ); ! ! // make sure that the page is written and committed a second time ! unset( $newdata[CMD_CONTENT] ); ! unset( $metaData[CMD_CONTENT] ); ! } ! ! // change any meta data information ! foreach ( $newdata as $key => $value ) { ! if ( $value == false || empty( $value ) ) { ! unset( $metaData[$key] ); ! } else { ! $metaData[$key] = $value; ! } ! } ! ! // update the page data, if required ! if ( isset( $metaData[CMD_CONTENT] ) ) { ! $this->_writePage( $pagename, $newdata[CMD_CONTENT] ); ! } ! ! // remove any content from the meta data before storing it ! unset( $metaData[CMD_CONTENT] ); ! $metaData[CMD_LAST_MODIFIED] = time(); ! $this->_writeMetaInfo( $pagename, $metaData ); ! ! $this->_commitPage( $pagename, serialize( $metaData ) ); ! } ! ! function get_latest_version($pagename) ! { ! $metaData = $this->get_pagedata( $pagename ); ! if ( $metaData ) { ! // the version number is everything about the '1.' ! return $metaData[CMD_VERSION]; ! } else { ! $this->_cvsDebug( "get_latest_versioned FAILED for [$pagename]" ); ! return 0; ! } } ! ! function get_previous_version($pagename, $version) ! { ! // cvs increments the version numbers, so this is real easy ;-) ! return ($version > 0 ? $version - 1 : 0); } ! ! /** ! * the version parameter is assumed to be everything about the '1.' ! * in the CVS versioning system. ! */ ! function get_versiondata($pagename, $version, $want_content = false) ! { ! $this->_cvsDebug( "get_versiondata: [$pagename] [$version] [$want_content]" ); ! ! $filedata = ""; ! if ( $want_content ) { ! // retrieve the version from the repository ! $cmdLine = sprintf("cvs -d \"%s\" co -p -r 1.%d %s/%s 2>&1", ! $this->_repository, $version, ! $this->_module_name, $pagename ); ! $this->_execCommand( $cmdLine, $filedata, true ); ! ! // TODO: DEBUG: 5 is a magic number here, depending on the ! // TODO: DEBUG: version of cvs used here, 5 might have to ! // TODO: DEBUG: change. Basically find a more reliable way of ! // TODO: DEBUG: doing this. ! // the first 5 lines contain various bits of ! // administrative information that can be ignored. ! for ( $i = 0; $i < 5; $i++ ) { ! array_shift( $filedata ); ! } ! } ! ! /** ! * Now obtain the rest of the pagehash information, this is contained ! * in the log message for the revision in serialized form. ! */ ! $cmdLine = sprintf("cd %s; cvs log -r1.%d %s", $this->_docDir, ! $version, $pagename ); ! $this->_execCommand( $cmdLine, $logdata, true ); ! ! // shift log data until we get to the 'revision X.X' line ! // FIXME: ensure that we don't enter an endless loop here ! while ( !ereg( "^revision ([^ ]+)$", $logdata[0], $revInfo ) ) { ! array_shift( $logdata ); ! } ! ! // serialized hash information now stored in position 2 ! $rVal = unserialize( _unescape( $logdata[2] ) ); ! ! // version information is incorrect ! $rVal[CMD_VERSION] = ereg_replace( "^1[.]", "", $revInfo[1] ); ! $rVal[CMD_CONTENT] = $filedata; ! ! foreach ( $rVal as $key => $value ) { ! $this->_cvsDebug( "$key == [$value]" ); ! } ! ! return $rVal; } ! ! /** ! * This returns false if page was not deleted or could not be deleted ! * else true is returned. ! */ ! function delete_page($pagename) ! { ! $this->_cvsDebug( "delete_page [$pagename]" ); ! $filename = $this->_docDir . "/" . $pagename; ! $metaFile = $this->_docDir . "/CVS/_" . $pagename; ! ! // obtain a write block before deleting the file ! if ( $this->_deleteFile( $filename ) == false ) { ! return false; ! } ! ! $this->_deleteFile( $metaFile ); ! ! $this->_removePage( $pagename ); ! ! $this->_cvsDebug( "CvsRemoveOutput [$cmdRemoveOutput]" ); ! ! return true; } ! ! function delete_versiondata($pagename, $version) ! { ! // TODO: Not Implemented. ! // TODO: This is, for CVS, difficult because it implies removing a ! // TODO: revision somewhere in the middle of a revision tree, and ! // TODO: this is basically not possible! ! trigger_error("delete_versiondata: Not Implemented", E_USER_WARNING); } ! ! function set_versiondata($pagename, $version, $data) ! { ! // TODO: Not Implemented. ! // TODO: requires changing the log(commit) message for a particular ! // TODO: version and this can't be done??? (You can edit the repository ! // TODO: file directly but i don't know of a way of doing it via ! // TODO: the cvs tools). ! trigger_error("set_versiondata: Not Implemented", E_USER_WARNING); } ! ! function update_versiondata($pagename, $version, $newdata) ! { ! // TODO: same problem as set_versiondata ! trigger_error("set_versiondata: Not Implemented", E_USER_WARNING); } ! ! function set_links($pagename, $links) ! { ! // TODO: to be implemented ! trigger_error("set_links: Not Implemented", E_USER_WARNING); } ! ! function get_links($pagename, $reversed) ! { ! // TODO: to be implemented ! trigger_error("get_links: Not Implemented", E_USER_WARNING); } ! ! function get_all_revisions($pagename) ! { ! // TODO: should replace this with something more efficient ! include_once('lib/WikiDB/backend/dumb/AllRevisionsIter.php'); ! return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); } ! ! function get_all_pages($include_defaulted) ! { ! // FIXME: this ignores the include_defaulted parameter. ! return new Cvs_Backend_Array_Iterator( ! $this->_getAllFileNamesInDir( $this->_docDir )); } ! ! function text_search($search = '', $fullsearch = false) ! { ! if ( $fullsearch ) { ! return new Cvs_Backend_Full_Search_Iterator( ! $this->_getAllFileNamesInDir( $this->_docDir ), ! $search, ! $this->_docDir ); ! } else { ! return new Cvs_Backend_Title_Search_Iterator( ! $this->_getAllFileNamesInDir( $this->_docDir ), ! $search); ! } } ! ! function most_popular($limit) ! { } ! ! function most_recent($params) ! { } ! ! function lock($write_lock = true) ! { } ! ! function unlock($force = false) ! { } ! ! function close () ! { } ! ! function sync() ! { } ! ! function optimize() ! { } ! ! function check() ! { } ! ! function rebuild() ! { } // + // ..-.-..-.-..-.-.. .--..-......-.--. --.-....----..... // The rest are all internal methods, not to be used // directly. + // ..-.-..-.-..-.-.. .--..-......-.--. --.-....----..... // + + function _writeMetaInfo( $pagename, $hashInfo ) + { + $this->_writeFileWithPath( $this->_docDir . "/CVS/_" . $pagename, + serialize( $hashInfo ) ); + } + function _writePage( $pagename, $content ) + { + $this->_writeFileWithPath( $this->_docDir . "/". $pagename, $content ); + } + function _removePage( $pagename ) + { + $cmdLine = sprintf("cd %s; cvs remove %s 2>&1; cvs commit -m '%s' " + ."%s 2>&1", $this->_docDir, $pagename, + "remove page", $pagename ); + + $this->_execCommand( $cmdLine, $cmdRemoveOutput, true ); + } + function _commitPage( $pagename, $commitMsg = "no_message" ) + { + $cmdLine = sprintf( "cd %s; cvs commit -m \"%s\" %s 2>&1", + $this->_docDir, escapeshellcmd( $commitMsg ), + $pagename ); + $this->_execCommand( $cmdLine, $cmdOutput, true ); + } + function _addPage( $pagename ) + { + // TODO: need to add a check for the mimetype so that binary + // TODO: files are added as binary files + $cmdLine = sprintf("cd %s; cvs add %s 2>&1", $this->_docDir, + $pagename ); + $this->_execCommand( $cmdLine, $cmdAddOutput, true ); + } + /** ! * Returns an array containing all the names of files contained ! * in a particular directory. The list is sorted according the ! * string representation of the filenames. */ ! function _getAllFileNamesInDir( $dirName ) ! { ! $namelist = array(); ! $d = opendir( $dirName ); ! while ( $entry = readdir( $d ) ) { ! $namelist[] = $entry; ! } ! closedir( $d ); ! sort( $namelist, SORT_STRING ); ! return $namelist; } *************** *** 84,98 **** * Recursively create all directories. */ ! function _mkdir( $path, $mode ) { ! $directoryName = dirname( $path ); ! if ( $directoryName != "." && $directoryName != "/" ! && $directoryName != "\\" && !is_dir( $direcoryName ) ) { ! $rVal = _mkdir( $directoryName, $mode ); ! } ! else { ! return true; ! } ! return ($rVal && mkdir( $path, $mode ) ); } --- 488,503 ---- * Recursively create all directories. */ ! function _mkdir( $path, $mode ) ! { ! $directoryName = dirname( $path ); ! if ( $directoryName != "/" && $directoryName != "\\" ! && !is_dir( $directoryName ) && $directoryName != "" ) { ! $rVal = $this->_mkdir( $directoryName, $mode ); ! } ! else { ! $rVal = true; ! } ! return ($rVal && @mkdir( $path, $mode ) ); } *************** *** 100,140 **** * Recursively create all directories and then the file. */ ! function _createFile( $path, $mode ) { ! _mkdir( dirname( $path ), $mode ); ! touch( $path ); ! chmod( $path, $mode ); } ! /** * Debug function specifically for the CVS database functions. * Can be deactived by setting the WikiDB['debug_file'] to "" */ ! function _cvsDebug( $msg ) { ! global $WikiDB; ! $filename = $WikiDB['debug_file']; ! if ( $filename == "" ) { ! return; ! } ! ! if ( !file_exists( $filename ) ) { ! _createFile( $filename, 0755 ); ! } ! ! if ( $fdlock = @fopen( $filename, 'a' ) ) { ! $locked = flock( $fdlock, 2 ); ! if ( !$locked ) { ! fclose( $fdlock ); ! return; ! } ! ! $fdappend = @fopen( $filename, 'a' ); ! fwrite( $fdappend, ($msg . "\n") ); ! fclose( $fdappend ); ! fclose( $fdlock ); ! } ! else { ! print( "unable to locate/open [$filename]\n" ); ! } } } ?> --- 505,794 ---- * Recursively create all directories and then the file. */ ! function _createFile( $path, $mode ) ! { ! $this->_mkdir( dirname( $path ), $mode ); ! touch( $path ); ! chmod( $path, $mode ); } ! /** ! * The lord giveth, and the lord taketh. ! */ ! function _deleteFile( $filename ) ! { ! if( $fd = fopen($filename, 'a') ) { ! ! $locked = flock($fd,2); // Exclusive blocking lock ! ! if (!$locked) { ! $this->_cvsError("Unable to delete file, lock was not obtained.", ! __LINE__, $filename, EM_NOTICE_ERRORS ); ! } ! ! if ( ($rVal = unlink( $filename )) == 0 ) { ! /* if successful, then do nothing */ ! } else { ! $this->_cvsDebug( "[$filename] --> Unlink returned [$rVal]" ); ! } ! ! return $rVal; ! } else { ! $this->_cvsError("deleteFile: Unable to open file", ! __LINE__, $filename, EM_NOTICE_ERRORS ); ! return false; ! } ! } ! ! /** ! * Called when something happened that causes the CVS backend to ! * fail. ! */ ! function _cvsError( $msg = "no message", ! $errline = 0, ! $errfile = "lib/WikiDB/backend/cvs.php", ! $errno = EM_FATAL_ERRORS) ! { ! $err = new PhpError( $errno, "[CVS(be)]: " . $msg, $errfile, $errline); ! // send error to the debug routine ! $this->_cvsDebug( $err->getDetail() ); ! // send the error to the error manager ! $GLOBALS['ErrorManager']->handleError( $err ); ! } ! /** * Debug function specifically for the CVS database functions. * Can be deactived by setting the WikiDB['debug_file'] to "" + */ + function _cvsDebug( $msg ) + { + if ( $this->_debug_file == "" ) { + return; + } + + if ( !file_exists( $this->_debug_file ) ) { + $this->_createFile( $this->_debug_file, 0755 ); + } + + if ( $fdlock = @fopen( $this->_debug_file, 'a' ) ) { + $locked = flock( $fdlock, 2 ); + if ( !$locked ) { + fclose( $fdlock ); + return; + } + + $fdappend = @fopen( $this->_debug_file, 'a' ); + fwrite( $fdappend, ($msg . "\n") ); + fclose( $fdappend ); + fclose( $fdlock ); + } + else { + // TODO: this should be replaced ... + print( "unable to locate/open [$filename], turning debug off\n" ); + $this->_debug_file = ""; + } + } + + /** + * Execute a command and potentially exit if the flag exitOnNonZero is + * set to true and the return value was nonZero + */ + function _execCommand( $cmdLine, &$cmdOutput, $exitOnNonZero ) + { + $this->_cvsDebug( "Preparing to execute [$cmdLine]" ); + exec( $cmdLine, $cmdOutput, $cmdReturnVal ); + if ( $exitOnNonZero && ($cmdReturnVal != 0) ) { + $this->_cvsError("Command failed [$cmdLine], Return value: $cmdReturnVal", + __LINE__ ); + $this->_cvsDebug( "Command failed [$cmdLine], Output: [" . + join("\n",$cmdOutput) . "]" ); + } + $this->_cvsDebug( "Done execution [" . join("\n", $cmdOutput ) . "]" ); + + return $cmdReturnVal; + } + + /** + * Either replace the contents of an existing file or create a + * new file in the particular store using the page name as the + * file name. + * + * Returns true if all went well, else false. + */ + // function _WriteFile( $pagename, $storename, $contents ) + // { + // global $WikiDB; + // $filename = $WikiDB[$storename] . "/" . $pagename; + // _WriteFileWithPath( $filename, $contents ); + // } + + function _writeFileWithPath( $filename, $contents ) + { + if( $fd = fopen($filename, 'a') ) { + $locked = flock($fd,2); // Exclusive blocking lock + if (!$locked) { + $this->_cvsError("Timeout while obtaining lock.",__LINE__); + } + + //Second (actually used) filehandle + $fdsafe = fopen($filename, 'w'); + fwrite($fdsafe, $contents); + fclose($fdsafe); + fclose($fd); + } else { + $this->_cvsError( "Could not open file [$filename]", __LINE__ ); + } + } + + /** + * Copy the contents of the source directory to the destination directory. + */ + function _copyFilesFromDirectory( $src, $dest ) + { + $this->_cvsDebug( "Copying from [$src] to [$dest]" ); + + if ( is_dir( $src ) && is_dir( $dest ) ) { + $this->_cvsDebug( "Copying " ); + $d = opendir( $src ); + while ( $entry = readdir( $d ) ) { + if ( is_file( $src . "/" . $entry ) + && copy( $src . "/" . $entry, $dest . "/" . $entry ) ) { + $this->_cvsDebug( "Copied to [$dest/$entry]" ); + } else { + $this->_cvsDebug( "Failed to copy [$src/$entry]" ); + } + } + closedir( $d ); + return true; + } else { + $this->_cvsDebug( "Not copying" ); + return false; + } + } + + /** + * Unescape a string value. Normally this comes from doing an + * escapeshellcmd. This converts the following: + * \{ --> { + * \} --> } + * \; --> ; + * \" --> " + */ + function _unescape( $val ) + { + $val = str_replace( "\\{", "{", $val ); + $val = str_replace( "\\}", "}", $val ); + $val = str_replace( "\\;", ";", $val ); + $val = str_replace( "\\\"", "\"", $val ); + + return $val; + } + + /** + * Function for removing the newlines from the ends of the + * file data returned from file(..). This is used in retrievePage */ ! function _strip_newlines( &$item, $key ) ! { ! $item = ereg_replace( "\n$", "", $item ); } + + } /* End of WikiDB_backend_cvs class */ + + /** + * Generic iterator for stepping through an array of values. + */ + class Cvs_Backend_Array_Iterator + extends WikiDB_backend_iterator + { + var $_array; + + function Cvs_Backend_Iterator( $arrayValue = Array() ) + { + $this->_array = $arrayValue; + } + + function next() + { + while ( ($rVal = array_pop( $this->_array )) != NULL ) { + return $rVal; + } + return false; + } + + function free() + { + unset( $this->_array ); + } + } + + class Cvs_Backend_Full_Search_Iterator + extends Cvs_Backend_Array_Iterator + { + var $_searchString = ''; + var $_docDir = ""; + + function Cvs_Backend_Title_Search_Iterator( $arrayValue = Array(), + $searchString = "", + $documentDir = ".") + { + $this->Cvs_Backend_Array_Iterator( $arrayValue ); + $_searchString = $searchString; + $_docDir = $documentDir; + } + + function next() + { + do { + $pageName = Cvs_Backend_Array_Iterator::next(); + } while ( !$this->_searchFile( $_searchString, + $_docDir . "/" . $pageName )); + + return $pageName; + } + + /** + * Does nothing more than a grep and search the entire contents + * of the given file. Returns TRUE of the searchstring was found, + * false if the search string wasn't find or the file was a directory + * or could not be read. + */ + function _searchFile( $searchString, $fileName ) + { + // TODO: using grep here, it might make more sense to use + // TODO: some sort of inbuilt/language specific method for + // TODO: searching files. + $cmdLine = sprintf( "grep -E -i '%s' %s > /dev/null 2>&1", + $searchString, $fileName ); + + return ( WikiDB_backend_cvs::_execCommand( $cmdLine, $cmdOutput, + false ) == 0 ); + } } + + /** + * Iterator used for doing a title search. + */ + class Cvs_Backend_Title_Search_Iterator + extends Cvs_Backend_Array_Iterator + { + var $_searchString = ''; + + function Cvs_Backend_Title_Search_Iterator( $arrayValue = Array(), + $searchString = "") + { + $this->Cvs_Backend_Array_Iterator( $arrayValue ); + $_searchString = $searchString; + } + + function next() + { + do { + $pageName = Cvs_Backend_Array_Iterator::next(); + } while ( !eregi( $this->_searchString, $pageName ) ); + + return $pageName; + } + } + + + ?> |
From: Gerrit R. <ri...@us...> - 2001-09-28 14:28:24
|
Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend In directory usw-pr-cvs1:/tmp/cvs-serv1331/backend Added Files: cvs.php Log Message: first skeleton version of the cvs ***** Error reading new file: [Errno 2] No such file or directory: 'cvs.php' |
From: Gerrit R. <ri...@us...> - 2001-09-28 14:28:24
|
Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB In directory usw-pr-cvs1:/tmp/cvs-serv1331 Added Files: cvs.php Log Message: first skeleton version of the cvs ***** Error reading new file: [Errno 2] No such file or directory: 'cvs.php' |
From: Steve W. <wai...@us...> - 2001-09-21 21:57:10
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv29174 Modified Files: Tag: release-1_2-branch pgsql.php Log Message: Fixed bug: BackLinkSearchNextMatch needed the address of $res. It was not incrementing $res[row] so it formed an infinite loop and phpwiki would just time out. Index: pgsql.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/pgsql.php,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -r1.4.2.1 -r1.4.2.2 *** pgsql.php 2001/08/18 00:35:10 1.4.2.1 --- pgsql.php 2001/09/21 21:57:07 1.4.2.2 *************** *** 297,303 **** $topage = addslashes($pagename); ! $res['res'] = pg_exec( $dbi["dbc"], ( "SELECT DISTINCT frompage FROM $WikiLinksPageStore" ! . " WHERE topage='$topage'" ! . " ORDER BY frompage" )); $res['row'] = 0; return $res; --- 297,304 ---- $topage = addslashes($pagename); ! $query = "SELECT DISTINCT frompage FROM $WikiLinksPageStore" ! . " WHERE topage='$topage'" ! . " ORDER BY frompage"; ! $res['res'] = pg_exec( $dbi["dbc"], $query); $res['row'] = 0; return $res; *************** *** 305,317 **** ! // iterating through database ! function BackLinkSearchNextMatch($dbi, $res) { ! if($a = @pg_fetch_row($res['res'], $res['row']++)) { ! return $a[0]; ! } ! else { ! return 0; ! } ! } --- 306,319 ---- ! // iterating through database ! function BackLinkSearchNextMatch($dbi, &$res) { ! if($a = @pg_fetch_row($res['res'], $res['row'])) { ! $res['row']++; ! return $a[0]; ! } ! else { ! return 0; ! } ! } |
From: Geoffrey T. D. <da...@us...> - 2001-09-21 19:59:20
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv31426/lib Modified Files: Tag: release-1_2-branch savepage.php Log Message: Patch by Gary Benson <ga...@in...>: Remove empty date headers when updating RecentChanges. Index: savepage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/savepage.php,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -C2 -r1.7.2.1 -r1.7.2.2 *** savepage.php 2001/02/08 18:28:31 1.7.2.1 --- savepage.php 2001/09/21 19:59:13 1.7.2.2 *************** *** 70,74 **** } ! $recentchanges['content'] = $newpage; InsertPage($dbi, gettext ("RecentChanges"), $recentchanges); --- 70,86 ---- } ! // copy the new page back into recentchanges, skipping empty days ! $numlines = sizeof($newpage); ! $recentchanges['content'] = array(); ! $k = 0; ! for ($i = 0; $i < $numlines; $i++) { ! if ($i != $numlines-1 && ! preg_match("/^____/", $newpage[$i]) && ! preg_match("/^[\r\n]*$/", $newpage[$i+1])) { ! $i++; ! } else { ! $recentchanges['content'][$k++] = $newpage[$i]; ! } ! } InsertPage($dbi, gettext ("RecentChanges"), $recentchanges); |
From: Geoffrey T. D. <da...@us...> - 2001-09-21 19:15:15
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv18637/lib Modified Files: Tag: release-1_2-branch transform.php Log Message: Efficiency patch from Gary Benson <ga...@in...>: don't compute MostPopular list unless it's needed. Index: transform.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/transform.php,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -C2 -r1.8.2.1 -r1.8.2.2 *** transform.php 2001/03/02 03:48:47 1.8.2.1 --- transform.php 2001/09/21 19:15:12 1.8.2.2 *************** *** 33,42 **** - // only call these once, for efficiency - $quick_search_box = RenderQuickSearch(); - $full_search_box = RenderFullSearch(); - $most_popular_list = RenderMostPopular(); - - // Loop over all lines of the page and apply transformation rules $numlines = count($pagehash["content"]); --- 33,36 ---- *************** *** 246,252 **** // concerned. Paragraph (<p>) elements are not allowed to contain // other block-level elements (like <form>s). ! $tmpline = str_replace('%%Search%%', $quick_search_box, $tmpline); ! $tmpline = str_replace('%%Fullsearch%%', $full_search_box, $tmpline); ! $tmpline = str_replace('%%Mostpopular%%', $most_popular_list, $tmpline); if(defined('WIKI_ADMIN') && strstr($tmpline, '%%ADMIN-')) $tmpline = ParseAdminTokens($tmpline); --- 240,249 ---- // concerned. Paragraph (<p>) elements are not allowed to contain // other block-level elements (like <form>s). ! if (strstr($tmpline, '%%Search%%')) ! $tmpline = str_replace('%%Search%%', RenderQuickSearch(), $tmpline); ! if (strstr($tmpline, '%%Fullsearch%%')) ! $tmpline = str_replace('%%Fullsearch%%', RenderFullSearch(), $tmpline); ! if (strstr($tmpline, '%%Mostpopular%%')) ! $tmpline = str_replace('%%Mostpopular%%', RenderMostPopular(), $tmpline); if(defined('WIKI_ADMIN') && strstr($tmpline, '%%ADMIN-')) $tmpline = ParseAdminTokens($tmpline); |
From: Geoffrey T. D. <da...@us...> - 2001-09-21 14:41:35
|
Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend In directory usw-pr-cvs1:/tmp/cvs-serv29527/lib/WikiDB/backend Modified Files: PearDB.php Log Message: Fix the fix: fun with regexps. (minor). Index: PearDB.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend/PearDB.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** PearDB.php 2001/09/20 19:09:26 1.5 --- PearDB.php 2001/09/21 14:41:33 1.6 *************** *** 691,695 **** function _pear_notice_filter($err) { return ( $err->isNotice() ! && preg_match('|DB[/\\]common.php$|', $err->errfile) && $err->errline == 126 && preg_match('/Undefined offset: +0\b/', $err->errstr) ); --- 691,695 ---- function _pear_notice_filter($err) { return ( $err->isNotice() ! && preg_match('|DB[/\\\\]common.php$|', $err->errfile) && $err->errline == 126 && preg_match('/Undefined offset: +0\b/', $err->errstr) ); |
From: Steve W. <wai...@us...> - 2001-09-21 01:04:57
|
Update of /cvsroot/phpwiki/phpwiki/tests In directory usw-pr-cvs1:/tmp/cvs-serv11244 Modified Files: maketest.pl Log Message: Updated assert_text. I think the version of httpunit I developed against was different in its output. Index: maketest.pl =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/tests/maketest.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** maketest.pl 2001/09/20 20:53:19 1.1 --- maketest.pl 2001/09/21 01:04:54 1.2 *************** *** 431,435 **** // find the text string '$search_string' in the page source ! if ( response.toString().indexOf( "$search_string" ) != -1) System.out.println( "I found the text '$search_string' in the page OK" ); else --- 431,435 ---- // find the text string '$search_string' in the page source ! if ( response.getText().indexOf( "$search_string" ) != -1) System.out.println( "I found the text '$search_string' in the page OK" ); else |
From: Steve W. <wai...@us...> - 2001-09-20 21:33:12
|
Update of /cvsroot/phpwiki/phpwiki/tests In directory usw-pr-cvs1:/tmp/cvs-serv3039 Added Files: AAD_FindText.inputs Log Message: Simple test to verify text appears in the source of a page. ***** Error reading new file: [Errno 2] No such file or directory: 'AAD_FindText.inputs' |