[add-on] Archive Messages

3rd party code for phpList

Re: [add-on] Archive Messages

Postby Dragonrider » 8:44pm, Sat 31 Oct, 2009

lwc wrote:Are you sure it's the right folder? You need the folder that has the other files.

It was the correct folder, it turns out sisyphe was using the wiki version which has several formatting errors, could you perhaps attach your lastest version to a post here please?
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [add-on] Archive Messages

Postby lwc » 3:45pm, Mon 02 Nov, 2009

I've fixed the format errors back in 13 Oct (and added a new version
later that day) . Are you sure you re-copied and pasted since then?
lwc
PL Nut
 
Posts: 35
Joined: 3:00pm, Fri 13 Feb, 2009

Re: [add-on] Archive Messages

Postby Dragonrider » 8:29pm, Mon 02 Nov, 2009

lwc wrote:I've fixed the format errors back in 13 Oct (and added a new version
later that day) . Are you sure you re-copied and pasted since then?

I copied it from the Wiki page this week, my first attempt, other than copy & pasting the 1.6 version from the topic. 1.9 has got too many errors when I copied it from the wiki page, as did sisyphe.

Where should we be looking for the latest upload please?
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [add-on] Archive Messages

Postby lwc » 9:44am, Tue 03 Nov, 2009

Since the fix, I have no problem copying from the Wiki. Did you officially use the "Grab" button?

If you want "the latest upload", you can try getting the admin letting me access to SVN.
lwc
PL Nut
 
Posts: 35
Joined: 3:00pm, Fri 13 Feb, 2009

Re: [add-on] Archive Messages

Postby Dragonrider » 11:55am, Tue 03 Nov, 2009

lwc wrote:Since the fix, I have no problem copying from the Wiki. Did you officially use the "Grab" button?

Tried that, just as many errors copied across.

If you want "the latest upload", you can try getting the admin letting me access to SVN.

No access there myself, sorry.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [add-on] Archive Messages

Postby lwc » 12:13pm, Tue 03 Nov, 2009

Sorry, you were right. I've just fixed the wrapping again. Both copying & pasting and "Grab" work now. I wonder if it's possible that some program in the Wiki unwraps it every once in a while by itself.
lwc
PL Nut
 
Posts: 35
Joined: 3:00pm, Fri 13 Feb, 2009

Re: [add-on] Archive Messages

Postby Dragonrider » 1:17pm, Tue 03 Nov, 2009

Thank you very much, GRABbed it perfectly now. uploaded and it works fine.

Two queries though, 1) at the bottom of the page it says version 2.10.5 rather than 2.10.10 which my phpList is and 2) all the links show as orange boxes until clicked, is this likely to be a CSS issue, or because my lists folder is not within a phplists folder?

Thanks again.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [add-on] Archive Messages

Postby lwc » 3:03pm, Tue 03 Nov, 2009

The code just takes the CSS and version number from laytout ID #1 (or $_GET['layoutID']).

BTW, I don't see a version number at all in any public pages (regardless of this file)...
lwc
PL Nut
 
Posts: 35
Joined: 3:00pm, Fri 13 Feb, 2009

Re: [add-on] Archive Messages

Postby ITCons » 5:33pm, Sat 21 Nov, 2009

Hello all
I wrote another version of the mailinglist archive. Two things are different, though:

1. Archive is accessed via a subfolder of the regular app root, eg. archive/index.php

2. Archived messages can be translated with the google translator

The second objective being the more important one in creating the archive, I attach the code to this post. In hope someone can profit from it.

Testsite can be found here: http://www.ascsoftware.ch/mailer/archiv/

Instruction: copy index.txt to your app subfolder. Rename to index.php

Reviews and comments welcome!

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
    * @modified by: Adrian Oliver Schmid, www.ascsoftware.ch
    * @if you have any questions, write to: me@ascsoftware.ch
    * @released uder the GPL Licence, use at own risk!
    */

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

    // Some handy variables
    $baselang="de"; // source language for translation combo
    $website="www.ascsoftware.ch"; // website from where translation is coming from
    $title="ASC Software Newsarchiv"; // Title for your archive

    if (!(isset($_GET['listID'])) || ($_GET['listID']<1) ) {
       $listID = 0;      // Later in the code, if $listID==0, it just lists the active lists.
    } else {
       $listID = intval($_GET['listID']);
    }

    // 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>
    <script type="text/javascript">
    //<![CDATA[
      if(top.location!=self.location)top.location=self.location;
      window["_tipoff"]=function(){};window["_tipon"]=function(a){};
      function doTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;
      if(location.hostname=="'.$website.'" && lang_pair=="'.$baselang.'|'.$baselang.'")return;
      else if(location.hostname!="'.$website.'" && lang_pair=="'.$baselang.'|'.$baselang.'")location.href=unescape(gfg("u"));
      else if(location.hostname=="'.$website.'" && lang_pair!="'.$baselang.'|'.$baselang.'")location.href=
      "http://translate.google.com/translate?client=tmpg&hl='.$baselang.'&langpair="+lang_pair+"&u="+escape(location.href);
      else location.href="http://translate.google.com/translate?client=tmpg&hl=de&langpair="+lang_pair+"&u="+unescape(gfg("u"));}
      function gfg(name) {name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS="[\\?&]"+name+"=([^&#]*)";
      var regex=new RegExp(regexS);
      var results=regex.exec(location.href);
      if(results==null)return "";return results[1];}
    //]]>
    </script>
    <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><h1>'.$title.'</h1>');

    // A very important data query ....
    //$SETQ="select * from ".$table_prefix."message,".$table_prefix."list,".$table_prefix."listmessage where "
    //.$table_prefix."list.id=".$table_prefix."listmessage.listid and ".$table_prefix."message.id=".$table_prefix."listmessage.messageid and "
    //.$table_prefix."message.status='sent' and " .$table_prefix."list.active=1 ORDER by ".$table_prefix."message.sent";
    $SETQ="select * from ".$table_prefix."message,".$table_prefix."list,".$table_prefix."listmessage where "
    .$table_prefix."list.id=".$listID." and "
    .$table_prefix."list.id=".$table_prefix."listmessage.listid and "
    .$table_prefix."message.id=".$table_prefix."listmessage.messageid and "
    .$table_prefix."message.status='sent' and "
    .$table_prefix."list.active=1 ORDER by ".$table_prefix."message.sent DESC";

    define("__QUERY__",$SETQ);

    // Decide whether to show a list of titles or show a specific message ....
    if(!isset($_GET['message'])){
        if ($listID == 0) {   // no listID was specified: list all active lists.
           if($DB = mysql_connect($database_host, $database_user, $database_password)){
               if(mysql_select_db($database_name)){
                   $_QUERY = "select * from ".$table_prefix."list where active=1";
                   if($RS = mysql_query($_QUERY, $DB)) {
                        if(mysql_num_rows($RS)<=0) {
                           print("<br /><h2>No active lists found.</h2><br /><br /><a href='javascript:history.back();'>&laquo; Back</a>");
                        } else {
                            while($_ROW = mysql_fetch_assoc($RS)){
                                printf('<br /><h2><a href="./%s?listID='.$_ROW['id'].'">'.$_ROW['name'].'</a></h2>', basename($_SERVER['PHP_SELF']));
                                printf("<p>".$_ROW['description']."</p>\n\n");
                            }
                        }

                        mysql_free_result($RS);
                        mysql_close($DB);
                   }else{
                        mysql_free_result($RS);
                        mysql_close($DB);

                        print("<h2>I 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  // a list was selected
        {
               if($DB = mysql_connect($database_host, $database_user, $database_password)){
                 if(mysql_select_db($database_name)){
                  printf('<p><a href="javascript:history.back()">&laquo; Back</a></p>');
                  if($RS = mysql_query(__QUERY__, $DB)){
                     while($_ROW = mysql_fetch_assoc($RS)){
                          // Print a list of sent newsletters ....
                          printf("<font color=#FFFFFF>%s</font><br><a href='%s?message=%s'>%s</a><br>Newsletterversand vom %s <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 ".$table_prefix."message where id=%s",$_GET['message']);
                  if($RS = mysql_query($_QUERY, $DB)){

                  // Print translate header
                  printf('<div align="left"><p><small>&Uuml;bersetzung | Traduction | Traduzione | Translation</p>');
                  printf('<select onchange="doTranslate(this);" class="dropdown"><option value="">Select Language</option>
                  <option value="'.$baselang.'|en">English</option>
        <option value="'.$baselang.'|hr">Croatian</option>
        <option value="'.$baselang.'|cs">Czech</option>
        <option value="'.$baselang.'|da">Danish</option>
        <option value="'.$baselang.'|nl">Dutch</option>
        <option value="'.$baselang.'|fi">Finnish</option>
         <option value="'.$baselang.'|fr">French</option>
        <option value="'.$baselang.'|de">German</option>
        <option value="'.$baselang.'|it">Italian</option>
        <option value="'.$baselang.'|no">Norwegian</option>
        <option value="'.$baselang.'|pl">Polish</option>
        <option value="'.$baselang.'|pt">Portuguese</option>
                  <option value="'.$baselang.'|ro">Romanian</option>
        <option value="'.$baselang.'|es">Spanish</option>
        <option value="'.$baselang.'|sv">Swedish</option>
        <option value="'.$baselang.'|ca">Catalan</option>
        <option value="'.$baselang.'|hu">Hungarian</option></select></div>');

                     $_ROW = mysql_fetch_assoc($RS);
                                         
                     // Print the select newsletter ....
                     printf('<div align="left"><br /><a href="javascript:history.back()">&laquo; Back</a><a href=./%s>&laquo; Liste</a></div><br>
                             <div align="left">Newsletter
                             <h2 align="left">%s</h2></div>
                             <br>Datum: %s</em><hr /><br />
                             <div align="left"><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://www.ascsoftware.ch" target="_asc" class="urhere">asc software</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>');


    ?>

ITCons
phpList newbie
 
Posts: 4
Joined: 4:53pm, Sat 21 Nov, 2009

Re: [add-on] Archive Messages

Postby H2B2 » 2:29am, Wed 25 Nov, 2009

ITCons wrote:I wrote another version of the mailinglist archive. Two things are different, though:

1. Archive is accessed via a subfolder of the regular app root, eg. archive/index.php

2. Archived messages can be translated with the google translator

The second objective being the more important one in creating the archive, I attach the code to this post. In hope someone can profit from it.

Haven't tried it yet, but looks like a very useful contrib. Thanks! :D
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: [add-on] Archive Messages

Postby jgkiefer » 7:13pm, Fri 27 Nov, 2009

ITCons wrote:I wrote another version of the mailinglist archive. Two things are different, though:

1. Archive is accessed via a subfolder of the regular app root, eg. archive/index.php

2. Archived messages can be translated with the google translator

The second objective being the more important one in creating the archive, I attach the code to this post. In hope someone can profit from it.


I am a complete newbie to PhPList and this worked right away!
Is there a way to set it so it just shows one list and not all of them?
jgkiefer
phpList newbie
 
Posts: 2
Joined: 7:10pm, Fri 27 Nov, 2009

Re: [add-on] Archive Messages

Postby Susa38 » 7:14pm, Mon 01 Mar, 2010

I've tried the Guest solution and it works fine.
It show the list of message and after show the message like in the mail.

But in if i send a newsletter with Attachment in the list archive o when show the message in the the web doesn't show the files attached in the mail.
¿is it possible? or the is a solution to show the attached files?
Susa38
phpList newbie
 
Posts: 2
Joined: 3:04pm, Mon 01 Mar, 2010

Re: [add-on] Archive Messages

Postby hotnuts21 » 9:12pm, Wed 21 Jul, 2010

I have a weird error, I have modified the code so that the newsletter shows in the newsletter format which is subscribe page id 2. I also have the <<archives link going to my default (id1) subscription page layout, which matches the website!

However if I got site/lists/archive.php it always loads in the phplist orange template and not my default layout. I have even echo'd out the $layoutID and its 1 the same as my website template.

Any ideas why this is? Its rather annoying!
hotnuts21
phpList newbie
 
Posts: 4
Joined: 8:58pm, Mon 19 Jul, 2010

Re: [add-on] Archive Messages

Postby leviathan » 12:50am, Wed 22 Sep, 2010

@ITCons : with your script, if you enter the URL :
http://localhost/phplist/public_html/li ... list_admin

You can show all username and password of the administrator. Escape $_GET['message'] before use in the SQL query
leviathan
phpList newbie
 
Posts: 1
Joined: 12:41am, Wed 22 Sep, 2010

Re: [add-on] Archive Messages

Postby ITCons » 8:03am, Mon 27 Sep, 2010

Thank you for pointing the security hick out to me.
As a matter of fact, the few more lines of code take care to check if the message variable is a number or contains a string. I the latter case, the query will be removed and the standard list with the newsletter front displayed.

Here are the lines:
Code: Select all
   // Special treatment for list ID
    if(is_numeric($_GET['listID']))
    {
      if (!(isset($_GET['listID'])) || ($_GET['listID']<1) ) {
         $listID = 0;      // Later in the code, if $listID==0, it just lists the active lists.
      } else {
         $listID = intval($_GET['listID']);
      }
    } else {  // if we have a query or something else than a number >>> null it!
      unset($_GET['listID']);
    }

    // Special treatment for message ID
    if(is_numeric($_GET['message']))
    {
      $messageID = $_GET['message'];
    } else {  // if we have a query or something else than a number >>> null it!
      unset($_GET['message']);
    }


Add these at the top of the script, right around where listID gets called.

Thanks again - hope this fixes the vulnerability by escaping the two variables.
ITCons
phpList newbie
 
Posts: 4
Joined: 4:53pm, Sat 21 Nov, 2009

PreviousNext

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

Who is online

Users browsing this forum: No registered users and 2 guests