[add-on] Archive Messages

3rd party code for phpList

[add-on] Archive Messages

Postby youthevang » 4:28am, Mon 06 Sep, 2004

Hello everyone. I love phplist and I am thankful for all the people who work on it to make it a success. The one thing that people would like to see in phplist the most is an archived section. I have been racking my brain on this as well. I have a script that will read your database and output your messages. This is just a beta version but it is a start. If your address is http://lists.yourdomain.com/lists, then you will need to place the script here http://lists.yourdomain.com/archive.php. This is just a simple script that needs much more development like archiving per month and etc. I will continue to work on it further, but anyone is free to take it further if you like. Below is the code you can use.


<DOCTYPE>
<html>
<head><title>Archived Newsletters</title>
</head>

<body>
<mysql_connect>
</body>
</html>

You will need to replace database, username, and password with the correct info for your database. You can check out how the script works on my site at http://e-news.jpministries.com/archive.php. I am using two newsletter systems until I can fully develop this script, but phplist is the newsletter system at this address.

I hope that this is helpful to someone.
youthevang
phpList newbie
 
Posts: 4
Joined: 4:14am, Mon 06 Sep, 2004

Postby godyn » 11:50am, Mon 17 Jan, 2005

great !
Im looking forward to try it out.
godyn
PL Nut
 
Posts: 22
Joined: 1:08pm, Thu 28 Oct, 2004

Postby jfriesen » 6:44pm, Mon 14 Mar, 2005

Hello Joshua--

Thank you for the contribution. I'd love to have the archiving functionality.

I'm not quite sure how to use your script though. I changed the dbconnect values, but when pulled up in the browser, the script generates the following:

Code: Select all
No data.
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /var/www/html/newsletter/archive2.php on line 21


Also, can this be set to pull messages from one particular list (I don't want to have archived links to my test mailings!)?

I see that you do indeed have archiving working on your site:

http://e-news.jpministries.com/lists/archives.php

but I can't see what version of PHPlist you're using. (I'm using 2.9.3.)

Did you use the same code that you have posted here? If not, could you post your new code?

Thanks again,
JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

Archives

Postby youthevang » 10:10pm, Thu 07 Apr, 2005

Sorry, I have been neglecting the forums, but no longer. The script that I use on my website is actually a script used by lubtex. Please check out this thread. It does not work with the development versions, but I will see if I can try to figure it out.
youthevang
phpList newbie
 
Posts: 4
Joined: 4:14am, Mon 06 Sep, 2004

Postby jfriesen » 12:15am, Fri 08 Apr, 2005

Hi Joshua--

Thanks for your reply. It seems that the 2.9.3 version of PHPlist that I'm using has different function names from earlier versions and this is why the previously posted archive contribution doesn't work with the newer versions. I should have a revised contribution that works with 2.9.3 ready next week some time. I will post it when complete.
JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

archive.php contribution for 2.9.3

Postby jfriesen » 1:44am, Sun 10 Apr, 2005

Hello--

Try this code out:

Code: Select all
<?php  // April 2005 -> PHP (4>=5) PHPlist
/**
* @version $Id: archive.php, v.1.0, 04/09/2005, kalan
* @package Contribution to PHPlist 2.9.3
* @copyright (C) 2005 solutions_PHP, www.solutionsphp.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

// Include the common configurations for data host, user, password, name.
include("./config/config.php");


// Print the head section of our document ....
print('
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Archived Newsletters &raquo;</title>
<link href="styles/phplist.css" type="text/css" rel="stylesheet">
</head>
<body bgcolor="#ffffff" background="images/bg.png">

<a name="top"></a>
<div align=center>
<table cellspacing=0 cellpadding=0 width=710 border=0>
<tr>
<td bgcolor="#000000" rowspan=3><img height=1 alt="" src="images/transparent.png" width=1 border=0></td>
<td bgcolor="#000000"><img height=1 alt="" src="images/transparent.png" width=708 border=0></td>
<td bgcolor="#000000" rowspan=3><img height=1 alt="" src="images/transparent.png" width=1 border=0></td>
</tr>

<tr valign="top" align="left">
<td>
<!--TOP TABLE starts-->
<TABLE cellSpacing=0 cellPadding=0 width=708 bgColor=#ffffff border=0>
  <TR vAlign=top>
    <TD colSpan=2 rowspan="2" height="63" background="images/topstrip.png"><a href="http://www.phplist.com" target="_blank"><img src="images/masthead.png" border=0 width=577 height=75></a></TD>

    <TD align=left
      background="images/topstrip.png" bgcolor="#F0D1A3"><FONT
      size=-2>&nbsp;<I>powered by: </I><BR>&nbsp;<B>[<A class=powered
      href="http://www.php.net/" target=_new><I>PHP</I></A>]</B> + <B>[<A
      class=powered href="http://www.mysql.com/"
      target=_new>mySQL</A>]</B></FONT></TD></TR>
  <TR vAlign=bottom>
    <TD vAlign=bottom width=132
    background="images/topright.png" bgcolor="#F0D1A3"><SPAN
      class=webblermenu>PHPlist</SPAN></TD></TR>
  <TR>

    <TD bgColor=#000000><IMG height=1 alt=""
      src="images/transparent.png" width=20
      border=0></TD>
    <TD bgColor=#000000><IMG height=1 alt=""
      src="images/transparent.png" width=576
      border=0></TD>
    <TD bgColor=#000000><IMG height=1 alt=""
      src="images/transparent.png" width=132
      border=0></TD></TR>
  <TR vAlign=top>
    <TD>&nbsp;</TD>
<td><div align=left>');




// A very important data query ....
define("__QUERY__","select * from phplist_message,phplist_list,phplist_listmessage where phplist_list.id=phplist_listmessage.listid and phplist_message.id=phplist_listmessage.messageid and phplist_list.active=1");

// Decide whether to show a list of titles or show a specific message ....
if(!isset($_GET['x'])){

           if($DB = mysql_connect($database_host, $database_user, $database_password)){

             if(mysql_select_db($database_name)){

              if($RS = mysql_query(__QUERY__, $DB)){

               
                  while($_ROW = mysql_fetch_assoc($RS)){

                      // Print a list of sent newsletters ....
                      printf("<br /><h2>%s</h2><a href='%s?x=%s'>%s</a><br /><em>Sent: %s</em><br /><br />",
                      stripslashes($_ROW['name']),$_SERVER['PHP_SELF'],$_ROW['messageid'],$_ROW['subject'],$_ROW['sent']);

                  }
                 
                  if(mysql_num_rows($RS)<=0){
                      print("<br /><h2>No entries were found in the archive.</h2><br /><br /><a href='javascript:history.back();'>&laquo; Back</a>");
                  }

                 
                  mysql_free_result($RS);
                  mysql_close($DB);


               }else{

                  mysql_free_result($RS);
                  mysql_close($DB);
                 
                  print("<h2>Could not retrieve requested information.</h2>");
                  exit(0);

               }
            }else{
                mysql_close($DB);
                print("<h2>Could not select database.</h2>");
            }
         }else{
             print("<h2>Could not connect to database.</h2>");
         }
 
}else{

           if($DB = mysql_connect($database_host, $database_user, $database_password)){

             if(mysql_select_db($database_name)){

              $_QUERY = sprintf("select * from phplist_message where id=%s",$_GET['x']);

              if($RS = mysql_query($_QUERY, $DB)){

                 $_ROW = mysql_fetch_assoc($RS);
                 
                 
                 // Print the select newsletter ....
                 printf("<div align='left'><br /><a href=./%s>&laquo; Archives</a></div>".
                         "<h1 align='center'>%s</h1>".
                         "<br>Sent: %s</em><hr /><br />".
                         "<br /><div align='center'><div align='left'>%s%s</div></div>",
                         basename($_SERVER['PHP_SELF']),
                         $_ROW['subject'],
                         $_ROW['sent'],$_ROW['message'],
                         $_ROW['footer']);
                         

                  if(mysql_num_rows($RS)<=0){
                      print("<br /><h2>Could not retrieve the selected message.</h2><br /><br /><a href='javascript:history.back();'>&laquo; Back</a>");
                  }


                  mysql_free_result($RS);
                  mysql_close($DB);


               }else{

                  mysql_free_result($RS);
                  mysql_close($DB);

                  print("<h2>Could not retrieve requested information.</h2>");
                  exit(0);

               }
            }else{
                mysql_close($DB);
                print("<h2>Could not select database.</h2>");
            }
         }else{
             print("<h2>Could not connect to database.</h2>");
         }


}


// Print our document's footer ....
print('
</div>
</td>
<td>
<div class="menutableright">
</div>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#000000" colspan=3>
<img height=1 alt="" src="images/transparent.png" width=1 border=0>
</td>
</tr>
<tr>
<td bgcolor="#000000">
<img height=1 alt="" src="images/transparent.png" width=1 border=0>
</td>
<td bgcolor="#ff9900" class="bottom">&copy;
<a href="http://tincan.co.uk" target="_tincan" class="urhere">tincan limited</a> |
<a class="urhere" href="http://www.phplist.com" target="_blank">phplist</a>
</td>
<td bgcolor="#000000">
<img height=1 alt="" src="images/transparent.png" width=1 border=0>
</td>
</tr>
<tr>
<td bgcolor="#000000" colspan=3>
<img height=1 alt="" src="images/transparent.png" width=1 border=0>
</td>
</tr>
<tr>
<td colspan=3><img height=3 alt="" src="images/transparent.png" width=1 border=0>
</td>
</tr>
<tr>
<td colspan=3>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>');


?>


Save this as archive.php.
Add the file to your .htaccess file.
Access with browser.
You should see a list of the previously sent messages for all active lists.
You can change the HTML code in the header/footer sections to customize the layout.
All of the markup is embedded in the script, and it uses the PHPlist style
sheet.

Please try this out and let me know what you think!
JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

Postby onga » 5:56pm, Sun 10 Apr, 2005

are we suppose to change the db name, user, password info in this script or does it already pull it up via the include config.php

I wasn't able to get it to work it says parse error

i have both variations from solutionsphp.com and from lubtex and neither are working as of yet,


i'm assuming the include config will pull the db info from that file ?
Last edited by onga on 11:34pm, Sun 10 Apr, 2005, edited 2 times in total.
onga
PL Nut
 
Posts: 20
Joined: 4:49am, Fri 08 Apr, 2005

Postby jfriesen » 6:02pm, Sun 10 Apr, 2005

Hello--

No need to set db connect values; the script grabs them from the config file.

Parse error... hmm, you are using PHPlist v.2.9.3? What line did the parse error occur on?

JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

Postby onga » 1:37pm, Tue 12 Apr, 2005

line 73

I belive i'm using phplist 2.9.4

i copied and pasted the code again in a page and now the parse error is at line 10 which is the include("./config/config.php");

i also tried removing the ./ but that didn't change anything

i see this script is for 2.9.3 is there any reason why it wouldn't work with 2.9.4 ?
onga
PL Nut
 
Posts: 20
Joined: 4:49am, Fri 08 Apr, 2005

Postby jfriesen » 2:52pm, Tue 12 Apr, 2005

Hmm... I can't say anything abou 2.9.4, not having used it myself. I can say that the differences between 2.8.x and 2.9.3 are such that a new archive script had to be composed, so it's possible that there is another change in 2.9.4 that inhibits this script's functionality.

However, what I find curious is the location of your parse errors, first on line 73, which for me is this:

Code: Select all
           if($DB = mysql_connect($database_host, $database_user, $database_password)){


Same for you? Then your second parse error is the link to the config.php file, again having to do with your mySQL connection. An idea: what happens if you replace the config line with your db connection info:

Code: Select all
$database_host = "localhost";
$database_name = "db_name";
$database_user = "youruserid";
$database_password = 'yourpasswd';


Does that help? Hope so!
JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

Postby onga » 5:15pm, Tue 12 Apr, 2005

that didn't work still line 10 issue

phplist is working fine so the db config.php must be fine

not sure why it would have connecting issues

doesn't everyone update to the current version regularly ?

I would think the most updated version would be the easier to configure

orginally what happen is when i copy/paste code into page the <?php was not activated only regular text. Only when I added a space after it the code began to look lik php (does this make sense?) i know nothing about php :)

the print ('
area is all red is this correct ?
onga
PL Nut
 
Posts: 20
Joined: 4:49am, Fri 08 Apr, 2005

Postby jfriesen » 7:29pm, Tue 12 Apr, 2005

Sorry this isn't working out smoothly for you!

doesn't everyone update to the current version regularly? I would think the most updated version would be the easier to configure


While I love PHPlist's functionality, I'm personally very cautious about upgrading. The version 2.9.x are considered development versions and are not necessarily stable. See: http://www.phplist.com/forums/viewtopic.php?t=2507&highlight=

orginally what happen is when i copy/paste code into page the <?php was not activated only regular text


Perhaps the code formatting of the file I pasted is causing problems. I tried attaching the file to this post, but .php/.txt is not allowed. I'll try PMing it to you. If that fails I can email it.
JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

Postby jfriesen » 7:31pm, Tue 12 Apr, 2005

PMing is disabled on this board. Drop me a line at jenniefriesen@yahoo.ca and I will email you the source file.
JF ;)

UPDATE: The file I emailed to Onga did the trick, so the issue must have something to do with how the script I pasted into the forum is formatted. To avoid this problem, the archive.php script is now available as a download from here: http://www.solutionsphp.com/contribute/phplist/archive.zip
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

archive folder dir

Postby onga » 9:08am, Mon 18 Apr, 2005

is there a way to place archive.php in a dir called 2005/ ?

i want to separate archive form signup list in order to password protect the archives

i tried adding a folder called 2005 an placing archive.php inside but it resulted in error seems like its set up to remain in the list dir i check the file and couldn't find any refernces to path

any ideas ?
onga
PL Nut
 
Posts: 20
Joined: 4:49am, Fri 08 Apr, 2005

Postby jfriesen » 2:00am, Thu 21 Apr, 2005

Ooops, thought I replied to this, but obviously forgot to hit "submit"!

Onga, what is the error message you receive, is it a database connect error? There is a path at the top of the script to the config file. Try adjusting that to your folder structure, and perhaps it will be fixed...?

Let us know what happens!
JF ;)
jfriesen
PL Geek
 
Posts: 72
Joined: 5:43am, Wed 26 Jan, 2005

Next

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: psykotik and 0 guests