1

Topic: Is there a simple solution to use archives generated by newsgenerator

Hi,

I'm using newsgenerator plugin. It works great. It's really great done.
I'm looking for a simple solution to use the archives generated. I mean, I want something like at the bottom of this page http://www.punbb.fr/
They don't want to give me the code they're using beacause they are not sure it's secured enough.
I want this to update automatically when there is a new month archived.

Any idea on how to do that?

Ludo,

Re: Is there a simple solution to use archives generated by newsgenerator

I started to write something for punbb.org, but it turned out everything else had a higher priority. I'd be interested in an elegant solution to this as well.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Is there a simple solution to use archives generated by newsgenerator

It looks like a simple directory listing and including of the proper html file to me, like what I have at http://www.armyofbjork.info/x/archive

4

Re: Is there a simple solution to use archives generated by newsgenerator

ctn|chrisw wrote:

It looks like a simple directory listing and including of the proper html file to me, like what I have at http://www.armyofbjork.info/x/archive

You can give your code? It seems to be a good solution.

Ludo,

5 (edited by ctn|chrisw 2005-06-01 10:15)

Re: Is there a simple solution to use archives generated by newsgenerator

<?

$date = $_GET['date'];
$date = strip_tags($date);
$date.= '.html';

?>
<h1>Archives</h1>
<!-- -->
<? if (!empty($date) && file_exists('/home/bjork/domains/armyofbjork.info/public_html/x/bbs/plugins/AP_News_Generator/archive/'.$date)) {
include('/home/bjork/domains/armyofbjork.info/public_html/x/bbs/plugins/AP_News_Generator/archive/'.$date);
} else {
?>
<div id="newshead"><span class="style3">Select an archive date </span></div>
  <div id="box"><p>
  <?php
if ($handle = opendir('/home/bjork/domains/armyofbjork.info/public_html/x/bbs/plugins/AP_News_Generator/archive/')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
       $file = $newphrase = str_replace(".html", "", $file);
           echo '<a href="archive?date='.$file.'">'.$file.'</a><br />';
       }
   }
   closedir($handle);
}
?> 
  </p>
</div> 
<? } ?>

6

Re: Is there a simple solution to use archives generated by newsgenerator

I really thank you.
I'll try this code as soon as I can.

Ludo,

7

Re: Is there a simple solution to use archives generated by newsgenerator

I've just tried it
It gives me a notification:
"Notice: Undefined index: date in /home/ju37853/archives.php on line 51"
You can see at http://www.pluriservices.net/archives.php

Ludo,

Re: Is there a simple solution to use archives generated by newsgenerator

try changing

$date = $_GET['date'];
$date = strip_tags($date);
$date.= '.html';

to

if (isset($_GET['date'])) {
$date = $_GET['date'];
$date = strip_tags($date);
$date.= '.html';
}

9

Re: Is there a simple solution to use archives generated by newsgenerator

Now I got the code under. It does not give me any notification. But, when I click on an archive, it does not work. It gives me a 404 error.

<?

if (isset($_GET['date'])) {
$date = $_GET['date'];
$date = strip_tags($date);
$date.= '.html';
}
?>
<!-- -->
<? if (!empty($date) && file_exists('/home/ju37853/forum/plugins/AMP_News_Generator/archive/'.$date)) {
include('/home/ju37853/forum/plugins/AMP_News_Generator/archive/'.$date);
} else {
?>
<div id="newshead"><span class="style3">Select an archive date </span></div>
  <div id="box"><p>
  <?php
if ($handle = opendir('/home/ju37853/forum/plugins/AMP_News_Generator/archive/')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
       $file = $newphrase = str_replace(".html", "", $file);
           echo '<a href="archive?date='.$file.'">'.$file.'</a><br />';
       }
   }
   closedir($handle);
}
?> 
  </p>
</div> 
<? } ?>

Ludo,

Re: Is there a simple solution to use archives generated by newsgenerator

I have my server set so that archive? goes to archive.php?.

For yours, change
           echo '<a href="archive?date='.$file.'">'.$file.'</a><br />';

so that "archive" is the name of the php file, ie archive.php?date=....

11 (edited by Ludo 2005-06-14 07:26)

Re: Is there a simple solution to use archives generated by newsgenerator

You were right. It seems to work good now except this:

When you clic on 2005-04 you don't get messages archived on april. You get those which were archived on march.
In fact if we want march, we must ask april.

In spite of this small problem, I thank you for your help wink

Ludo,

12

Re: Is there a simple solution to use archives generated by newsgenerator

has a good solution been found now? Something has been done?

Ludo,

Re: Is there a simple solution to use archives generated by newsgenerator

I haven't done anything about it since the archives are in the forums anyway.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

14 (edited by Ludo 2005-10-22 10:03)

Re: Is there a simple solution to use archives generated by newsgenerator

Ok, I've gone on searching and it seems that vin100 from punbb.fr has a good solution working.
He has given me some code but it must certainly be adapted because it does not work at the moment. Any suggestions appreciated.

<?php
function liste($bloc='<ul>%s</ul>', $item='<li>%s</li>')
    {
        global $pun_config;
        
        $archives = array();
        $d = dir('/forum/plugins/AMP_News_Generator/archive');
        while (($entry = $d->read()) !== false)
        {
            if (substr($entry, strlen($entry)-5) == '.html')
                $archives[] = substr($entry, 0, strlen($entry)-5);
        }
        $d->close();
        
        @natsort($archives);
        $archives = array_reverse($archives);
        
        $items = '';
        foreach ($archives as $k=>$v)
            $items .= sprintf($item, '<a href="index.php?mod=news&archives='.$v.'">'.$v.'</a>');
        
        printf($bloc, $items);
    }
?>