• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Verify if user is logged in for non-vb pages, using Jquery

Admin

Well-Known Member
Staff member
Administrator
1 - vbconnect.php
PHP:
<?php
chdir('./YOUR_FORUM_FOLDER_NAME');
define('CVD', (($getcwd = getcwd()) ? $getcwd : '.'));
require_once(CVD . '/global.php');

$vbulletin->input->clean_array_gpc('p', array('ajax' => TYPE_BOOL));

if($vbulletin->GPC['ajax'] == true)	
{
	$result = array(
        'username' => $vbulletin->userinfo['username'],
        'userid' => $vbulletin->userinfo['userid'],
        'userpost' => $vbulletin->userinfo['posts'],
     );
	echo json_encode($result);
}
?>

2- jquery_cookie.js
Create this file using the code from this page

3- jquery_vbulletin.js
Change *** with any another prefix wich do you want
Code:
$(document).ready(function () 
{
    $.ajax({
        url:'vbconnect.php',
        type:'POST',
        data:'&ajax=1',
        cache:false,
        async:false,
        dataType:'json',
        success:function(result){
            $.cookie('XXXuserid', result['userid'], { expires: 7, path: '/' });
            $.cookie('XXXusername', result['username'], { expires: 7, path: '/' });
            $.cookie('XXXuserpost', result['userpost'], { expires: 7, path: '/' });},
        error:function(){
            $.cookie('XXXuserid', '', { expires: 7, path: '/' });
            $.cookie('XXXusername', '', { expires: 7, path: '/' });
            $.cookie('XXXuserpost', '', { expires: 7, path: '/' });}
    })
});
4- In your php file (external file and not in directory of the forum)
Change *** with your prefix using in jquery_vbulletin.js file
PHP:
<?php

$vb_userid    = $_COOKIE['XXXuserid'];
$vb_username  = $_COOKIE['XXXusername'];
$vb_userpost  = $_COOKIE['XXXuserpost'];

if($vb_userid)
{
	// The guest is logged in 
	// Exemple
	$output = "Welcome $vb_username";
}
else
{
	// The guest is not logged in 
	// Exemple
	$output = "Welcome " . $_SERVER['REMOTE_ADDR'] . " , you are not connected to the forum";
}

?>

5- Your output (html / php)
Code:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="your/path/to/javascript/directory/jquery_cookie.js"></script>
<script src="your/path/to/javascript/directory/jquery_vbulletin.js"></script>
<?php echo $output; ?>
 

Facebook Comments

Similar threads
Thread starter Title Forum Replies Date
Admin DRC - User must verify their site (prevent spam links in postbit & profiles) Vbb tutorial 0
Admin Hướng dẫn xác nhận Google Webmaster bằng plugin seo by Yoast - Verify Google Webmaster with plugin seo by Yoast Wordpress 0
Admin Hướng dẫn xác minh Paypal mới nhất 2019 - How to get verify paypal simple latest Thảo luận wap việt 0
Admin [Tut] verify phone call chưa bao giờ đơn giản đến thế Tut, tool, mmo 0
C [VH] Bytecode 1.5.1 việt hóa fix lỗi verify S40 1
C COMBO CONVERTER EMAIL:PASS TO USER:PASS Tut, tool, mmo 0
Admin Batch Update User Website Xenforo 1
olalavui Hướng dẫn Enable User-ID tracking in Google Analytics for Xenforo Xenforo 3
Admin [INZ] User Upgrade Conversation Xenforo 0
Admin Yilmaz - User Profile Menu vB5 Add-ons 0
Admin Yilmaz - User Info Stats (Compatible 5.6.x) Add-ons 0
Admin Customising the layout with custom user fields xenforo 2 Xenforo 0
Admin Yilmaz - Easy Postbit User Information Settings vBulletin 3.8.x Add-ons 0
Admin User Date/Time Format Settings Xenforo 0
Admin [OzzModz]/[Kirby] Filtered User Change Log Xenforo 0
Admin [ITD] Change User Online Indicator Icon & Color Xenforo 0
Admin API endpoint: Find a User by Criteria Xenforo 2 Xenforo 0
Admin [MMO] User Ban Info xenforo 2 Xenforo 0
Admin Creating custom user banner styling xenforo 2 Xenforo 0
Admin Sugar Coding - User Feedback xenforo 2 Xenforo 0
N Share SRC-Combo To User:Pass Source Code C# / C++ 0
S Xin [Xin] Tool Leech Từ user Mwork Cho John CMS Johncms 0
Admin [OzzModz] Demo User Account Add-ons 0
Admin Cel User Always Online Add-ons 0
Admin Attractive User Info Boxes for Posts Vbb tutorial 2
Admin Disable Right Click For User Groups Vbb tutorial 0
Admin Temporary Passwords by BOP5 (Allow admins to login as any user without user password) Add-ons 0
Smobi Share Tích hợp CKEditor + CKFinder vào CI (Nâng cao+CKFinder Chia quyền thư mục theo user) PHP 0
Admin VBulletin Advanced User Tagging Cross Site Scripting Exploit 0
Admin Hiển thị thành viên trực tuyến - Show user is online xenforo Xenforo 0
Admin e360 User Profile Fields Permissions Add-ons 0
Admin [RT] User Rank Ribbons 2.3.3 Xenforo 0
Admin [RT] User Rank Images 1.1.5 Xenforo 0
Admin Nginx - Hướng dẫn chặn ip, xss exploits, sql injections, file injections, spam, user agents VPS & Dedicated Server 0
Admin [ozzy47] Ignore User In Postbit Dropdown Menu Add-ons 1
Admin Hướng dẫn tự động check ghi nhớ khi đăng nhập user thành viên Xenforo 0
Admin Hướng dẫn tăng thời gian user online, tăng số lượng user online xenforo Xenforo 0
Admin Hướng dẫn xóa bản quyền dbtech advanced user tagging Vbb tutorial 0
Admin Hướng dẫn sửa lỗi Invalid SQL: ALTER TABLE user DROP topxtab; MySQL Error : Can't DROP 'topxtab'; check that c Vbb tutorial 2
Admin PM User When Reaching X Posts Add-ons 0
Admin Ignored User Post Better Layout Vbulletin 0
Admin [vB5] User Profile Fields in the postbit templates Vbb tutorial 0
Admin [cydia] fake user agent ios (iphone, ipod, ipad) Android, ios, java, windows phone 0
Admin vBUT - User Group User Titles & Custom User Titles Add-ons 0
Admin User Self Delete 1.0.2 Xenforo 0
Admin Share code thay đổi user và pass admin nukeviet 3 Mã nguồn web 0
Admin [DBTech] Follow User v1.1.2 Add-ons 0
Admin User Essentials 1.0.9 NULL Xenforo 0
Admin Restore Deleted User Add-ons 4
Admin Tìm user của victim khi local Local attack 0

Similar threads

New posts New threads New resources

Back
Top