Revision history for GmBowenCounter
Revision [23332]
Last edited on 2016-05-20 07:38:47 by WillyPs [Replaces old-style internal links with new pipe-split links.]Additions:
>>//see also:// [[TRBCounter | TRBCounter]]>>====Page Counter Action====
Deletions:
Additions:
>>//see also:// [[TRBCounter TRBCounter]]>>====Page Counter Action====
Deletions:
Revision [19437]
Edited on 2008-01-28 00:16:01 by JavaWoman [Modified links pointing to docs server]No Differences
Revision [17826]
Edited on 2007-12-12 12:25:53 by JavaWoman [prevent function references looking as page links]Additions:
====Page Counter Action====
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
{
// Start output of counter
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4);
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2"> ';
print "$hit_count3";
echo '</font></td></tr></table>';
}
// End Output of counter
?>
%%
===Preventing the reset of the counter===
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
to
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the ""SavePage()"" function (see below....which is why $pagehits doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the ""SavePage()"" function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
note that $pagehits has to PRECEDE the $comment_on variable
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
----
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
{
// Start output of counter
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4);
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2"> ';
print "$hit_count3";
echo '</font></td></tr></table>';
}
// End Output of counter
?>
%%
===Preventing the reset of the counter===
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
to
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the ""SavePage()"" function (see below....which is why $pagehits doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the ""SavePage()"" function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
note that $pagehits has to PRECEDE the $comment_on variable
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
----
Deletions:
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
{
// Start output of counter
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4);
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2"> ';
print "$hit_count3";
echo '</font></td></tr></table>';
}
// End Output of counter
?>
%%
===Preventing the reset of the counter===
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
to
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the SavePage function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
note that $pagehits has to PRECEDE the $comment_on variable
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
----
Additions:
====Page Counter Action====
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
{
// Start output of counter
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4);
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2"> ';
print "$hit_count3";
echo '</font></td></tr></table>';
}
// End Output of counter
?>
%%
===Preventing the reset of the counter===
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
to
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the SavePage function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
note that $pagehits has to PRECEDE the $comment_on variable
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
----
CategoryUserContributions
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
{
// Start output of counter
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4);
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2"> ';
print "$hit_count3";
echo '</font></td></tr></table>';
}
// End Output of counter
?>
%%
===Preventing the reset of the counter===
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
to
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the SavePage function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
note that $pagehits has to PRECEDE the $comment_on variable
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
----
CategoryUserContributions
Deletions:
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off'
Additions:
====Page Counter Action====
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off'
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off'
Deletions:
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
%%(php)
<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2);
$hit_count1 = $row2[hits];
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
// End Get hit Count Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits Start Update Hit
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
}
// End Update Hit
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
{
// Start output of counter
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4);
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2"> ';
print "$hit_count3";
echo '</font></td></tr></table>';
}
// End Output of counter
?>
%%
===Preventing the reset of the counter===
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
to
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the SavePage function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
note that $pagehits has to PRECEDE the $comment_on variable
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
----
CategoryUserContributions
Additions:
CategoryUserContributions
Deletions:
Additions:
And that's it folks....it should work pretty well.
----
CategoryDevelopment
----
CategoryDevelopment
Deletions:
Additions:
- ''it also might be useful to have it so that an owner could set show=off or show=no but show up if it is the pageowner looking...I'll have to think through the coding on that though''
Additions:
====Page Counter Action====
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
===Preventing the reset of the counter===
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the SavePage function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
- Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others).
- If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show=''"off"'' or show=''"no"''.
- It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
- ''the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion''
the **_pages table** has to have the following field added....
%%`hits` int(50) NOT NULL default '0'%%
and the **counter.php** code (save as a file in the action directory)....
===Preventing the reset of the counter===
In the **handlers/edit.php** file I changed the line (''around line 35'').....
%%(php)$this->SavePage($this->tag, $body, $note);%%
%%(php)$this->SavePage($this->tag, $body, $note, $this->page['hits']);%%
In the **WAKKA.PHP** file in the wiki root:
''Around line 235'', in the SavePage function, the line has to be changed to
%%function SavePage($tag, $body, $note, $pagehits, $comment_on = "")%%
''a few lines down'', the following line has to be added....
%%"hits = '".mysql_escape_string($pagehits)."', ".%%
I added it ''after the line''....
%%"user = '".mysql_escape_string($user)."', ".%%
And that's it folks....it should work pretty well.
Deletions:
the _pages table has to have the following field added....
`hits` int(50) NOT NULL default '0'
and the counter.php code (save as a file in the action directory)....
%%In the handlers/edit.php file I changed the line (around line 35).....
$this->SavePage($this->tag, $body, $note);
$this->SavePage($this->tag, $body, $note, $this->page['hits']);
In the WAKKA.PHP file in the wiki root.....
Around line 235, in the SavePage function, the line has to be changed to
function SavePage($tag, $body, $note, $pagehits, $comment_on = "")
a few lines down, the following line has to be added....
"hits = '".mysql_escape_string($pagehits)."', ".
I added it after the line....
"user = '".mysql_escape_string($user)."', ".
And that's it folks....it should work pretty well.
%%
Additions:
Additions:
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
Deletions:
Additions:
Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others). If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show="off" or show="no". It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen) ''[the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user for exclusion]''
Deletions:
Additions:
Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others). If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show="off" or show="no". It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen) ''[the only thing I can think might be useful to add, is if you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user]''
Deletions:
Additions:
Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others). If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show="off" or show="no". It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen) ''[the only thing I can think might be useful to add, is if the you could add the parameter ignore="//name1, name2, name3//"...but I had no idea how to parse a list like that and include a comparison of to the current user]''
Deletions:
Deletions:
Additions:
%%(php)
Additions:
Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others). If you want it to keep a count, but without showing the number (so people don't have the urge to "up" the number on you), you can set the parameter show="off" or show="no". It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
the _pages table has to have the following field added....
and the counter.php code (save as a file in the action directory)....
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
And that's it folks....it should work pretty well.
the _pages table has to have the following field added....
and the counter.php code (save as a file in the action directory)....
// parameter show="off" or "no" being checked for
$show = strtolower($show);
if ($show != 'off' && $show !='no')
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually...I said it was a "rough" count didn't I??). If you don't want that to happen you have to do the following changes as well....
And that's it folks....it should work pretty well.
Deletions:
entry into _pages table....
and the counter.php code....
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually). If you don't want that to happen you have to do the following changes as well....
Additions:
Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted (it doesn't increment if it's your own page, only for the pages of others). It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
Deletions:
Additions:
// Count is incremented if not your own page
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
}
if ($this->GetUserName() != $this->GetPageOwner($tag))
{
}
Additions:
%%In the handlers/edit.php file I changed the line (around line 35).....
$this->SavePage($this->tag, $body, $note, $this->page['hits']);
variables is important relative to the SavePage function (see below....which is why $this->page['hits'] doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
%%
$this->SavePage($this->tag, $body, $note, $this->page['hits']);
variables is important relative to the SavePage function (see below....which is why $this->page['hits'] doesn't follow
the $comment_on variable in the list of variables in the function but precedes it)
%%
Deletions:
$pagehits = $this->page['hits'];
on the third line immediately before....
if ($this->HasAccess("write") && $this->HasAccess("read"))
and then on around line 35 changed....
$this->SavePage($this->tag, $body, $note, $pagehits);
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable but precedes it)
Additions:
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable but precedes it)
variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow
the $comment_on variable but precedes it)
Deletions:
Additions:
Below are the changes needed to create an action that allows the number of hits on a page to be roughly counted. It works pretty well overall. Of course, it doesn't "count" if the action isn't on the page, but I thought for "help" pages etc that aren't open for editing it might be pretty useful. Usually we put lots of work into different things in a wiki, I thought it'd be interesting to be able to gauge the use of the different parts. Hope you find it useful. -- Mike (aka GmBowen)
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually). If you don't want that to happen you have to do the following changes as well....
%%In the handlers/edit.php file I added.....
$pagehits = $this->page['hits'];
on the third line immediately before....
if ($this->HasAccess("write") && $this->HasAccess("read"))
and then on around line 35 changed....
$this->SavePage($this->tag, $body, $note);
to
$this->SavePage($this->tag, $body, $note, $pagehits);
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow the $comment_on variable but precedes it)
In the WAKKA.PHP file in the wiki root.....
Around line 235, in the SavePage function, the line has to be changed to
function SavePage($tag, $body, $note, $pagehits, $comment_on = "")
note that $pagehits has to PRECEDE the $comment_on variable
a few lines down, the following line has to be added....
"hits = '".mysql_escape_string($pagehits)."', ".
I added it after the line....
"user = '".mysql_escape_string($user)."', ".
If you only use the above code the counter will re-set to zero every time you edit a page (well, 2 actually). If you don't want that to happen you have to do the following changes as well....
%%In the handlers/edit.php file I added.....
$pagehits = $this->page['hits'];
on the third line immediately before....
if ($this->HasAccess("write") && $this->HasAccess("read"))
and then on around line 35 changed....
$this->SavePage($this->tag, $body, $note);
to
$this->SavePage($this->tag, $body, $note, $pagehits);
AND I learned (through seemingly bizarre but now understandable errors cropping up) that the order of the variables is important relative to the SavePage function (see below....which is why $pagehits doesn't follow the $comment_on variable but precedes it)
In the WAKKA.PHP file in the wiki root.....
Around line 235, in the SavePage function, the line has to be changed to
function SavePage($tag, $body, $note, $pagehits, $comment_on = "")
note that $pagehits has to PRECEDE the $comment_on variable
a few lines down, the following line has to be added....
"hits = '".mysql_escape_string($pagehits)."', ".
I added it after the line....
"user = '".mysql_escape_string($user)."', ".
Deletions:
Deletions:
Additions:
$result2 = mysql_query( "SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'" );
echo $result2;
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
echo $result2;
$sql = "UPDATE `".$this->config["table_prefix"]."pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
$result4 = mysql_query("SELECT hits FROM ".$this->config["table_prefix"]."pages WHERE tag='$thispage' AND latest='Y'");
Deletions:
$sql = "UPDATE `$this->config["table_prefix"]pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
$result4 = mysql_query("SELECT hits FROM '.$this->config["table_prefix"].'pages WHERE tag='$thispage' AND latest='Y'");
Additions:
$result2 = mysql_query( "SELECT hits FROM '.$this->config["table_prefix"].'pages WHERE tag='$thispage' AND latest='Y'" );
$sql = "UPDATE `$this->config["table_prefix"]pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
$result4 = mysql_query("SELECT hits FROM '.$this->config["table_prefix"].'pages WHERE tag='$thispage' AND latest='Y'");
$sql = "UPDATE `$this->config["table_prefix"]pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
$result4 = mysql_query("SELECT hits FROM '.$this->config["table_prefix"].'pages WHERE tag='$thispage' AND latest='Y'");
Deletions:
$sql = "UPDATE `wakka_pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
$result4 = mysql_query("SELECT hits FROM wakka_pages WHERE tag='$thispage' AND latest='Y'");
Deletions:
Additions:
%php%
Deletions:
Additions:
Well, this script works "sort of"....the counter works just fine until the page is edited, and then it resets. I thought that I could find a place in edit.php to get the old counter value from and then when the page saved write that value to the new row in the pages table. Uh, but no luck. And I tried changing Loadpage and Savepage functions in wakka.php adding the $hits variable there, but without success (remember all, I'm not a programmer so have trouble sometimes figuring out someone else's code to add to it). So, if anyone who has a better understanding of wikka structure has any suggestions about where I'd do the work of reading the old count and writing the new one I'd appreciate the guidance. -- Mike
%%php
%%php
Deletions:
Additions:
Well, this script works "sort of"....the counter works just fine until the page is edited, and then it resets. I thought that I could find a place in edit.php to get the old counter value from and then when the page saved write that value to the new row in the pages table. Uh, but no luck. And I tried changing Loadpage and Savepage functions in wakka.php without success (remember all, I'm not a programmer so have trouble sometimes figuring out someone else's code). So, if anyone who has a better understanding of wikka structure has any suggestions about where I'd do the work of reading the old count and writing the new one I'd appreciate the guidance. -- Mike