/** * Hook for processing uploads via SWFUpload * * Process the upload and print the response */ function iphorm_process_swfupload() { if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['iphorm_swfupload']) && $_GET['iphorm_swfupload'] == 1) { if (isset($_POST['iphorm_id'], $_POST['iphorm_form_uniq_id'], $_POST['iphorm_element_id'], $_POST['iphorm_element_name'], $_POST['PHPSESSID'])) { $form = iphorm_get_form($_POST['iphorm_id'], $_POST['iphorm_form_uniq_id']); $filesKey = $_POST['iphorm_element_name']; if ($form instanceof iPhorm && isset($_FILES[$filesKey]) && is_uploaded_file($_FILES[$filesKey]['tmp_name']) && $_FILES[$filesKey]['error'] == UPLOAD_ERR_OK) { $element = $form->getElementById($_POST['iphorm_element_id']); if ($element instanceof iPhorm_Element_File) { $tmpDir = untrailingslashit(iphorm_get_temp_dir()); if (is_writable($tmpDir)) { $iphormTmpDir = $tmpDir . '/iphorm'; if (!is_dir($iphormTmpDir)) { wp_mkdir_p($iphormTmpDir); } if (is_writable($iphormTmpDir)) { if ($element->isValid('')) { $filename = tempnam($iphormTmpDir, 'iphorm'); move_uploaded_file($_FILES[$filesKey]['tmp_name'], $filename); $_FILES[$filesKey]['tmp_name'] = $filename; $sessionKey = 'iphorm-' . $_POST['iphorm_form_uniq_id']; if (!isset($_SESSION[$sessionKey])) { $_SESSION[$sessionKey] = array(); } if ($element->getIsMultiple()) { $keys = array('name', 'type', 'tmp_name', 'error', 'size'); foreach ($keys as $key) { if (isset($_SESSION[$sessionKey][$filesKey][$key]) && is_array($_SESSION[$sessionKey][$filesKey][$key])) { $_SESSION[$sessionKey][$filesKey][$key][] = $_FILES[$filesKey][$key]; } else { $_SESSION[$sessionKey][$filesKey][$key] = array(0 => $_FILES[$filesKey][$key]); } } } else { $_SESSION[$sessionKey][$filesKey] = $_FILES[$filesKey]; } } else { $response = array('type' => 'error', 'data' => $element->getErrors()); echo iphorm_json_encode($response); } } } } } } exit; } }
/** * Get the list of available fields to export */ function iphorm_get_export_field_list_ajax() { $id = isset($_POST['form_id']) ? absint($_POST['form_id']) : 0; if (iphorm_form_exists($id)) { $form = iphorm_get_form_config($id); $response = array('type' => 'success', 'data' => array()); foreach ($form['elements'] as $element) { if (isset($element['save_to_database']) && $element['save_to_database']) { $response['data'][] = array('value' => 'element_' . $element['id'], 'label' => iphorm_get_element_admin_label($element)); } } $defaultFields = iphorm_get_valid_entry_fields(); foreach ($defaultFields as $key => $label) { $response['data'][] = array('value' => $key, 'label' => $label); } header('Content-Type: application/json'); echo iphorm_json_encode($response); exit; } }
<span class="ifb-save-failed"></span> </a> <a id="ifb-scroll-top"><?php esc_html_e('Top', 'iphorm'); ?> </a> </div> </div> <!-- /.ifb-left-col --> </div> </div> </form> <script type="text/javascript"> //<![CDATA[ jQuery(document).ready(function () { iPhorm.init(<?php echo iphorm_json_encode($form); ?> ); }); //]]> </script> <?php } else { ?> <?php echo '<div class="iphorm-admin-notice iphorm-admin-notice-no-form error"><p><strong>' . sprintf(esc_html__('The form with that ID does not exist, %sgo back to the form list%s.', 'iphorm'), '<a href="' . admin_url('admin.php?page=iphorm_forms') . '">', '</a>') . '</strong></p></div>'; ?> <?php } ?> </div>
/** * Get the JSON formatted conditional logic of the elements * * @return string */ public function getConditionalLogicJson() { $logic = array(); $dependents = array(); foreach ($this->_elements as $element) { if ($element->getLogic() && count($elementLogicRules = $element->getLogicRules())) { $logic[$element->getId()] = array('action' => $element->getLogicAction(), 'match' => $element->getLogicMatch(), 'rules' => $elementLogicRules); foreach ($elementLogicRules as $elementLogicRule) { if (!isset($dependents[$elementLogicRule['element_id']])) { $dependents[$elementLogicRule['element_id']] = array($element->getId()); } else { $dependents[$elementLogicRule['element_id']][] = $element->getId(); } } } } return iphorm_json_encode(array('logic' => $logic, 'dependents' => $dependents, 'animate' => $this->getConditionalLogicAnimation())); }
} if (!isset($element['options']['minFontSize'])) { $element['options']['minFontSize'] = 12; } if (!isset($element['options']['maxFontSize'])) { $element['options']['maxFontSize'] = 19; } if (!isset($element['options']['minAngle'])) { $element['options']['minAngle'] = 0; } if (!isset($element['options']['maxAngle'])) { $element['options']['maxAngle'] = 20; } $captchaImagePath = iphorm_plugin_url() . '/includes/captcha.php'; $captchaConfig = array('uniqId' => 1, 'tmpDir' => iphorm_get_temp_dir(), 'options' => $element['options']); $captchaConfig = base64_encode(iphorm_json_encode($captchaConfig)); $helpUrl = iphorm_help_link('element-captcha'); ?> <div id="ifb-element-wrap-<?php echo $id; ?> " class="ifb-element-wrap ifb-element-wrap-captcha <?php if (!$element['required']) { echo 'ifb-element-optional'; } ?> <?php echo "ifb-label-placement-{$form['label_placement']}"; ?> "> <div class="ifb-top-element-wrap qfb-cf">
</script> <?php } ?> <script type="text/javascript"> //<![CDATA[ var iphormPreviewL10n = <?php echo iphorm_json_encode($previewL10n); ?> ; //]]> </script> <script type="text/javascript"> //<![CDATA[ var iphormL10n = <?php echo iphorm_json_encode(iphorm_js_l10n()); ?> ; //]]> </script> <script type="text/javascript" src="<?php echo iphorm_admin_url() . '/js/iphorm-preview.js'; ?> "></script> <script type="text/javascript" src="<?php echo iphorm_plugin_url() . '/js/jquery.form.min.js'; ?> "></script> <script type="text/javascript" src="<?php echo iphorm_plugin_url() . '/js/jquery.iphorm.js'; ?>