vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Converting from Xenforo to vBulletin (https://vborg.vbsupport.ru/showthread.php?t=321469)

Alice 01-11-2016 07:09 AM

Converting from Xenforo to vBulletin
 
Hey,

I was wondering if someone might be willing to give me a hand with converting this matter of code to be cross-compatible with vbulletin?

Thanks,

Code:

<?php
 
// **************************************************************************************************
//      IMPORTANT CONFIGURATION ITEMS
// **************************************************************************************************
 
$enabled = true;
$serverip = '127.0.0.1';
 
// **************************************************************************************************
//      END OF IMPORTANT CONFIGURATION ITEMS
//      DO NOT EDIT ANYTHING BEYOND THIS POINT!
// **************************************************************************************************
 
// Necessary XenForo Hooks
require($fileDir . 'library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . 'library');
XenForo_Application::initialize($fileDir . 'library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
 
// Assistance in placing file in correct directory w/o include/require.
$proxyfile = 'proxy.php';
$adminfile = 'admin.php';
if (!file_exists($proxyfile)) {
    die('This file is not in the correct directory. Please contact a website administrator.');
};
if (!file_exists($adminfile)) {
    die('This file is not in the correct directory. Please contact a website administrator.');
};
 
// Checks to make sure accessing IP is server IP.
$acuntite = $_SERVER['REMOTE_ADDR'];
if (strlen($_SERVER['REMOTE_ADDR'])<6) {
die ('Access denied.');
};
if ($acuntite != $serverip) {
die('Access denied.');
};
 
// Post get items
$username = $_GET['un'];
$password = $_GET['pw'];
 
// If no info specified
if(is_null($username) && is_null($password)) return;
$error = "";
$ph = new XenForo_Model_User();
$result = $ph->validateAuthentication($username, $password, $error);
 
// Ensures system is enabled before continuing. If not, returns error
if ($enabled != true) {
    die('3');
}
 
// Final get id
if(is_numeric($result) && $result > 0 && !(strpos($username, '@') !== false))
{
    $user = $ph->getFullUserById($result);
 
    // ensures user is not banned
    $banned = $user['is_banned'];
    // if banned, return error 2
    if($banned == 1) echo "2";
 
    // if not banned, successful login
    else echo "1";
}
 
// and if all else fails, the shit you provided is wrong so return error 0
else echo "0";
 
// Echo 0 = Incorrect user/pass
// Echo 1 = Successful Login
// Echo 2 = Banned User
// Echo 3 = System disabled
 
?>


Alice 01-11-2016 03:31 PM

Anyone know if they can help?

Dave 01-11-2016 03:55 PM

Untested, upload to the root of your vBulletin forum.

PHP Code:

<?php
require('./global.php');
require(
'includes/functions_login.php');

$enabled true;
$serverip '127.0.0.1';
  
// Checks to make sure accessing IP is server IP.
$acuntite $_SERVER['REMOTE_ADDR'];
if (
strlen($_SERVER['REMOTE_ADDR']) < || $acuntite != $serverip || !$enabled) {
    die(
3);
}
 
// Post get items
$username $_GET['un'];
$password $_GET['pw'];
 
// If no info specified
if(is_null($username) && is_null($password)) return;

$error "";
$result verify_authentication($username$passwordmd5($password), md5($password), ''false);
 
// Final get id
if($result === true && !(strpos($username'@') !== false)){
    if(
$vbulletin->userinfo['usergroupid'] == 8){
        echo 
2// Banned
    
}else{
        echo 
1// Not banned.
    
}
}else{
    echo 
0// and if all else fails, the shit you provided is wrong so return error 0
}
 
// Echo 0 = Incorrect user/pass
// Echo 1 = Successful Login
// Echo 2 = Banned User
// Echo 3 = System disabled


Alice 01-11-2016 04:12 PM

First off, thank you so much for being willing to help me with this project. Now, I uploaded the code to the root of the forums, and in Xenforo its supposed to print either a 0,1 or 2 and this only shows a completely blank page. But no errors we're printed, so go you. :)

Dave 01-11-2016 04:17 PM

It's because of the check that checks if the current IP matches the $serverip variable.
You probably want it to be something like this in that case:

PHP Code:

<?php 
require('./global.php'); 
require(
'includes/functions_login.php'); 
   
// Post get items 
$username urldecode($_GET['un']); 
$password urldecode($_GET['pw']); 
  
// If no info specified 
if(is_null($username) && is_null($password)){
    die(
'No login provided.');


$result verify_authentication($username$passwordmd5($password), md5($password), ''false);
  
// Final get id 
if($result === true && !(strpos($username'@') !== false)){ 
    if(
$vbulletin->userinfo['usergroupid'] == 8){ 
        echo 
2// Banned 
    
}else{ 
        echo 
1// Not banned. 
    

}else{ 
    echo 
0// and if all else fails, the shit you provided is wrong so return error 0
}

Then you execute it as follows: http://example.com/script.php?un=Dave&pw=password

Alice 01-11-2016 04:21 PM

That code is producing the following error

Code:

Parse error: syntax error, unexpected 'if' (T_IF) in /home4/swgnge/public_html/forums/includes/functions_login.php(209) : eval()'d code on line 3
0

--------------- Added [DATE]1452536737[/DATE] at [TIME]1452536737[/TIME] ---------------

Scratch that, I was using the wrong syntax.

Dave 01-11-2016 04:26 PM

That's caused by a plugin you have installed, more specifically at the login_verify_failure_username hook.

Alice 01-11-2016 04:26 PM

Thank you so much Your my hero!! :)

Dave 01-11-2016 04:26 PM

No problem. ;)

Alice 01-11-2016 07:48 PM

Quote:

Originally Posted by Seraphyn (Post 2562469)
That code is producing the following error

Code:

Parse error: syntax error, unexpected 'if' (T_IF) in /home4/swgnge/public_html/forums/includes/functions_login.php(209) : eval()'d code on line 3
0

--------------- Added [DATE]1452536737[/DATE] at [TIME]1452536737[/TIME] ---------------

Scratch that, I was using the wrong syntax.

This is still an issue, specifically when you input a username that doesn't exist... like swglegends.com/forums/auth.php?un=username&pw=password

Please advise,


All times are GMT. The time now is 04:01 AM.

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.01193 seconds
  • Memory Usage 1,767KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete