Fully integrated into site, with small sign up form starter

Show us your phpList site

Fully integrated into site, with small sign up form starter

Postby clubwager » 12:27pm, Thu 23 Aug, 2007

I have fully integrated phplist 2.10.4 into my site.

I have a small form for email submission on every page. When it is submitted it goes to the full form page for more selections. Look at http://clubwager.net.

The full form is at http://clubwager.net/lists/?p=subscribe&id=15

***SPAM*** Alerts use the rss function.

I incorporated captcha using SOLMETRA FormValidator from http://www.spaweditor.com/en/disp.php/en_products/en_formvalidator/en_formvalidator_intro
Comments are welcome.
Last edited by clubwager on 9:56am, Tue 26 May, 2009, edited 1 time in total.
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Postby Dragonrider » 1:46pm, Thu 23 Aug, 2007

Hi Dave,

Whilst the subject matter does not appeal to me personally, gotta say That is a VERY good customizing of phpList!!

Way to go!

I do like the Subscribe on every page option, and the Captcha thing is very neat! Would you care to share how you did it? Please? (both)
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

Postby clubwager » 11:30pm, Thu 23 Aug, 2007

Thank you for your kind words.

The small sign up form on every page was done by simply taking the html form generated by phplist in a subscribe page, and modifying it by moving most of the javascript to an external file and stripping away all of the html. Then, I styled the resulting bare form to a size and look that fit in with the rest of the site.

There is much more detail on doing this at this thread: http://forums.phplist.com/viewtopic.php?t=5712

Here is the code for the entire form:
Code: Select all
<form id='newsletter' style="margin-right:0px;margin-left:0px;margin-bottom:5px;margin-top:0px;padding:0px;width:180px" action="/lists/?p=subscribe" method="post" name="subscribeform">
<label for="Email" style="padding-top:3px;font-size:10px;width:33px;float:left;clear:left;color:navy;font-weight:bold;margin-right:0px;margin-bottom:2px">Email</label><input name="email" type="text" style="font-size:10px;width:127px;height:13px;color:navy;background:#F5FFFA;border:1px solid #8FB98E;margin-bottom:2px;margin-left:3px" id="Email" value="" size="20" maxlength="100" />
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script>
  <input name="attribute4" type="hidden" value="" /> 
  <input type="hidden" name="list[2]" value="signup" />
  <input type="hidden" name="listname[2]" value="Club Wager Newsletter" />
  <input type="hidden" name="htmlemail" value="1" />
  <input name="subscribe" type="submit" style="height:22px;width:52px;text-align:center;font-size:10px;padding:0px;margin-right:0px;margin-left:0px;margin-bottom:0px;margin-top:0px;float:left;clear:left;" value="Continue" onclick="return checkform();" /> </form>

I set this up to make the full form open when an email is submitted. I want the subscriber to have a chance to subscribe to the rss feeds (***SPAM*** alerts) and I wanted to use captcha to try to reduce spambot sign ups. In my installation, "attribute4" is the name field - which I set to be required. By using type="hidden" and value="" for that attribute, phplist will force open the main form with an error message that the name is needed. The other variables (email, list, etc.) are all passed to the main form, so the subscriber does not need to re-enter that info.

Everyone is welcome to try this form out on my site. So long as you do not click the confirmation link in the email the system sends, you will not get any of our email newsletter or ***SPAM*** alerts and your email address will be removed after 72 hours. Even if you choose to confirm to see the thank you page etc., you can easily unsubscribe after you are done testing it.

As to how I got captcha working, it is more complex. I have noticed some other posts looking for this, so I will try to put together some detailed instructions and post a new topic with it as soon as I can.

Thanks again for your feedback.
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Postby kuber » 3:02pm, Fri 07 Sep, 2007

Very good. This is exactly what I have been meaning to do. Thanks for sharing it with us.
kuber
phpLister
 
Posts: 14
Joined: 5:32pm, Fri 11 May, 2007

Postby clubwager » 11:54pm, Sat 13 Oct, 2007

Here is my quick and dirty solution to integrate SOLMETRA FormValidator captcha into phplist version 2.10.4 (see it working at http://www.clubwager.net/lists/?p=subscribe).

SOLMETRA FormValidator is free GPL when integrated into GPL-licensed software. Start by downloading and installing SOLMETRA FormValidator http://www.solmetra.com/en/disp.php/en_products/en_scripts/en_formvalidator/en_formvalidator_intro. Essentially, all you need to do is extract the downloaded archive to a separate directory on your hard disk (I called it "captcha"), and upload it to your server, and make sure the directory is writeable (usually set permissions to be writeable by owner and readable and executable by all; i.e., CHMOD 755).

Then, assuming you installed SOLMETRA FormValidator in a directory called "captcha" and phplist is installed in a directory called "lists", make these changes to phplist files:

In /lists/admin/subscribelib2.php at about line 7 right after
Code: Select all
$randval = mt_rand();
add this code:
Code: Select all
 // begin captcha code
if(USE_CAPTCHA){
include("../captcha/SPAF_FormValidator.class.php");
$obj = new SPAF_FormValidator();
if (isset($_POST['Verification'])) {
  if ($obj->validRequest($_POST['Verification'])) {
    // destroy successful code
    $obj->destroy();
  }
  else {
    exit('<p>Verification Code was entered incorrectly.</p> <p><ol><li>Please use the &quot;back&quot; button on your browser to return to the form, and</li><li>Fill out the form and re-submit it with the verification characters correctly entered.</li></ol>If you keep getting this error, please contact us for assistance.</p>');
  }
}
      }
// end captcha code


In /lists/index.php at about line 450 right after
Code: Select all
if (empty($data['button'])) {
    $data['button'] = $GLOBALS['strSubmit'];
  }

add this code:
Code: Select all
 // begin captcha code
if(USE_CAPTCHA)
  $html .= '<table><tr><td><img src="../captcha/img.php?&amp;&lt;?php echo time(); ?&gt;" alt="Enter these 6 characters in the box below."></td></tr><tr><td><div class="required">Enter the Verification Code from the above box:</div></td><td class="attributeinput"> <input name="Verification" class="attributeinput" size="6" maxlength="6" value="" id="verification_code" type="text"><script language="Javascript" type="text/javascript">addFieldToCheck("Verification","verification_code");</script></td></tr></table>'; 
// end captcha code 


Add this near the top of /lists/config/config.php:
Code: Select all
# to use captcha on subscription forms set this to true; to not use it set this to false
define("USE_CAPTCHA",true);


Unfortunately, using captcha does not make phplist invulnerable to spambots. The problem is that although captcha assures there is a real human when a visitor submits the form from a website, it does not have any effect if the form is bypassed by making a direct submission/request to the server. See the discussion at http://forums.phplist.com/viewtopic.php?t=3402. I tried to solve this by making certain form fields (that a spambot might not recognize), required. Seems to have worked so far.
Last edited by clubwager on 8:22pm, Sat 27 Oct, 2007, edited 1 time in total.
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Thanks, and some additions

Postby admash » 12:25am, Thu 18 Oct, 2007

I am brand new to PHPList, and after beating my head against the wall trying to get CAPTCHA to work, this thread gave me the tools to get going. A couple of additions:

In order to display the image using SOLMETRA, you have to be sure and add the full image tag to the code in index.php. For instance, if you have PHPlist inside the 'lists' dir, and 'captcha' located inside the 'lists' dir, the code from the example might be:

Code: Select all
// begin captcha code
  if(USE_CAPTCHA)
  $html .= "<table><tr><td><img></td></tr><tr><td><div>Enter the Verification Code from the above box:</div></td><td> <input><script>addFieldToCheck(\"Verification\",\"verification_code\");</script></td></tr></table>";
// end captcha code


Another thing that I had to do since 'captcha' was located inside my 'lists' directory, was to modify the .htaccess file to allow the img.php. Just open .htaccess and find:

<FilesMatch>

and change to

<FilesMatch>

If these edits seem strange or out of 'best practices', please correct me. This is simply how this is working for me now.

EDIT: I see what happened now, the forum edits the script when we post. To get the script to work, you have to add the 'src' and path to img.php inside the <img> tag (spaced out for the forum):

<img>

EDIT 2: - well, the forum keeps editing out the code, sorry! the .htaccess edit is simply adding img.php to the allowed pages, and the other is just fixing the source of the html image tag. Sorry about the edits!
admash
phpList newbie
 
Posts: 1
Joined: 12:17am, Thu 18 Oct, 2007

Re: Thanks, and some additions

Postby H2B2 » 1:31am, Thu 18 Oct, 2007

admash wrote:EDIT: I see what happened now, the forum edits the script when we post. To get the script to work, you have to add
the 'src' and path to img.php inside the <img> tag (spaced out for the forum):

<img>
When posting HTML code on the forum, you should make sure you click on "Disable HTML in this post" on the left of your
editing window. Otherwise HTML tags will be truncated. Try editing your post, paste the code again and select "Disable HTML in this post".
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby helloukw » 3:24pm, Sat 27 Oct, 2007

Hi!

This works for latest version also?

I can't get it work , the image doesn't show up.

Please help!

Thanks.
helloukw
phpLister
 
Posts: 5
Joined: 3:20pm, Sat 27 Oct, 2007

Postby clubwager » 3:45pm, Sat 27 Oct, 2007

Check the path to where you have SPAF_FormValidator.class.php. Also, make sure the permissions allow you to write.

If you need help, please tell me what version of phplist you are using and where you installed it and give me the url to where you are trying the page where the form is located so I can look at it.
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Postby helloukw » 4:57pm, Sat 27 Oct, 2007

I'm using PhpList 2.10.5

Here is the URL : visual85 dot com /lists/

I installed "Captcha" in visual85 dot com/captcha/

Thank you for help!


PS: Sry i can't post links yet, i don`t have enough posts.
helloukw
phpLister
 
Posts: 5
Joined: 3:20pm, Sat 27 Oct, 2007

Postby clubwager » 5:15pm, Sat 27 Oct, 2007

In the posts above there appears to be a problem if captcha is under the lists folder. I do not know what causes it but you might try simply moving the captcha folder to the main directory. Make sure it has correct permissions.

You could also try just making sure you use the correct full absolute path to the captcha folder such as
Code: Select all
include("http://[yourdomain]/lists/captcha/SPAF_FormValidator.class.php");
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Postby helloukw » 5:18pm, Sat 27 Oct, 2007

I managed to make the image appear.. it put the full path to img.

Another problems appears tho.. it validates no matter if i put the right answer or not.

Any ideas why?
helloukw
phpLister
 
Posts: 5
Joined: 3:20pm, Sat 27 Oct, 2007

Postby clubwager » 8:28pm, Sat 27 Oct, 2007

This forum deletes some html code unless the "Disable HTML in this post" box is checked. I failed to do that in the original Sun Oct 14, 2007 6:54 am post above so it omitted some essential code that is needed in the index.php file. I have now edited that prior post to correct it.

Thank you for catching this and bringing it to my attention. Let me know if you have any other problems with it.
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Postby helloukw » 9:17pm, Sat 27 Oct, 2007

Works like a charm now!

Thank you so much!
helloukw
phpLister
 
Posts: 5
Joined: 3:20pm, Sat 27 Oct, 2007

Postby rmacian » 4:18pm, Wed 07 Nov, 2007

In case that the image does not appear and if you try to see the image you recieve an error like thtat the createimagefrompng does not exist you have to install the package php5-gd and restart apache.

Now I can see the image but if I try to subcribe to a list I can t do it. After introducing the right code I am redirected to the subsribe page again with a different code.

Any idea?
rmacian
phpList newbie
 
Posts: 4
Joined: 12:28pm, Wed 07 Nov, 2007

Next

Return to Showcase

Who is online

Users browsing this forum: No registered users and 1 guest

cron