[mod] link to view an online version of the message

3rd party code for phpList

Postby pedromau » 1:45pm, Wed 24 Sep, 2008

My mistake :P

<FilesMatch>

Although, there's an error...
Parse error: syntax error, unexpected '}' in /home/fabricad/public_html/newsletter/email.php on line 98

??????
pedromau
PL Nut
 
Posts: 30
Joined: 12:58am, Wed 05 Mar, 2008

Postby Guest » 12:43pm, Tue 18 Nov, 2008

Pedro:

Add email.php in the .htaccess:
Code: Select all
...connector.php|upload.php|email.php)..etc


And comment line 98 and line 142 like this:
Code: Select all
<?php //} // etc...


Then, configure the db params and the require route (line 28).
Guest
 

Re: Got another question

Postby thongta » 5:51am, Sat 17 Jan, 2009

lefty4080 wrote:I did not want to use this page within the PHP List as I wanted to make a archive page in my site. I am using Joomla so I removed the header information of the archive page. Then I used a wrapper in Joomla to show th e archive.

It worked great but it is not taking on the style of my site. How do I get it to use the style sheet of my joomla site or any style for that matter?

Any help greatly appreciated.

Thanks

lefty4080, please take a look at this topic.
thongta
PL Nut
 
Posts: 22
Joined: 3:19pm, Mon 06 Mar, 2006

Re: [mod] link to view an online version of the message

Postby roseple » 8:29am, Tue 17 Nov, 2009

Hi..

I follow what nachotronics advice in post # 6. Yes, the link "If you are having trouble...." is present. And when you click that link you will be directed to http://www.mydomain.com/lists/static/169.html but with the error 404 Not found, The requested URL /lists/static/169.html was not found on this server. What is seem to be the problem? What will I need to do to eliminate that error and view the online version of the message.

Please help.
Thanks..
roseple
phpLister
 
Posts: 6
Joined: 3:32am, Fri 13 Nov, 2009

Re: [mod] link to view an online version of the message

Postby spgd01 » 4:37pm, Tue 19 Jan, 2010

roseple,

in the code you need to remove the trialling slash (/) after static. What the script does is it creates a file called "static169.html" and then you link to that file. The reference to the file is in two locations. One under;
"
# some readers fail when it doesn't
if (!preg_match("#<body.*</body>#ims",$htmlmessage)) { ............
"
the other under

"
#write to static file here ......
"
It is important to make sure both instances of "/newsletter/static" is the same.
spgd01
phpList newbie
 
Posts: 3
Joined: 3:35pm, Tue 19 Jan, 2010

Re: [mod] link to view an online version of the message

Postby spgd01 » 4:48pm, Tue 19 Jan, 2010

The link "view online" dose not show when using a complete template with a <body> tag. So I modified the code accordingly. (Commented out the part looking for the body tag) It isn't pretty because the link to view online is outside the <body> tag, but it works. the only other option is to put the top half of your template in the code below. But then you couldn't use different templates and different styles for messages. You are stuck with the one template.

What would work best would be a place holder tag that we could use inside of a template and then place the link to view online anywhere in the template. If anyone has a better way to make this work with a template please post it here.

Code: Select all
## check that the HTML message as proper <head> </head> and <body> </body> tags
  # some readers fail when it doesn't
 # if (!preg_match("#<body.*</body>#ims",$htmlmessage)) {
   if ($GLOBALS["generate_static"] == 1){
        $htmlmessagestatic = '<meta><title>'.$message["subject"].'</title><body><div>Message sent on '.date(" m, j, Y").'<br></div>'.$htmlmessage.'</body>';
     $htmlmessage = '<div align="center"><p style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 10px; color: #FFF;">If you are having trouble viewing this message, <a href="http://www.'.getConfig("domain").'/emaillists/messages/newsletter'.$messageid.'.html">click here to view on-line</a>.</p>'.$htmlmessage.'</div><';
   }else{   
      $htmlmessage = '<body>'.$htmlmessage.'</body>';
   }
#  }
   if (!preg_match("#<head>.*</head>#ims",$htmlmessage)) {
    if (!$adddefaultstyle) {
     $defaultstyle = "";
    }
    $htmlmessage = '<head>
        <meta content="text/html;charset='.$cached[$messageid]["html_charset"].'" http-equiv="Content-Type">
        <title></title>'.$defaultstyle.'</head>'.$htmlmessage;
  }

#write to static file here
  if ($GLOBALS["generate_static"] == 1){
   $static = '../messages/newsletter'.$messageid.'.html';
   $statichandle = fopen($static, 'w');
   fwrite($statichandle, $htmlmessagestatic);
   fclose($statichandle);
}
spgd01
phpList newbie
 
Posts: 3
Joined: 3:35pm, Tue 19 Jan, 2010

Re: [mod] link to view an online version of the message

Postby connections » 10:19am, Wed 03 Mar, 2010

Hello everyone, this is my first post to this forum. :)

How can I get this mod to create the static copy to my server? Everything works fine, but I can't get the php to write an html static file (eg. static/123.html).

Here is the code I am using at present. I have got it working so that the 'view an online version' line points to a file that I have manually created and saved on my server called 'newsletter.php' but I would love it if it could automatically create static file instead.
Code: Select all
## check that the HTML message as proper <head> </head> and <body> </body> tags
     # some readers fail when it doesn't
     # if (!preg_match("#<body.*</body>#ims",$htmlmessage)) {
       if ($GLOBALS["generate_static"] == 1){
            $htmlmessagestatic = '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>'.$message["subject"].'</title><div align="center" style="font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 10px;">Message sent on '.date("j, m, Y").'<br><br></div>'.$htmlmessage.'';
         
         #$htmlmessage = '<div align="center" style="color:#000000; font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 10px;">If you are having trouble viewing this message, <a href="http://www.'.getConfig("domain").'/lists/static/'.$messageid.'.html">click here</a>.<br><br></div>'.$htmlmessage.'';
         
       $htmlmessage = '<div align="center" style="color:#000000; font-family: Arial,Verdana,Helvetica,sans-serif; font-size: 10px;">If you are having trouble viewing this message, <a href="http://www.'.getConfig("domain").'/newsletter.php">click here</a>.<br><br></div>'.$htmlmessage.'';
       }else{   
          $htmlmessage = '<body>'.$htmlmessage.'</body>';
       }
     # }

 
  #write to static file here
  if ($GLOBALS["generate_static"] == 1){
   $static = '../static/'.$messageid.'.html';
   $statichandle = fopen($static, 'w');
   fwrite($statichandle, $htmlmessagestatic);
   fclose($statichandle);
}

I have created a folder called 'static' in the newsletter directory with Permissions set to 755.
I have removed <body></body> tags.
I am using a Standard template.
I have the 'generate_static == 1' file in /config directory set to 1.

Do you think I should check with my host company to see if the write function disabled on my account? Any help would be appreciated.
connections
phpLister
 
Posts: 11
Joined: 2:41pm, Tue 02 Mar, 2010

Re: evitar Error 404

Postby reus » 3:44pm, Thu 06 May, 2010

pedromau wrote:Forbidden
You don't have permission to access /newsletter/email.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Pedro:
Thi htaccess of PHPList only permit execute php file with this names: index.php|dl.php|ut.php|lt.php|download.php, because the configuration (.htaccess file) says:
Code: Select all
<FilesMatch "(index.php|dl.php|ut.php|lt.php|download.php)$">


To repair this problem add email.php to .htaccess file or rename the email.php file to index.php

Byes
reus
PL Nut
 
Posts: 18
Joined: 1:56am, Wed 13 May, 2009

Re: [mod] link to view an online version of the message

Postby vancoovur » 8:44pm, Thu 02 Sep, 2010

Further to the mod post by harty83...
The page that's created on the web server retains the footer information, such as 'unsubscribe', 'update preferences' and 'forward this message'. When the 'update preferences' link is selected on the page residing on the web server it defaults to one specific user no matter who clicks the link. Not good.

Is it possible to write the web server page without including the footer information (and incorrect preferences link)?
vancoovur
PL Geek
 
Posts: 120
Joined: 1:48am, Wed 28 Jan, 2009
Location: Canada

Mod for link to view an online version : problem...

Postby trucmuche2005 » 3:58pm, Wed 08 Dec, 2010

Hello !

I tried to follow instructions here to add to my newsletters a link to view the online version of the newsletter, but without success.

Here are the problems :
1) the link to the online version is only added to the text version of my newsletter, and NOT to the HTML version. How can I add it to the HTML version ??
2) the archive files "newsletter-3.html","newsletter-4.html", ... are created, but they are empty !

How can I do to make it work ?


Here is what I did :
1) I created a directory "archives" in the root directory of phpList (beside the admin directory) and I set permissions to 777 (just for the test).
2) I added in the config.php file those lines :
Code: Select all
## turn on option to create a link in each email to a static copy of the message in case users have a hard time viewing message
$generate_static = 1;

3) I backuped the file sendemaillib.php and modified it this way :
(a) I removed the lines
Code: Select all
      ## check that the HTML message as proper <head> </head> and <body> </body> tags
      # some readers fail when it doesn't
      if (!preg_match("#<body.*</body>#ims",$htmlmessage)) {
        $htmlmessage = '<body>'.$htmlmessage.'</body>';
      }
      if (!preg_match("#<head>.*</head>#ims",$htmlmessage)) {
        if (!$adddefaultstyle) {
         $defaultstyle = "";
        }
        $htmlmessage = '<head>
            <meta content="text/html;charset='.$cached[$messageid]["html_charset"].'" http-equiv="Content-Type">
            <title></title>'.$defaultstyle.'</head>'.$htmlmessage;
      }
      if (!preg_match("#<html>.*</html>#ims",$htmlmessage)) {
        $htmlmessage = '<html>'.$htmlmessage.'</html>';
      }

and I replaced them by
Code: Select all
      if (!preg_match("#<body.*</body>#ims",$htmlmessage)) {
       if ($GLOBALS["generate_static"] == 1){
       $htmlmessagestatic = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>'.$message["subject"].'</title><body><div align="center" style="color:#003366; font-family: sans-serif; font-size: 12px; font-weight:bold">Message envoyé le '.date("j m Y").'<br></div>'.$htmlmessage.'</body>';

       $htmlmessage = '<body><div align="center" style="color:#003366; font-family: sans-serif; font-size: 9px;">Si cet email est incomplet ou illisible, <a href="http://www.'.getConfig("domain").'/newsletter/archives/newsletter-'.$messageid.'.html">cliquez ici</a>.<br></div>'.$htmlmessage.'</body>';
       }else{   
          $htmlmessage = '<body>'.$htmlmessage.'</body>';
       }
      }

    #write to static file here
      if ($GLOBALS["generate_static"] == 1){
       $static = '../archives/newsletter-'.$messageid.'.html';
       $statichandle = fopen($static, 'w');
       fwrite($statichandle, $htmlmessagestatic);
       fclose($statichandle);
    }


Where is the mistake ?

Thank you very much for your valuable help !!

Trucmuche
trucmuche2005
PL Nut
 
Posts: 18
Joined: 11:04am, Thu 25 Nov, 2010

Re: [mod] link to view an online version of the message

Postby trucmuche2005 » 4:09pm, Sun 12 Dec, 2010

Hello !

Could someone help me, please ? I didn't managed to put the link into the HTML version...

Many many many thanks for your valuable help !

Trucmuche
trucmuche2005
PL Nut
 
Posts: 18
Joined: 11:04am, Thu 25 Nov, 2010

Re: [mod] link to view an online version of the message

Postby bhup18 » 6:27pm, Thu 16 Dec, 2010

Same here, doesn't seem to work in HTML messages.

I think modifying this to be used with a TAG is much more efficient. Back to the drawing board.
bhup18
phpLister
 
Posts: 11
Joined: 8:26pm, Wed 15 Dec, 2010

Re: [mod] link to view an online version of the message [2]

Postby solmar » 3:04pm, Tue 15 Feb, 2011

Adding two cents to the code below by nachotronics, that we chose for our on line newsletter display.
PHPlist 2.11.5

- On 5th line, in $htmlmessagestatic definition, the variable $message["subject"] must become $messageid["subject"]
- After "write to static file here", the relative path must become a full file system path. This might depend on our particular PHP configuration, but anyway, writing a full path is normally fail-safe.

The following code is already corrected, replace "[real file system path]" with yours. If the path is unknown, upload a phpinfo.php file to the server, open it in the browser and see where the web server root is located.

I figured out I didn't want the static link on the actual static page hosted on the server, instead I wanted some "Published on DATEHERE", maybe also add styles to the text, and a title. So here goes instead of the above:

Code: Select all
## check that the HTML message as proper <head> </head> and <body> </body> tags
  # some readers fail when it doesn't
  if (!preg_match("#<body.*</body>#ims",$htmlmessage)) {
   if ($GLOBALS["generate_static"] == 1){
        $htmlmessagestatic = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>'.$messageid["subject"].'</title><body><div align="center" style="color:#003366; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; font-weight:bold">Message sent on '.date("j, m, Y").'<br></div>'.$htmlmessage.'</body>';
     $htmlmessage = '<body><div align="center" style="color:#003366; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; font-weight:bold">If you are having trouble viewing this message, <a href="http://www.'.getConfig("domain").'/newsletter/static/'.$messageid.'.html">click here</a>.<br></div>'.$htmlmessage.'</body>';
   }else{   
      $htmlmessage = '<body>'.$htmlmessage.'</body>';
   }
  }

Notice we save two different versions of the same message in two variables
And we need to set the saved file to our static version:

Code: Select all
  #write to static file here
  if ($GLOBALS["generate_static"] == 1){
   $static = '/var/[real file system path]/static/'.$messageid.'.html';
   $statichandle = fopen($static, 'w');
   fwrite($statichandle, $htmlmessagestatic);
   fclose($statichandle);
}



If there are still problems, turn on debugging by putting at the very beginning of sendemaillib.php

ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);

Create a campaign and send a test message to yourself. When the page reloads, PHPlist will show any error message, included those related to the inability of creating the static version and/or writing it. These debug messages must be forwarded to a developer.
solmar
PL Nut
 
Posts: 20
Joined: 5:16pm, Thu 26 Jun, 2008

Re: [mod] link to view an online version of the message

Postby jjbgoode » 6:16pm, Wed 11 May, 2011

vancoovur wrote:Further to the mod post by harty83...
The page that's created on the web server retains the footer information, such as 'unsubscribe', 'update preferences' and 'forward this message'. When the 'update preferences' link is selected on the page residing on the web server it defaults to one specific user no matter who clicks the link. Not good.

Is it possible to write the web server page without including the footer information (and incorrect preferences link)?


After following lefty4080's install instructions, I found a function that removes tags from a string by id or class using regex. Since my entire footer is in a div with the id of "footer", I add the function to the top of the sendemaillib.php file. After the line that starts with $htmlmessagestatic, I applied the function to the $htmlmessage variable like so:

stripID("footer", $htmlmessage).

This removed the entire footer div from the html file without affecting the emails.

This might not be the cleanest or most appropriate method, but it was a quick fix that worked very well for me. I hope this helps out you or anyone who has had this problem.
jjbgoode
phpLister
 
Posts: 8
Joined: 4:13pm, Thu 18 Nov, 2004
Location: CA

Re: [mod] link to view an online version of the message

Postby barrancoguillaume » 11:32am, Thu 02 Feb, 2012

Hi all,
I used the solution given by harty83 on 2.10.17 version and I get the link on my messages.
But when I click on it, I have this error message (in white on a red background) :
Code: Select all
Database error 1064 while doing query You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where messageid = 8 and uniqid = "91ce873d2ef07e6f075aeb14d1e3d020" order by mod' at line 1

It's the only thing I have on the page.

I put a track of the query in vm.php and saw that the variable $GLOBALS["tables"]["messageview"] isn't pass to the query so I have an empty from clause.
I looked on the database but I haven't found a table that look like the one vm.php is searching for (a table with the fields data, messageid and uniqid).

Did someone find the solution ?

Thanks by advance
barrancoguillaume
phpLister
 
Posts: 6
Joined: 1:16pm, Wed 01 Feb, 2012

PreviousNext

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

Who is online

Users browsing this forum: No registered users and 1 guest