contact form update
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 1 Dec 2016 20:37:23 +0000 (15:37 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 1 Dec 2016 20:37:23 +0000 (15:37 -0500)
classes/class_contact_form.inc

index 4fc10f6..49b4a47 100755 (executable)
@@ -18,17 +18,17 @@ class contact_form {
 
        /**
         * contact_form: constructor
-        * 
-        * @return void 
+        *
+        * @return void
         * @access public
         **/
        function contact_form()
        {
-               $this->CDB =& new GLM_DB();     // creates DB object    
+               $this->CDB =& new GLM_DB();     // creates DB object
                $this->set_DB_fields();                 // set up the DB_fields array (configuration)
                $this->set_int_array();                 // interest array
                $this->email = OWNER_EMAIL;             // email address for mail function
-               $this->table_name = 'contact'; // the contact table 
+               $this->table_name = 'contact'; // the contact table
                $this->styleLabel = "labelcell";// css style for the labelcell
                $this->fieldcell = "fieldcell"; // css style for the field input
                $this->styleLabelSmall = "smalllabelcell";// css style for the labelcell
@@ -40,9 +40,9 @@ class contact_form {
 
        /**
        * get_form: one function to rule them all
-        * 
-        * @return void 
-        * @access 
+        *
+        * @return void
+        * @access
         **/
        function get_form()
        {
@@ -63,9 +63,9 @@ class contact_form {
 
        /**
         * set_DB_fields:
-        * 
-        * @return 
-        * @access 
+        *
+        * @return
+        * @access
         **/
        function set_DB_fields()
        {
@@ -85,17 +85,17 @@ class contact_form {
                $DB_fields[]=array('name'=>'contact_method','title' => 'Preferred Contact Method',      'type' => 'radio', 'options'=>'Telephone|E-mail');
                $DB_fields[]=array('name'=>'comments',          'title' =>'Message',    'type' => 'desc');
                $DB_fields[]=array('name'=>'mail_ok',           'title' => 'Sign me up for the Newsletter',     'type' => 'checkbox','value'=>'t','colspan'=>4,'checked'=>1);
-               
-               $this->DB_fields = &$DB_fields; 
+
+               $this->DB_fields = &$DB_fields;
        }
 
        /**
         * set_int_array:
-        * 
-        * @return 
-        * @access 
+        *
+        * @return
+        * @access
         **/
-       
+
        function set_int_array()
        {
                $int_array = array(
@@ -104,44 +104,44 @@ class contact_form {
                                "class_registration" => "Class Registration",
                                "ticket_sales"          => "Ticket Sales",
                                "no_preference"         => "No Preference",
-                               );              
+                               );
                $this->int_array = $int_array;
        }
 
 
        /**
         * interest:
-        * @param $field: 
-        * 
-        * @return 
-        * @access 
+        * @param $field:
+        *
+        * @return
+        * @access
         **/
        function interest($field)
-       {               
+       {
                $out .= '<table><tr>';
                $count = 0;
                foreach($this->int_array as $key=>$value)
                {
                        if($count==0)
                        {
-                               $out .= '<td>';         
+                               $out .= '<td>';
                        }
                        $out .= '<input type="checkbox" name="interest[]" value="'.$key.'"';
                        if(strstr($field,$key))
                        {
-                               $out .= ' checked';                             
+                               $out .= ' checked';
                        }
-                       $out .= '>'.$value.'<br>';              
+                       $out .= '>'.$value.'<br>';
                        if($count==5)
                        {
-                               $out .= '</td><td>';            
+                               $out .= '</td><td>';
                        }
                        if($count==11)
                        {
-                               $out .= '</td>';                
+                               $out .= '</td>';
                        }
-                       $count++;               
-               }               
+                       $count++;
+               }
                $out .= "</tr></TABLE>";
                return( $out );
        }
@@ -149,13 +149,13 @@ class contact_form {
 
        /**
        * display_form: shows the form and any errors in it
-        * @param $error = NULL: error array  
-        * 
+        * @param $error = NULL: error array
+        *
         * @return string $out
         * @access public
         **/
        function display_form($error=NULL)
-       {                       
+       {
                if(is_array($_POST))
                {
                        foreach($_POST as $k=>$v)
@@ -194,7 +194,7 @@ class contact_form {
                                        //if($value['req'])
                                        //{
                                        //      $out .= '</span>';
-                                       //}     
+                                       //}
                                        $out .= '</td>
                                                <td colspan="'.$value["colspan"].'" class="'.$field.'">';
                                        $out .= GLM_TEMPLATE::build_picklist($value['name'],$GLOBALS['states_US'],$_POST['state']);
@@ -214,7 +214,7 @@ class contact_form {
                                                $colcount++;
                                        }
                                break;
-                               
+
                                case "country":
                                        if( $value['colspan'] == 2 || $colcount == 1 )
                                        {
@@ -231,21 +231,21 @@ class contact_form {
                                                $field = $this->fieldcell;
                                        }
                                        //$out .= '<tr>';
-                                       
+
                                        $out .= "\n\t".'<td colspan="'.$value['colspan'].'" class="'.$label.'">';
                                        if($value['req'])
                                        {
                                                $out .= '<span class="req">*</span> ';
                                        }
                                        $out.=$value['title']."</td>";
-                                       
+
                                        $out .= "\n\t".'<td colspan="'.$value['colspan'].'" class="'.$field.'">';
                                        $out .= GLM_TEMPLATE::build_picklist($value['name'],$GLOBALS['country_codes'],$_POST['country']);
                                        $out .= "</td>\n";
-                                       
+
                                        $out .= '</tr>';
                                break;
-                               
+
                                case "text":
                                        if( $value['colspan'] == 2 || $colcount == 1 )
                                        {
@@ -267,11 +267,11 @@ class contact_form {
                                                $out .= '<span class="req">*</span> ';
                                        }
                                        $out .= $value['title'];
-                                       /* 
+                                       /*
                                        if($value['req'])
                                        {
                                                $out .= '</span>';
-                                       }       
+                                       }
                                         */
                                        $out .= '</td>
                                                <td colspan="'.$value["colspan"].'" class="'.$field.'">
@@ -360,7 +360,7 @@ class contact_form {
                                        {
                                                $cols=' cols="'.$value['cols'].'"';
                                        }
-                                       
+
                                        $out .= '<tr><td colspan="4" class="'.$this->fieldcell.'">'.$value[title].':
                                                <textarea cols="30" rows="5" name="'.$value["name"].'"'.$rows.$cols.'>'.$_POST[$value["name"]].'</textarea>';
                                $out .= '</tr>';
@@ -385,13 +385,13 @@ class contact_form {
                                        $out .= '</td>';
                                        $out .= '</tr>';
                                break;
-                               
+
                                case "radio":
                                        $out .= '<tr><td colspan="2" class="'.$this->styleLabel.'" nowrap>'.$value[title].':</td>';
                                        $rvals = explode("|",$value['options']);
-                                       
+
                                        // check to see if any of these vals is in the post array (did we already submit this form basically)
-                                       
+
                                        if(isset($_POST[$value['name']])) // it's set, so we must have something there
                                        {
                                                $dvar = $_POST[$value['name']];
@@ -399,9 +399,9 @@ class contact_form {
                                        {
                                                $dvar = 'notset';
                                        }
-                                       
+
                                        $inc = 0;
-                                       
+
                                        foreach($rvals as $rvK => $rvV)
                                        {
                                                if($dvar != 'notset')
@@ -417,24 +417,24 @@ class contact_form {
                                                {
                                                        if($inc == 0)
                                                        {
-                                                               $checked = ' checked';                                                  
+                                                               $checked = ' checked';
                                                                $inc =1;
                                                        }else
                                                        {
                                                                $checked = '';
                                                        }
                                                }
-                                               
+
                                                $rads .= '<input type="radio" name="'.$value['name'].'" value="'.$rvV.'"'.$checked.'> '.$rvV.'<br>'."\n";
                                        }
-                                       
+
                                        $out .= '<td colspan="2" class="'.$this->fieldcell.'">';
                                         $out.=$rads;
                                        $out .= '</td>';
                                        $out .= '</tr>';
                                break;
                        }
-               }               
+               }
                $out .= '<tr align="center"><td colspan="4"><input type="submit" name="Command" value="Send"></td></tr>';
                $out .= '</table>';
                $out .= '</form></div>';
@@ -444,8 +444,8 @@ class contact_form {
        /**
        * form_process: process the form checking for any required form values as set up in the
        * DB_fields array.
-        * 
-        * @return error array if bad 
+        *
+        * @return error array if bad
         * @access public
         **/
        function form_process()
@@ -455,7 +455,7 @@ class contact_form {
                $ban_words[] = "mime-version";
                $ban_words[] = "cc\:";
                $ban_words[] = "bcc\:";
-               
+
                if(is_array($_POST))
                {
                        foreach($_POST as $k=>$v)
@@ -498,14 +498,14 @@ class contact_form {
                                                $in_vars[] = 'f';
                                        }else
                                        {
-                                               $in_vars[] = addslashes(trim($_POST[$value['name']]));
+                                               $in_vars[] = addslashes(stripslashes(trim($_POST[$value['name']])));
                                        }
                                        $in_fields[] = $value['name'];
-                                       
+
                                }else
                                {
                                        $in_fields[] = $value['name'];
-                                       $in_vars[] = addslashes(trim($_POST[$value['name']]));
+                                       $in_vars[] = addslashes(stripslashes(trim($_POST[$value['name']])));
                                }
                        }
                }
@@ -521,7 +521,7 @@ class contact_form {
                {
                        $invars = implode("','",$in_vars);
                }
-               $query = "INSERT INTO ".$this->table_name." 
+               $query = "INSERT INTO ".$this->table_name."
                        ($infds)
                        VALUES
                        ('$invars')";