[ ] - [ ] - [ ]
: PHP
x0ka
.
- :
$_POST, $_SESSION $_COOKIE

...

:
?
() ()?

...

,, =)

PHP
<?
functiontrack_text($str)
{
$BS
=array('`','\'','\\','/',',','.','?',';',":");
$str=trim($str);
$str=strip_tags($str);
$str=str_replace($BS,'',$str);
return($str);
};

functionuser($uLogin,$uPass,$bd)
{
include("../inc/MySQL.php");
$db=mysql_connect($server,$user,$password);
$base="Base";
mysql_select_db($base,$db);
$sql="SELECT*FROM`users`WHERE`login`='$uLogin'and`pass`='$uPass'LIMIT1";
$result=mysql_query($sql,$db);
$myrow=mysql_fetch_array($result);
return($myrow[$bd]);
};

session_start();

if($_GET['do']=='exit')
{
session_destroy();
unset($autorization);
setcookie('login','',time());
setcookie('pass','',time());
};

if(isset($_POST['enter']))
{
$aut_login=track_text($_POST['login']);
$aut_pass=md5(track_text($_POST['pass']));

}else{

session_start();

if((isset($_SESSION['login']))&&(isset($_SESSION['pass']))
&&($_SESSION['login']!='')&&($_SESSION['pass']!=''))
{
$aut_login=$_SESSION['login'];
$aut_pass=$_SESSION['pass'];

}else{)

if(isset($_COOKIE['login'])&&isset($_COOKIE['pass'])
&&($_COOKIE['login']!='')&&($_COOKIE['pass']!=''))
{
$aut_login=$_COOKIE['login'];
$aut_pass=$_COOKIE['pass'];
};

};

};

if(user($aut_login,$aut_pass,'id'))
{
$autorization=true;
$login=user($aut_login,$aut_pass,"login");
$pass=user($aut_login,$aut_pass,"pass");

session_start
();

$_SESSION
['login']=$login;
$_SESSION['pass']=$pass;

if($_POST['save']==1)
{
setcookie('login',$login,time()+18000);
setcookie('pass',$pass,time()+18000);
};

};


if(
$autorization)
{
echo":".$login."<br>";
echo"<ahref='?do=exit'></a>";

}
else{

echo"
<formaction=''method='post'>
<tablecellspacing='0'cellpadding='0'border='0'>
<tr>
<td>:</td>
<td><inputname='login'type='text'size='15'maxlength='35'></td>
</tr>
<tr>
<td>:</td>
<td><inputname='pass'type='password'size='15'maxlength='35'></td>
</tr>
<tr>
<tdcolspan='2'>
<inputname=entervalue=''type='submit'>
<inputname='save'type='checkbox'value='1'>
.
</td>
</tr>
</table>
</form>"
;
};





52 , 13 (17.05.2009 - 04:56) kirik ():
1. , <br />'`:; ?
2. user() ?
3. - , -
4. ?
5. ,
6. if($_POST['save'] == 1) ,
7. $_SESSION['pass'] = $pass; - ?
8. ( ), ( , . .7)
9. if(...isset($_COOKIE['login'])...&&...$_COOKIE['login'] != ''...) if(...!empty($_COOKIE['login'])...) ( IF )
...

3 , 19 (17.05.2009 - 04:59) x0ka ():
...

6 , 38 (17.05.2009 - 05:06) x0ka ():
kirik
3 ...
.session
..Cookie
...POST

1 , 48 , 40 (17.05.2009 - 06:54) kirik ():
(x0ka @ 16.05.2009 - 21:06)
3 ...
.session
..Cookie
...POST

!

(x0ka @ 16.05.2009 - 20:59)

, smile.gif

27 , 16 (17.05.2009 - 07:22) x0ka ():
kirik wink.gif
:

  |  
.
Invision Power Board © 2001-2024 Invision Power Services, Inc.