ho would i set up mysql query to do this
#11
You want to count the group members? then this will work:

$count = $db->fetch_field( $db->query( "SELECT COUNT(*) as numberofmembers FROM ".TABLE_PREFIX."users WHERE `usergroup` = 8 "), 'numberofmembers' ); 

Remember to change "8" to your desired GID.

If this is not what you're looking for, then I don't know. Please explain more...

Credits to Ad Bakker.
Reply
#12
This user has been denied support. This user has been denied support.
here is what i am after a conversion from vbulletin to my bee here is full code for vbulletin that works want the same thing but for mybb forum application

<?php

mysql_connect("buns223.db.9821506.hostedresource.com", "buns223", "Irock2u2!") or die("Could not connect!"); //ip connect - login username - login password - or die - message if mysql connection failed

mysql_select_db("buns223")or die("Could not select Database");



$id=$_GET['username'];





$query = "SELECT usergroupid AS group FROM user WHERE username ='{$id}'"; //SELECT the subtable name as 'group' FORM tablename WHERE username='$id'



$result = mysql_query($query);



while(($row = mysql_fetch_assoc($result)) !== false) {

$info = $row;

}



echo $info['group'];





?>
Reply
#13
This user has been denied support. This user has been denied support.
here is code i was after it works it relly works lol

<?php
header ("Content-Type:text/xml");
define("IN_MYBB", 1);
require_once "./global.php";
require_once "./inc/functions_time.php";

$user = $db->simple_select("users", "*", "username='".$mybb->input['username']."'");

if($mybb->input['username'] && $db->num_rows($user) != 0)
{
$user = $db->fetch_array($user);
$usergroupcache = $cache->read("usergroups");

$doc = new DOMDocument();
$doc->formatOutput = true;

$u = $doc->createElement("user");
$doc->appendChild($u);









$usergroup = $doc->createElement("usergroup");
$usergroup->appendChild($doc->createTextNode($usergroupcache[$user['usergroup']]['gid']));



$numthreads = $db->simple_select("threads", "COUNT(tid) as count", "uid = ".$user['uid']);
$numthreads = $db->fetch_field($numthreads, "count");




$timesearch = TIME_NOW - $mybb->settings['wolcutoffmins']*60;
$query = $db->simple_select("sessions", "location,nopermission", "uid='".$user['uid']."' AND time>'".$timesearch."'", array('order_by' => 'time', 'order_dir' => 'DESC', 'limit' => 1));
$session = $db->fetch_array($query);

if ($db->num_rows($query) == 0)
{
$onlinestatustext = "Offline";
}
else
{
require_once MYBB_ROOT."inc/functions_online.php";
$lang->load("online");
$location = fetch_wol_activity($session['location'], $session['nopermission']);
$location = build_friendly_wol_location($location);
$onlinestatustext = "Online - ".strip_tags($location);
}






$u->appendChild($usergroup);





echo $doc->saveXML();
}
else
{
error("invalid user");
}
?>
example of
http://haxcore.net/forum/5.php?username=virus

it works user group check

now the ve.net code

Public Sub checkusergroup()



Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.haxcore.net/forum/5.php?username=" & ReactorTextBox1.Text)

Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim usergroup As String = sr.ReadToEnd()

If usergroup.Contains("<usergroup>4</usergroup>") Then 'admin
MsgBox("Welcome admin Member")

Form2.ReactorButton2.Visible = True 'This turn on the VIP side of the loader
ElseIf usergroup.Contains("<usergroup>5</usergroup>") Then 'super mod
MsgBox("Welcome registeredr")
Form2.ReactorButton1.Visible = True
ElseIf usergroup.Contains("7") Then 'mod
MsgBox("Welcome Staff Member")
'ReactorButton4.Visible = True
ElseIf usergroup.Contains("<usergroup>19</usergroup>") Then ' CA VIP
MsgBox("Welcome retired Staff Member")
Form2.ReactorButton3.Visible = True
ElseIf usergroup.Contains("10") Then ' WR VIP
MsgBox("Welcome Staff Member")
'ReactorButton4.Visible = True
ElseIf usergroup.Contains("11") Then ' Respected AKA Friends
MsgBox("Welcome Staff Member")
'ReactorButton4.Visible = True
ElseIf usergroup.Contains("12") Then ' Coders
MsgBox("Welcome Staff Member")
'ReactorButton4.Visible = True
ElseIf usergroup.Contains("13") Then ' Support Staff
MsgBox("Welcome Staff Member")
'ReactorButton4.Visible = True
MsgBox("Welcome Staff Member")
ElseIf usergroup.Contains("8") Then ' Banned User
MsgBox("You have been banned by a Forum Staff member! Please contact anyone of the staff to appeal your ban. In order to secure the loader you have been banned on the loader and forums!", MsgBoxStyle.Critical, "AmazingHacks.net Ban Message")
Me.Close()
Else
'ReactorButton4.Visible = False 'VIP button on form1
End If

End Sub
Private Sub ReactorButton1_Click(sender As Object, e As EventArgs) Handles ReactorButton1.Click
checkusergroup()
Dim wrkr As New HTTPWorker()
Dim myBBForum As New myBB("http://haxcore.net/forum/", ReactorTextBox1.Text, ReactorTextBox2.Text)
If wrkr.login(myBBForum) Then
MsgBox("Logged in successfully!")
Me.Hide()
Form2.Show()
Else
MsgBox("Invalid account, please try again! Register if you don't have an account.")
End If
End Sub
this is what i was looking for
Reply
#14
This user has been denied support. This user has been denied support.
here is update of vb.net mybb user group check other method did work but this method is better
note php need to be fix code does work but mysql injection attack can be plausibly i dont think they can obtain anything from database but this will display a result what is not good  ' or ''=' in php code i need help with mysqli escape strings


<?php

$conn = mysqli_connect("localhost", "user name ", "password");

if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

if (!mysqli_select_db($conn,"database name")) {
    echo "Unable to select apptest: " . mysql_error();
    exit;
}

$id=$_GET['username'];


$sql = "SELECT `usergroup` as `group` FROM mybb_users WHERE username ='{$id}'";

$result = mysqli_query($conn,$sql);

if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " ;
    exit;
}

if (mysqli_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
}

// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//      then create $userid, $fullname, and $userstatus
while ($row = mysqli_fetch_assoc($result)) {
    echo $row["group"];
}

mysqli_free_result($result);

?>

note this code for vb.net was originally set up for vbulletin
just make your changes in id numbers

Public Sub checkusergroup()

        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://haxcore.net/vbu/usergroup3.php?username=" & TextBox1.Text)

        Dim response As System.Net.HttpWebResponse = request.GetResponse()
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
        Dim usergroupcheck As String = sr.ReadToEnd()

        If usergroupcheck.Contains("6") Then 'Admin
            MsgBox("Welcome Admin")
            inter.Button4.Visible = True
        ElseIf usergroupcheck.Contains("7") Then 'Moderator
            MsgBox("Welcome Moderator")
            inter.Button4.Visible = False
        ElseIf usergroupcheck.Contains("5") Then 'Super Moderator
            MsgBox("Welcome SMOD")
            inter.Button4.Visible = False
        ElseIf usergroupcheck.Contains("10") Then 'Coder
            MsgBox("Welcome Coder")
            inter.Button4.Visible = True
        ElseIf usergroupcheck.Contains("2") Then 'Registered
            MsgBox("Welcome Registered")
            inter.Visible = False
        ElseIf usergroupcheck.Contains("14") Then 'VIP
            MsgBox("Welcome VIP")
            inter.Button4.Visible = True
        ElseIf usergroupcheck.Contains("9") Then 'Tech Support
            MsgBox("Welcome Tech")
            inter.Button4.Visible = True


        ElseIf usergroupcheck.Contains("8") Then ' Banned User
            MsgBox("You have been banned by a Forum Staff member! Please contact anyone of the staff to appeal your ban. In order to secure the loader you have been banned on the loader and forums!", MsgBoxStyle.Critical, "AmazingHacks.net Ban Message")
            Me.Close()
        Else
            inter.Button4.Visible = False 'VIP button on form1
        End If

    End Sub

all numbers in check user group need to be changed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)