VERSION HISTORY for what's new and current bugfixes.
Author: Oliver Seidel
Version: 8.3
Author URI: http://www.deliciousdays.com
*/
/*
Copyright 2006-2008 Oliver Seidel (email : oliver.seidel@deliciousdays.com)
WHAT's NEW in cformsII - v8.3
*) feature: Completely revised Tracking/Edit UI
*) feature: Tracking: XML download
*) feature: Tracking: Editable fields
*) bugfix: fixed IIS issues with CAPTCHA RESET
*) bugfix: datepicker default values (non-digit) would cause false start dates
*) bugfix: "page" wasn't properly recorded in some cases for ajax submission
*) bugfix: multiple upload fields: if the first field wasn't populated, none of the
following attachments would be send in the email (but saved on the server)
*) bugfix: if all submissions were deleted from tracking tables, the first new form
submission would be partially broken
*/
$localversion = '8.3';
load_plugin_textdomain('cforms');
### http://trac.wordpress.org/ticket/3002
$plugindir = dirname(plugin_basename(__FILE__));
$cforms_root = get_settings('siteurl') . '/wp-content/plugins/'.$plugindir;
global $wpdb;
### db settings
$wpdb->cformssubmissions = $wpdb->prefix . 'cformssubmissions';
$wpdb->cformsdata = $wpdb->prefix . 'cformsdata';
if( !class_exists('buttonsnap') )
require_once (dirname(__FILE__) . '/buttonsnap.php');
require_once (dirname(__FILE__) . '/editor.php');
require_once (dirname(__FILE__) . '/lib_aux.php');
### need this for captchas
add_action('template_redirect', 'start_cforms_session');
function start_cforms_session() {
@session_cache_limiter('private, must-revalidate');
@session_cache_expire(0);
@session_start();
}
### do a couple of things necessary as part of plugin activation
if (isset($_GET['activate']) && $_GET['activate'] == 'true')
require_once(dirname(__FILE__) . '/lib_activate.php');
###
### main function
###
function cforms($args = '',$no = '') {
global $smtpsettings, $styles, $subID, $cforms_root, $wpdb, $track, $wp_db_version;
//Safety, in case someone uses '1' for the default form
$no = ($no=='1')?'':$no;
parse_str($args, $r); // parse all args, and if not specified, initialize to defaults
//custom fields support
if ( !(strpos($no,'+') === false) ) {
$no = substr($no,0,-1);
$customfields = build_fstat($args);
$field_count = count($customfields);
$custom=true;
} else {
$custom=false;
$field_count = get_option('cforms'.$no.'_count_fields');
}
$content = '';
$err=0;
$filefield=0; // for multiple file upload fields
$validations = array();
$all_valid = 1;
$off=0;
$fieldsetnr=1;
$c_errflag=false;
$custom_error='';
$usermessage_class='';
//??? check for WP2.0.2
if ( $wp_db_version >= 3440 && function_exists('wp_get_current_user') )
$user = wp_get_current_user();
if( isset($_REQUEST['sendbutton'.$no]) ) { /* alternative sending: both events r ok! */
require_once (dirname(__FILE__) . '/lib_nonajax.php');
$usermessage_class = $all_valid?' success':' failure';
}
if ( get_option('cforms'.$no.'_tellafriend')=='2' && $send2author ) //called from lib_WPcomments ?
return $all_valid;
//
// paint form
//
$success=false;
if ( isset($_GET['cfemail']) && get_option('cforms'.$no.'_tellafriend')=='2' ){ // fix for WP Comment (loading after redirect)
$usermessage_class = ' success';
$success=true;
if ( $_GET['cfemail']=='sent' )
$usermessage_text = preg_replace ( '|\r\n|', '
', stripslashes(get_option('cforms'.$no.'_success')) );
elseif ( $_GET['cfemail']=='posted' )
$usermessage_text = preg_replace ( '|\r\n|', '
', stripslashes(get_option('cforms_commentsuccess')) );
}
$break='
';
$nl="\n";
$tab="\t";
$tt="\t\t";
$ntt="\n\t\t";
$nttt="\n\t\t\t";
//either show message above or below
if( substr(get_option('cforms'.$no.'_showpos'),0,1)=='y' ) {
$content .= $ntt . '
cforms contact form by delicious:days
'; ### either show message above or below if( substr(get_option('cforms'.$no.'_showpos'),1,1)=='y' && !($success&&get_option('cforms'.$no.'_redirect')==2)) $content .= $tt . '' . $nl; return $content; } ### some css for positioning the form elements function cforms_style() { global $wp_query, $cforms_root, $localversion; ### add content actions and filters $page_obj = $wp_query->get_queried_object(); $onPages = str_replace(' ','',stripslashes(htmlspecialchars( get_option('cforms_include') ))); $onPagesA = explode(',', $onPages); if( $onPages=='' || in_array($page_obj->ID,$onPagesA) ){ echo "\n\n"; if( get_option('cforms_no_css')<>'1' ) echo ''."\n"; echo ''."\n"; if( get_option('cforms_datepicker')=='1' ){ $nav = get_option('cforms_dp_nav'); $dformat = str_replace(array('M','EE','E'),array('m','dddd','ddd'),stripslashes(get_option('cforms_dp_date'))); echo ''."\n"; echo ''."\n"; } echo ''."\n\n"; } } ### replace placeholder by generated code function cforms_insert( $content ) { global $post; if ( strpos($content,'#', $content) && check_for_taf('',$post->ID) ) $content = preg_replace('/()?(<\/p>)?/', cforms('').'$1$2', $content); } else { if(preg_match('##', $content) && check_for_taf($i,$post->ID) ) $content = preg_replace('/(
)?(<\/p>)?/', cforms('',$i).'$1$2', $content); } $content = str_replace('
','',$content); } } return $content; } ### build field_stat string from array (for custom forms) function build_fstat($fields) { $cfarray = array(); for($i=0; $i