|
From: Geoffrey T. D. <da...@us...> - 2001-11-07 18:58:17
|
Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv29293/lib
Modified Files:
Tag: release-1_2-branch
pgsql.php msql.php mssql.php
Log Message:
Fix SF bug #462168: hit count broken for pages with apostrophes in their names.
These fixes are untested, but they are entirely analogous to similar fixes
in mysql.php (which I have tested). Barring typos on my part, I think
they're unlikely to cause problems.
Index: pgsql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/pgsql.php,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -C2 -r1.4.2.3 -r1.4.2.4
*** pgsql.php 2001/11/04 03:46:10 1.4.2.3
--- pgsql.php 2001/11/07 18:58:14 1.4.2.4
***************
*** 319,328 ****
function IncreaseHitCount($dbi, $pagename) {
global $HitCountPageStore;
! $query = "update $HitCountPageStore set hits=hits+1 where pagename='$pagename'";
$res = pg_exec($dbi['dbc'], $query);
if (!pg_cmdtuples($res)) {
$query = "insert into $HitCountPageStore (pagename, hits) " .
! "values ('$pagename', 1)";
$res = pg_exec($dbi['dbc'], $query);
}
--- 319,330 ----
function IncreaseHitCount($dbi, $pagename) {
global $HitCountPageStore;
!
! $qpagename = addslashes($pagename);
! $query = "update $HitCountPageStore set hits=hits+1 where pagename='$qpagename'";
$res = pg_exec($dbi['dbc'], $query);
if (!pg_cmdtuples($res)) {
$query = "insert into $HitCountPageStore (pagename, hits) " .
! "values ('$qpagename', 1)";
$res = pg_exec($dbi['dbc'], $query);
}
***************
*** 333,337 ****
function GetHitCount($dbi, $pagename) {
global $HitCountPageStore;
! $query = "select hits from $HitCountPageStore where pagename='$pagename'";
$res = pg_exec($dbi['dbc'], $query);
if (pg_cmdtuples($res)) {
--- 335,340 ----
function GetHitCount($dbi, $pagename) {
global $HitCountPageStore;
! $qpagename = addslashes($pagename);
! $query = "select hits from $HitCountPageStore where pagename='$qpagename'";
$res = pg_exec($dbi['dbc'], $query);
if (pg_cmdtuples($res)) {
Index: msql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/msql.php,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -C2 -r1.6.2.2 -r1.6.2.3
*** msql.php 2001/11/04 03:46:10 1.6.2.2
--- msql.php 2001/11/07 18:58:14 1.6.2.3
***************
*** 455,469 ****
function IncreaseHitCount($dbi, $pagename) {
! $query = "select hits from hitcount where pagename='$pagename'";
$res = msql_query($query, $dbi['dbc']);
if (msql_num_rows($res)) {
$hits = msql_result($res, 0, 'hits');
$hits++;
! $query = "update hitcount set hits=$hits where pagename='$pagename'";
$res = msql_query($query, $dbi['dbc']);
} else {
$query = "insert into hitcount (pagename, hits) " .
! "values ('$pagename', 1)";
$res = msql_query($query, $dbi['dbc']);
}
--- 455,470 ----
function IncreaseHitCount($dbi, $pagename) {
! $qpagename = addslashes($pagename);
! $query = "select hits from hitcount where pagename='$qpagename'";
$res = msql_query($query, $dbi['dbc']);
if (msql_num_rows($res)) {
$hits = msql_result($res, 0, 'hits');
$hits++;
! $query = "update hitcount set hits=$hits where pagename='$qpagename'";
$res = msql_query($query, $dbi['dbc']);
} else {
$query = "insert into hitcount (pagename, hits) " .
! "values ('$qpagename', 1)";
$res = msql_query($query, $dbi['dbc']);
}
***************
*** 474,478 ****
function GetHitCount($dbi, $pagename) {
! $query = "select hits from hitcount where pagename='$pagename'";
$res = msql_query($query, $dbi['dbc']);
if (msql_num_rows($res)) {
--- 475,480 ----
function GetHitCount($dbi, $pagename) {
! $qpagename = addslashes($pagename);
! $query = "select hits from hitcount where pagename='$qpagename'";
$res = msql_query($query, $dbi['dbc']);
if (msql_num_rows($res)) {
Index: mssql.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/Attic/mssql.php,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** mssql.php 2001/11/04 03:43:36 1.1.2.3
--- mssql.php 2001/11/07 18:58:14 1.1.2.4
***************
*** 218,230 ****
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;
--- 218,231 ----
global $HitCountStore;
+ $qpagename = addslashes($pagename);
$rowexists = 0;
! if ($res = mssql_query("select count(*) from $dbi[table] where pagename='$qpagename'", $dbi['dbc'])) {
$rowexists = (mssql_result($res, 0, 0));
}
if ($rowexists)
! $res = mssql_query("update $HitCountStore set hits=hits+1 where pagename='$qpagename'", $dbi['dbc']);
else
! $res = mssql_query("insert into $HitCountStore (pagename, hits) values ('$qpagename', 1)", $dbi['dbc']);
return $res;
***************
*** 235,239 ****
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);
--- 236,241 ----
global $HitCountStore;
! $qpagename = addslashes($pagename);
! $res = mssql_query("select hits from $HitCountStore where pagename='$qpagename'", $dbi['dbc']);
if (mssql_num_rows($res))
$hits = mssql_result($res, 0, 0);
|