Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2007, 01:30 PM
HuggyCT2 HuggyCT2 is offline
 
Join Date: May 2007
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom Login

Hey guys,

Well I am making a seperate cms for my site www.clantemplates2.com

Now what I want to do is make a login script for the admin panel on the cms. I have coded many login scripts before but this just wont work and I cant see why.

Heres the code.

PHP Code:
<div id="staff1">
<?php
/*
www.clantemplates2.com
CT2 Custom cms
Coding by Supernal and Huggy
*/

// staff login for the cms

    
if (!$_SESSION['ct2_logged'])
        {
            if (!
$_POST['login'])
                {
?>
<h3>CT2 Staff Login - ACP</h3>
<h5>Please Login</h5>
<form action="" name="login" method="post">
<p>Username: <input type="text" name="username" class="forms"/></p>
<p>Password: <input type="password" name="password" class="forms"/></p>
<p><input type="submit" name="login" value="Login to Staff" class="forms"/></p>
</form>
<?php
}else{
    if(
$_POST['login'])
        {
        
$username addslashes(strip_tags($_POST['username']));
        
$password md5(md5(addslashes($_POST['password'])));
        
        if (!
$password || !$username)
            {
            echo 
"<div class='error'>Please enter a username and password</div>";
        }else{
            
$query "SELECT * FROM user WHERE username = '$username' AND password = '$password'";
            
$result mysql_query($query) or die (mysql_error());
            
$row = @mysql_fetch_array($result);
            
            
$rank $row['usergroupid'];
            
            if (
$rank == 2)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 4)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 1)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 3)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 8)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            
            if (
$row)
                {
                
$_SESSION['ct2_logged'] = $username;
                echo 
"<div class='error'>Loggin into CT2 staff ACP<br />
                <a href='index.php?page=admin'>Click here if you are not auto redirected</a></div>
                <meta http-equiv='refresh' content='3; url=index.php?page=admin'>
                <img src='images/loading.gif' alt='Loading' title='Loading'/>"
;
            }else{
                echo 
"<div class='error'>Wrong username or password</div>";
                echo 
"<meta http-equiv='refresh' content='2; url=index.php?page=login'>";
                }
            }
        }
    }
}
if (
$_SESSION['ct2_logged'])
    {
?>
Logged in as <?php echo $_SESSION['ct2_logged']; ?><br />
<a href="index.php?page=admin">Go to ACP</a> or <a href="index.php?page=login&amp;action=logout">Logout</a>
<?php
if ($_GET['action'] == "logout")
    {
    
session_start();
    
session_destroy();
    echo 
"Logging out......<br />";
    echo 
"<img src='images/loading.gif' alt='Loading' title='Loading'/>";
    echo 
"<meta http-equiv='refresh' content='3; url=index.php?page=login'>";
    }
}
?>
</div>
It just wont login, and I cannot figure out why, does anyone know of anything I should be doing different?
Reply With Quote
  #2  
Old 05-24-2007, 02:44 AM
byon byon is offline
 
Join Date: Apr 2007
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by HuggyCT2 View Post

It just wont login, and I cannot figure out why, does anyone know of anything I should be doing different?

You've forgotten the salt under,
PHP Code:
$password md5(md5(addslashes($_POST['password']))); 
check out the vbulletin articles at the navbar ontop. lots of tutorials there. :P
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:41 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04442 seconds
  • Memory Usage 2,198KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete