Recent Topics

1 Feb 05, 2010 17:32    

I searched the forum here but I can't seem to find a way (yet) to reset the page views counter - can someone please point me in the right direction?

Thank you

2 Feb 05, 2010 17:41

Welcome to the forums!

There's no option to reset the counter from control panel.
What you can do is create a file /conf/hacks.php with the following code

<?php

if( $post_ID = param('reset_views', 'integer') )
{
    global $DB;
    $DB->query('UPDATE T_items__item SET post_views = 0 WHERE post_ID = '.$post_ID);
}

?>

Then you can reset views for post 777 by adding index.php?reset_views=777 to your blog URL

3 Feb 10, 2010 21:10

Thank you for your reply. I was successful in implementing the hack and resetting page views, however, I did get this error message once the hack went "live"

Warning: Cannot modify header information - headers already sent by (output started at /home/weopine/public_html/conf/hacks.php:9) in /home/weopine/public_html/inc/skins/_skin.funcs.php on line 379

I just renamed the hack when I was done in case I need it again but, Is it typical for hacks to elicit error messages like this? I"m basically new to doing anything outside the standard configuration so I was just wondering.

Thanks again for your help.

4 Feb 10, 2010 21:46

Make sure there's no space or line breaks on line 9.
The file should end with ?>

5 Apr 21, 2010 14:25

Hi sam2kb i have a ploblem help me, please.
referable: www.blogtika.com

I would like reset page views automatic all blog "admin and users" every 24 hr. You have a code for referable.

6 Apr 22, 2010 02:42

managerblue wrote:

Hi sam2kb i have a ploblem help me, please.
referable: www.blogtika.com

I would like reset page views automatic all blog "admin and users" every 24 hr. You have a code for referable.

Are you talking about post views or blog stats? To reset blog stats go to Global settings > Features and configure "Hit & session logging" section

8 Apr 22, 2010 05:07

Create a file stats_reset.php in blog root directory. Then create a cron job and set it to run the above file every 24 hours.

This should work for you

0 0 * * * /usr/bin/php /real/path/stats_reset.php

stats_reset.php

require_once dirname(__FILE__).'/PATH TO/conf/_config.php';
require_once $inc_path .'_main.inc.php';

$DB->query('UPDATE T_items__item SET post_views = 0');

9 Apr 22, 2010 05:22

Where for paste stats_reset.php? Please, tell folder.

10 Apr 22, 2010 05:27

This code it's ok?

<?php
require_once dirname(__FILE__).'/PATH TO/conf/_config.php';
require_once $inc_path .'_main.inc.php';
$DB->query('UPDATE T_items__item SET post_views = 0');
?>

I don't know more about PHP :roll:

11 Apr 22, 2010 16:53

managerblue wrote:

Where for paste stats_reset.php? Please, tell folder.

In blog root directory (where your blog index.php is), e.g. /home/username/www/blog/

Don't forget to edit "PATH TO" to the real path to config file. If you put stats_reset.php in blog root, the following should work.

require_once dirname(__FILE__).'/conf/_config.php';

12 Apr 22, 2010 17:45

Now, it's ok.

This code:

<?php 
require_once dirname(__FILE__).'/conf/_config.php'; 
require_once $inc_path .'_main.inc.php'; 
$DB->query('UPDATE T_items__item SET post_views = 0'); 
?>

My question.
1.Automatic reset post views? i world like to reset everyday, how to?
2.How to use stats_reset.php or only type url?

14 Apr 22, 2010 18:32

Where? if i would like to paste or set cron jobs.
Create cron job with a php file? How to.

This my code:

<?php
0 0 * * * /usr/bin/php /home/blogtika/public_html/stats_reset.php
?>

16 Apr 22, 2010 19:01

I save this code

<?php
0 0 * * * /usr/bin/php /home/blogtika/public_html/stats_reset.php
?>

to stats_reset_auto.php and paste to /plublic_html/... it wrong? if i paste stats_reset_auto.php outside .../plublic_html it correct?

17 Apr 22, 2010 19:08

You don't need stats_reset_auto.php

Please read the info I linked to, you can create cron job in cPanel or directly linux shell.

18 Apr 22, 2010 19:49

After i find tools in cpanel. I use cron jobs for set your code.

Now, it work!

Good friend, Thank you.


Form is loading...