VERSION HISTORY for what's new and current bugfixes.
Author: Oliver Seidel
Version: 8.5
Author URI: http://www.deliciousdays.com
*/
/*
Copyright 2006-2008 Oliver Seidel (email : oliver.seidel@deliciousdays.com)
WHAT's NEW in cformsII - v8.5
*) feature: better custom-files support (CSS, CAPTCHA) to outwit the short comings of
the WP auto update feature that removes/overwrites custom files
*ALL custom files** should go into "/plugins/cforms-custom"
*) feature: added/changed default way of referencing forms, now:
for better transparency and persistence (when deleting forms)
*) feature: WP comment feature: extra admin notification option available now
*) bugfix: tracking: fixed filter by form name
*) bugfix: radio option ID != label "for=", now they match up
*) bugfix: fixed 'waiting' message while submitting (escaped characters & styling)
*) bugfix: fixed RoleManager support for the new & enhanced tracking page
*) bugfix: fixed HTML tags in checkbox group display text (wizard dialog)
*) bugfix: fixed HTML tags in checkbox group display text (in form email)
*) other: enhanced sanitizing of custom IDs for input fields
*) other: added {Referer} & {PostID}
*) other: enhanced XML download format
*) other: replaced all deprecated get_settings()
*) feature: added the possiblity to change the FROM: address to fake the user's
this is not recommended, but a widely asked for 'feature', use at your own risk
*/
$localversion = '8.5';
load_plugin_textdomain('cforms');
### http://trac.wordpress.org/ticket/3002
$plugindir = dirname(plugin_basename(__FILE__));
$cforms_root = get_option('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 ( substr(get_option('cforms'.$no.'_tellafriend'),0,1)=='2' && $send2author ) ### called from lib_WPcomments ?
return $all_valid;
###
### paint form
###
$success=false;
if ( isset($_GET['cfemail']) && substr(get_option('cforms'.$no.'_tellafriend'),0,1)=='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
$usermessage_text = check_default_vars($usermessage_text,$no);
$usermessage_text = check_cust_vars($usermessage_text,$track,$no);
if( substr(get_option('cforms'.$no.'_showpos'),0,1)=='y' ) {
$content .= $ntt . '