Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 05:49 am EST
Geeklog Forums
Ewiki, stats.php and What's New
Status: offline
ajzz
Forum User
Regular Poster
Registered: 01/19/05
Posts: 113
Ewiki is just right for what our site needed and the current configuration allows logged in users only to view/edit.
Unfortunately, Stats page i.e. stats.php (not the stats plugin) shows the top 10 Wiki pages and their links to Anonymous users (although they cannot access the page using the link).
Is there a simple way to set this right - so that only logged-in users will see this information in the stats page?
Thanks folks,
Ajay
PS: I am using the latest versions of both GL and euan's Ewiki integration.
EDIT: I checked and the above behavior also carries through to the EWIKI entries in the What's New Block (so i changed the thread title)
Unfortunately, Stats page i.e. stats.php (not the stats plugin) shows the top 10 Wiki pages and their links to Anonymous users (although they cannot access the page using the link).
Is there a simple way to set this right - so that only logged-in users will see this information in the stats page?
Thanks folks,
Ajay
PS: I am using the latest versions of both GL and euan's Ewiki integration.
EDIT: I checked and the above behavior also carries through to the EWIKI entries in the What's New Block (so i changed the thread title)
6
8
Quote
Status: Banned
machinari
Forum User
Full Member
Registered: 03/22/04
Posts: 1512
I'm looking at version 1.1 and I dunno if that is the latest version or not...
to disable stats for all but logged in members: In functions.inc, change this function
{
global $_CONF, $_TABLES;
$stat_templates = new Template($_CONF['path_layout'] . 'stats');
$stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml',
'statrow'=>'singlestat.thtml'));
$retval='';
if ($showsitestats == 1) {
// This shows in the summary box
$total_pages=DB_count($_TABLES['ewiki']); // Fill this with count for summary
$summary_label = "Ewiki"; // Fill this with label displayed
$retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>";
$retval .= "<tr><td>$summary_label</td>";
$retval .= "<td align='right'>" . $total_pages . " </td></tr></table>";
} else {
// This fills the top the box Use the following as a template
$result = DB_query("SELECT DISTINCT pagename, hits
FROM {$_TABLES['ewiki']}
WHERE hits > 0
ORDER BY hits desc LIMIT 10");
$nrows = DB_numRows($result);
$retval .= COM_startBlock("Top Ten Ewiki Pages");
if ($nrows > 0) {
$stat_templates->set_var('item_label',"Page Title");
$stat_templates->set_var('stat_name',"Hits");
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$stat_templates->set_var('item_url', $_CONF['site_url'] . '/ewiki/index.php?id=' . $A['pagename']);
$stat_templates->set_var('item_text', $A['pagename']);
$stat_templates->set_var('item_stat', $A['hits']);
$stat_templates->parse('stat_row','statrow',true);
}
$stat_templates->parse('output','itemstats');
$retval .= $stat_templates->finish($stat_templates->get_var('output'));
} else {
$retval .= 'It appears that there are no ewikis on this site or no one has ever viewed them.';
}
$retval .= COM_endBlock();
}
return $retval;
}
to this
{
global $_CONF, $_TABLES, $_USER;
if( empty( $_USER['uid'] ) OR $_USER['uid'] <= 1 )
$retval = '';
} else {
$stat_templates = new Template($_CONF['path_layout'] . 'stats');
$stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml',
'statrow'=>'singlestat.thtml'));
$retval='';
if ($showsitestats == 1) {
// This shows in the summary box
$total_pages=DB_count($_TABLES['ewiki']); // Fill this with count for summary
$summary_label = "Ewiki"; // Fill this with label displayed
$retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>";
$retval .= "<tr><td>$summary_label</td>";
$retval .= "<td align='right'>" . $total_pages . " </td></tr></table>";
} else {
// This fills the top the box Use the following as a template
$result = DB_query("SELECT DISTINCT pagename, hits
FROM {$_TABLES['ewiki']}
WHERE hits > 0
ORDER BY hits desc LIMIT 10");
$nrows = DB_numRows($result);
$retval .= COM_startBlock("Top Ten Ewiki Pages");
if ($nrows > 0) {
$stat_templates->set_var('item_label',"Page Title");
$stat_templates->set_var('stat_name',"Hits");
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$stat_templates->set_var('item_url', $_CONF['site_url'] . '/ewiki/index.php?id=' . $A['pagename']);
$stat_templates->set_var('item_text', $A['pagename']);
$stat_templates->set_var('item_stat', $A['hits']);
$stat_templates->parse('stat_row','statrow',true);
}
$stat_templates->parse('output','itemstats');
$retval .= $stat_templates->finish($stat_templates->get_var('output'));
} else {
$retval .= 'It appears that there are no ewikis on this site or no one has ever viewed them.';
}
$retval .= COM_endBlock();
}
}
return $retval;
}
all I did was to add the if/else wrapper checking the uid.
a similar thing can be done for the what's new block
to disable stats for all but logged in members: In functions.inc, change this function
Text Formatted Code
function plugin_showstats_ewiki($showsitestats) {
global $_CONF, $_TABLES;
$stat_templates = new Template($_CONF['path_layout'] . 'stats');
$stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml',
'statrow'=>'singlestat.thtml'));
$retval='';
if ($showsitestats == 1) {
// This shows in the summary box
$total_pages=DB_count($_TABLES['ewiki']); // Fill this with count for summary
$summary_label = "Ewiki"; // Fill this with label displayed
$retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>";
$retval .= "<tr><td>$summary_label</td>";
$retval .= "<td align='right'>" . $total_pages . " </td></tr></table>";
} else {
// This fills the top the box Use the following as a template
$result = DB_query("SELECT DISTINCT pagename, hits
FROM {$_TABLES['ewiki']}
WHERE hits > 0
ORDER BY hits desc LIMIT 10");
$nrows = DB_numRows($result);
$retval .= COM_startBlock("Top Ten Ewiki Pages");
if ($nrows > 0) {
$stat_templates->set_var('item_label',"Page Title");
$stat_templates->set_var('stat_name',"Hits");
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$stat_templates->set_var('item_url', $_CONF['site_url'] . '/ewiki/index.php?id=' . $A['pagename']);
$stat_templates->set_var('item_text', $A['pagename']);
$stat_templates->set_var('item_stat', $A['hits']);
$stat_templates->parse('stat_row','statrow',true);
}
$stat_templates->parse('output','itemstats');
$retval .= $stat_templates->finish($stat_templates->get_var('output'));
} else {
$retval .= 'It appears that there are no ewikis on this site or no one has ever viewed them.';
}
$retval .= COM_endBlock();
}
return $retval;
}
to this
Text Formatted Code
function plugin_showstats_ewiki($showsitestats) {
global $_CONF, $_TABLES, $_USER;
if( empty( $_USER['uid'] ) OR $_USER['uid'] <= 1 )
$retval = '';
} else {
$stat_templates = new Template($_CONF['path_layout'] . 'stats');
$stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml',
'statrow'=>'singlestat.thtml'));
$retval='';
if ($showsitestats == 1) {
// This shows in the summary box
$total_pages=DB_count($_TABLES['ewiki']); // Fill this with count for summary
$summary_label = "Ewiki"; // Fill this with label displayed
$retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>";
$retval .= "<tr><td>$summary_label</td>";
$retval .= "<td align='right'>" . $total_pages . " </td></tr></table>";
} else {
// This fills the top the box Use the following as a template
$result = DB_query("SELECT DISTINCT pagename, hits
FROM {$_TABLES['ewiki']}
WHERE hits > 0
ORDER BY hits desc LIMIT 10");
$nrows = DB_numRows($result);
$retval .= COM_startBlock("Top Ten Ewiki Pages");
if ($nrows > 0) {
$stat_templates->set_var('item_label',"Page Title");
$stat_templates->set_var('stat_name',"Hits");
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$stat_templates->set_var('item_url', $_CONF['site_url'] . '/ewiki/index.php?id=' . $A['pagename']);
$stat_templates->set_var('item_text', $A['pagename']);
$stat_templates->set_var('item_stat', $A['hits']);
$stat_templates->parse('stat_row','statrow',true);
}
$stat_templates->parse('output','itemstats');
$retval .= $stat_templates->finish($stat_templates->get_var('output'));
} else {
$retval .= 'It appears that there are no ewikis on this site or no one has ever viewed them.';
}
$retval .= COM_endBlock();
}
}
return $retval;
}
a similar thing can be done for the what's new block
5
7
Quote
Status: offline
ajzz
Forum User
Regular Poster
Registered: 01/19/05
Posts: 113
Hi Machinari,
Naively speaking, do we need to redeclare the variables on the lower side of the else statement?
Getting a parse error on Line 123
120 if( empty( $_USER['uid'] ) OR $_USER['uid'] <= 1 )
121 $retval = '';
122 } else {
123 $stat_templates = new Template($_CONF['path_layout'] . 'stats');
124 $stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml', 125 'statrow'=>'singlestat.thtml'));
of functions.inc at the else statement when i make above changes and open stats.php. Also, the following errors when I open the stats page and try to login after that.
Parse error: parse error in pathtogeeklog/plugins/ewiki/functions.inc on line 123
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in pathtogeeklog/system/lib-sessions.php on line 317
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in public_html/users.php on line 835
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in public_html/users.php on line 838
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in public_html/users.php on line 865
Thanks,
Ajay
Naively speaking, do we need to redeclare the variables on the lower side of the else statement?
Getting a parse error on Line 123
Text Formatted Code
119 { global $_CONF, $_TABLES, $_USER;120 if( empty( $_USER['uid'] ) OR $_USER['uid'] <= 1 )
121 $retval = '';
122 } else {
123 $stat_templates = new Template($_CONF['path_layout'] . 'stats');
124 $stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml', 125 'statrow'=>'singlestat.thtml'));
Text Formatted Code
Parse error: parse error in pathtogeeklog/plugins/ewiki/functions.inc on line 123
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in pathtogeeklog/system/lib-sessions.php on line 317
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in public_html/users.php on line 835
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in public_html/users.php on line 838
Warning: Cannot add header information - headers already sent by (output started at pathtogeeklog/plugins/ewiki/functions.inc:123) in public_html/users.php on line 865
Thanks,
Ajay
8
6
Quote
Status: Banned
machinari
Forum User
Full Member
Registered: 03/22/04
Posts: 1512
whoops, forgot a curly brace at the end of the first if line...
change this
to this
and the header error is probably due to whitespace that crept into your file at the beginning or end (outside the open/close tags). this is caused by crappy editing software usually.
change this
Text Formatted Code
if( empty( $_USER['uid'] ) OR $_USER['uid'] <= 1 )Text Formatted Code
if( empty( $_USER['uid'] ) OR $_USER['uid'] <= 1 ){and the header error is probably due to whitespace that crept into your file at the beginning or end (outside the open/close tags). this is caused by crappy editing software usually.
5
6
Quote
All times are EST. The time is now 05:49 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content