ID ){ $validations[$i+$off] = 1; // auto approved continue; } } ### captcha not for logged in users $jump = ($field_stat[1] == 'captcha') && is_user_logged_in() && $captchaopt['fo']<>'1'; $jump = $jump || ( ($field_stat[1] == 'verification') && is_user_logged_in() && $captchaopt['foqa']<>'1' ); if( $jump ) continue; ### if subscribe not shown, skip $isSubscribed==''; if ( class_exists('sg_subscribe') ){ global $sg_subscribe; sg_subscribe_start(); $isSubscribed = $sg_subscribe->current_viewer_subscription_status(); } if( in_array($field_type,array('subscribe')) && $isSubscribed<>'' ) continue; ### comment luv get_currentuserinfo(); global $user_level; if( in_array($field_type,array('luv')) && $user_level==10 ) continue; //input field names & label $custom_names = ($cformsSettings['form'.$no]['cforms'.$no.'_customnames']=='1')?true:false; if ( $custom_names ){ preg_match('/^([^#\|]*).*/',$field_name,$input_name); if ( strpos($input_name[1],'[id:')!==false ){ $idPartA = strpos($input_name[1],'[id:'); $idPartB = strpos($input_name[1],']',$idPartA); $current_field = $_REQUEST[ cf_sanitize_ids( substr($input_name[1],$idPartA+4,($idPartB-$idPartA)-4) ) ]; $field_name = substr_replace($input_name[1],'',$idPartA,($idPartB-$idPartA)+1); } else $current_field = $_REQUEST[ cf_sanitize_ids($input_name[1]) ]; } else $current_field = $_REQUEST['cf'.$no.'_field_' . ((int)$i+(int)$off)]; if( in_array($field_type,array('luv','subscribe','comment','url','email','cauthor')) ) // WP comment field name exceptions $current_field = $_REQUEST[$field_type]; $current_field = is_array($current_field) ? $current_field : stripslashes($current_field); if( $field_emailcheck ) { // email field // special email field in WP Commente if ( $field_type=='email' ) $validations[$i+$off] = cforms_is_email( $_REQUEST['email']) || (!$field_required && $_REQUEST['email']==''); else $validations[$i+$off] = cforms_is_email( $current_field ) || (!$field_required && $current_field==''); if ( !$validations[$i+$off] && $err==0 ) $err=1; } else if( $field_required ) { // just required if( in_array($field_type,array('cauthor','url','comment','pwfield','textfield','datepicker','textarea','yourname','youremail','friendsname','friendsemail')) ){ $validations[$i+$off] = ($current_field=='')?false:true; }else if( $field_type=="checkbox" ) { $validations[$i+$off] = ($current_field=='')?false:true; }else if( $field_type=="selectbox" || $field_type=="emailtobox" ) { $validations[$i+$off] = !($current_field == '-' ); }else if( $field_type=="multiselectbox" ) { // how many multiple selects ? $all_options = $current_field; if ( count($all_options) <= 1 && $all_options[0]=='' ) $validations[$i+$off] = false; else $validations[$i+$off] = true; }else if( $field_type=="upload" ) { // prelim upload check $validations[$i+$off] = !($_FILES['cf_uploadfile'.$no][name][$filefield++]==''); if ( !$validations[$i+$off] && $err==0 ) { $err=3; $fileerr = $cformsSettings['global']['cforms_upload_err2']; } }else if( in_array($field_type,array('cauthor','url','email','comment')) ) { // prelim upload check $validations[$i+$off] = ($_REQUEST[$field_type]=='')?false:true; // regexp set for textfields? $obj = explode('|', $c_err[0], 3); if ( $obj[2] <> '') { $reg_exp = str_replace('/','\/',stripslashes($obj[2]) ); if( !preg_match('/'.$reg_exp.'/',$_REQUEST[$field_type]) ) $validations[$i+$off] = false; } } if ( !$validations[$i+$off] && $err==0 ) $err=1; } else if( $field_type == 'verification' ){ // visitor verification code $validations[$i+$off] = 1; if ( $_REQUEST['cforms_a'.$no] <> md5(rawurlencode(strtolower($_REQUEST['cforms_q'.$no]))) ) { $validations[$i+$off] = 0; $err = !($err)?2:$err; } } else if( $field_type == 'captcha' ){ // captcha verification $validations[$i+$off] = 1; $a = explode('+',$_COOKIE['turing_string_'.$no]); $a = $a[1]; $b = md5( ($captchaopt['i'] == 'i')?strtolower($_REQUEST['cforms_captcha'.$no]):$_REQUEST['cforms_captcha'.$no]); if ( $a <> $b ) { $validations[$i+$off] = 0; $err = !($err)?2:$err; } } else $validations[$i+$off] = 1; // REGEXP now outside of 'is required' if( in_array($field_type,array('cauthor','url','comment','pwfield','textfield','datepicker','textarea','yourname','youremail','friendsname','friendsemail')) ){ // regexp set for textfields? $obj = explode('|', $c_err[0], 3); if ( $obj[2] <> '') { // check against other field! if ( isset($_REQUEST[$obj[2]]) && $_REQUEST[$obj[2]]<>'' ){ if( $current_field <> $_REQUEST[$obj[2]] ) $validations[$i+$off] = false; } else { // classic regexp $reg_exp = str_replace('/','\/',stripslashes($obj[2]) ); if( $current_field<>'' && !preg_match('/'.$reg_exp.'/', $current_field) ){ $validations[$i+$off] = false; } } } if ( !$validations[$i+$off] && $err==0 ) $err=1; } $all_valid = $all_valid && $validations[$i+$off]; if ( $c_err[1] <> '' && $validations[$i+$off] == false ){ $c_errflag=4; if ( $cformsSettings['global']['cforms_liID']=='1' ){ $custom_error .= '
  • '.stripslashes($c_err[1]).' »
  • '; } else $custom_error .= '
  • ' . stripslashes($c_err[1]) . '
  • '; } } // // have to upload a file? // $uploadedfile=''; $filefield=0; // for multiple file upload fields if( isset($_FILES['cf_uploadfile'.$no]) && $all_valid){ foreach( $_FILES['cf_uploadfile'.$no][name] as $value ) { if(!empty($value)){ // this will check if any blank field is entered $file = $_FILES['cf_uploadfile'.$no]; $fileerr = ''; // A successful upload will pass this test. It makes no sense to override this one. if ( $file['error'][$filefield] > 0 ) $fileerr = $cformsSettings['global']['cforms_upload_err1']; // A successful upload will pass this test. It makes no sense to override this one. $fileext[$filefield] = strtolower( substr($value,strrpos($value, '.')+1,strlen($value)) ); $allextensions = explode(',' , preg_replace('/\s/', '', strtolower($cformsSettings['form'.$no]['cforms'.$no.'_upload_ext'])) ); if ( $cformsSettings['form'.$no]['cforms'.$no.'_upload_ext']<>'' && !in_array($fileext[$filefield], $allextensions) ) $fileerr = $cformsSettings['global']['cforms_upload_err5']; // A non-empty file will pass this test. if ( !( $file['size'][$filefield] > 0 ) ) $fileerr = $cformsSettings['global']['cforms_upload_err2']; // A non-empty file will pass this test. if ( $file['size'][$filefield] >= (int)$cformsSettings['form'.$no]['cforms'.$no.'_upload_size'] * 1024 ) $fileerr = $cformsSettings['global']['cforms_upload_err3']; // A properly uploaded file will pass this test. There should be no reason to override this one. if (! @ is_uploaded_file( $file['tmp_name'][$filefield] ) ) $fileerr = $cformsSettings['global']['cforms_upload_err4']; if ( $fileerr <> '' ){ $err = 3; $all_valid = false; } else { // cool, got the file! if ( !$cformsSettings['form'.$no]['cforms'.$no.'_noattachments'] ) { $uploadedfile = file($file['tmp_name'][$filefield]); $fp = fopen($file['tmp_name'][$filefield], "rb"); //Open it $fdata = fread($fp, filesize($file['tmp_name'][$filefield])); //Read it $filedata[$filefield] = chunk_split(base64_encode($fdata)); //Chunk it up and encode it as base64 so it can emailed fclose($fp); } } // file uploaded } // if !empty $filefield++; } // while all file } // no file upload triggered // // what kind of error message? // switch($err){ case 0: break; case 1: $usermessage_text = preg_replace ( array("|\\\'|",'/\\\"/','|\r\n|'),array(''','"','
    '), $cformsSettings['form'.$no]['cforms'.$no.'_failure'] ); break; case 2: $usermessage_text = preg_replace ( array("|\\\'|",'/\\\"/','|\r\n|'),array(''','"','
    '), $cformsSettings['global']['cforms_codeerr'] ); break; case 3: $usermessage_text = preg_replace ( array("|\\\'|",'/\\\"/','|\r\n|'),array(''','"','
    '), $fileerr); break; case 4: $usermessage_text = preg_replace ( array("|\\\'|",'/\\\"/','|\r\n|'),array(''','"','
    '), $cformsSettings['form'.$no]['cforms'.$no.'_failure'] ); break; } if ( $err<>0 && $c_errflag ) $usermessage_text .= '
      '.$custom_error.'
    '; // proxy functions function cforms_is_email($string){ return eregi("^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $string); } ?>