MyBB Central

Full Version: Merging a script with MyBB.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Simple question that i cant work out. Hoping someone can answer.

Basically i have a script for uploading files to my server. Now i want to be able to get the script to require the user to be logged in.
I only want registered users to be able to use this script as its the forums image/file upload script.
I want it to use the existing cookie or whatever it has to do to pick up that info.
Is this simple to do or rather complicated?
I Have Always Wanted to know How To Do That. Hope It Is Possible
(Feb 01, 2009, 03:24 AM)joshuam08 Wrote: [ -> ]I Have Always Wanted to know How To Do That. Hope It Is Possible

Its certainly possible. I believe it uses hooks or something like that.
Glad to see im not the only one wanting to know though Joshuam08. I was worried i was going to get scalded for a silly question.
You can require the mybb global.php in your script to start with. I believe at mybboard.net there are some tuts on cookie and site integration.
(Feb 01, 2009, 05:41 PM)labrocca Wrote: [ -> ]You can require the mybb global.php in your script to start with. I believe at mybboard.net there are some tuts on cookie and site integration.

Bugger. The man and he wont share the gold.
Its all good. I understand why. Are you willing to do it for me for a small fee?
Its a running upload script. Works great just have a login issue i cant figure out.
I haven't really gone and done something like this yet. It shouldn't be super difficult. Are you sure you really need this feature?

My guess is to do a require of the global in the top of your script then do a simple if statement.

require_once 'PATH/TO/global.php';

if (!$mybb->user['uid']) {
error_no_permissions();
}

Something like that at least.
Thats the start i need Labrocca. Thankyou so much for this. Its given me a starting point to work with.
I will now try make a new script that simply uses the global.php even if its nothing more than a blank page. If i can get that to work then the world is my oyster. I love playing with scripts and have no problem there. Its always been the integration that i could not work out.
Thankyou again. I feel a little inspired now to be honest.
It would appear i have got it to work. I had to edit a little but now i have made a blank page that only registered users can see... Smile
Would buy you a beer if you were closer Labrocca. So happy bloke. Anyways for the rest here is what i did so far. Yet to test on a running script but suspect that will be simple.

PHP Code:
<?php

define
("IN_MYBB"1);


require_once 
"./global.php";

if(!
$mybb->user['uid']){
error_no_permission();
}

?>
Testing 

Now the location to your global.php file may well vary. But this worked for me. Smile Smile Smile