View Single Post
ישן 22-07-08, 16:02   # 19
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

PHP קוד:
<?php

include "config.php";
$tp = <<<EOF
<html dir="rtl">
<head>
    <title>דף ראשי</title>
</head>
<body>
EOF;
$hour time() + 3600;
$username $_COOKIE['user'];
$password $_COOKIE['pass'];

if (!isset(
$_COOKIE['user'])) {
    
$tp .= "אתה אינך מחובר :: <a href=\"?act=loginform\">התחברות</a><br />";
} else
    
$tp .= "ברוך הבא $username :: <a href=\"?act=logout\">התנתק</a><br />";

$act = isset($_GET['act']) ? $act $_GET['act'] : $act "loginform"// הגדרת משתנה ראשי

if ($act == "logincheck") { // בדיקת התחברות
    // הכנסת פרטי הטופס למשתנים
    
$user $_POST['User'];
    
$pass $_POST['Pass'];
    
// בדיקת טופס
    
$tp .= "
    <table class=\"loginchecktable\">
    <tr><td valign=\"top\" dir=\"rtl\" class=\"login_check_td_table\">"
;

    if (
$pass == "") {
        
$tp .= "סיסמא לא הוזנה
<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=?act=loginform\">"
;
    } else if (
$user == "") {
        
$tp .= "שם משתמש לא הוזן
       <META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=?act=loginform\">"
;
    } else {
        
$s mysql_query("SELECT * FROM members WHERE username='$user' && password='$pass'") or die(mysql_error());
        
$checkform mysql_num_rows($s);

        if (
$checkform == "0") {
            
$tp .= "אחד מהפרטים אינו נכון
        <META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=?act=loginform\">"
;
        } else {
            
$tp .= "התחברת בהצלחה<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=index.php\">";
            
setcookie('user'$user$hour);
            
setcookie('pass'$pass$hour);
        }
    }

    
$tp .= "</td></tr>
</table>"
;
} else if (
$act == "loginform") { // טופס התחברות
    
if (!isset($_COOKIE['user'])) {
        
$tp .= <<<LOGINFORM

<form action="?act=logincheck" method="post">
<table class="logintable">

    <tr><td valign="top" dir="rtl" class="logintdtable">שם משתמש: </td>
    <td valign="top" dir="rtl" class="logintdtable"><input type="text" name="User"></td>
    </tr>
    <tr><td valign="top" dir="rtl" class="logintdtable">סיסמא:  </td>
    <td valign="top" dir="rtl" class="logintdtable"><input type="password" name="Pass"></td>
    </tr>
    <tr><td valign="top" dir="rtl" class="logintdtable"></td>
    <td valign="top" dir="rtl" class="logintdtable"><input type="reset" value="נקה"><input type="submit" value="התחבר"></td>
    </tr>
</table>
</form>

LOGINFORM;
    } else {
        
$tp .= "אתה מחובר למערכת
<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=index.php\">"
;
    }
} else if (
$act == "logout") {
    
$past time() - 100;
    
setcookie('user''I dont know PHP'$past);
    
setcookie('pass''I dont know PHP'$past);
    
$tp .= "התנתקת בהצלחה
        <META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=index.php\">"
;
}
$tp .= "</body></html>";
echo 
$tp;

?>
  Reply With Quote