[MySQL][PHP] Small Usersystem

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 35
  1. #16
    Account Upgraded | Title Enabled! Hexadecimal is offline
    MemberRank
    Dec 2010 Join Date
    424Posts

    Re: [MySQL][PHP] Small Usersystem

    Quote Originally Posted by XCON View Post
    I'll consider using SALTs in the future, but wouldn't it be safer to have a salt on each side of the password? Otherwise, you could just use SubStr on the password until you have removed the salt.

    Code:
    <?php
    
    $salt = "ABBBCBCBCBBCBCBCBCB0109293839299292920902";
    function enc($in) { return sha1($salt.md5($in).$salt); }
    
    ?>
    That would be a much safer alternative.
    Go for it. If you know what you're doing, and feel it's a good thing to do, then try it.

    I suggest using special characters in your SALT, such as "!*%!SGJ*!!()*!"

  2. #17
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    I have recoded the usersystem from scratch, the design has been updated and new features have been added.

    There is now a page with a member list plus a user profile page.
    There is also a page that lets you read and send private messages to other users.

    I was thinking maybe coding a chatbox or a mini-forum.

  3. #18
    Web Developer Markshall is offline
    MemberRank
    Oct 2009 Join Date
    EnglandLocation
    628Posts

    Re: [MySQL][PHP] Small Usersystem

    If it works, great! But I'm with other people on this, I don't like the way you capitalize things such as expressions, but like I said if it works... great.

    I also don't like the way you stretch functions onto one line instead of line breaking them and indenting. I know other people viewing the website won't see the PHP coding, but I have 'OCD' with my PHP and like to keep it all tidy behind the scenes, lol.

    Nice work with it though.

  4. #19
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    I removed the capitalizations, while I do admit that it does look nicer, it will take some time to get used to.

    I can also inform you that I wont be using functions in the same way this time, I wont have a function for getting the information from users and similar, the only functions I have now is for securing inputs from forms and encrypting passwords.

  5. #20
    Apprentice skylle is offline
    MemberRank
    Dec 2011 Join Date
    9Posts

    Re: [MySQL][PHP] Small Usersystem

    nice 1

  6. #21
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    Thanks.

    I haven't got the private messaging system working 100%, some problems with the Javascripts that are supposed to work.
    EDIT: Works now. I hate that \n and \r breaks Javascript codes.
    Last edited by XCON; 09-01-12 at 05:28 PM.

  7. #22
    Account Upgraded | Title Enabled! zkemppel is offline
    MemberRank
    Apr 2007 Join Date
    RootLocation
    241Posts

    Re: [MySQL][PHP] Small Usersystem

    You should add an authorization level system, for admins and such.

    PHP Code:
        function verifyauth($sessuser$variable)
        {
            
    $query mysql_query("SELECT AUTH FROM users WHERE ID = '".$sessuser."'");
            
    $run mysql_fetch_assoc($query);

            if(
    $variable == 1)
            {
                if(
    $run["AUTH"] >= 1)
                {
                    return 
    true;
                }
            }        
            elseif(
    $variable == 2)
            {
                if(
    $run["AUTH"] >= 2)
                {
                    return 
    true;
                }
            }
            else
            {
                return 
    false;
            }
        }

    define("AUTH_1", (verifyauth($_SESSION["user"], 1)));
    define("AUTH_2", (verifyauth($_SESSION["user"], 2))); 
    Last edited by zkemppel; 10-01-12 at 07:43 PM.

  8. #23
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    There is an authorization system, just not completed yet, I'm working on that.

    I added the feature to enable and disable private messaging.
    I added the feature to hide and show your email address on your profile page.
    Last edited by XCON; 10-01-12 at 03:43 PM.

  9. #24
    Account Upgraded | Title Enabled! zkemppel is offline
    MemberRank
    Apr 2007 Join Date
    RootLocation
    241Posts

    Re: [MySQL][PHP] Small Usersystem

    I only glanced at the code, just throwing some ideas at you. authorization system shouldn't take too much work. with that code you just wrap different functions with:
    PHP Code:
    if(AUTH_1)
    {
    //execute code
    }
    else
    {
    echo 
    "You do not have sufficient authorization.";


  10. #25
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    What would I need an authorization system for? I have a rank system coded, in place and its working perfectly fine.

  11. #26
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,098Posts

    Re: [MySQL][PHP] Small Usersystem

    Try to make your code look like the code examples here:
    Manual :: Coding Standards

    Particularly your function definitions:
    http://pear.php.net/manual/en/standards.funcdef.php

    Also keep your lines limited to 75-85 characters, where a tab is 4 or 8 spaces (not both/either- pick one or the other.. pick 4).

    Also this is already a bool:
    PHP Code:
    IsSet($_SESSION["id"]) && UserExist(Secure($_SESSION["id"])) 
    So you don't need to append ' ? true : false ', as it's already going to be true/false. In fact, never use a control statement to evaluate to true/false.. it's already true/false.


    Finally, refrain from your nesting habit.
    PHP Code:
    if(condition1)
    {
        
    // condition1 code

        
    if(condition2)
        {
            
    // condition2 code

            
    if(condition3)
            {
                
    // condition3 code

            
    } else {
                
    error3
            
    }
        } else {
            
    error2
        
    }
    } else {
        
    error1

    can easily be improved like so:
    PHP Code:
    if (!condition1)
    {
        
    error1
    }

    // condition1 code

    if (!condition2)
    {
        
    error2
    }

    // condition2 code

    if (!condition3)
    {
        
    error3
    }

    // condition3 code 
    If you're not going to have code for each condition, this is even better:
    PHP Code:
    if (   condition1
        
    && condition2
        
    && condition3
    ) {
        
    // code here

    No matter what you're coding, the goal is to keep it readable for your future self or other developers, as it's not going to be perfect the first time.
    Last edited by s-p-n; 10-01-12 at 06:48 PM.

  12. #27
    Account Upgraded | Title Enabled! zkemppel is offline
    MemberRank
    Apr 2007 Join Date
    RootLocation
    241Posts

    Re: [MySQL][PHP] Small Usersystem

    Quote Originally Posted by XCON View Post
    What would I need an authorization system for? I have a rank system coded, in place and its working perfectly fine.
    If someone is an administrator, they have authorization to access certain functions, but a regular user without authorization would not be able to. This might be what you mean by rank system. Stuff such as editing/deleting users.

  13. #28
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    s-p-n, thanks for the advice, but I'm used to my way of coding, and I will probably keep using it.

    zkemppel, the rank system I coded is very efficient and extendable, the authorization system you suggested isnt, but thank you for your advice.
    Posted via Mobile Device

  14. #29
    i didnt do this. Donkjam is offline
    MemberRank
    Jul 2007 Join Date
    4,494Posts

    Re: [MySQL][PHP] Small Usersystem

    Welcome back ^^. Looks alright ^^ I'm maybe learning php so will look at how it works
    Posted via Mobile Device

  15. #30
    Apprentice XCON is offline
    MemberRank
    Jan 2012 Join Date
    20Posts

    Re: [MySQL][PHP] Small Usersystem

    Thanks Donkjam, but as s-p-n made very clear, my code isn't the best learning source, however, if you do learn anything from me, I'm glad I could help.



Page 2 of 3 FirstFirst 123 LastLast

Advertisement