vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   What does this PHP code do? (https://vborg.vbsupport.ru/showthread.php?t=323047)

akz645 07-18-2016 12:14 AM

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.

Dave 07-18-2016 11:45 AM

It's a contact form.

Dragonsys 07-18-2016 01:46 PM

odd that the THIS_SCRIPT is index though, but yes, as Dave mentioned that is a contact form.

Paul M 07-18-2016 05:17 PM

You would think this gives it away really ;

PHP Code:

    $navbits[''] = 'Contact Form';
    
$navbits construct_navbits($navbits);
    
$navbar render_navbar_template($navbits);
    
$templater vB_Template::create('ws_contact_forum'); 


akz645 07-19-2016 10:44 AM

Quote:

Originally Posted by Paul M (Post 2573401)
You would think this gives it away really ;

PHP Code:

    $navbits[''] = 'Contact Form';
    
$navbits construct_navbits($navbits);
    
$navbar render_navbar_template($navbits);
    
$templater vB_Template::create('ws_contact_forum'); 


Well I got that much. I probably should have explained the context.

It was a file php file named "ws_send_email", which was inside a mod somebody created.

Hence I was suspicious whether or not there was any malicious code in it.
That's why I'm asking, since I don't understand why it's needed for the modification to work.

If the purpose was malicious, this is what I was thinking:
All the details I have stored in the 'contact us' section will be sent to the coder. Also, if anybody else uses that part in my forum, their details will be sent to the coder too.

In Omnibus 07-19-2016 12:05 PM

If I recall that is part of a mod by Wolfshead Solutions. Mosh Shigdar has been effectively retired for quite some time but he was among the finest coders vBulletin had and certainly not malicious by any reasonable measure.

Paul M 07-19-2016 03:51 PM

I have not seen Mosh around for ages (last logged on the site in 2013).
He wrote quite a few add-ons to my mods for Flashchat, and borrowed (with permission) some other bits of my code.

Not sure which of his mods that would be part of, but nothing of his would be malicious.


All times are GMT. The time now is 10:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01092 seconds
  • Memory Usage 1,799KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete