Results 1 to 1 of 1

Thread: [PHP] IP.Board auth

Threaded View

  1. #1
    Josh's Avatar
    Joined
    Dec 2011
    Posts
    415
    Userbars
    2
    Thanks
    25
    Thanked
    378/143
    DL/UL
    82/6
    Mentioned
    120 times
    Time Online
    17d 9h 48m
    Avg. Time Online
    5m

    [PHP] IP.Board auth

    Simple IP.Board auth. I got bored last night and decided to see if I still remembered some php...

    PHP Code:
    <?php
    include 'conf_global.php';

    if (
    $_GET["r"] AND $_GET["u"] AND $_GET["p"]){


    $dbusername $INFO['sql_user'];
    $dbpassword $INFO['sql_pass'];
    $hostname $INFO['sql_host']; 
    $database $INFO['sql_database'];
    $r $_GET["r"];
    $username mysql_real_escape_string($_GET["u"]);
    $password $_GET["p"]; 

    $show_groups false;
    //Will list groups and their ID number. Keep on false usually. Just helpful for writing the rank checking part of the code.




    $dbhandle mysql_connect($hostname$dbusername$dbpassword)
      or die(
    "Unable to connect to MySQL");

    $selected mysql_select_db($database,$dbhandle)
      or die(
    "Could not select database");
    $result mysql_query("SELECT * FROM `forum_members` WHERE name = '$username'");
    $row mysql_fetch_array($result);


        if (empty(
    $row)) {
            
            echo 
    "<error>Invalid username</error>";
            
        }
        else{
            
    $getsalt $row{'members_pass_salt'};        
            
            
    $hash md5(md5($row{'members_pass_salt'}). md5($password));
            if(
    $hash != $row['members_pass_hash']){
            
                echo 
    "<error>Invalid Password</error>";
            }
            else{
                
    $get_rank_id $row{'member_group_id'};    
                
    $ranks = array(-=> '1'=> '5'=> '3'=> '6'=> '4');
            
    //List of all rank ids. Current ones are the default groups for IP.Board
            //Numbers in quotes are the IDs of the group.
            //1 = Validating
            //5 = Banned
            //3 = Members
            //4 = Admins
            //6 = Mods
            //First number ranks those groups from least to greatest. 0 and below = Access to nothing.
            // There are others ways of doing this, but this was easy.
            
                
    $rank array_search($get_rank_id$ranks); 
                
                if(
    $rank >= $r){
                    echo 
    "Posts: <posts>".$row{'posts'}."</posts>"." <rank>".$row{'member_group_id'}."</rank>";
                    echo 
    "<error>Success</error>";            
                }else{
                    echo 
    "<error>Rank not high enough</error>";
                }
            
            

                    
            }    
                    
        }



    if (
    $show_groups) {
    echo 
    "<br><br><table border='1'>
    <tr>
    <th>ID</th>
    <th>Group Name</th>
    </tr>"
    ;


    $result mysql_query("SELECT * FROM `forum_groups`");
    while(
    $row mysql_fetch_array($result))
      {
      echo 
    "<tr>";
      echo 
    "<td>" $row['g_id'] . "</td>";
      echo 
    "<td>" $row['g_title'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";


    }

    mysql_close($dbhandle);
    } else{
    echo 
    "...You forgot something";
    }
    ?>
    Last edited by Josh; 07-22-2013 at 08:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •