Topic: FIX: Auto Archiving for the New Year

What's this for?
There seems to be a bug where auto archiving wont archive your news for the new year.

Note: If you are after the fix which displays false auto archiving errors when the auto archive feature is turn off check out https://cutephp.com/forum/index.php?s=&show...indpost&p=61660

How to Fix?
Open functions.inc.php

Replace this (Line 179 in CN 1.4.1)..

if($now[year] >= (int)$last_archived[year] and $now[month] > (int)$last_archived[month]){


With this..

if(($now[year] >= (int)$last_archived[year] and $now[month] > (int)$last_archived[month]) or ((int)$last_archived[month] != 1 and $now[month] == 1)){

Re: FIX: Auto Archiving for the New Year

That looks fine for people who've always had archiveing and need it fixed, but it doesn't fully address the possibilities of someone who turned off archving in 2005 and wants to turn it on in 2006...

Assumptions:
1) No matter what, if you've turned on archiving and the last run was last year, you want it to run.
2) If you've always had archiving run, and it hasn't run 'this month' then run.

Maybe ...

if ( ($now[year] >= (int)$last_archived[year]) or ($now[year] == (int)$last_archived[year] and $now[month] > (int)$last_archived[month]) ) {

Re: FIX: Auto Archiving for the New Year

Thanks! I only have one problem... the link of that other topic is broken... where can I find it?

Re: FIX: Auto Archiving for the New Year

The Link is broken...

and what about CN 1.3.6 users????
Where can we fix this bug???
Thanks

Re: FIX: Auto Archiving for the New Year

The feature this fix is for.. does not come with cutenews 1.3.6 only comes in 1.4.0+

the link i believe has been deleted... well the post anyway.

Re: FIX: Auto Archiving for the New Year

The feature this fix is for.. does not come with cutenews 1.3.6 only comes in 1.4.0+

the link i believe has been deleted... well the post anyway.


Omg..pls..pls..pls...pls...anyone can help a poor user???  https://cutephp.com/forum/style_emoticons/default/sad.gif  still using 1.3.6?

7 (edited by 2006-02-13 10:18:46)

Re: FIX: Auto Archiving for the New Year

well if I'm not mistaken the beginning of auto_archive.php needs to be changed to

$now[year]      = date("Y");
$now[month]    = date("m");
$now[stamp] = $now[year].$now[month];

$db_content = file("$cutepath/auto_archive.db.php");
list($last_archived[year], $last_archived[month]) = split("\|", $db_content[0] );
$last_archived[stamp] = $last_archived[year].$last_archived[month];


archive stamp is now calculated as YEAR.MONTH, so Jan 05 would be 200501.

If you already have the autoarchive mod added, you'll need to prefix all month values in auto_archive.db.php with a '0'.

The achive db should look something like:

2005|1
2004|12
2004|11
0|0

change the first line to read 2005|01

when finished it shoule look like this changes are in bold
$now[year]      = date("Y");
$now[month]     = date("m");
$now[stamp] = $now[year].$now[month];

$db_content = file("$cutepath/auto_archive.db.php");
list($last_archived[year], $last_archived[month]) = split("\|", $db_content[0] );
$last_archived[stamp] = $last_archived[year].$last_archived[month];

Re: FIX: Auto Archiving for the New Year

This is my autoarchive.php

<?PHP
error_reporting (E_ALL ^ E_NOTICE);
$cutepath =  __FILE__;
$cutepath = preg_replace( "'\\\auto_archive\.php'", "", $cutepath);
$cutepath = preg_replace( "'/auto_archive\.php'", "", $cutepath);
$now[year]    = date("Y");
$now[month]    = date("n");
$now[stamp] = $now[year] + $now[month];
$db_content = file("$cutepath/auto_archive.db.php");
list($last_archived[year], $last_archived[month]) = split("\|", $db_content[0] );
$last_archived[stamp] = $last_archived[year] + $last_archived[month];
if($now[stamp] > $last_archived[stamp]){
$error = FALSE;
$arch_name = time();
if(!@copy("$cutepath/data/news.txt","$cutepath/data/archives/$arch_name.news.arch"))          { $error = "Can not copy news.txt"; }
if(!@copy("$cutepath/data/comments.txt","$cutepath/data/archives/$arch_name.comments.arch"))  { $error = "Can not copy comments.txt"; }
$handle = fopen("$cutepath/data/news.txt","w") or $error = "Can not open news.txt";
fclose($handle);
$handle = fopen("$cutepath/data/comments.txt","w") or $error = "Can not open comments.txt";
fclose($handle);
$fp = @fopen("$cutepath/auto_archive.db.php", "w");
if(!$errors){ fwrite($fp, $now[year]."|".$now[month]."\n"); }
else{ fwrite($fp, "0|0|$error\n"); }
foreach($db_content as $line){
@fwrite($fp, $line);
}
@fclose($fp);
}
?>


And this is my autoarchive.db.php
2005|12
2005|11
2005|10

and this is how is show the archive news:
My Webpage


But still not working...why news are archived in December-February2006?
Bella

Re: FIX: Auto Archiving for the New Year

The line of code that Ipstenu suggested fixes the problem except for the fact that it casues CuteNews to autoarchive every time there is more than 1 post. Instead of using the code he wrote, use the one below, it is exactly the same except a >= was changed to >.

if ( ($now[year] > (int)$last_archived[year]) or ($now[year] == (int)$last_archived[year] and $now[month] > (int)$last_archived[month]) ) {

10 (edited by 2006-03-02 22:44:18)

Re: FIX: Auto Archiving for the New Year

does this stuff also fix:

Attention!
CuteNews has performed auto-archive opperation since your last login at 02 Mar 2006 23:33:53
If you don't want your news to be auto-archived every month,
you can swith this option off from System Configurations.


or how do i fix this stuff on my main page?
i dont use any auto-archive options, never have

Re: FIX: Auto Archiving for the New Year

The line of code that Ipstenu suggested fixes the problem except for the fact that it casues CuteNews to autoarchive every time there is more than 1 post. Instead of using the code he wrote, use the one below, it is exactly the same except a >= was changed to >.

if ( ($now[year] > (int)$last_archived[year]) or ($now[year] == (int)$last_archived[year] and $now[month] > (int)$last_archived[month]) ) {

Omg, i cant use the new hack cos im still using C.N. 1.3.6, but having the autoarchive, that's happen to me too: everytime i have news, they are autoarchived. lol
And i cant even un-archive the news now....lol
The only thing i can do, is to manually move news from archives to archives...and this sucks

Re: FIX: Auto Archiving for the New Year

The line of code that Ipstenu suggested fixes the problem except for the fact that it casues CuteNews to autoarchive every time there is more than 1 post. Instead of using the code he wrote, use the one below, it is exactly the same except a >= was changed to >.

if ( ($now[year] > (int)$last_archived[year]) or ($now[year] == (int)$last_archived[year] and $now[month] > (int)$last_archived[month]) ) {

'She' wrote https://cutephp.com/forum/style_emoticons/default/smile.gif Yes, well .. *ahem* Awesome catch! As I said before I don't actually use the auto-archive so there were some aspects I wasn't suited to test https://cutephp.com/forum/style_emoticons/default/smile.gif

13 (edited by 2007-01-02 01:21:51)

Re: FIX: Auto Archiving for the New Year

i am using CN 1.4.5 and i have no problems at all... i added news after 2007 started and it didnt get archived i dont know if the error has been fixed there...
*edit*
after looking inside the archives something has gone wrong, the code i have to replace isnt in inc/function.inc.php
help plz

14 (edited by 2007-01-06 11:11:45)

Re: FIX: Auto Archiving for the New Year

Your saying you have no problems with 1.4.5 so i dont see why you are looking for that code.

The code will of course change from version to version the first post made by myself was for 1.4.1

Re: FIX: Auto Archiving for the New Year

oops sorry https://cutephp.com/forum/style_emoticons/default/wacko.gif multiple things went wrong on 2006-2007 im so sorry

Re: FIX: Auto Archiving for the New Year

The problem should be fixed in the latest version, but i could be wrong. Im not a user of cutenews these days.

Re: FIX: Auto Archiving for the New Year

I can't understand very well english. Sorry if you don't understand.

I wanna know what is the final OFFICIAL fix for this problem please. I only have to do the fix ine the first message of this topic or is this anything else to do? You could put a system link beetweem cute news users and cutephp to informe us about fixes. A link in the interface would be appreciated by everybody I think.

Thx

Re: FIX: Auto Archiving for the New Year

will cn 1.46 have the same problem? coz 2009 will come soon.

Re: FIX: Auto Archiving for the New Year

honestly, i don't know.
But i can't remember seeing any mention of that problem with 2007-2008
so i think it is fixed.
Also when i compair the code from 1.4.0 and 1.4.6 for the auto archive i see they are different around the line that the fix in this topic refers to, so that's another reason to think it is fixed.

Re: FIX: Auto Archiving for the New Year

I can't understand the code, but i will try

Re: FIX: Auto Archiving for the New Year

it's work
great job!