/** * Main plugin call. * * @param string $id A form ID. * * @return string (X)HTML. * * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global string The script name. * @global string The (X)HTML fragment containing error messages. * @global array The paths of system files and folders. */ function Advancedform_main($id) { global $plugin_cf, $plugin_tx, $sn, $e, $pth; $pcf = $plugin_cf['advancedform']; $ptx = $plugin_tx['advancedform']; $fn = $pth['folder']['plugins'] . $pcf['captcha_plugin'] . '/captcha.php'; if (file_exists($fn)) { include_once $fn; } else { e('cntopen', 'file', $fn); } $hooks = Advancedform_dataFolder() . $id . '.inc' . ($pcf['php_extension'] ? '.php' : ''); if (file_exists($hooks)) { include $hooks; } $forms = Advancedform_db(); if (!isset($forms[$id])) { $e .= '<li>' . sprintf($ptx['error_form_missing'], $id) . '</li>' . PHP_EOL; return ''; } $form = $forms[$id]; if (isset($_POST['advfrm']) && $_POST['advfrm'] == $id) { if (($res = Advancedform_check($id)) === true) { if ($form['store']) { Advancedform_appendCsv($id); } if (!Advancedform_mail($id, false)) { return Advancedform_formView($id); } if (function_exists('advfrm_custom_thanks_page')) { Advancedform_fields($fields); $thanks = advfrm_custom_thanks_page($id, $fields); } if (empty($thanks)) { $thanks = $form['thanks_page']; } if (!empty($thanks)) { if (!Advancedform_mail($id, true)) { return Advancedform_formView($id); } header('Location: ' . $sn . '?' . $thanks); // FIXME: exit()? } else { return Advancedform_mailInfo($id, false, true); } } else { return $res . Advancedform_formView($id); } } return Advancedform_formView($id); }
/** * Main plugin call. * * @param string $id A form ID. * * @return string (X)HTML. * * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global string The script name. * @global string The (X)HTML fragment containing error messages. * @global array The paths of system files and folders. */ public static function main($id) { global $plugin_cf, $plugin_tx, $sn, $e, $pth; $pcf = $plugin_cf['advancedform']; $ptx = $plugin_tx['advancedform']; $fn = $pth['folder']['plugins'] . $pcf['captcha_plugin'] . '/captcha.php'; if (file_exists($fn)) { include_once $fn; } else { e('cntopen', 'file', $fn); } $hooks = Data::folder() . $id . '.inc' . ($pcf['php_extension'] ? '.php' : ''); if (file_exists($hooks)) { include $hooks; } $form = Data::fetchForm($id); if (!isset($form)) { $e .= '<li>' . sprintf($ptx['error_form_missing'], $id) . '</li>' . PHP_EOL; return ''; } if (isset($_POST['advfrm']) && $_POST['advfrm'] == $id) { $validator = new FormValidator($form); if (($res = $validator->validate()) === true) { if ($form->isStored()) { self::appendCsv($id); } if (!self::mail($form, false)) { return self::formView($form); } if (function_exists('advfrm_custom_thanks_page')) { self::fields($fields); $thanks = advfrm_custom_thanks_page($id, $fields); } if (empty($thanks)) { $thanks = $form->getThanksPage(); } if (!empty($thanks)) { if (!self::mail($form, true)) { return self::formView($form); } header('Location: ' . $sn . '?' . $thanks); // FIXME: exit()? } else { $view = MailView::make($form, false, true); return $view->render(); } } else { return $res . self::formView($form); } } return self::formView($form); }