Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 07-18-2016, 11:45 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's a contact form.
Reply With Quote
  #3  
Old 07-18-2016, 01:46 PM
Dragonsys's Avatar
Dragonsys Dragonsys is offline
 
Join Date: Jan 2008
Location: DFW, Texas
Posts: 743
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

odd that the THIS_SCRIPT is index though, but yes, as Dave mentioned that is a contact form.
Reply With Quote
  #4  
Old 07-18-2016, 05:17 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'); 
Reply With Quote
Благодарность от:
In Omnibus
  #5  
Old 07-19-2016, 10:44 AM
akz645 akz645 is offline
 
Join Date: Jul 2015
Posts: 183
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M View Post
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.
Reply With Quote
  #6  
Old 07-19-2016, 12:05 PM
In Omnibus's Avatar
In Omnibus In Omnibus is offline
 
Join Date: Apr 2010
Location: Inside A Blade Server
Posts: 840
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
2 благодарности(ей) от:
Dragonsys, RichieBoy67
  #7  
Old 07-19-2016, 03:51 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:33 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.03928 seconds
  • Memory Usage 2,296KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (3)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete