View Single Post
  #1  
Old 07-18-2016, 12:14 AM
akz645 akz645 is offline
 
Join Date: Jul 2015
Posts: 183
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What does this PHP code do?

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']) < 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.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01197 seconds
  • Memory Usage 1,865KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete