VERSION HISTORY for what's new and current bugfixes.
Author: Oliver Seidel
Version: 9.4
Author URI: http://www.deliciousdays.com
*/
/*
Copyright 2006-2008 Oliver Seidel (email : oliver.seidel@deliciousdays.com)
WHAT's NEW in cformsII - v9.4
README:
v9.0 introduces a completely new method of storing its settings,
***** please make a WP database backup first (!) *****
and then migrate your settings (cforms will guide you!)
*) feature: post form submission admin-email-TO: address correction ("dynamic admin email address")
*) feature: specific insert position can now be determined when adding new fields
*) feature: TAF: added support for proper WP 2.7 custom field registration (screen options)
*) bugfix: major bug causing the tracking page to not display correctly
*) bugfix: fixed some WP2.7 admin UI incompatibilities
*) bugfix: fixed TAF-option for WP2.7 New post/page UI (drag&drop, open/close)
*) bugfix: multi-select / check box groups for multi-page form hack
*) bugfix: special characters would cause captcha reload to revert back to certain default settings
*) bugfix: fixed autosave issue with TellAFriend flag being deleted
*) other: added default number (5) of shown RSS entries, if not configured by user
*/
$localversion = '9.4';
### db settings
global $wpdb, $wp_db_version;
$wpdb->cformssubmissions = $wpdb->prefix . 'cformssubmissions';
$wpdb->cformsdata = $wpdb->prefix . 'cformsdata';
### button stuff
if( !class_exists('buttonsnap') )
require_once (dirname(__FILE__) . '/buttonsnap.php');
require_once(dirname(__FILE__) . '/lib_functions.php');
### new global settings container, will eventually be the only one!
global $cformsSettings;
$cformsSettings = get_option('cforms_settings');
### do a couple of things necessary as part of plugin activation
$dummy = __('Please go to the cforms admin page and run the update process.', 'cforms');
add_action('admin_notices', create_function('', 'global $plugindir, $cformsSettings; if (is_array($cformsSettings) && $cformsSettings[\'global\'][\'update\']) echo \'
\' . sprintf( __(\'Please go to the cforms admin page and run the update process.\', \'cforms\') ,\'admin.php?page=\'.$plugindir.\'/cforms-global-settings.php\') . \'
\';') );
register_activation_hook( __FILE__, 'cforms_activate' );
function cforms_activate() {
cforms_init();
require_once(dirname(__FILE__) . '/lib_activate.php');
}
### settings corrputed?
if ( !is_array($cformsSettings) ){
add_action('admin_menu', 'settings_corrupted');
return;
}
### if all data has been erased quit
function settings_corrupted() {
$tmp = basename(dirname(__FILE__));
if (function_exists('add_menu_page')) {
add_menu_page(__('cformsII', 'cforms'), __('cformsII', 'cforms'), 'manage_cforms', $tmp.'/cforms-corrupted.php');
}
elseif (function_exists('add_management_page')) {
add_management_page(__('cformsII', 'cforms'), __('cformsII', 'cforms'), 'manage_cforms', $tmp.'/cforms-corrupted.php');
}
}
require_once (dirname(__FILE__) . '/lib_aux.php');
require_once (dirname(__FILE__) . '/editor.php');
### http://trac.wordpress.org/ticket/3002
$plugindir = $cformsSettings['global']['plugindir'];
$cforms_root = $cformsSettings['global']['cforms_root'];
### 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();
}
###
### main function
###
function cforms($args = '',$no = '') {
global $smtpsettings, $styles, $subID, $cforms_root, $wpdb, $track, $wp_db_version, $cformsSettings;
//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 = $cformsSettings['form'.$no]['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($cformsSettings['form'.$no]['cforms'.$no.'_tellafriend'],0,1)=='2' && $send2author ) ### called from lib_WPcomments ?
return $all_valid;
###
### paint form
###
$success=false;
if ( isset($_GET['cfemail']) && substr($cformsSettings['form'.$no]['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($cformsSettings['form'.$no]['cforms'.$no.'_success']) );
elseif ( $_GET['cfemail']=='posted' )
$usermessage_text = preg_replace ( '|\r\n|', ' ', stripslashes($cformsSettings['form'.$no]['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);
$umc = ($usermessage_class<>''&&$no>1)?' '.$usermessage_class.$no:'';
if( substr($cformsSettings['form'.$no]['cforms'.$no.'_showpos'],0,1)=='y' ) {
$content .= $ntt . '
' . $usermessage_text . '
';
$actiontarget = 'a';
} else if ( substr($cformsSettings['form'.$no]['cforms'.$no.'_showpos'],1,1)=='y' )
$actiontarget = 'b';
### redirect == 2 : hide form? || or if max entries reached!
if ( ($cformsSettings['form'.$no]['cforms'.$no.'_redirect']==2 && isset($_REQUEST['sendbutton'.$no]) && $all_valid) )
return $content;
else if ( ($cformsSettings['form'.$no]['cforms'.$no.'_maxentries']<>'' && get_cforms_submission_left($no)<=0) || !cf_check_time($no) ){
if ( $cflimit == "reached" )
return stripslashes($cformsSettings['form'.$no]['cforms'.$no.'_limittxt']);
else
return $content.stripslashes($cformsSettings['form'.$no]['cforms'.$no.'_limittxt']);
}
### alternative form action
$alt_action=false;
if( $cformsSettings['form'.$no]['cforms'.$no.'_action']=='1' ) {
$action = $cformsSettings['form'.$no]['cforms'.$no.'_action_page'];
$alt_action=true;
}
else if( substr($cformsSettings['form'.$no]['cforms'.$no.'_tellafriend'],0,1)=='2' )
$action = $cforms_root . '/lib_WPcomment.php'; ### re-route and use WP comment processing
else
$action = get_current_page(false) . '#usermessage'. $no . $actiontarget;
$content .= $ntt . '';
### link love? you bet ;)
$content .= $ntt . '