Example #1
0
/**
 * 	Easy Contact Forms entrypoint
 *
 */
function easycontactforms_entrypoint()
{
    $l_locale = get_locale();
    $map = $_REQUEST;
    if (!defined('EASYCONTACTFORMS__APPLICATION_ROOT')) {
        DEFINE('EASYCONTACTFORMS__APPLICATION_ROOT', rtrim(get_bloginfo('wpurl'), '/'));
    }
    if (!defined('EASYCONTACTFORMS__engineWebAppDirectory')) {
        DEFINE('EASYCONTACTFORMS__engineWebAppDirectory', plugins_url('', __FILE__));
    }
    if (!defined('_EASYCONTACTFORMS_PLUGIN_PATH')) {
        DEFINE('_EASYCONTACTFORMS_PLUGIN_PATH', rtrim(plugin_dir_path(__FILE__), "/\\"));
    }
    $tag = strtolower(str_replace('_', '-', $l_locale));
    $map['l'] = $tag;
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-strings.php';
    if (!@(include_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-resources_' . $tag . '.php')) {
        require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-resources_en-gb.php';
        $map['l'] = 'en-gb';
    }
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-utils.php';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-database.php';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-root.php';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-applicationsettings.php';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-appconfigdata.php';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-securitymanager.php';
    global $current_user;
    $userid = $current_user->ID;
    unset($map['frid']);
    $map['frid'] = $userid;
    if (isset($map['ac']) && $map['ac'] == '1') {
        EasyContactFormsRoot::ajaxCall($map);
        die;
    }
    $map = EasyContactFormsSecurityManager::getRights($map);
    if (isset($map['m']) && $map['m'] == 'download') {
        EasyContactFormsRoot::download($map);
        die;
    }
    if (!isset($map['m'])) {
        $map['m'] = 'show';
    }
    if (!isset($map['t'])) {
        $map['t'] = 'DashBoardView';
    }
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-widget');
    wp_enqueue_script('jquery-ui-mouse');
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_style('easy-contact-forms-admin-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/smoothness/jquery-ui.css', false, '1.4.9', false);
    wp_enqueue_script('jquery-ui-draggable');
    wp_enqueue_script('jquery-ui-position');
    wp_enqueue_script('jquery-ui-resizable');
    wp_enqueue_script('jquery-ui-dialog');
    wp_enqueue_script('json-json', plugins_url('js/json.js', __FILE__));
    wp_enqueue_script('easy-contact-forms-html', plugins_url('easy-contact-formshtml.1.4.9.js', __FILE__));
    wp_enqueue_script('jqui-scrollto', plugins_url('js/jqui/scrollto.js', __FILE__));
    wp_enqueue_script('js-as', plugins_url('js/as.js', __FILE__));
    wp_enqueue_script('calendar-stripped', plugins_url('js/calendar/calendar_stripped.js', __FILE__));
    wp_enqueue_script('calendar-setup-stripped', plugins_url('js/calendar/calendar-setup_stripped.js', __FILE__));
    wp_enqueue_script('calendar-lang-en', plugins_url('js/calendar/lang/calendar-en.js', __FILE__));
    wp_enqueue_script('js-as', plugins_url('js/as.js', __FILE__));
    if (EasyContactFormsApplicationSettings::getInstance()->get('UseTinyMCE')) {
        wp_enqueue_script('tiny_mce', plugins_url('js/tinymce/tiny_mce.js', __FILE__));
    }
    $js = "config = {};";
    $js .= "config.url='" . admin_url('admin-ajax.php') . "';";
    $js .= "config.phonenumberre=/^" . EasyContactFormsApplicationSettings::getInstance()->get('PhoneRegEx') . "/;";
    $js .= "config.initial = {t:'" . $map['t'] . "', m:'" . $map['m'] . "'};";
    $js .= "config.bodyid = 'divEasyContactForms';";
    $js .= "config.resources = {};";
    $js .= "config.resources['EmailFormatIsExpected'] = " . json_encode(EasyContactFormsT::get('EmailFormatIsExpected')) . ";";
    $js .= "config.resources['ValueLengthShouldBeBetween'] = " . json_encode(EasyContactFormsT::get('ValueLengthShouldBeBetween')) . ";";
    $js .= "config.resources['ValueLengthShouldBeMoreThan'] = " . json_encode(EasyContactFormsT::get('ValueLengthShouldBeMoreThan')) . ";";
    $js .= "config.resources['ValueLengthShouldBeLessThan'] = " . json_encode(EasyContactFormsT::get('ValueLengthShouldBeLessThan')) . ";";
    $js .= "config.resources['ThisIsAPhoneNumber'] = " . json_encode(EasyContactFormsT::get('ThisIsAPhoneNumber')) . ";";
    $js .= "config.resources['ThisIsAnIntegerField'] = " . json_encode(EasyContactFormsT::get('ThisIsAnIntegerField')) . ";";
    $js .= "config.resources['ThisFieldIsRequired'] = " . json_encode(EasyContactFormsT::get('ThisFieldIsRequired')) . ";";
    $js .= "config.resources['ThisIsAFieldOfCurrencyFormat'] = " . json_encode(EasyContactFormsT::get('ThisIsAFieldOfCurrencyFormat')) . ";";
    $js .= "config.resources['ItwillDeleteRecordsAreYouSure'] = " . json_encode(EasyContactFormsT::get('ItwillDeleteRecordsAreYouSure')) . ";";
    $js .= "config.resources['NoRecordsSelected'] = " . json_encode(EasyContactFormsT::get('NoRecordsSelected')) . ";";
    $js .= "config.resources['CloseFilter'] = " . json_encode(EasyContactFormsT::get('CloseFilter')) . ";";
    $js .= "config.resources['Search'] = " . json_encode(EasyContactFormsT::get('Search')) . ";";
    $js .= "config.resources['NoResults'] = " . json_encode(EasyContactFormsT::get('NoResults')) . ";";
    $js .= "config.resources['Uploading'] = " . json_encode(EasyContactFormsT::get('Uploading')) . ";";
    $js .= "config.resources['Upload'] = " . json_encode(EasyContactFormsT::get('Upload')) . ";";
    $js .= "config.resources['ItWillReorderFieldsets'] = " . json_encode(EasyContactFormsT::get('ItWillReorderFieldsets')) . ";";
    $js .= "config.resources['CF_Pin'] = " . json_encode(EasyContactFormsT::get('CF_Pin')) . ";";
    $js .= "config.resources['CF_UnPin'] = " . json_encode(EasyContactFormsT::get('CF_UnPin')) . ";";
    $js .= "var appManConfig = config;";
    echo "<link href='" . EASYCONTACTFORMS__engineWebAppDirectory . '/js/calendar/css/calendar-system.css' . "' rel='stylesheet' type='text/css'/>";
    if (function_exists('is_admin')) {
        $paramName = is_admin() ? 'DefaultStyle2' : 'DefaultStyle';
        $styleName = EasyContactFormsApplicationSettings::getInstance()->get($paramName);
        $paramName = is_admin() ? 'ApplicationWidth2' : 'ApplicationWidth';
        $appWidth = EasyContactFormsApplicationSettings::getInstance()->get($paramName);
    } else {
        $styleName = EASYCONTACTFORMS__DEFAULT_STYLE;
        $appWidth = EasyContactFormsApplicationSettings::getInstance()->get('ApplicationWidth');
    }
    $wrStyle = 'style=\'width:' . $appWidth . 'px\'';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'styles' . DIRECTORY_SEPARATOR . $styleName . DIRECTORY_SEPARATOR . 'easy-contact-forms-getstyle.php';
    require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-menu.php';
    echo "<div id='ufo-app-wrapper' {$wrStyle}>";
    EasyContactFormsMenu::getMenu($map);
    echo "<div id='divEasyContactForms'>";
    echo "<script>{$js}</script>";
    echo EasyContactFormsRoot::processRequest($map);
    echo "</div>";
    echo "</div>";
}
Example #2
0
         $ufovalidators = TRUE;
         $vjs[] = "if(typeof(ufoValidators)=='undefined'){ufoValidators={};};";
     }
     $vjs[] = "ufoValidators.recaptcharequired = function(config, evt){ var submits = ufoForms.submits[config.form]; var setkeypress = function() { var respel = ufoForms.get('recaptcha_response_field'); ufoForms.addEvent(respel, 'keypress', function(){ for (var i = 0; i < submits.length; i++) { submits[i].disabled = false; } ufoForms.fieldReset(config); config.isvalid = true; ufoForms.validateForm(config.form); }); }; var respel = ufoForms.get('recaptcha_response_field'); if (!config.reselblur) { config.reselblur = true; setkeypress(); } if (respel.value == '') { return false; } if (config.validCaptha == true) { return true; } for (var i = 0; i < submits.length; i++) { ufoForms.addClass(submits[i].domEl, 'ufo-loading'); submits[i].disabled = true; } ufoForms.fieldReset(config); var callback = function(){}; var chlel = ufoForms.get('recaptcha_challenge_field'); var values = []; var id = config.id.split('-'); id = id[id.length - 2] + '-' + id[id.length - 1]; values.push(id+'=1'); var hidden = ufoForms.get(config.id+'-sid'); values.push('sid='+hidden.value); values.push('recaptcha_challenge_field='+chlel.value); values.push('recaptcha_response_field='+respel.value); values = values.join('&'); ufoForms.request(values, callback, 'val', false); var result = (uhxr.responseText == 'true'); config.validCaptha = result; if (!result) { var rcdiv = ufoForms.get(config.id); rcdiv.style.height = rcdiv.offsetHeight+'px'; config.rcparams.callback = setkeypress; Recaptcha.create(config.pbk, config.id, config.rcparams); config.reselblur = false; } for (var i = 0; i < submits.length; i++) { ufoForms.removeClass(submits[i].domEl, 'ufo-loading'); submits[i].disabled = false; } return result; };";
     break;
 case 5:
     $cxml = simplexml_load_string($fld->get('Settings'));
     if (!isset($pvk)) {
         $pvk = (string) $cxml->ReCaptchaPrivateKey;
     }
     $pbk = (string) $cxml->ReCaptchaPublicKey;
     $jssid = $fld->get('id') . '-sid';
     if (isset($varmap[$jssid])) {
         $varmap['sid'] = $varmap[$jssid];
     }
     $str = EasyContactFormsSecurityManager::getGetSessionValue($varmap, 'ufo_forms_recaptcha');
     $valid = $str == 'TRUE';
     if (!$valid && !empty($pbk) && !empty($pvk) && isset($_POST['recaptcha_response_field'])) {
         require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'recaptchalib.php';
         $resp = recaptcha_check_answer($pvk, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
         $valid = $resp->is_valid;
         if (!$valid) {
             $this->sendBack = TRUE;
             if (!isset($this->errors)) {
                 $this->errors = array();
             }
             $this->errors[$fld->get('Description')] = $resp->error;
         }
         $varmap['id-' . $fldid] = $varmap['sid'];
     } else {
         if (!$valid) {
Example #3
0
        if (isset($ufovalidators) && $ufovalidators === FALSE) {
            $ufovalidators = TRUE;
            $vjs[] = "if(typeof(ufoValidators)=='undefined'){ufoValidators={};};";
        }
        if (!isset($form->fileuploadsriptloaded)) {
            $form->fileuploadsriptloaded = true;
            $vjs[] = "ufoValidators.validfileattached = function(config, evt){var fileupload = ufoFormsConfig.uploads[config.form][config.id];if (!fileupload.fileattached && !config.Required) return undefined;if (!fileupload.fileattached && config.Required) return false;return true;};";
            $rows[] = '<script type="text/javascript" src="' . EASYCONTACTFORMS__engineWebAppDirectory . '/js/ajaxupload.js"></script>';
        }
        if (!is_dir(EASYCONTACTFORMS__fileUploadDir)) {
            EasyContactFormsUtils::createFolder(EASYCONTACTFORMS__fileUploadDir);
        }
        break;
    case 5:
        $filerequestid = 'CustomFormsFileUpload_' . $fld->get('id');
        $test = isset($_FILES[$filerequestid]) && $_FILES[$filerequestid]['error'] == UPLOAD_ERR_OK;
        if ($test) {
            $valid = TRUE;
        } else {
            $jssid = $fld->get('id') . '-sid';
            if (isset($varmap[$jssid])) {
                $varmap['sid'] = $varmap[$jssid];
            }
            $str = EasyContactFormsSecurityManager::getGetSessionValue($varmap, $filerequestid);
            $valid = !empty($str);
            if (!$valid) {
                $this->processInvalid($fld, 'validfileattached', $config);
            }
        }
        break;
}
 /**
  * 	refreshForm
  *
  * @param  $map
  * 
  *
  * @return
  * 
  */
 function refreshForm($map)
 {
     $fid = intval($map['oid']);
     $form = new EasyContactFormsCustomForms(true, $fid);
     $form->user = EasyContactFormsSecurityManager::getGuest();
     $form->preview = true;
     $html = $form->preprocess();
     $text = array();
     $text[] = "<script type='text/javascript' src='" . EASYCONTACTFORMS__engineWebAppDirectory . "/easy-contact-forms-forms.1.4.2.js'></script>";
     $text[] = "<table align=center style='height:100%'><tr>";
     $text[] = "<td style='padding-top:50px;vertical-align:top'>";
     $text[] = $html;
     $text[] = "</td>";
     $text[] = "</tr></table>";
     $text = implode('', $text);
     if (!isset($map['ufo-skipoutput'])) {
         echo $text;
         exit;
     }
 }
 /**
  * 	ajaxCall
  *
  * 	handles ajax-based requests
  *
  * @param array $_acmap
  * 	request data
  *
  * @return string
  * 	arbitrary data in response to requests
  */
 function ajaxCall($_acmap)
 {
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-cache, must-revalidate");
     header("Pragma: no-cache");
     $_acmap = EasyContactFormsSecurityManager::getRights($_acmap);
     echo EasyContactFormsRoot::processRequest($_acmap);
 }
 /**
  * 	getSid
  *
  *
  * @return
  * 
  */
 function getSid()
 {
     if (rand(1, 10) == 9) {
         $nDaysAgo = 3;
         $query = "DELETE FROM `#wp__easycontactforms_sessions` WHERE opentime < '" . date("Y-m-d H:i:s", time() - 24 * 60 * 60 * $nDaysAgo) . "'";
         EasyContactFormsDB::query($query);
     }
     $pwd = EasyContactFormsSecurityManager::getServerPwd();
     $maxid = EasyContactFormsDB::getValue('SELECT MAX(id) FROM #wp__easycontactforms_sessions');
     $sid = md5($maxid + 10 . $pwd);
     $query = 'INSERT INTO #wp__easycontactforms_sessions(sid, value) VALUES (\'' . $sid . '\', \'<data />\')';
     EasyContactFormsDB::query($query);
     return $sid;
 }
 /**
  * 	getStorageFileName
  *
  * 	return a new file name
  *
  * @param object $filespec
  * 	file data
  *
  * @return string
  * 	file name
  */
 function getStorageFileName($filespec)
 {
     $storagename = $filespec->docType . '_' . $filespec->id . '_' . $filespec->fieldname . '_' . $filespec->filename;
     if (!$filespec->protect) {
         return $storagename;
     }
     $strarr = explode(".", $filespec->filename);
     $ext = $strarr[count($strarr) - 1];
     $md5name = md5(EasyContactFormsSecurityManager::getServerPwd() . $storagename . 'easycontactforms');
     $newfilename = $storagename . '_' . $md5name . '.' . $ext;
     return $newfilename;
 }
 /**
  * 	intercept
  *
  * 	Checks ACL
  *
  * @param array $_imap
  * 	Request data
  *
  * @return array
  * 	Request data
  */
 function intercept($_imap)
 {
     $_imap = EasyContactFormsSecurityManager::getRights($_imap);
     $viewname = EasyContactFormsSecurityManager::getViewName($_imap);
     if (!isset($viewname) || $viewname == '') {
         return NULL;
     }
     $_imap['n'] = $viewname;
     return $_imap;
 }