Jump to content

forums minimum userclass error oO?


rootKID

Recommended Posts

Hello W3S.

 

I know i have posted something similar a few days ago, but since i didn't get the error fixed im posting it again, since im not currently aware of how to make fix it.

 

Im currently trying to make a forum, and right now im trying to make the users only be able to see the forums IF they have a minimum user-class... and guess what, that part is somehow not working, and i just cannot figure out why -.-'.

 

This is the forum code:

<?php$overforum_res = sql_query("SELECT * FROM overforums ORDER BY of_id");while($of_arr = mysql_fetch_assoc($overforum_res)){	// User has reading rights. (if BIGGER or EQUAL to!)	if($CURUSER['u_FK_uc_id'] >= $of_array['of_u_class_read_min'])	{		$HTMLOUT .= "<table class='overforum_table_holder' border='0' cellpadding='0' cellspacing='0'>";			//======================================			// OVERFORUMS			//======================================						$HTMLOUT .= "<tr class='overforum_tr_holder'>";				// Forum Name				$HTMLOUT .= "<td class='overforum_name'>";					$HTMLOUT .= "<a href='forums.php?f_action=overforumview&overforum_id=".$of_arr['of_id']."'>";						$HTMLOUT .= $of_arr['of_name'];					$HTMLOUT .= "</a>";				$HTMLOUT .= "</td>";								// Last Post & Last Reply				$HTMLOUT .= "<td class='overforum_last_post_and_reply'>";					$HTMLOUT .= "Sidste Indlæg";				$HTMLOUT .= "</td>";								// Topic(s) Count By Forums				$HTMLOUT .= "<td class='overforum_topics'>";					$HTMLOUT .= "Emner";				$HTMLOUT .= "</td>";								// Answer(s) Count By Topic				$HTMLOUT .= "<td class='overforum_posts'>";					$HTMLOUT .= "Indlæg";				$HTMLOUT .= "</td>";			$HTMLOUT .= "</tr>";						//======================================			// FORUMS			//======================================						// TO DEFINE USER RIGHTS			$farray_res = sql_query("SELECT * FROM forums WHERE f_FK_of_id = ".$of_arr['of_id']." ORDER BY f_id");			$f_array = mysql_fetch_assoc($farray_res);						$f_res = sql_query("SELECT * FROM forums WHERE f_FK_of_id = ".$of_arr['of_id']." ORDER BY f_id");			while($f_arr = mysql_fetch_assoc($f_res))			{				// User has reading rights. (if BIGGER or EQUAL to!)				if($CURUSER['u_FK_uc_id'] >= $f_array['f_u_class_read_min'])				{					$HTMLOUT .= "<tr class='forum_tr_holder'>";												// Forum Name						$HTMLOUT .= "<td class='forum_name'>";							$HTMLOUT .= "<a href='forums.php?f_action=viewforum&forum_id=".$f_arr['f_id']."'>";								$HTMLOUT .= $f_arr['f_name'];							$HTMLOUT .= "</a>";						$HTMLOUT .= "</td>";												// Forum Last Post & Last Reply						$HTMLOUT .= "<td class='forum_last_post_and_reply'>";							//If bigger than 20 letters OR equal...							if(strlen("Pasta gratin for fattigrøve eller travle forældre/unge (nok til 4 personer)") >= 40)							{								$HTMLOUT .= "<span class='forum_float_left'>";									$HTMLOUT .= "".substr("Pasta gratin for fattigrøve eller travle forældre/unge (nok til 4 personer)", 0, 35)."...";								$HTMLOUT .= "</span>";																$HTMLOUT .= "<span class='forum_float_right'>";									//$HTMLOUT .= "Af Hyperion, 15 timer siden";									$HTMLOUT .= "Af Hyperion";								$HTMLOUT .= "";							}							else							{								$HTMLOUT .= "<span class='forum_float_left'>";									$HTMLOUT .= "Pasta gratin for fattigrøve eller travle forældre/unge (nok til 4 personer)";								$HTMLOUT .= "</span>";																$HTMLOUT .= "<span class='forum_float_right'>";									//$HTMLOUT .= "Af Hyperion, 15 timer siden";									$HTMLOUT .= "Af Hyperion";								$HTMLOUT .= "";							}						$HTMLOUT .= "</td>";												// Forum Topics						$HTMLOUT .= "<td class='forum_topics'>";							//$HTMLOUT .= number_format("10000000000");							$HTMLOUT .= number_format(get_forum_topics_row_count("topics", "WHERE ft_FK_f_id = " . $f_arr['f_id']));						$HTMLOUT .= "</td>";												// Forum Posts						$HTMLOUT .= "<td class='forum_posts'>";							//$HTMLOUT .= number_format("10000000000");							$HTMLOUT .= number_format(get_forum_posts_row_count("posts", "WHERE fp_FK_ft_id = " . $f_arr['f_id']));						$HTMLOUT .= "</td>";					$HTMLOUT .= "</tr>";				} // USER RIGHTS END!			} // WHILE LOOP FORUMS END!		$HTMLOUT .= "</table>";	} // USER READING RIGHTS END! ( IF / ELSE )} // OVERFORUMS WHILE-LOOP END!?>

In the top where the first WHILE-LOOP is for the overforums, you can see i use clearly the $CURUSER variable (direct connection to the user-table) to take the user-class it has. What i want now is to take FOREACH overforums minimum user-class number to see if the user is EQUAL or ABOVE that number, and i also do that by doing so (>= / if i am not mistaken).

 

And one of my forum-table's (overforums) are the class of 20 or above, just to see if it's coming out, and it's still getting out. This means it does not work properly.

 

Now my question if simply, how can i fix this? And did i do it in the proper way? Oo..

 

Hope you have some solutions where i cannot see one.

 

- thanks as always! :D

Link to comment
Share on other sites

I don't see where $of_array is being set.

 

If the system is not working properly, manually print out the values of $CURUSER['u_FK_uc_id'] and the result from the database to see what's wrong.

 

I notive you're doing the exact same query twice:

$farray_res = sql_query("SELECT * FROM forums WHERE f_FK_of_id = ".$of_arr['of_id']." ORDER BY f_id");$f_array = mysql_fetch_assoc($farray_res);            $f_res = sql_query("SELECT * FROM forums WHERE f_FK_of_id = ".$of_arr['of_id']." ORDER BY f_id");

You can avoid that by moving the result pointer back to the first result using mysql_data_seek().

 

You probably should use a newer database extension than mysql, because mysql is deprecated due to security.

Link to comment
Share on other sites

Ingolme, you told me in the last post/thread that it did not work due to the SQL line being used already, so that is why i made one more...

and that is because i include this code from another file into THE forums.php file... or trying to anyways, this is the code for my forums.php file:

<?php$page_title = "Forums";// ------------------// OVERFORUM// ------------------// OF_ARRAY = Over Forums Assoc (ROW / OUTPUT) - (NORMAL / NOT WHILE LOOP!)// $HTMLOUT .= $of_array[''];// OF_ARR = Over Forums Assoc (ROW / OUTPUT) - (WHILE LOOP!)// $HTMLOUT .= $of_arr[''];// ------------------// FORUMS// ------------------// F_ARRAY = Forums Assoc (ROW / OUTPUT) - (NORMAL / NOT WHILE LOOP!)// $HTMLOUT .= $f_array[''];// F_ARR = Forums Assoc (ROW / OUTPUT) - (WHILE LOOP!)// $HTMLOUT .= $f_arr[''];// $HTMLOUT .= "";//============================================// One Column System (Main Forums)$HTMLOUT .= "ttt"."<div id='forums_one_column_container'>"."n";	$HTMLOUT .= box_start("Forums");		$of_res = sql_query("SELECT * FROM overforums ORDER BY of_id");		$of_array = mysql_fetch_assoc($of_res);				// if "overforums" BIGGER than 0		if (mysql_num_rows($of_res) > 0)		{			if(isset($CURUSER))			{				// USER FORUMS!				// ---------------------------				// $HTMLOUT .= "USER VIEW!";				include_once("user.forums.php");			}			else			{				// GUEST FORUMS!				// ---------------------------				//$HTMLOUT .= "GUEST VIEW!";				include_once("guest.forums.php");			}		}		else		{			$HTMLOUT .= "<center>Ingen forums er tilføjet i nu!</center>";		}	$HTMLOUT .= box_end();$HTMLOUT .= "ttt"."</div>"."n";?>

Hope this helps... i die for an answer actually! I really dont know what the heck is wrong Oo... even tho my higest class is like 13 and i set the minimum user-class read right to 20, he/she can still see the damn forum/overforum... it's crazy tho, the $CURUSER SHOULD be working properly as i already did as you said, posted out the $CURUSER class line.. i got 12 as in "System Operator" class... i just dont get it Oo..

Link to comment
Share on other sites

To find oút if the values are correct print out the values and see what they are:

echo $CURUSER['u_FK_uc_id'];echo ' ';echo $of_array['of_u_class_read_min'];

Check for yourself which one is larger.

Link to comment
Share on other sites

i made this code for my overforums:

$of_res = sql_query("SELECT * FROM overforums ORDER BY of_id");while($of_array = mysql_fetch_assoc($of_res)){	$HTMLOUT .= $CURUSER['u_FK_uc_id'];	$HTMLOUT .= " / ";	$HTMLOUT .= $of_array['of_u_class_read_min'];	$HTMLOUT .= "<br />";}

and got this out:

 

12/0 -> MY CLASS / FORUM READ CLASS

12/15 -> MY CLASS / FORUM READ CLASS

 

and i made this code for all the forums to show up:

$of_res = sql_query("SELECT * FROM overforums ORDER BY of_id");while($of_array = mysql_fetch_assoc($of_res)){	/*	$HTMLOUT .= $CURUSER['u_FK_uc_id'];	$HTMLOUT .= " / ";	$HTMLOUT .= $of_array['of_u_class_read_min'];	$HTMLOUT .= "<br />";	*/		$f_res = sql_query("SELECT * FROM forums WHERE f_FK_of_id = ".$of_array['of_id']." ORDER BY f_id");	while($f_array = mysql_fetch_assoc($f_res))	{		$HTMLOUT .= $CURUSER['u_FK_uc_id'];		$HTMLOUT .= " / ";		$HTMLOUT .= $f_array['f_u_class_read_min'];		$HTMLOUT .= "<br />";	}}

and i got this out:

 

12/0

12/0

12/0

12/20...

 

this only shows i am right... i just dont understand still why the heck they wont do as i say.. only show when they are EQUAL or BIGGER than that number... annoying -.-'.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...