SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv8120/lib
Modified Files:
 Tag: release-1_2-branch
	db_filesystem.php dbalib.php dbmlib.php mysql.php pgsql.php 
Added Files:
 Tag: release-1_2-branch
	backlinks.php 
Log Message:
Added real back-link searches.
The pgsql and msql backends are completely untested at this point,
but they "should work". (I.e.: they're probably broken now.)
***** Error reading new file: [Errno 2] No such file or directory: 'backlinks.php'
Index: db_filesystem.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/db_filesystem.php,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -r1.4 -r1.4.2.1
*** db_filesystem.php	2001年01月01日 23:18:46	1.4
--- db_filesystem.php	2001年08月18日 00:35:10	1.4.2.1
***************
*** 13,16 ****
--- 13,19 ----
 InitFullSearch($dbi, $search)
 FullSearchNextMatch($dbi, $res)
+ MakeBackLinkSearchRegexp($pagename)
+ InitBackLinkSearch($dbi, $pagename) 
+ BackLinkSearchNextMatch($dbi, &$pos) 
 IncreaseHitCount($dbi, $pagename)
 GetHitCount($dbi, $pagename)
***************
*** 152,155 ****
--- 155,207 ----
 // new database features
 
+ // Compute PCRE suitable for searching for links to the given page.
+ function MakeBackLinkSearchRegexp($pagename) {
+ global $WikiNameRegexp;
+ 
+ // Note that in (at least some) PHP 3.x's, preg_quote only takes
+ // (at most) one argument. Also it doesn't quote '/'s.
+ // It does quote '='s, so we'll use that for the delimeter.
+ $quoted_pagename = preg_quote($pagename);
+ if (preg_match("/^$WikiNameRegexp\$/", $pagename)) {
+ 	 # FIXME: This may need modification for non-standard (non-english) $WikiNameRegexp.
+ 	 return "=(?<![A-Za-z0-9!])$quoted_pagename(?![A-Za-z0-9])=";
+ }
+ else {
+ 	 // Note from author: Sorry. :-/
+ 	 return ( '='
+ 		 . '(?<!\[)\[(?!\[)' // Single, isolated '['
+ 		 . '([^]|]*\|)?' // Optional stuff followed by '|'
+ 	 . '\s*' // Optional space
+ 		 . $quoted_pagename // Pagename
+ 		 . '\s*\]=' );	 // Optional space, followed by ']'
+ 	 // FIXME: the above regexp is still not quite right.
+ 	 // Consider the text: " [ [ test page ]". This is a link to a page
+ 	 // named '[ test page'. The above regexp will recognize this
+ 	 // as a link either to '[ test page' (good) or to 'test page' (wrong).
+ } 
+ }
+ 
+ // setup for back-link search
+ function InitBackLinkSearch($dbi, $pagename) {
+ return InitTitleSearch($dbi, MakeBackLinkSearchRegexp($pagename));
+ }
+ 
+ // iterating through back-links
+ function BackLinkSearchNextMatch($dbi, &$pos) {
+ global $WikiPageStore;
+ while (list($key, $page) = each($pos['data'])) {
+ $pagedata = RetrievePage($dbi, $page, $WikiPageStore);
+ 	 printf("Page: '%s' => '%s'<br>\n",
+ 		htmlspecialchars($page),
+ 		htmlspecialchars($pagedata));
+ 	 
+ 	 while (list($i, $line) = each($pagedata['content'])) {
+ 	 if (preg_match($pos['search'], $line))
+ 	 return $page;
+ 	 }
+ }
+ return 0;
+ }
+ 
 function IncreaseHitCount($dbi, $pagename) {
 return;
***************
*** 226,234 ****
 function GetAllWikiPagenames($dbi) {
 $namelist = array();
! 	 $d = opendir($dbi);
! 	 $curr = 0;
! 	 while($entry = readdir($d)) {
! $namelist[$curr++] = $entry;
! 	 }
 
 return $namelist;
--- 278,286 ----
 function GetAllWikiPagenames($dbi) {
 $namelist = array();
! $d = opendir($dbi);
! while($entry = readdir($d)) {
! 	 if ($entry != '.' && $entry != '..')
! 	 $namelist[] = $entry;
! }
 
 return $namelist;
Index: dbalib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/dbalib.php,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** dbalib.php	2001年01月31日 02:01:27	1.2
--- dbalib.php	2001年08月18日 00:35:10	1.2.2.1
***************
*** 19,22 ****
--- 19,25 ----
 InitFullSearch($dbi, $search) 
 FullSearchNextMatch($dbi, &$pos) 
+ MakeBackLinkSearchRegexp($pagename)
+ InitBackLinkSearch($dbi, $pagename) 
+ BackLinkSearchNextMatch($dbi, &$pos) 
 IncreaseHitCount($dbi, $pagename) 
 GetHitCount($dbi, $pagename) 
***************
*** 173,177 ****
--- 176,227 ----
 // new database features
 
+ // Compute PCRE suitable for searching for links to the given page.
+ function MakeBackLinkSearchRegexp($pagename) {
+ global $WikiNameRegexp;
+ 
+ $quoted_pagename = preg_quote($pagename, '/');
+ if (preg_match("/^$WikiNameRegexp\$/", $pagename)) {
+ 	 // FIXME: This may need modification for non-standard (non-english) $WikiNameRegexp.
+ 	 return "/(?<![A-Za-z0-9!])$quoted_pagename(?![A-Za-z0-9])/";
+ }
+ else {
+ 	 // Note from author: Sorry. :-/
+ 	 return ( '/'
+ 		 . '(?<!\[)\[(?!\[)' // Single, isolated '['
+ 		 . '([^]|]*\|)?' // Optional stuff followed by '|'
+ 	 . '\s*' // Optional space
+ 		 . $quoted_pagename // Pagename
+ 		 . '\s*\]/' );	 // Optional space, followed by ']'
+ 	 // FIXME: the above regexp is still not quite right.
+ 	 // Consider the text: " [ [ test page ]". This is a link to a page
+ 	 // named '[ test page'. The above regexp will recognize this
+ 	 // as a link either to '[ test page' (good) or to 'test page' (wrong).
+ } 
+ }
+ 
+ // setup for back-link search
+ function InitBackLinkSearch($dbi, $pagename) {
+ return InitTitleSearch($dbi, MakeBackLinkSearchRegexp($pagename));
+ }
 
+ // iterating through back-links
+ function BackLinkSearchNextMatch($dbi, &$pos) {
+ while ($pos['key']) {
+ $page = $pos['key'];
+ $pos['key'] = dba_nextkey($dbi['wiki']);
+ 
+ $rawdata = dba_fetch($page, $dbi['wiki']);
+ 	 if ( ! preg_match($pos['search'], $rawdata))
+ 	 continue;
+ 	 
+ 	 $pagedata = unserialize(UnPadSerializedData($rawdata));
+ 	 while (list($i, $line) = each($pagedata['content'])) {
+ 	 if (preg_match($pos['search'], $line))
+ 	 return $page;
+ 	 }
+ }
+ return 0;
+ }
+ 
 function IncreaseHitCount($dbi, $pagename) {
 
***************
*** 201,205 ****
 }
 
- 
 function InitMostPopular($dbi, $limit) {
 // iterate through the whole dbm file for hit counts
--- 251,254 ----
***************
*** 255,257 ****
 }
 
! ?>
\ No newline at end of file
--- 304,306 ----
 }
 
! ?>
Index: dbmlib.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/dbmlib.php,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -r1.7 -r1.7.2.1
*** dbmlib.php	2001年01月31日 03:11:25	1.7
--- dbmlib.php	2001年08月18日 00:35:10	1.7.2.1
***************
*** 16,19 ****
--- 16,22 ----
 InitFullSearch($dbi, $search)
 FullSearchNextMatch($dbi, $res)
+ MakeBackLinkSearchRegexp($pagename)
+ InitBackLinkSearch($dbi, $pagename) 
+ BackLinkSearchNextMatch($dbi, &$pos) 
 IncreaseHitCount($dbi, $pagename)
 GetHitCount($dbi, $pagename)
***************
*** 210,213 ****
--- 213,267 ----
 ////////////////////////
 // new database features
+ 
+ // Compute PCRE suitable for searching for links to the given page.
+ function MakeBackLinkSearchRegexp($pagename) {
+ global $WikiNameRegexp;
+ 
+ // Note that in (at least some) PHP 3.x's, preg_quote only takes
+ // (at most) one argument. Also it doesn't quote '/'s.
+ // It does quote '='s, so we'll use that for the delimeter.
+ $quoted_pagename = preg_quote($pagename);
+ if (preg_match("/^$WikiNameRegexp\$/", $pagename)) {
+ 	 # FIXME: This may need modification for non-standard (non-english) $WikiNameRegexp.
+ 	 return "=(?<![A-Za-z0-9!])$quoted_pagename(?![A-Za-z0-9])=";
+ }
+ else {
+ 	 // Note from author: Sorry. :-/
+ 	 return ( '='
+ 		 . '(?<!\[)\[(?!\[)' // Single, isolated '['
+ 		 . '([^]|]*\|)?' // Optional stuff followed by '|'
+ 	 . '\s*' // Optional space
+ 		 . $quoted_pagename // Pagename
+ 		 . '\s*\]=' );	 // Optional space, followed by ']'
+ 	 // FIXME: the above regexp is still not quite right.
+ 	 // Consider the text: " [ [ test page ]". This is a link to a page
+ 	 // named '[ test page'. The above regexp will recognize this
+ 	 // as a link either to '[ test page' (good) or to 'test page' (wrong).
+ } 
+ }
+ 
+ // setup for back-link search
+ function InitBackLinkSearch($dbi, $pagename) {
+ return InitTitleSearch($dbi, MakeBackLinkSearchRegexp($pagename));
+ }
+ 
+ // iterating through back-links
+ function BackLinkSearchNextMatch($dbi, &$pos) {
+ while ($pos['key']) {
+ $page = $pos['key'];
+ $pos['key'] = dbmnextkey($dbi['wiki'], $pos['key']);
+ 
+ $rawdata = dbmfetch($dbi['wiki'], $page);
+ 	 if ( ! preg_match($pos['search'], $rawdata))
+ 	 continue;
+ 	 
+ 	 $pagedata = unserialize(UnPadSerializedData($rawdata));
+ 	 while (list($i, $line) = each($pagedata['content'])) {
+ 	 if (preg_match($pos['search'], $line))
+ 	 return $page;
+ 	 }
+ }
+ return 0;
+ }
 
 function IncreaseHitCount($dbi, $pagename) {
Index: mysql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/mysql.php,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -C2 -r1.10 -r1.10.2.1
*** mysql.php	2001年01月04日 18:37:56	1.10
--- mysql.php	2001年08月18日 00:35:10	1.10.2.1
***************
*** 20,23 ****
--- 20,25 ----
 InitFullSearch($dbi, $search)
 FullSearchNextMatch($dbi, $res)
+ InitBackLinkSearch($dbi, $pagename) 
+ BackLinkSearchNextMatch($dbi, &$pos) 
 InitMostPopular($dbi, $limit)
 MostPopularNextMatch($dbi, $res)
***************
*** 262,265 ****
--- 264,291 ----
 }
 }
+ 
+ // setup for back-link search
+ function InitBackLinkSearch($dbi, $pagename) {
+ global $WikiLinksStore;
+ 
+ $topage = addslashes($pagename);
+ $res = mysql_query( "SELECT DISTINCT frompage FROM $WikiLinksStore"
+ 			 . " WHERE topage='$topage'"
+ 			 . " ORDER BY frompage",
+ 			 $dbi["dbc"]);
+ return $res;
+ }
+ 
+ 
+ // iterating through database
+ function BackLinkSearchNextMatch($dbi, $res) {
+ if($a = mysql_fetch_row($res)) {
+ return $a[0];
+ }
+ else {
+ return 0;
+ }
+ }
+ 
 
 function InitMostPopular($dbi, $limit) {
Index: pgsql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/pgsql.php,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -r1.4 -r1.4.2.1
*** pgsql.php	2000年11月02日 04:23:59	1.4
--- pgsql.php	2001年08月18日 00:35:10	1.4.2.1
***************
*** 16,19 ****
--- 16,21 ----
 InitFullSearch($dbi, $search)
 FullSearchNextMatch($dbi, $res)
+ InitBackLinkSearch($dbi, $pagename) 
+ BackLinkSearchNextMatch($dbi, &$pos) 
 IncreaseHitCount($dbi, $pagename)
 GetHitCount($dbi, $pagename)
***************
*** 289,292 ****
--- 291,317 ----
 ////////////////////////
 // new database features
+ 
+ // setup for back-link search
+ function InitBackLinkSearch($dbi, $pagename) {
+ global $WikiLinksPageStore;
+ 
+ $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;
+ }
+ 
+ 
+ // iterating through database
+ function BackLinkSearchNextMatch($dbi, $res) {
+ if($a = @pg_fetch_row($res['res'], $res['row']++)) {
+ 	 return $a[0];
+ }
+ else {
+ return 0;
+ }
+ }
 
 
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /