анти бот

C++ JAVA
Post Reply
pro12
Турист
Турист
Posts: 452
Joined: Thu Jan 10, 2013 3:08 pm

анти бот

Post by pro12 » Sun Jun 08, 2014 7:16 pm

Как да сложа този код

Code: Select all

if( md5( $_POST['randimage_txt'] ) != $_SESSION['image_random_value'] ){
print'Объркахте кода за сигурност. Моля опитайте отново!';
}
else{
//код, който да се изпълни ако секретния код е вярно попълнен
print'Кода за сигурност е верен.';} 
в този

Code: Select all

<? 


session_start&#40;&#41;;
oB_start&#40;&#41;; 

include&#40;"conff.php"&#41;; 
if &#40;!$logged&#91;username&#93;&#41; 
&#123; 
if &#40;!$_POST&#91;login&#93;&#41; 
&#123; 
echo&#40;" 
<center><form method=\"POST\"> 
<table> 
<tr> 
<td align=\"right\"> 
Потребител&#58; <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> 
</td> 
</tr> 
<tr> 
<td align=\"right\"> 
Парола&#58; <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> 
</td></tr><tr> 
<td align=\"center\"> 
<input type=\"submit\" name=\"login\" value=\"Влез\"> 
</td></tr><tr> 
<td align=\"center\"> 
<a href=\"reguser.php\">Регистрирай се</a> 
</td></tr></table></form></center>"&#41;; 
&#125; 
if &#40;$_POST&#91;login&#93;&#41; &#123; 
 
$username=$_POST&#91;'username'&#93;; 
$password = md5&#40;$_POST&#91;password&#93;&#41;; 
// the above lines set variables with the submitted information. 
$info = mysql_query&#40;"SELECT * FROM users WHERE username = '$username'"&#41; or die&#40;mysql_error&#40;&#41;&#41;; 
$data = mysql_fetch_array&#40;$info&#41;; 
if&#40;$data&#91;password&#93; != $password&#41; &#123; 
// the password was not the user's password! 
echo "Грешен потребител или парола!"; 
&#125;else&#123; 

$query = mysql_query&#40;"SELECT * FROM users WHERE username = '$username'"&#41; or die&#40;mysql_error&#40;&#41;&#41;; 
$user = mysql_fetch_array&#40;$query&#41;; 

setcookie&#40;"id", $user&#91;id&#93;,time&#40;&#41;+&#40;60*60*24*5&#41;, "/", ""&#41;; 
setcookie&#40;"pass", $user&#91;password&#93;,time&#40;&#41;+&#40;60*60*24*5&#41;, "/", ""&#41;;
$_SESSION&#91;'level'&#93; = 1;  
// the above lines set 2 cookies. 1 with the user's id and another with his/her password. 
echo &#40;"<meta http-equiv=\"Refresh\" content=\"0; URLhttp&#58;//vivaaa.netau.net/test\"/>Вие успешно влязохте в акаунта си. <a href=\"edit.php\">Промени профила си</a><br /> "&#41;; 
// modify the above line...add in your site url instead of yoursite.com 
&#125; 
&#125; 
&#125; 
else 
&#123; 
// we now display the user controls. 
echo &#40;"<center>Добре дошли <b>$logged&#91;username&#93;</b><br /></center> 
<a href=\"edit.php\">Промени профила си</a><br /> 
<a href=\"members.php\">Виж всички регистрирани потребители</a><br /> 
<a href=\"logoout.php\">Излез от акаунта си</a>"&#41;; 
&#125; 
?>

fbian
Турист
Турист
Posts: 204
Joined: Sat May 26, 2012 3:55 pm
Answers: 18

Post by fbian » Sun Jun 08, 2014 8:04 pm

[php]
<?


session_start();
oB_start();

include("conff.php");
if (!$logged[username])
{
if (!$_POST[login])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Потребител: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Влез\">
</td></tr><tr>
<td align=\"center\">
<a href=\"reguser.php\">Регистрирай се</a>
</td></tr></table></form></center>");
}
if ($_POST[login]) {

$username=$_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Грешен потребител или парола!";
}
elseif(md5( $_POST['randimage_txt'] ) != $_SESSION['image_random_value']) {
echo 'Объркахте кода за сигурност. Моля опитайте отново!';
}
else{

$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);

setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
$_SESSION['level'] = 1;
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URLhttp://vivaaa.netau.net/test\"/>Вие успешно влязохте в акаунта си. <a href=\"edit.php\">Промени профила си</a><br /> ");
// modify the above line...add in your site url instead of yoursite.com
}
}
}
else
{
// we now display the user controls.
echo ("<center>Добре дошли <b>$logged[username]</b><br /></center>
<a href=\"edit.php\">Промени профила си</a><br />
<a href=\"members.php\">Виж всички регистрирани потребители</a><br />
<a href=\"logoout.php\">Излез от акаунта си</a>");
}
?>
[/php]

Post Reply