Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Надо вывести инфу из таблицы в файл, не имея прав на работу с файлами. file_priv:N . как реализовать ,кто подскажет?
123|2
456|2
789|2
<?php
session_start();
// put k faylu s parolyami
$path = 'passwords.txt';
// adres stranichi, na kotoriy nujna peresilat posle avtorizchii
$page = 'http://serfeli.az';
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
// esli vveli parol
if(isset($_POST['password']) && ! empty($_POST['password'])){
$passwords = array();
$tmp_pass = array();
$doLogin = false;
// chitaem paroli i kol-vo zaxodov v massiv
$passwords = file($path);
foreach($passwords as $k=>$v){
// $tmp_pass = array(0 => parol, 1 => zaxodi)
$tmp_pass = explode('|',$v);
$tmp_pass[1] = trim($tmp_pass[1]);
// proveryayem parol i skolko raz ego ispolzivali
if($tmp_pass[0] == $_POST['password'] && $tmp_pass[1]>0){
// esli vsyo v paryadke to umenshaem kolichestvo zaxodov na 1
$passwords[$k] = $tmp_pass[0].'|'.(--$tmp_pass[1]);
$doLogin = true;
break;
}
}
if($doLogin){
$_SESSION['auth']=true;
// obnavlyayem dannie v fayle
file_put_contents($path,implode("\r\n",$passwords));
// redidirektim stranichu na avtorizovannix
header('Location: '.$page);die;
}
$error = 'Vash parol ne podxodit';
}
else{
$error = 'Vvedite parol';
}
}
?>
<form method="post">
<?=isset($error)?$error.'<br />':null?>
Parol: <input name="password" type="password" /> <input type="submit" name="go" value="Vxod" />
</form>
Можна на етом скрипте исползоват база данных вместо "passwords.txt".
<?php
session_start();
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
// esli vveli parol
$PassEntered = $_POST['password'];
if(isset($PassEntered) && ! empty($PassEntered)){
$sql="SELECT * FROM table WHERE password = '".$PassEntered."'";
$result=mysql_query($sql) or die("Ошибка запроса: " . mysql_error());
if($row=mysql_fetch_array($result)){
$sql="UPDATE table SET exists_count = exists_count + 1 WHERE password = '".$PassEntered."'";
$result=mysql_query($sql) or die("Ошибка запроса: " . mysql_error());
$_SESSION['auth']=true;
header('Location: '.$page);die;
}
else{
$error = 'Vvedite parol';
}
}
}
?>
<form method="post">
<?=isset($error)?$error.'<br />':null?>
Parol: <input name="password" type="password" /> <input type="submit" name="go" value="Vxod" />
</form>
$sql="SELECT * FROM table WHERE password = '".$PassEntered."'";
$sql="SELECT * FROM table WHERE password = '$PassEntered'";
[COLOR=#000000][COLOR=#0000BB]<?php
session_start[/COLOR][COLOR=#007700]();
if([/COLOR][COLOR=#0000BB]strtoupper[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$_SERVER[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'REQUEST_METHOD'[/COLOR][COLOR=#007700]])==[/COLOR][COLOR=#DD0000]'POST'[/COLOR][COLOR=#007700]){
[/COLOR][COLOR=#FF8000]// esli vveli parol
[/COLOR][COLOR=#0000BB]$PassEntered [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'password'[/COLOR][COLOR=#007700]];
if(isset([/COLOR][COLOR=#0000BB]$PassEntered[/COLOR][COLOR=#007700]) && ! empty([/COLOR][COLOR=#0000BB]$PassEntered[/COLOR][COLOR=#007700])){
[/COLOR][COLOR=#0000BB]$sql[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"SELECT [/COLOR][/COLOR]`exists_count[COLOR=#000000][COLOR=#DD0000]` FROM `table` WHERE `password` = '"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$PassEntered[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]"'"[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]$result[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$sql[/COLOR][COLOR=#007700]) or die([/COLOR][COLOR=#DD0000]"Ошибка запроса: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000BB]mysql_error[/COLOR][COLOR=#007700]());
if([/COLOR][COLOR=#0000BB]$row[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]mysql_fetch_array[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$result[/COLOR][COLOR=#007700])){
if [/COLOR][/COLOR][COLOR=#000000][COLOR=#DD0000]($row[[/COLOR][/COLOR]'exists_count'[COLOR=#000000][COLOR=#DD0000]][/COLOR][/COLOR]> 0) {
[COLOR=#000000][COLOR=#007700] [/COLOR][COLOR=#0000BB]$sql[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"UPDATE `table` SET `exists_count` = `exists_count` - 1 WHERE `password` = '"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$PassEntered[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]"'"[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]$result[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$sql[/COLOR][COLOR=#007700]) or die([/COLOR][COLOR=#DD0000]"Ошибка запроса: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000BB]mysql_error[/COLOR][COLOR=#007700]());
[/COLOR][COLOR=#0000BB]$_SESSION[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'auth'[/COLOR][COLOR=#007700]]=[/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]header[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]'Location: '[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$page[/COLOR][COLOR=#007700]);die;
}
}
else{
[/COLOR][COLOR=#0000BB]$error [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]'Vvedite parol'[/COLOR][COLOR=#007700];
}
}
}
[/COLOR][COLOR=#0000BB]?>
[/COLOR] <form method="post">
[COLOR=#0000BB]<?=[/COLOR][COLOR=#007700]isset([/COLOR][COLOR=#0000BB]$error[/COLOR][COLOR=#007700])?[/COLOR][COLOR=#0000BB]$error[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]'<br />'[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]null?>
[/COLOR] Parol: <input name="password" type="password" /> <input type="submit" name="go" value="Vxod" />
</form>[/COLOR]
<?php
session_start();
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
// esli vveli parol
$PassEntered = $_POST['password'];
if(isset($PassEntered) && ! empty($PassEntered)){
$sql="SELECT `exists_count` FROM `table` WHERE `password` = '".$PassEntered."'";
$result=mysql_query($sql) or die("Ошибка запроса: " . mysql_error());
if($row=mysql_fetch_array($result)){
if ($row['exists_count']< 5) {//где 5 это то количество раз которое дается юзверу.
$sql="UPDATE `table` SET `exists_count` = `exists_count` + 1 WHERE `password` = '".$PassEntered."'";
$result=mysql_query($sql) or die("Ошибка запроса: " . mysql_error());
$_SESSION['auth']=true;
header('Location: '.$page);die;
}else{$error="Вы исчерпали количество попыток";}
}
else{
$error = 'Vvedite parol';
}
}
}
?>
<form method="post">
<?=isset($error)?$error.'<br />':null?>
Parol: <input name="password" type="password" /> <input type="submit" name="go" value="Vxod" />
</form>