הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 05-01-15, 14:55   # 1
Jonathan Zeierman
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
הודעות: 1,003

Jonathan Zeierman לא מחובר  

ייעול קוד | טופס התחברות

היי חברים,
אשמח להמלצות בנוגע לאבטחה / ייעול של הקוד אימות התחברות שלי.
PHP קוד:
<?php
###################################################################
##                     Strating Sessions.                             ##
###################################################################
session_start();
###################################################################
##                Set Cases For Functions.                         ##
###################################################################
switch ($_GET['page'])
{
    case 
'login':
        
login();
        break;
        
    default:
        
login();
        break;
}
###################################################
    
$security_code rand(000000,999999);         ##
    
$_SESSION['security_code'] = $security_code##
###################################################################
##                    Strating Login Function.                     ##
###################################################################
function Login()
{
    
################################################################################################
    ##                             Require A DB Connection File.                                      ##
    ################################################################################################
    
require_once ('db/connect.php');                                                              ##
    ################################################################################################
   
if (isset($_POST['login_check']))
   {
        
################################################################################################
        ##                                        Variables.                                              ##
        ################################################################################################
        
$user mysql_real_escape_string(htmlspecialchars($_POST['user']));                           ##
        
$pass mysql_real_escape_string(htmlspecialchars(md5($_POST['pass'])));                       ##
        
$query = ("SELECT password, groups FROM users WHERE user = '".$user."'");                      ##
        
$result mysql_query($query)    or die("Mysql Getting The Next Error:" mysql_error());      ##
        ################################################################################################
        
if ($row mysql_fetch_array($result))
        {
            if(
$row['password'] == $pass && $_SESSION['security_code'] == $_POST['security_code_check'] && $row['groups'] == 1)
            {
                
$_SESSION['user'] = $user;
                
$_SESSION['pass'] = $pass;
                
$_SESSION['groups'] = $_SESSION['groups'] + 1;
                
header('Location: index.php?page=Administrators');
            }
            if(
$row['password'] == $pass && $_SESSION['security_code'] == $_POST['security_code_check'] && $row['groups'] == 2)
            {
                
$_SESSION['user'] = $user;
                
$_SESSION['pass'] = $pass;
                
$_SESSION['groups'] = $_SESSION['groups'] + 2;
                
header('Location: index.php?page=Administrators_Deputys');
            }
            if(
$row['password'] == $pass && $_SESSION['security_code'] == $_POST['security_code_check'] && $row['groups'] == 3)
            {
                
$_SESSION['user'] = $user;
                
$_SESSION['pass'] = $pass;
                
$_SESSION['groups'] = $_SESSION['groups'] + 3;
                
header('Location: index.php?page=Workers');
            }
                
mysql_close($db_connection); //Closing The Db Connection.
        
}
        if(
htmlspecialchars($_POST['user']) =='' || htmlspecialchars($_POST['pass'])=='' || htmlspecialchars($_POST['security_code_check'])=='')
        {
        echo 
'אנא מלא את כל השדות';
        }
        else
        {
        echo 
'שם משתמש ואו סיסמא שגויים';
        }
    }
}
?>
תודה לעוזרים, יונתן.
__________________
יונתן.
אימייל: jonathan@zeierman.net
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
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 מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 13:32.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ