Hi, can somebody please help me understand what the PHP code below is meant to do?
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'index');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
define('VB_ENTRY', 'forum.php');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
// pre-cache templates used by all actions
$globaltemplates = array(
'ws_contact_forum',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions.php');
$haserror = 0;
$thanks = 0;
if (isset($_POST['btnsubmit'])) {
$to = $vbulletin->options['ws_contact_us'];
$vbulletin->input->clean_array_gpc('r', array(
'first_name' => TYPE_STR,
'last_name' => TYPE_STR,
'email' => TYPE_STR,
'internationalCode' => TYPE_STR,
'phone' => TYPE_STR,
'location' => TYPE_STR,
'company' => TYPE_STR,
'businessType' => TYPE_STR,
'advertisingBudget' => TYPE_STR,
'comments' => TYPE_STR,
'region' => TYPE_ARRAY,
));
$error_message = "<ul class='wsul'>";
if (empty($to)) {
$error_message .= '<li class="wserror">Contact us email not set yet please contact Adminstrator.</li>';
}
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $vbulletin->GPC['email'])) {
$error_message .= '<li class="wserror">The Email Address you entered does not appear to be valid.</li>';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if (!preg_match($string_exp, $vbulletin->GPC['first_name'])) {
$error_message .= '<li class="wserror">The First Name you entered does not appear to be valid.</li>';
}
if (!preg_match($string_exp, $vbulletin->GPC['last_name'])) {
$error_message .= '<li class="wserror">The Last Name you entered does not appear to be valid.</li>';
}
if (strlen($vbulletin->GPC['comments']) < 2) {
$error_message .= '<li class="wserror">The Comments you entered do not appear to be valid.</li>';
}
if ((!is_numeric($vbulletin->GPC['internationalCode']) or ! is_numeric($vbulletin->GPC['phone']))) {
$error_message .= '<li class="wserror">The Phone you entered do not appear to be valid.</li>';
} else {
if (strlen($vbulletin->GPC['internationalCode']) < 1 or strlen($vbulletin->GPC['internationalCode']) > 4) {
$error_message .= '<li class="wserror">The Phone code you entered should be max length 4 and min length 1.</li>';
}
}
if (!$vbulletin->GPC['location']) {
$error_message .= '<li class="wserror">The location you entered do not appear to be valid.</li>';
}
if (empty($vbulletin->GPC['company'])) {
$error_message .= '<li class="wserror">The company you entered do not appear to be valid.</li>';
}
if (!$vbulletin->GPC['region']) {
$error_message .= '<li class="wserror">Select at least one Regions of interest.</li>';
}
if (!$vbulletin->GPC['advertisingBudget']) {
$error_message .= '<li class="wserror">The advertisingBudget you entered do not appear to be valid.</li>';
}
if (!$vbulletin->GPC['businessType']) {
$error_message .= '<li class="wserror">The businessType you entered do not appear to be valid.</li>';
}
$error_message .= "</ul>";
if (strlen($error_message) > 22) {
$haserror = 1;
} else {
$firstName = $vbulletin->GPC['first_name'];
$lastName = $vbulletin->GPC['last_name'];
$comments = $vbulletin->GPC['comments'];
$phoneNo = $vbulletin->GPC['internationalCode'] . '-' . $vbulletin->GPC['phone'];
$location = $vbulletin->GPC['location'];
$company = $vbulletin->GPC['company'];
$businessType = $vbulletin->GPC['businessType'];
$advertisement = $vbulletin->GPC['advertisingBudget'];
$email = $vbulletin->GPC['email'];
foreach ($vbulletin->GPC['region'] as $key => $region) {
$regions.=$region . ' ,';
}
$regions = trim($regions, ',');
$headers = 'From: ' . $email . '' . "\r\n" .
'Reply-To: ' . $to . '' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
eval(fetch_email_phrases('ws_contactform'));
@mail($to, $subject, $message, $headers);
//vbmail($to, $subject, $message);
$thanks = 1;
}
$navbits = array();
$navbits[''] = 'Contact Form';
$navbits = construct_navbits($navbits);
$navbar = render_navbar_template($navbits);
$templater = vB_Template::create('ws_contact_forum');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('error_message', $error_message);
$templater->register('haserror', $haserror);
$templater->register('thanks', $thanks);
print_output($templater->render());
} else {
$url = $vbulletin->options['bburl'];
header("Location:$url");
}
// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTTA HERE... ###
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 04:27, Mon Oct 20th 2014
|| # CVS: $RCSfile$ - $Revision: 29446 $
|| ####################################################################
\*======================================================================*/
Edit:
I just realised I posted this is the wrong section. Sorry about that.
vB4 Programming Discussions - The moderators can move this thread over there if they want.
Edit 2:
Thanks for moving it.