web/wp-content/plugins/ggis-subscribe/ggis-subscribe.php
branchwordpress
changeset 109 03b0d1493584
equal deleted inserted replaced
-1:000000000000 109:03b0d1493584
       
     1 <?php
       
     2 /*
       
     3 Plugin Name: ggis Subscribe
       
     4 Plugin URI: http://dvector.com/oracle/category/ggissubscribe/
       
     5 Description: Manages subscriptions to email lists. Simply add [-ggis-subscribe-] to your post.
       
     6 Author: Gary Dalton
       
     7 Version: 0.9
       
     8 Author URI: http://dvector.com/oracle/
       
     9 */
       
    10 
       
    11 /*  Copyright 2008 Gary Dalton  (email : PLUGIN AUTHOR EMAIL)
       
    12 
       
    13     This program is free software; you can redistribute it and/or modify
       
    14     it under the terms of the GNU General Public License as published by
       
    15     the Free Software Foundation; either version 2 of the License, or
       
    16     (at your option) any later version.
       
    17 
       
    18     This program is distributed in the hope that it will be useful,
       
    19     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    21     GNU General Public License for more details.
       
    22 
       
    23     You should have received a copy of the GNU General Public License
       
    24     along with this program; if not, write to the Free Software
       
    25     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    26 */
       
    27 
       
    28 // Pre-2.6 compatibility
       
    29 if ( ! defined( 'WP_CONTENT_URL' ) )
       
    30       define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
       
    31 if ( ! defined( 'WP_CONTENT_DIR' ) )
       
    32       define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
       
    33 if ( ! defined( 'WP_PLUGIN_URL' ) )
       
    34       define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
       
    35 if ( ! defined( 'WP_PLUGIN_DIR' ) )
       
    36       define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
       
    37 
       
    38 /*
       
    39 *	START CLASS
       
    40 */
       
    41 if (!class_exists("ggisSubscribe")) {
       
    42 	class ggisSubscribe {
       
    43 		/*
       
    44 			formAction - URL to post form to.
       
    45 			maillist - Which mailing list the subscription is for. [validated]
       
    46 				listname@npexchange.org
       
    47 			action - Subscribe or unsubscribe [validated]
       
    48 			email - Email address to manage [validated
       
    49 			name - Subscriber's name [optional] [validated]
       
    50 			nextpage - Go to this URL after processing subscription.[validated]
       
    51 				http://example.com
       
    52 			formurl - URL with full subscribe/unsubscribe form[validated]
       
    53 				http://example.com
       
    54 			listmanager - Software managing the mailing list
       
    55 				ezmlm, mailman
       
    56 		*/
       
    57 
       
    58 		
       
    59 		
       
    60 //		var $formAction = 'http://dvector.com/ggis_wp-subscribe.php';
       
    61 		var $formAction = '';
       
    62 		var $maillist;
       
    63 		var $nextpage;
       
    64 		var $formurl;
       
    65 		var $managerdefault = 'ezmlm';
       
    66 		var $managertypes = array('ezmlm', 'mailman');
       
    67 
       
    68 		var $adminOptionsName = 'ggisSubscribeAdminOptions';
       
    69 		
       
    70 
       
    71 		function ggisSubscribe() { //constructor
       
    72 //			$this->formAction = 'http://dvector.com/ggis_wp-subscribe.php';
       
    73 //			$this->formAction = WP_PLUGIN_URL . '/ggis_wp-subscribe.php';
       
    74 		}
       
    75 		function addHeaderCode(){
       
    76 			echo '<!-- ggisSubscribe Plugin - Copyright 2008 - GGIS -->';
       
    77 		}
       
    78 		
       
    79 		// OUTPUT FUNCTIONS
       
    80 		var $processing_unit_tag;
       
    81 		var $processing_within;
       
    82 		var $unit_count;
       
    83 		var $widget_count;
       
    84 		var $regex;
       
    85 		function the_content_filter($content) {
       
    86 			$this->processing_within = 'p' . get_the_ID();
       
    87 			$this->unit_count = 0;
       
    88 			
       
    89 			
       
    90 			$regex = '/\[-\s*ggis-subscribe\s*(\d+)?\s*(".*")?\s*-\]/';
       
    91 //			$regex = '/\[-\s*ggis-subscribe\s+(\d+)(?:\s+.*?)?\s*-\]/'; // [-ggis-subscribe 1 -]
       
    92 //			$regex = '/<!--\s*ggis-subscribe\s+(\d+)\s+(.*)\s*-->/';
       
    93 			return preg_replace_callback($regex, array(&$this, 'the_content_filter_callback'), $content);
       
    94 			
       
    95 			$this->processing_within = null;
       
    96 		}
       
    97 		
       
    98 		function widget_text_filter($content) {
       
    99 			$this->widget_count += 1;
       
   100 			$this->processing_within = 'w' . $this->widget_count;
       
   101 			$this->unit_count = 0;
       
   102 	
       
   103 			$regex = '/\[-\s*ggis-subscribe\s*(\d+)?\s*(".*")?\s*-\]/';	
       
   104 			return preg_replace_callback($regex, array(&$this, 'the_content_filter_callback'), $content);
       
   105 			
       
   106 			$this->processing_within = null;
       
   107 		}
       
   108 		
       
   109 		function the_content_filter_callback($matches) {
       
   110 
       
   111 			// GET AND SET VARIABLES
       
   112 			$list_select = '';
       
   113 			$listonly = NULL;
       
   114 			$options = unserialize( get_option( 'ggis-Subscribe'));
       
   115 			$options['maillists'] = explode( ',', $options['maillists'] );
       
   116 			$id = (int) $matches[1];
       
   117 			
       
   118 			// DETERMINE FORM TYPE
       
   119 			if ( $id == 1 ){
       
   120 				$listonly = str_replace( '"', '', $matches[2]);
       
   121 				if ( !is_email( $listonly) ){
       
   122 					$id = 0;
       
   123 				}
       
   124 			}else {
       
   125 				$id = 0;
       
   126 			}
       
   127 			
       
   128 			// FORM HEADERS
       
   129 			$this->unit_count += 1;
       
   130 			$unit_tag = 'ggis-subscribe-f' . $id . '-' . $this->processing_within . '-o' . $this->unit_count;
       
   131 			$this->processing_unit_tag = $unit_tag;
       
   132 
       
   133 			$form = '<div class="ggis-subscribe-form" id="' . $unit_tag . '">';
       
   134 			$form .= '<form action="' . $this->formAction . '" method="post" class="ggis-subscribe-form">';
       
   135 			$form .= '<input type="hidden" name="formtype" id="formtype" value="ggis-subscribe-form">';
       
   136 			$form .= '<input type="hidden" name="nextpage" id="nextpage" class="ggis-subscribe-form" value="'. $options['nextpage'] . '">';
       
   137 			$form .= '<input type="hidden" name="formurl" id="formurl" class="ggis-subscribe-form" value="'. $options['formurl'] . '">';
       
   138 			
       
   139 			// CREATE EITHER A HIDDEN FIELD OR SELECT BOX FOR MAILING LIST
       
   140 			if ( $id == 1 ){
       
   141 				$list_select .= '<input type="hidden" name="maillist" id="maillist" class="ggis-subscribe-form" value="'. $listonly . '">';
       
   142 			}else{
       
   143 				if ( count( $options['maillists']) == 1 ){
       
   144 					$list_select .= '<input type="hidden" name="maillist" id="maillist" class="ggis-subscribe-form" value="'. $options['maillists'][0] . '">';
       
   145 				} else{
       
   146 					$list_select .= 'Which list?<br>
       
   147 									<select name="maillist">';
       
   148 					foreach( $options['maillists'] as $key=>$list ){
       
   149 						$list_select .= '<option value="' . $list . '"';
       
   150 						if ( $key == 0 ){
       
   151 							$list_select .= ' SELECTED';
       
   152 						}
       
   153 						$list_select .= ">$list</option>";
       
   154 					}
       
   155 					$list_select .= '</select>';
       
   156 				}
       
   157 			}
       
   158 
       
   159 			if ( $id == 0){
       
   160 				// LONG FORM
       
   161 				$form .= '<fieldset><legend>Subscription Management</legend>
       
   162 						<p class="ggis-subscribe-form">';
       
   163 				$form .= $list_select;
       
   164 				$form .= '</p><p>&nbsp;Action:<br>
       
   165 						&nbsp;&nbsp;<input type="radio" name="action" id="subscribe" value="subscribe" checked="checked" /> Subscribe<br>
       
   166 						&nbsp;&nbsp;<input type="radio" name="action" id="unsubscribe" value="unsubscribe" /> Unsubscribe</p>
       
   167 						<p>&nbsp;Your Email:<br>
       
   168 						&nbsp;<input type="text" name="ggis-subscribe-email" id="ggis-subscribe-email" class="ggis-subscribe-email" size="40" maxlength="100" /></p>
       
   169 						</fieldset>
       
   170 						<input type="submit" name="Submit" value="Submit" />
       
   171 						</p>';
       
   172 			} elseif ( $id == 1 ) {
       
   173 				// SHORT FORM
       
   174 				$form .= $list_select;
       
   175 				$form .= '<input type="hidden" name="action" id="subscribe" class="ggis-subscribe-form" value="subscribe">';
       
   176 				$form .= '<p><input type="text" name="ggis-subscribe-email" id="ggis-subscribe-email" maxlength="100" class="ggis-subscribe-email" value="your email"/>
       
   177 						<input type="submit" name="Subscribe" value="Subscribe" /></p>';
       
   178 			}
       
   179 			
       
   180 			// FORM FOOTERS
       
   181 			$form .= '</form>';			
       
   182 			$form .= '</div>';
       
   183 			
       
   184 			$this->processing_unit_tag = null;
       
   185 			return $form;
       
   186 		}
       
   187 				
       
   188 		// ADMIN MENUS
       
   189 		var $adminform = '';
       
   190 		function ggis_admin_add_pages() {
       
   191 			add_options_page('ggisSubscribe', 'ggisSubscribe', 'manage_options', basename(__FILE__), array(&$this, 'ggissubscribe_options'));
       
   192 		}
       
   193 		
       
   194 		function form_ggissubscribe_options(){
       
   195 			$form = '';
       
   196 			$options = unserialize( get_option( 'ggis-Subscribe'));
       
   197 			
       
   198 			$list_select .= 'Which list manager?<br>
       
   199 							<select name="ggissubscribe_managertype">';
       
   200 			foreach( $this->managertypes as $manager ){
       
   201 				$list_select .= '<option value="' . $manager . '"';
       
   202 				if ( isset( $options['managertype']) ){
       
   203 					if ( $manager == $options['managertype'] ){
       
   204 						$list_select .= ' SELECTED';
       
   205 					}
       
   206 				}elseif ( $manager == $managerdefault ){
       
   207 					$list_select .= ' SELECTED';
       
   208 				}
       
   209 				$list_select .= ">$manager</option>";
       
   210 			}
       
   211 			$list_select .= '</select>';
       
   212 		
       
   213 			
       
   214 			$form .= '<form method="post">';
       
   215 			$form .= wp_nonce_field('ggis-subscribe-update-options_base');
       
   216 			$form .= '<fieldset><legend>Mailing List Options</legend>
       
   217 						<p>All fields are required.</p>
       
   218 						<p>';
       
   219 			$form .= $list_select;
       
   220 			$form .= '</p>
       
   221 						<p>
       
   222 						Mailing List Address (comma separated)<br />
       
   223 						example: maillist@npexchange.org,list2@npexchange.org<br />';
       
   224 			$form .= '<textarea cols="60" rows="4" name="ggissubscribe_maillists">'. $options['maillists'] .'</textarea>';
       
   225 			$form .= '</p>
       
   226 						<p>
       
   227 						URL of page to go to upon success<br />
       
   228 						example: http://your.blog/name/thank_you/<br />';
       
   229 			$form .= '<input type="text"  size="60" name="ggissubscribe_nextpage" value="'. $options['nextpage'] . '" />';
       
   230 			$form .= '</p>
       
   231 						<p>
       
   232 						URL of page containing the full subscription management form<br />
       
   233 						example: http://your.blog/name/manage_subscriptions/<br />';
       
   234 			$form .= '<input type="text"  size="60" name="ggissubscribe_formurl" value="' . $options['formurl'] . '">';
       
   235 			$form .= '</p>
       
   236 						<input type="hidden" name="action" value="update" />
       
   237 						<input type="hidden" name="page_options" value="ggissubscribe_maillists,ggissubscribe_nextpage,ggissubscribe_formurl" />
       
   238 						<p class="submit">';
       
   239 			$form .= '<input type="submit" name="submit" value="Save Changes" /></p>
       
   240 						</fieldset>';
       
   241 						
       
   242 			return $form;
       
   243 		}
       
   244 
       
   245 		
       
   246 		function ggissubscribe_options() {
       
   247 			$this->adminform .= '<div class="wrap"><h2>ggis Subscribe</h2>';
       
   248 			if ( $_POST['submit'] ){
       
   249 				$this->adminform .= $this->update_ggissubscribe_options();
       
   250 			}
       
   251 			$this->adminform .= $this->form_ggissubscribe_options();
       
   252 			$this->adminform .= '</div>';
       
   253 			echo $this->adminform;
       
   254 		}
       
   255 		
       
   256 		function update_ggissubscribe_options(){
       
   257 			$maillists = NULL;
       
   258 			$msg = '';
       
   259 			$options = NULL;
       
   260 			
       
   261 			check_admin_referer('ggis-subscribe-update-options_base');
       
   262 			
       
   263 			if ( $_POST['ggissubscribe_managertype'] ) {
       
   264 				$options['managertype'] = $_POST['ggissubscribe_managertype'];
       
   265 			} else {
       
   266 				$msg .= '<p>Manager type is required.</p>';
       
   267 			}
       
   268 			
       
   269 			if ( $_POST['ggissubscribe_maillists'] ) {
       
   270 				$maillists = explode(',', $_POST['ggissubscribe_maillists']);
       
   271 				foreach ( $maillists as $key => $val ){
       
   272 					$val = trim( strtolower( $val));
       
   273 					$maillists[$key] = $val;
       
   274 					if ( !is_email( $val) ){
       
   275 						$msg .= "<p>Please enter a valid email address for the mailing list. Your invalid entry was $val</p>";
       
   276 						unset( $maillists[$key]);
       
   277 					}
       
   278 				}
       
   279 				$options['maillists'] = implode( ',', $maillists);
       
   280 			} else {
       
   281 				$msg .= '<p>Mailing list entries are required.</p>';
       
   282 			}
       
   283 			
       
   284 			if ( $_POST['ggissubscribe_nextpage'] ) {
       
   285 				if ( !$this->is_url_valid( $_POST['ggissubscribe_nextpage'])){
       
   286 					$msg .= '<p>Please enter a valid next page. Your invalid entry was ' . $_POST['ggissubscribe_nextpage'] .'</p>';
       
   287 					unset( $_POST['ggissubscribe_nextpage']);
       
   288 				}
       
   289 				$options['nextpage'] = $_POST['ggissubscribe_nextpage'];
       
   290 			} else {
       
   291 				$msg .= '<p>Next page is required.</p>';
       
   292 			}
       
   293 			
       
   294 			if ( $_POST['ggissubscribe_formurl'] ) {
       
   295 				if ( !$this->is_url_valid( $_POST['ggissubscribe_formurl'])){
       
   296 					$msg .= '<p>Please enter a valid form URL. Your invalid entry was ' . $_POST['ggissubscribe_formurl'] .'</p>';
       
   297 					unset( $_POST['ggissubscribe_formurl']);
       
   298 				}
       
   299 				$options['formurl'] = $_POST['ggissubscribe_formurl'];
       
   300 			} else {
       
   301 				$msg .= '<p>Form URL is required.</p>';
       
   302 			}
       
   303 			if ( $msg <> '' ){
       
   304 				$msg = '<div id="message" class="error fade">'. $msg . '</div>';
       
   305 			}
       
   306 			if ( !is_null( $options) ){
       
   307 				update_option( 'ggis-Subscribe', serialize( $options));
       
   308 				$msg .= '<div id="message" class="updated fade"><p>Options saved.</p></div>';
       
   309 			}
       
   310 			return $msg;
       
   311 		}
       
   312 		
       
   313 		
       
   314 		// Verify string for valid URL format
       
   315 		function is_url_valid($url){			
       
   316 		    $url = @parse_url($url);
       
   317 		    if (!$url) {
       
   318 		        return false;
       
   319 		    }
       
   320 		
       
   321 		    $url = array_map('trim', $url);
       
   322 		    $url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port'];
       
   323 		
       
   324 		    $path = (isset($url['path'])) ? $url['path'] : '/';
       
   325 		    $path .= (isset($url['query'])) ? "?$url[query]" : '';
       
   326 		
       
   327 		    if (isset($url['host']) AND $url['host'] != gethostbyname($url['host'])) {
       
   328 		        if (PHP_VERSION >= 5) {
       
   329 		            $headers = implode('', get_headers("$url[scheme]://$url[host]:$url[port]$path"));
       
   330 		        }
       
   331 		        else {
       
   332 		            $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
       
   333 		
       
   334 		            if (!$fp)
       
   335 		            {
       
   336 		                return false;
       
   337 		            }
       
   338 		            fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $url[host]\r\n\r\n");
       
   339 		            $headers = fread($fp, 4096);
       
   340 		            fclose($fp);
       
   341 		        }
       
   342 		        return (bool)preg_match('#^HTTP/.*\s+[(200)]+\s#i', $headers);
       
   343 		    }
       
   344 		    return false;
       
   345 		}
       
   346 		
       
   347 	/*
       
   348 	*	START formSubmitProcess FUNCTION
       
   349 	*/
       
   350 		function formSubmitProcess(){
       
   351 		/*
       
   352 		*	Handles form subscription submissions to ezmlm-idx.
       
   353 		*	These are sent via email.
       
   354 		*		formtype - indicates that form is for this plugin [validated]
       
   355 		*			ggis-subscribe-form
       
   356 		*		maillist - Which mailing list the subscription is for. [validated]
       
   357 		*			listname@npexchange.org
       
   358 		*		action - Subscribe or unsubscribe [validated]
       
   359 		*		email - Email address to manage [validated
       
   360 		*		name - Subscriber's name [optional] [validated]
       
   361 		*		nextpage - Go to this URL after processing subscription.[validated]
       
   362 		*			http://example.com
       
   363 		*		formurl - URL with full subscribe/unsubscribe form[validated]
       
   364 		*			http://example.com
       
   365 		*		message - Any error messages plus comments to be output for visitor. [internal]
       
   366 		*		mailto - Fully formatted email address to process request. [internal]
       
   367 		*		errmsg - Message array for the user when some of the input valuse are invalid. [internal]
       
   368 		*/
       
   369 				
       
   370 			if ( !isset($_POST['formtype']) ){
       
   371 				return;
       
   372 			}
       
   373 						
       
   374 			// SET INITIAL VALUES
       
   375 			$_GET = array();	//flush GET
       
   376 			$formtype = 'ggis-subscribe-form';
       
   377 			$maillist = NULL;
       
   378 			$action = NULL;
       
   379 			$email = NULL;
       
   380 			$name = NULL;
       
   381 			$nextpage = NULL;
       
   382 			$formurl = NULL;
       
   383 			$message = '';
       
   384 			$mailto = NULL;
       
   385 			$errmsg = array(
       
   386 				'action'	=> '<p>That action does not exist. Please contact the site owner.</p>',
       
   387 				'email'	=> '<p>The email address you entered is not valid.</p>',
       
   388 				'name'	=> '<p>The name you entered is not valid.</p>',
       
   389 				'nexturl'	=> '<p>The Next URL is not valid. Please contact the site owner.</p>',
       
   390 				'formurl'	=> '<p>The Form URL is not valid. Please contact the site owner.</p>'
       
   391 				);
       
   392 			$ar_mailing = NULL;
       
   393 			$options = unserialize( get_option( 'ggis-Subscribe'));
       
   394 			
       
   395 			if ( $_POST['formtype'] != $formtype ) return;
       
   396 			
       
   397 			// POPULATE VALUES FROM POST
       
   398 			if( isset( $_POST['maillist'] ) )	$maillist = strtolower($_POST['maillist']);
       
   399 			if( isset( $_POST['action'] ) )	$action	=	strtolower($_POST['action']);
       
   400 			if( isset( $_POST['ggis-subscribe-email'] ) )	$email	=	strtolower($_POST['ggis-subscribe-email']);
       
   401 			if( isset( $_POST['name'] ) )	$name	=	$_POST['name'];
       
   402 			if( isset( $_POST['nextpage'] ) )	$nextpage	=	$_POST['nextpage'];
       
   403 			if( isset( $_POST['formurl'] ) )	$formurl	=	$_POST['formurl'];
       
   404 			
       
   405 			$_POST = array();	// flush POST
       
   406 			
       
   407 			// VALIDATION
       
   408 			if (!(in_array($action, array('subscribe', 'unsubscribe')))){
       
   409 				$message .= $errmsg['action'];
       
   410 			}
       
   411 			if (!(is_email($email))){
       
   412 				$message .= $errmsg['email'];
       
   413 			}
       
   414 			if (!(empty($name) || is_name_valid($name))){
       
   415 				$message .= $errmsg['name'];	
       
   416 			}
       
   417 			if (!($this->is_url_valid($nextpage))){
       
   418 				$message .= $errmsg['nexturl'];
       
   419 			}
       
   420 			if (!($this->is_url_valid($formurl))){
       
   421 				$message .= $errmsg['formurl'];
       
   422 			}
       
   423 			
       
   424 			// PROCESS SUBSCRIPTION
       
   425 			if ( $message === '' ){	// no errors
       
   426 				$ar_mailing = serialize( array(
       
   427 								'maillist'		=>	$maillist,
       
   428 								'action'		=>	$action,
       
   429 								'email'			=>	$email,
       
   430 								'name'			=>	$name
       
   431 							) );
       
   432 							
       
   433 				if ( $options['managertype'] == 'ezmlm' ) {
       
   434 					$ar_mailing = $this->formatEzmlm($ar_mailing);
       
   435 				}else if ( $options['managertype'] == 'mailman' ) {
       
   436 					$ar_mailing = $this->formatMailman($ar_mailing);
       
   437 				}else{
       
   438 					print_r ($options);
       
   439 					exit;
       
   440 				}
       
   441 			
       
   442 				// BUILD LIST ACTION EMAIL
       
   443 				$ar_mailing = unserialize($ar_mailing);
       
   444 			
       
   445 				// Do it
       
   446 				mail($ar_mailing['to'], $ar_mailing['subject'], $ar_mailing['message']);
       
   447 				
       
   448 				// Go to next page
       
   449 				header("Location: $nextpage");
       
   450 				exit;
       
   451 			}
       
   452 			
       
   453 			// ERRORS ON FORM
       
   454 			// Doctype setup
       
   455 			$doctype = '<?xml version="1.0" encoding="utf-8"?>';
       
   456 			$doctype .= "\n";
       
   457 			$doctype .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
       
   458 			$doctype .= "\n";
       
   459 			$doctype .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
       
   460 			$doctype .= "\n";
       
   461 				
       
   462 			?>
       
   463 			<?php echo $doctype; ?>
       
   464 			
       
   465 			<head>
       
   466 				<title>Subscription Management Errors - Please Correct</title>
       
   467 				<meta http-equiv="content-type" content="text/html;charset=utf-8" />
       
   468 				<meta http-equiv="Content-Style-Type" content="text/css" />
       
   469 			</head>
       
   470 			
       
   471 			<body>
       
   472 				<h1>There were some errors with your subscription management.</h1>
       
   473 				<?php echo $message; ?>
       
   474 				<p>To try again, please visit this page</p>
       
   475 				<blockquote><a id="subscription" name="subscription" title="Subscription Form" href="<?php echo $formurl; ?>"><?php echo $formurl; ?></a></blockquote>
       
   476 			
       
   477 			</body>
       
   478 			</html>
       
   479 			
       
   480 			<?php exit; ?>
       
   481 			<?php			
       
   482 			
       
   483 		}
       
   484 		/*
       
   485 		*	END formSubmitProcess FUNCTION
       
   486 		*/
       
   487 		
       
   488 		/*
       
   489 		*	START formatMailman FUNCTION
       
   490 		*/
       
   491 		function formatMailman($serialized_string){
       
   492 			$body = NULL;
       
   493 			$ar_mailing = unserialize( $serialized_string );
       
   494 			
       
   495 			// Properly format email
       
   496 			$mailto = str_replace('@', '-request@', $ar_mailing['maillist']);
       
   497 			// Format body
       
   498 			$body = $ar_mailing['action'] . ' address=' . $ar_mailing['email'];
       
   499 			$ar_mailing = serialize( array(
       
   500 								'to'		=>	$mailto,
       
   501 								'subject'		=>	$ar_mailing['action'],
       
   502 								'message'			=>	$body
       
   503 							) );
       
   504 			return $ar_mailing;
       
   505 		}
       
   506 		/*
       
   507 		*	END formatMailman FUNCTION
       
   508 		*/
       
   509 		
       
   510 		/*
       
   511 		*	START formatEzmlm FUNCTION
       
   512 		*/
       
   513 		function formatEzmlm($serialized_string){
       
   514 			$body = NULL;
       
   515 			$ar_mailing = unserialize( $serialized_string );
       
   516 			
       
   517 			// Properly format email
       
   518 			$email = str_replace('@', '=', $ar_mailing['email']);
       
   519 			// Create mailto
       
   520 			$mailto = str_replace('@', '-'. $ar_mailing['action'] .'-'. $email . '@', $ar_mailing['maillist']);
       
   521 			$ar_mailing = serialize( array(
       
   522 								'to'		=>	$mailto,
       
   523 								'subject'		=>	$ar_mailing['action'],
       
   524 								'message'			=>	$body
       
   525 							) );
       
   526 			return $ar_mailing;
       
   527 		}
       
   528 		/*
       
   529 		*	END formatEzmlm FUNCTION
       
   530 		*/
       
   531 		
       
   532 		// Verify string for valid name format
       
   533 		function is_name_valid($strname) { 
       
   534 		  if(preg_match('/^[a-zA-Z][a-zA-Z\',\.\- \s]*$/', $strname)) return TRUE; 
       
   535 		  else return FALSE; 
       
   536 		}
       
   537 
       
   538 	}	//End Class ggisSubscribe
       
   539 	
       
   540 	// SUBSTANTIATE AND ACT USING CLASS	
       
   541 	if (class_exists("ggisSubscribe")) {
       
   542 		$ggisSubscribe = new ggisSubscribe();
       
   543 	}
       
   544 	
       
   545 	//Actions and Filters   
       
   546 	if (isset($ggisSubscribe)) {
       
   547 		//Actions
       
   548 		add_action('init', array(&$ggisSubscribe, 'formSubmitProcess'));
       
   549 		add_action('wp_head', array(&$ggisSubscribe, 'addHeaderCode'));
       
   550 		add_action('admin_menu', array(&$ggisSubscribe, 'ggis_admin_add_pages'));
       
   551 		//Filters
       
   552 		add_filter('the_content', array(&$ggisSubscribe, 'the_content_filter')); 
       
   553 		add_filter('widget_text', array(&$ggisSubscribe, 'widget_text_filter'));
       
   554 	}
       
   555 
       
   556 }	// End ggis Subscribe
       
   557 
       
   558 ?>