define('INSTALLFILE', 'installationForm.php');
define('CONFIGFILE', 'formConfiguration.php');
define('FORMFILE', 'contactForm.htm');
define('ABSPATH', dirname(__FILE__) . '/');
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
$install_complete = 'OK, Installation complete.
Visit your form.
To reinstall, delete the file: ' . CONFIGFILE . ' then run this installer again.';
if (file_exists(ABSPATH . CONFIGFILE)) {
echo $install_complete;
exit(0);
}
$fields = array(
"EMAIL",
"SUBJECT",
"TYPE",
"USESMTP",
"HOST",
"USER",
"PASS",
"PORT",
"USESMTP",
"USERECAPTCHA",
"SITEKEY",
"PRIVATEKEY",
"USEGDPR");
$config_template = '
Form
{RECAPTCHASCRIPT}
';
$error_strings = array();
if (isset($_POST['EMAIL'])) {
installForm($config_template, $form_template, $install_complete, $fields);
exit();
}
function installForm($config_template, $form_template, $install_complete, $fields) {
global $error_strings;
if (!file_exists(ABSPATH . CONFIGFILE)) {
setDefaults($fields);
$search = getSearch($fields);
$replace = getReplace($fields);
createFile($search, $replace, $config_template, ABSPATH . CONFIGFILE);
$search = array("{RECAPTCHASCRIPT}", "{RECAPTCHASITEKEY}");
$replace = array(" ", " ");
if (isset($_POST['USERECAPTCHA']) && $_POST['USERECAPTCHA'] == "yes") {
$replace = array(
'',
'');
}
if(isset($_POST['USEGDPR']) && $_POST['USEGDPR'] == "yes") {
$search[] = "{GDPR_ROW}";
$replace[] = '';
$search[] = "{jsValidator}";
$replace[] = "formValidatorConsent";
} else {
$search[] = "{GDPR_ROW}";
$replace[] = " ";
$search[] = "{jsValidator}";
$replace[] = "formValidator";
}
createFile($search, $replace, $form_template, ABSPATH . FORMFILE);
}
if (count($error_strings) > 0) {
echo "Number of errors: ".count($error_strings)."
";
foreach ($error_strings as $es) {
echo "$es
";
}
} else {
echo $install_complete;
}
}
function createFile($search, $replace, $template, $filename) {
global $error_strings;
$file_contents = str_replace($search, $replace, $template);
if (!$handler = fopen($filename, "wb")) {
$error = true;
} else {
if (!fwrite($handler, trim($file_contents))) { $error = true; }
fclose($handler);
}
if($error) {
$viewable_code = nl2br(str_replace("<", "<", $file_contents));
$error_strings[] = "Cannot write your file to: $filename - Please change the directory permissions to allow write access.
If you prefer, you can create the file using the code below:
" . $viewable_code . "
Save the above code to a new file at: $filename";
}
}
function setDefaults($fields) {
foreach ($fields as $field) {
if (!isset($_POST[$field])) {
$_POST[$field] = "";
}
}
}
function getSearch($fields) {
$search = array();
foreach ($fields as $field) {
$search[] = '{' . $field . '}';
}
return $search;
}
function getReplace($fields) {
$replace = array();
foreach ($fields as $field) {
$replace[] = $_POST[$field];
}
return $replace;
}
?>
Installation Form
define('INSTALLFILE', 'installationForm.php');
define('CONFIGFILE', 'formConfiguration.php');
define('FORMFILE', 'contactForm.htm');
define('ABSPATH', dirname(__FILE__) . '/');
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
$install_complete = 'OK, Installation complete.
Visit your form.
To reinstall, delete the file: ' . CONFIGFILE . ' then run this installer again.';
if (file_exists(ABSPATH . CONFIGFILE)) {
echo $install_complete;
exit(0);
}
$fields = array(
"EMAIL",
"SUBJECT",
"TYPE",
"USESMTP",
"HOST",
"USER",
"PASS",
"PORT",
"USESMTP",
"USERECAPTCHA",
"SITEKEY",
"PRIVATEKEY",
"USEGDPR");
$config_template = '
Form
{RECAPTCHASCRIPT}
';
$error_strings = array();
if (isset($_POST['EMAIL'])) {
installForm($config_template, $form_template, $install_complete, $fields);
exit();
}
function installForm($config_template, $form_template, $install_complete, $fields) {
global $error_strings;
if (!file_exists(ABSPATH . CONFIGFILE)) {
setDefaults($fields);
$search = getSearch($fields);
$replace = getReplace($fields);
createFile($search, $replace, $config_template, ABSPATH . CONFIGFILE);
$search = array("{RECAPTCHASCRIPT}", "{RECAPTCHASITEKEY}");
$replace = array(" ", " ");
if (isset($_POST['USERECAPTCHA']) && $_POST['USERECAPTCHA'] == "yes") {
$replace = array(
'',
'');
}
if(isset($_POST['USEGDPR']) && $_POST['USEGDPR'] == "yes") {
$search[] = "{GDPR_ROW}";
$replace[] = '';
$search[] = "{jsValidator}";
$replace[] = "formValidatorConsent";
} else {
$search[] = "{GDPR_ROW}";
$replace[] = " ";
$search[] = "{jsValidator}";
$replace[] = "formValidator";
}
createFile($search, $replace, $form_template, ABSPATH . FORMFILE);
}
if (count($error_strings) > 0) {
echo "Number of errors: ".count($error_strings)."
";
foreach ($error_strings as $es) {
echo "$es
";
}
} else {
echo $install_complete;
}
}
function createFile($search, $replace, $template, $filename) {
global $error_strings;
$file_contents = str_replace($search, $replace, $template);
if (!$handler = fopen($filename, "wb")) {
$error = true;
} else {
if (!fwrite($handler, trim($file_contents))) { $error = true; }
fclose($handler);
}
if($error) {
$viewable_code = nl2br(str_replace("<", "<", $file_contents));
$error_strings[] = "Cannot write your file to: $filename - Please change the directory permissions to allow write access.
If you prefer, you can create the file using the code below:
" . $viewable_code . "
Save the above code to a new file at: $filename";
}
}
function setDefaults($fields) {
foreach ($fields as $field) {
if (!isset($_POST[$field])) {
$_POST[$field] = "";
}
}
}
function getSearch($fields) {
$search = array();
foreach ($fields as $field) {
$search[] = '{' . $field . '}';
}
return $search;
}
function getReplace($fields) {
$replace = array();
foreach ($fields as $field) {
$replace[] = $_POST[$field];
}
return $replace;
}
?>
Installation Form
define('INSTALLFILE', 'installationForm.php');
define('CONFIGFILE', 'formConfiguration.php');
define('FORMFILE', 'contactForm.htm');
define('ABSPATH', dirname(__FILE__) . '/');
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
$install_complete = 'OK, Installation complete.
Visit your form.
To reinstall, delete the file: ' . CONFIGFILE . ' then run this installer again.';
if (file_exists(ABSPATH . CONFIGFILE)) {
echo $install_complete;
exit(0);
}
$fields = array(
"EMAIL",
"SUBJECT",
"TYPE",
"USESMTP",
"HOST",
"USER",
"PASS",
"PORT",
"USESMTP",
"USERECAPTCHA",
"SITEKEY",
"PRIVATEKEY",
"USEGDPR");
$config_template = '
Form
{RECAPTCHASCRIPT}
';
$error_strings = array();
if (isset($_POST['EMAIL'])) {
installForm($config_template, $form_template, $install_complete, $fields);
exit();
}
function installForm($config_template, $form_template, $install_complete, $fields) {
global $error_strings;
if (!file_exists(ABSPATH . CONFIGFILE)) {
setDefaults($fields);
$search = getSearch($fields);
$replace = getReplace($fields);
createFile($search, $replace, $config_template, ABSPATH . CONFIGFILE);
$search = array("{RECAPTCHASCRIPT}", "{RECAPTCHASITEKEY}");
$replace = array(" ", " ");
if (isset($_POST['USERECAPTCHA']) && $_POST['USERECAPTCHA'] == "yes") {
$replace = array(
'',
'');
}
if(isset($_POST['USEGDPR']) && $_POST['USEGDPR'] == "yes") {
$search[] = "{GDPR_ROW}";
$replace[] = '';
$search[] = "{jsValidator}";
$replace[] = "formValidatorConsent";
} else {
$search[] = "{GDPR_ROW}";
$replace[] = " ";
$search[] = "{jsValidator}";
$replace[] = "formValidator";
}
createFile($search, $replace, $form_template, ABSPATH . FORMFILE);
}
if (count($error_strings) > 0) {
echo "Number of errors: ".count($error_strings)."
";
foreach ($error_strings as $es) {
echo "$es
";
}
} else {
echo $install_complete;
}
}
function createFile($search, $replace, $template, $filename) {
global $error_strings;
$file_contents = str_replace($search, $replace, $template);
if (!$handler = fopen($filename, "wb")) {
$error = true;
} else {
if (!fwrite($handler, trim($file_contents))) { $error = true; }
fclose($handler);
}
if($error) {
$viewable_code = nl2br(str_replace("<", "<", $file_contents));
$error_strings[] = "Cannot write your file to: $filename - Please change the directory permissions to allow write access.
If you prefer, you can create the file using the code below:
" . $viewable_code . "
Save the above code to a new file at: $filename";
}
}
function setDefaults($fields) {
foreach ($fields as $field) {
if (!isset($_POST[$field])) {
$_POST[$field] = "";
}
}
}
function getSearch($fields) {
$search = array();
foreach ($fields as $field) {
$search[] = '{' . $field . '}';
}
return $search;
}
function getReplace($fields) {
$replace = array();
foreach ($fields as $field) {
$replace[] = $_POST[$field];
}
return $replace;
}
?>
Installation Form
Contact-EWCO
Home | About | Past Concerts | Blog | EWCO Board | Contact