[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Formatting a Wordpress Plugin Fom

Asked by David_Zucker in WordPress, PHP Scripting Language, Cascading Style Sheets (CSS)

Tags: Wordpress, PHP

Hi,
Please take a look at the following page on my website:
http://jlm-dubno-maggid.org/blog/email-subscription/

On this page there are two form boxes. The second one is generated using the Wordpress PHPList-Integration Plugin. I would like to format this second form so that it looks like the first one, ie Submit box on the right rather than underneath, and amber shading in the box. How can I do this? I am appending in the Code box the PHP and CSS files..

Thanks,
David
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
PHP File
<?php
/*
Plugin Name: PHPlist
Plugin URI: http://www.jesseheap.com/projects/wordpress-phplist-plugin.php?ver=1.0
Description: Allows you to easily integrate the PHPList subscribe form in your blog
Version: 1.5
License: GPL
Author: Jesse Heap
Author URI: http://www.jesseheap.com
Contributors:
 ==============================================================================
   Rich Cowan 							Initial idea for PHPList API		
 
Thanks to Ryan Duff, creator of the Wordpress Contact form plug-in (http://ryanduff.net), for the
Spam Handling Feature, CSS, and flexible design idea for dropping the subscriber form on any wordpress page.
*/
/*Globals*/
$admin_phplist_config_page = get_settings('siteurl') . '/wp-admin/options-general.php?page=phplist.php"';
$ver='1.5';
$default_list_size = 2;
$o = phplist_get_options();
 
$phplist_strings = array(
	'field1' => '<input type="text" name="'. $o['php_list_txt_id'] . '" id="'. $o['php_list_txt_id'] .'" size="'. $o['php_list_txt_size'] .'" maxlength="'. $o['php_list_txt_max'] .'" value="' . paranoid($_POST[$o['php_list_txt_id']], array('-', ' ')) . '"   /> <br/>',
	'email' => '<input type="text" name="email" id="email" size="'. $o['php_list_email_size'] .'" maxlength="'. $o['php_list_email_max'] .'" value="'. paranoid($_POST['email'], array('@', '.', '_', '-')) .'"  /> <br/>',
	'error' => '');
 
function phplist_subscribe($input_data) {
    global $admin_phplist_config_page;
	$o=phplist_get_options();
  	$domain = $o['php_list_uri'];
	$lid =$o['php_list_listid'];      // lid is the default PHPlist List ID to use 
	$login =  $o['php_list_login'];
	$pass = $o['php_list_pass'];
	$skipConfirmationEmail = $o['php_list_skip_confirm'];               // Set to 0 if you require a confirmation email to be sent.  
 
	if (!phplist_check_curl()) {
		echo 'CURL library not detected on system.  Need to compile php with cURL in order to use this plug-in';
	    return(0);
		}
//   $post_data = array(); 
   
	foreach ($input_data as $varname => $varvalue) {
      // Handle Arrays (i.e Checkgroups)		 
     if (is_array($varvalue) && (strcasecmp($varname, 'list')!==0)) {
		 foreach ($varvalue as $varname1 => $varvalue1) {
			if (empty($var))
			 $var = $varvalue1;
			else  $var = $var . ',' . $varvalue1 ;
		 }
		 $post_data[$varname] = $var;
	 }
	 // Handle Multiple Lists
	 else if (is_array($varvalue) && strcasecmp($varname, 'list')==0){
		foreach ($varvalue as $varname1 => $varvalue1) {
				$varname = 'list['. $varname1 .']';
				$post_data[$varname] = $varvalue1;		
			 }
	 }
	 else if (strcasecmp($varname, 'email') == 0)  
	    $post_data[$varname] = paranoid($varvalue,  array('@', '.', '_', '-')); 
     else
	    $post_data[$varname] = paranoid($varvalue, array('-', ' '));
   /* echo 'Post_Data['.$varname.'] = ' . $post_data[$varname] . '<br>';*/
   }    
 
	// Ensure email is provided 
	$email = $post_data['email'];//
   if ($email == '') { 
         echo('You must supply an email address ' . $email); 
    return(0); 
   } 
 
// 3) Login to phplist as admin and save cookie using CURLOPT_COOKIEFILE 
// NOTE: Must log in as admin in order to bypass email confirmation
   $url = $domain . "admin/?"; 
   $ch = curl_init(); 
   $login_data = array(); 
   $login_data["login"] = $login; 
   $login_data["password"] = $pass; 
   curl_setopt($ch, CURLOPT_POST, 1); 
   curl_setopt($ch, CURLOPT_URL, $url);    
   curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); 
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
   curl_setopt($ch, CURLOPT_COOKIEFILE, ""); //Enable Cookie Parser.  
   //File does not need to exist - http://curl.netmirror.org/libcurl/c/libcurl-tutorial.html for more info 
   $result = curl_exec($ch); 
   //echo("Result was: $result"); //debug 
   if (curl_errno($ch)) {
   print '<h3 style="color:red">Error: ' . curl_error($ch) . ' Check <a href=" '. $admin_phplist_config_page .'"> admin config options page.</a> </h3>';
   return(0);
	} 
 
// 3) Now simulate post to subscriber form.  
   $post_data["emailconfirm"] = $email; 
   $post_data["htmlemail"] = "1"; 
 // No longer required  $post_data["list[$lid]"] = "signup"; 
   $post_data["subscribe"] = "Subscribe"; 
   $post_data["makeconfirmed"] = $skipConfirmationEmail;  //If set to 1 it will confirm user bypassing confirmation email 
   $url = $domain . "?p=subscribe"; 
 
   curl_setopt($ch, CURLOPT_POST, 1); 
   curl_setopt($ch, CURLOPT_URL, $url);    
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
   $result = curl_exec($ch); 
 
   //echo('Result was: ' .$result); 
   if (curl_errno($ch)) {
   print '<h3 style="color:red">Error: ' . curl_error($ch) . ' Check <a href=" '. $admin_phplist_config_page .'"> admin config options page.</a> </h3>';
   return(0);
	} 
  echo ('<h3>Thank you for subscribing to our email list</h3>');
//) Clean up 
   curl_close($ch);
 
 }  // end of function
 
function phplist_get_options(){
		global $default_list_size;
		$defaults = array();
		$defaults['php_list_txt_label'] = 'Name';
		$defaults['php_list_txt_id'] = 'attribute1';
		$defaults['php_list_txt_size'] = '30';
		$defaults['php_list_txt_max'] = '50';
		$defaults['php_list_txt_show'] = FALSE;
		$defaults['php_list_txt_req'] = FALSE;
		$defaults['php_list_email'] = 'Email';
		$defaults['php_list_email_size'] ='20';
		$defaults['php_list_email_max'] = '50';
		$defaults['php_list_show_css'] = TRUE;	
		$defaults['php_list_login']='admin';
		$defaults['php_list_uri']='http://yourdomain.com/lists/';
		$defaults['php_list_pass']='';
		$defaults['php_list_maxLists']=$default_list_size;
		$counter=1;
		for ($counter; $counter <$defaults['php_list_maxLists']; $counter += 1) {
			$defaults['php_list_listid' . $counter]= '';
			$defaults['php_list_listname' . $counter]= '';
		}
		$defaults['php_list_skip_confirm']= 0;
		
		$options = get_option('phplistsettings');
 
		if (!is_array($options)){
			$options = $defaults;
			update_option('phplistsettings', $options);
		}
 
		return $options;
	}
function phplist_check_curl() {
 if (function_exists('curl_exec')) {
 
	return(1);
 
  } else {
 
   return (0);
 
 }
}
function phplist_subpanel() {
	global $ver;
	global $default_list_size;
		if ($_POST['phplist']){
		    //Check for trailing slash
			  $option_phplisturi = $_POST['phplist']['php_list_uri'];
			  if  (strcmp($option_phplisturi[strlen($option_phplisturi)-1], '/') !=0) {
	 				$_POST['phplist']['php_list_uri'] .= '/';
	 			}
			if ($_POST['add_more']) {
				$_POST['phplist']['php_list_maxLists'] = $_POST['phplist']['php_list_maxLists'] + 1;
				$sub_mesg = ' and added additional line for Lists.  Make sure to enter List ID.';
			}
			if ($_POST['reset']) {
				$counter = $default_list_size;
				$max_lists = (empty($o['php_list_maxLists'])) ? $default_list_size : $o['php_list_maxLists'];
				for ($counter; $counter <$max_lists; $counter += 1) {
					 $o['php_list_listid' . $counter] = '';
					 $o['php_list_listname'. $counter ] = '';
				}
				$_POST['phplist']['php_list_maxLists'] = $default_list_size;
				$sub_mesg = 'and Reset List Count';
			}
			update_option('phplistsettings', $_POST['phplist']);
			$message = '<div class="updated"><p><strong>Options saved ' . $sub_mesg . '</strong></p></div>';
			echo $message;
		}
		
	if (!phplist_check_curl()) {
		echo 'CURL library not detected on system.  Need to compile php with cURL in order to use this plug-in';
	    return(0);
		}  
	
	$o = phplist_get_options();
	$skip_confirmation_chkbox = ($o['php_list_skip_confirm'] == 1) ? ' checked="checked"' : '';
	$show_optional_field = ($o['php_list_txt_show'] == 1) ? ' checked="checked"' : '';
    $optional_field_req = ($o['php_list_txt_req'] == 1) ? ' checked="checked"' : '';
	$show_css = ($o['php_list_show_css'] == 1) ? ' checked="checked"' : '';
	$max_lists = (empty($o['php_list_maxLists'])) ? $default_list_size : $o['php_list_maxLists'];
    $counter=1;
	for ($counter; $counter <$max_lists; $counter += 1) {
		$lists = $lists . '<tr>
              <td><input name="phplist[php_list_listid' . $counter . ']" type="text" id="phplist[php_list_listid' . $counter . ']" value="' . $o['php_list_listid' . $counter] .'" size="50" /></td>
              <td><input name="phplist[php_list_listname' . $counter .']" type="text" id="phplist[php_list_listname' . $counter . ']" value="' . $o['php_list_listname'. $counter ] .'" size="50"/></td></tr>';
	}
  echo <<<EOT
    <div class="wrap">   
         <h2>General Settings</h2>
		<form method="post">
        <fieldset class="options">
		<table>
         <tr>
          <td><p><strong><label for="php_list_uri">PHPList URL:</label></strong></td>
          <td><input name="phplist[php_list_uri]" type="text" id="php_list_uri" value="{$o['php_list_uri']}" size="50" /> <em>http://www.yoursite.com/lists/</em></p></td>
         </tr>
         <tr>
          <td><p><strong><label for="php_list_login">PHPList Admin Login</label></strong></td>
          <td><input name="phplist[php_list_login]" type="text" id="php_list_login" value="{$o['php_list_login']}" size="50" /> <em>Enter PHPList Admin Login</em></p></td>
         </tr>
		 <tr>
          <td><p><strong><label for="php_list_pass">PHPList Admin Password</label></strong></td>
          <td><input name="phplist[php_list_pass]" type="password" id="php_list_pass" value="{$o['php_list_pass']}" size="50" /> <em>Enter PHPList Admin Password</em></p></td>
         </tr>
		  <tr>
          <td valign="top"><p><strong><label for="php_list_listid">PHPList List Information</label></strong></td>
          <td>		 
		  <table width="100%" border="0">
            <tr>
              <td><em><b>Enter PHPList ID</b></em></td>
              <td><em><b>Enter Name of List</b></em></td>
            </tr>
				{$lists}
          </table>
		<input type="submit" name="reset" value="Reset &raquo;" style="font-weight:bold;float:right" />	
		  <input type="submit" name="add_more" value="Add Another List &raquo;" style="font-weight:bold;float:right" />
			<div style="clear:both"></div>
            <p><em>For each list enter the list number and name of the list in the above table.  <a href="http://www.jesseheap.com/projects/wordpress-phplist-plugin.php#ListID"><strong>See 
                help</strong></a> for more info.</em></p>
            </td>
         </tr>
		 <tr>
		  <td></td>
		  <td><p><input name="phplist[php_list_skip_confirm]" type="checkbox" id="php_list_skip_confirm" value="1" {$skip_confirmation_chkbox}/>  <label for="php_list_skip_confirm"><strong>Skip Confirmation Email</strong> (Check to bypass confirmation email)</label></p></td>
		 </tr>
        </table>
        </fieldset>
        <div class="submit">
			  <input type="hidden" name="phplist[php_list_maxLists]" value="{$max_lists}" />
           <input type="submit" name="save_settings" value="Update Options &raquo;" style="font-weight:bold;" />
		</div>
    </div>
	
 
	    <div class="wrap">   
        <h2>Form Settings</h2>
		
		<p>Use these settings to <strong>OPTIONALLY</strong> configure your form.  Currently the form supports two text fields.  
		The first field supports any text label and should correspond to a text field you capture in PHPList.  Most people capture NAME in this field.  The second field is the <strong>required</strong> email field.</p>
        <fieldset class="options">
		
    <table>
      <tr> 
        <td align="left" ><p><strong> 
            <label for "php_list_txt_show">Show on Form?</label>
            </strong></p></td>
        <td align="left" ><p><strong> 
            <label for "php_list_txt_label">Text Field Label Name</label>
            </strong></p></td>
        <td align="left"><p><strong> 
            <label for "php_list_txt_id">Text Field ID</label>
            </strong></p></td>
        <td align="left"><p><strong> 
            <label for="php_list_txt_size">Text Field Size</label>
            </strong></td>
        <td align="left"><p><strong> 
            <label for="php_list_txt_max">Text Field Max Size</label>
            </strong></td>
        <td align="left"><p><strong> 
            <label for="php_list_txt_req">Required Field?</label>
            </strong></td>
      </tr>
      <tr> 
        <td><input name="phplist[php_list_txt_show]" type="checkbox" id="php_list_txt_show" value="1" {$show_optional_field} /> 
        </td>
        <td><input name="phplist[php_list_txt_label]" type="text" id="php_list_txt_label" value="{$o['php_list_txt_label']}" size="20" /> 
        </td>
        <td><input name="phplist[php_list_txt_id]" type="text" id="php_list_txt_id" value="{$o['php_list_txt_id']}" size="20" /> 
        </td>
        <td><input name="phplist[php_list_txt_size]" type="text" id="php_list_txt_size" value="{$o['php_list_txt_size']}" size="5" /></td>
        <td><input name="phplist[php_list_txt_max]" type="text" id="php_list_txt_max" value="{$o['php_list_txt_max']}" size="5" /></td>
        <td><input name="phplist[php_list_txt_req]" type="checkbox" id="php_list_txt_req" value="1"  {$optional_field_req} /></td>
      </tr>
      <tr> 
        <td><em>Check to show field on form</em></em></td>
        <td><em>Enter Text Label (i.e. Name)</em></td>
        <td><em>Enter Text ID - <a href="http://www.jesseheap.com/projects/wordpress-phplist-plugin.php#FieldID" target="_blank">see 
          help </a>for more information</em></td>
        <td><em>Enter size of text field</em></td>
        <td><em>Enter max size of text field</em></td>
        <td><em>Check to make field required</em></td>
      </tr>
      <tr> 
        <td><input name="phplist[php_list_email_show]" type="checkbox" id="php_list_email_show" disabled value="1" checked="checked">
        </td>
        <td ><input name="phplist[php_list_email]" type="text" id="php_list_email"  value="{$o['php_list_email']}" size="20" /> </p> 
        </td>
        <td ><input name="phplist[php_list_email_id]" type="text" id="php_list_email_id" disabled value="email" size="20" /></p> 
        </td>
        <td ><input name="phplist[php_list_email_size]" type="text" id="php_list_email_size"  value="{$o['php_list_email_size']}" size="5" /> </p> 
        </td>
        <td ><input name="phplist[php_list_email_max]" type="text" id="php_list_email_max"  value="{$o['php_list_email_max']}" size="5" /> </p> 
        </td>
        <td ><input name="phplist[php_list_email_req]" type="checkbox" id="php_list_email_req" disabled value ="1" checked="checked"/> </p> 
        </td>
      </tr>
      <tr> 
        <td colspan="6"> 
          <input name="phplist[php_list_show_css]" id="php_list_show_css" type="checkbox" value="1" {$show_css}>
          Use default CSS for subscriber form. (Uncheck to use your own CSS for the form)</td>
      </tr>
    </table>
        </fieldset>
        <div class="submit">
           <input type="submit" name="save_form_settings" value="Update Options &raquo;" style="font-weight:bold;" /></div>
        </form>
    </div>
	
	<div class="wrap">
	<h2>Information & Support</h2>
	
  <p>Visit <a href="http://www.jesseheap.com/projects/wordpress-phplist-plugin.php?ver=<?php echo $ver ?>" target="_blank">our 
    help section</a> for installation and help</p>
  <p><strong>Like this script?</strong> Show your support by linking to <a href="http://www.jesseheap.com">our 
    site</a> - www.jesseheap.com.</p>
	</div>
EOT;
} // end phplist_subpanel()
 
/* Original Author: Ryan Duff */
function phplist_is_malicious($input) {
	$is_malicious = false;
	$bad_inputs = array("\r", "\n", "mime-version", "content-type", "cc:", "to:");
	foreach($bad_inputs as $bad_input) {
		if(strpos(strtolower($input), strtolower($bad_input)) !== false) {
			$is_malicious = true; break;
		}
	}
	return $is_malicious;
}
 
 
/* This function checks for errors on input and changes $phplist_strings if there are any errors.  Returns false if there has not been a submission */
/* Original Author: Ryan Duff */
function phplist_check_input()
{
	if(!(isset($_POST['phplist_submit']))) {return false;} // Exit returning false.
    $email = $_POST['email']; 
	$email = stripslashes(trim($email));
    $email = paranoid($email, array('@', '.', '_', '-'));
	$optionvalue = paranoid($_POST[$txt_id], array('-', '_', ' '));
	global $phplist_strings, $admin_phplist_config_page;
	$ok = true;
 
 
	/*See if custom field is required */
	$o = phplist_get_options();
    $required = $o['php_list_txt_req'];
	$txt_id = $o['php_list_txt_id'];
	$txt_size = $o['php_list_txt_size'];
	$txt_max = $o['php_list_txt_max'];
	$txt_show = $o['php_list_txt_show'];
    $email_size = $o['php_list_email_size'];
	$email_max = $o['php_list_email_max'];
 
	if (!(phplist_using_single_list($o))) {
		$max_lists = (empty($o['php_list_maxLists'])) ? 4 : $o['php_list_maxLists'];
		if (!is_array($_POST['list'])) {
				$ok = false; $reason = 'No Mailing List';
		}
 
	}
	if (strlen($required)>0 && $txt_show) {
			if(empty($_POST[$txt_id]))  {
				$ok = false; $reason = 'empty';
				$phplist_strings['field1'] = '<input class="requiredOutline" type="text" name="'. $txt_id .'" id="' . $txt_id .'" size="' . $txt_size . '" maxlength="'. $txt_max . '" value="' .$optionvalue . '"  /> <br class="br" /> ';
			}
	}
    if(!is_email($email))
    {
	    $ok = false; $reason = 'Invalid Email';
	    $phplist_strings['email'] = '<input class="requiredOutline" type="text" name="email" id="email" size="'. $email_size .'" maxlength="'. $email_max .'" value="' . $email . '"  /> <br class="br" />';
	}
 
	if( phplist_is_malicious($email)) {
		$ok = false; $reason = 'malicious';
	}
 
	if($ok == true)
	{
		return true;
	}
	else {
		if($reason == 'malicious') {
			$phplist_strings['error'] = "<div class='required'>You can not use any of the following in the Name or Email fields: a linebreak, or the phrases 'mime-version', 'content-type', 'cc:' or 'to:'.</div>";
			}
		elseif($reason == 'empty') {
			$phplist_strings['error'] = '<label for="Error"></label><div class="required">Missing Required Field </div>';
			}
		 elseif($reason == 'Invalid Email')  {
			$phplist_strings['error'] = '<label for="Error"></label><div class="required">Invalid Email</div>';
			}
		 elseif($reason == 'No Mailing List')  {
			$phplist_strings['error'] = '<label for="Error"></label><div class="required">You Must Check a Mailing List</div>';
			}
	   return false;
	}
}
 
 
/* From http://api.cakephp.org/sanitize_8php-source.html#l00046 */
/* Thanks to Gordon */
function paranoid($string, $allowed = array()) {
        $allow = null;
         if (!empty($allowed)) {
             foreach ($allowed as $value) {
                 $allow .= "\\$value";
             }
         }
 
         if (is_array($string)) {
             foreach ($string as $key => $clean) {
                 $cleaned[$key] = preg_replace("/[^{$allow}a-zA-Z0-9]/", "", $clean);
             }
         } else {
             $cleaned = preg_replace("/[^{$allow}a-zA-Z0-9]/", "", $string);
         }
         return $cleaned;
     }
	 
/*Wrapper function which calls the form.*/
/* Original Author: Ryan Duff */
function phplist_callback( $content )
{
 
	/* Check to see if the phplist form comment is found in the incoming content
	   If no match then return the content as is */
		if(! preg_match('|<!--phplist form-->|', $content)) {
		return $content;
		}
 
    if(phplist_check_input()) // If the input check returns true (ie. there has been a subscriber & input is ok)
    {
           phplist_subscribe($_POST);
    }
    else // Else show the form. If there are errors the strings will have updated during running the inputcheck.
    {
 		$form = phplist_construct_form();
 
        return str_replace('<!--phplist form-->', $form, $content);
    }
}
 
function phplist_using_single_list($options) {
	return (empty($options["php_list_listid2"]));
	}
function phplist_generate_list_elements () {
	$o = phplist_get_options();
	$max_lists = (empty($o['php_list_maxLists'])) ? 4 : $o['php_list_maxLists'];
	if (phplist_using_single_list($o)) {
		$lists_form = '<input type="hidden" name="list['. $o["php_list_listid1"] . ']" value="signup">';
	}
	else
	{
		$lists_mes = '<br><span style="caption">Please select the newsletters you want to sign up for:</span><br>';
		$lists_ul = '<ul class="list">';
		$lists_li = '<li class="list">';
		$lists_form = $lists_mes . $lists_ul;
		$counter=1;
		for ($counter; $counter <$max_lists; $counter += 1) {
			if (!(empty($o["php_list_listid" . $counter]))) {
				$lists_form = $lists_form . $lists_li . ' <input type="checkbox" name="list[' . $o["php_list_listid". $counter ] . ']" value=signup  /> 
				<b>' . $o['php_list_listname'. $counter ] .'</b></li>';
			}
		}
		$lists_form = $lists_form . '</ul>';
	}
	return $lists_form;
}
function phplist_construct_form() {
	global $phplist_strings, $admin_phplist_config_page;
	$o = phplist_get_options();
       if (strlen($o['php_list_uri'])>0) {
			$label_name = $o['php_list_txt_label'];
			$txt_id = $o['php_list_txt_id'];
			$email_name = $o['php_list_email'];
			$txt_show = $o['php_list_txt_show'];			
 
			if ($txt_show==true)  {
				$txt_optional_field = '<label for="'. $txt_id . '" '. (strlen($o['php_list_txt_req'])>0 ? 'class="required"':  '') . '>' . __($label_name, 'phplist') . '</label>'. $phplist_strings['field1'];
			}
			else { 
				$txt_optional_field = '';
			}
 
			$form = '       	
				<form action="" method="post" class="phplist">
			' . $phplist_strings['error'] . '
				' . $txt_optional_field . '
			    <label for="email" class="required">' . __($email_name, 'phplist') . '</label>'. $phplist_strings['email'] . '
					'. phplist_generate_list_elements() . '
					<label for="kludge"></label>
					<input type="submit" name="Submit" value="' . __('Submit', 'phplist') . '" id="contactsubmit" />
					<input type="hidden" name="phplist_submit" value="process" />
				</form>
			<div style="clear:both; height:1px;">&nbsp;</div>'; 
			}
		else { //Key configuration option has not been set - alert user.
			$form = '<h3>Must <a href= "' . $admin_phplist_config_page . '"> configure options</a> under admin panel before using form</h3>';
			}
		return $form;
}
/*CSS Styling*/
function phplist_css()
	{
	global $ver;
	$phplist_wp_url = get_bloginfo('wpurl') . "/";
	echo "\n\t<!-- CSS Added By PhpList Plugin. Version {$ver} -->\n";
    echo "\n\t<link href='{$phplist_wp_url}wp-content/plugins/phplist.css' rel='stylesheet' type='text/css' />";
	}
	
function phplist_admin_menu() {
   if (function_exists('add_options_page')) {
        add_options_page('phplist Options Page', 'PHPlist', 8, basename(__FILE__), 'phplist_subpanel');
        }
}
 
add_action('admin_menu', 'phplist_admin_menu');
add_filter('the_content', 'phplist_callback', 99);
$o = phplist_get_options();
if  ($o['php_list_show_css'] ==TRUE)  {
	add_filter('wp_head', 'phplist_css');
	}
?>
##############################################################
 
CSS File
 
/* PHPLIST CSS Document */
.phplist fieldset legend {
	font-size:1.1em; /* bump up legend font size, not too large or it'll overwrite border on left */
                       /* be careful with padding, it'll shift the nice offset on top of border  */
}
.phplist label { 
	display: block;  /* block float the labels to left column, set a width */
	float: left; 
	width: 40px; 
	padding: 0; 
	margin: 5px 0 0; /* set top margin same as form input - textarea etc. elements */
	text-align: right; 
}
.phplist {  /* set width in form, not fieldset (still takes up more room w/ fieldset width */
  font:100% verdana,arial,sans-serif;
  margin: 0;
  padding: 0;
/*  min-width: 500px;
  max-width: 700px;
  width: 660px; */
}
/* Use to style multiple lists */
.phplist .list {
	list-style-type: none;
}
/* Caption for multiple lists */
.phplist .caption {
 
}
.phplist fieldset {
  / * clear: both; note that this clear causes inputs to break to left in ie5.x mac, commented out */
  border-color: #000;
  border-width: 1px;
  border-style: solid;
  padding: 10px;        /* padding in fieldset support spotty in IE */
  margin: 0;
}
.phplist input, .phplist textarea, .phplist select{
	/* display: inline; inline display must not be set or will hide submit buttons in IE 5x mac */
	width:auto;      /* set width of form elements to auto-size, otherwise watch for wrap on resize */
	margin:5px 0 0 10px; /* set margin on left of form elements rather than right of
                              label aligns textarea better in IE */
}
 
.phplist input#reset {
	margin-left:0px; /* set margin-left back to zero on reset button (set above) */
}
 
.phplist textarea{ overflow: auto; }
 
.phplist small {
	display: block;
	margin: 0 0 5px 160px; /* instructions/comments left margin set to align w/ right column inputs */
	padding: 1px 3px;
	font-size: 88%;
}
.phplist .required{
	font-weight:bold; 
	color:red;
} 
.phplist .requiredOutline {
	border: 1px solid #ff0000;
}
 
/* uses class instead of div, more efficient */
.phplist br {
	clear:left; /* setting clear on inputs didn't work consistently, so brs added for degrade */
}
/* End Contact Form CSS */
[+][-]02/07/09 03:31 PM, ID: 23580985Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: WordPress, PHP Scripting Language, Cascading Style Sheets (CSS)
Tags: Wordpress, PHP
Sign Up Now!
Solution Provided By: David_Zucker
Participating Experts: 1
Solution Grade: A
 
[+][-]02/06/09 06:21 AM, ID: 23569901Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625