עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

פורסם

שלום,

אני מנסה לחשוב על ייעול הקוד אימות התחברות שלי, אשמח להצעות ייעול / שיפור / אבטחה ולביקורת בונה.

 <?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 'שם משתמש ואו סיסמא שגויים';
}
}
}
?>

תודה, יונתן.

פורסם

לא יודע לגבי יעול, אבל תקרא על SALT ועל למה לא להשתמש ב MD5, שניהם בהקשר של סיסמא.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.