Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
Ok, this should be very simple.. I just don't quite have the php knowledge (or time to try to figure it out) to finish the task.

Anyway.. I have an external script that I only want a particular group or groups to access. So really, all I have to add to this script is this authenticate logic to test whether or not they should have access to the page.

So, I know this is needed:

Code
	$threadspath= "/home/mydomain/public_html/forums";<br /><br />   require ("$threadspath/main.inc.php");<br /><br />   $userob = new user;<br />   $user = $userob -> authenticate();<br />


So... with that, what would come next? I basically just need it to check to see if they are in group X. If they are... run/display the script as intended.

If they are not in group X, then they are re-directed to another page, or a simple message is displaying telling them why they can't access it.

It is probably just a simple query to U_Group or whatever, and then an if statement to check... but, it would take me 3 weeks to figure it out

So any help would be great

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
What you have to start is Good.

Change the last line to this:

Code
<br />   $user = $userob -> authenticate("U_Groups");<br /><br />// Adjust the group number to the group that IS allowed to access.<br />// If they are not part of this group - they will get intercepted by the not right page<br />if (!strstr($user['U_Groups'],"-5-")) {  <br />   $html = new html;<br />   $html -> not_right ('You are not authorized to view this page.',$Cat);<br />}<br /><br />// Otherwise continue on with your page here. :)<br /><br />


Untested.... but hope that helps.

Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
Thanks josh.. that is even more simple than I had immagined. I didn't know the authenticate() function would work just by sticking the U_Groups in there

I'll give it a gow in the morning, my brain is fried tonight.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Yeah, the authenticate function queries a bunch of stuff from the Users table automatically, but then you can add extra fields in there. It's really quite handy.

If you were doing alot of Group checking all over your site - you could find the function in ubbt.inc.php and add the U_Groups to the end of the database query in there. Then $user['U_Groups'] would work everywhere without having to add it to authenticate on every page.

Glad I could help you - you've been quite helpful to me lately. That tip on installing the GD library was a timesaver.

Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759


Well, you guys know PHP, I know little server tricks. Its good I can help out at least somehow

My problem is, I completely understand programming logic, as I used to program in PASCAL and C/C++ many years ago... but, I just can't remember all of the syntax and odd little things to make it work So I typically know how to go about completing a task, It just takes forever to impliment because I have to look up every command or query

Sponsored Links
Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
Hey Josh, that almost worked perfectly

It half works... When I add this code, if you are not logged in, or in the wrong group, you are correctly displayed with the not authorized message. Sweet I know

But when an authorized user does try to access the page, either a bunch of jumbled characters display on a white screen, or the browser prompts you to download a file.. which is just more jumbled text.

So, somehow this code isn't working friendly with the existing script. I tried changing positions of the threads authenticate code, and if you put it below one of the initial commands of the existing script.. the threads stuff doesn't even go into effect, yet produces no errors. So, it has to be at the very top to work.

Anyway, I'm just wondering if there has to be another greater if statement that encloses all of the threads code? Or there has to be some way to isolate it a bit.

I was also thinking, maybe put the threads script in a completely seperate file.. then call the file at the top of the existing script returning a do or don't proceed value?

I dunno which would work best for something like this

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
That's odd - is Zlib compression on in this other script? Sometimes you get junk if 2 programs are trying to compress the same thing twice.

if you want to make the threads stuff a separate file - the one they visit first - and leave your exisiting script untouched - you could try this:

Code
 <br />// Adjust the group number to the group that IS allowed to access. <br />// If they are not part of this group - they will get intercepted by the not right page <br />if (!strstr($user['U_Groups'],"-5-")) { <br />   $html = new html; <br />   $html -> not_right ('You are not authorized to view this page.',$Cat); <br />} <br />else { <br />   header ("Location: http://www.jeremeyssite.com/the/page/where/the/real/script/is.php"); <br />} <br />


Then it'll stop them if they aren't allowed - or redirect them to the real page if they are allowed.

Of course - if the other page is unprotected. Someone could directly access it via URL.

Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
I'll give it a try. And as far as I can tell, all of the scripts are not encoded by zend or ioncube or anything, which is why I found that odd.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)