我有下面的PHP工作因localhost apache服务器(WAMP服务器)而异,但是当我把它放在网上有任何原因或错误它不能完成它的工作!请需要一个答案,虽然我会更改我的托管服务器,我不喜欢他们的服务,因为有许多功能被禁用。 (更新:我有一个“html代码”,这是该代码应该登录的配置文件。配置文件html是在php之后。这个php有问题显示死信息,即使用户和密码是正确。这个问题只在在线服务器上)
<?php
function password($username='noneuser') {
$tegjitha=file_get_contents("pasetkkadmin.txt");
$infot=preg_split('/'.PHP_EOL.'/',$tegjitha,-1,PREG_SPLIT_NO_EMPTY);
$final=null;
foreach ($infot as $info) {
$pos=preg_split('/:/',$info,-1,PREG_SPLIT_NO_EMPTY);
if ($pos[0]==$username){
$final=$pos[1];
}
}
return $final;
}
function isuser($input) {
$tegjitha=file_get_contents("pasetkkadmin.txt");
$infot=preg_split('/'.PHP_EOL.'/',$tegjitha,-1,PREG_SPLIT_NO_EMPTY);
$rezultati=false;
foreach ($infot as $info) {
$pos=preg_split('/:/',$info,-1,PREG_SPLIT_NO_EMPTY);
if ($input==md5('albipatozi'.$pos[0])) { $rezultati=true;}
}
return $rezultati;
}
if ( isset($_GET['dil']) ) {
setcookie('mbajmend','',time()-3600*24*365);
die('<meta http-equiv="REFRESH" content="0;url=index.php" />');
}
if ( isset($_POST['username']) && !empty($_POST['username']) ) {
$username=$_POST['username'];
} else {$username=null;}
if ( isset($_POST['pass']) && !empty($_POST['pass']) ) {
$passwd=sha1('justastring£"'.$_POST['pass']);
} else {$passwd='none';}
if ( isset($_POST['mbajmend']) && !empty($_POST['mbajmend']) ) {
$koha=time()+3600*24*60;
} else {$koha=null;}
$duhet=password($username);
if ($passwd==$duhet) {
setcookie('mbajmend',md5('sdaggs'.$username),$koha);
} elseif (!( isset($_COOKIE['mbajmend']) && isuser($_COOKIE['mbajmend']) )) {
setcookie('mbajmend','',time()-3600*24*360);
if (isset($_SERVER['HTTP_REFERER']) && (preg_match('/[index.php]$/',$_SERVER['HTTP_REFERER']) || preg_match('/[admin\/]$/',$_SERVER['HTTP_REFERER'])) ) { $textshtes='Perdoruesi ose Fjalkalimi jane Gabim ! '; }
else { $textshtes='Ju Lutem Vendosni Te Dhenat Thuaja'; }
die('<body style="background:lightgrey;">
<div id="trupi" style="position:relative; background:#999999; margin:auto; width:360px; margin-top:160px; height:260px;">
<form id="form1" name="form1" method="post" action="" style="position:absolute; margin:56px; text-shadow:black; font-style:oblique; color:darkred">
<label><strong>Perdoruesi: </strong>
<input type="text" name="username" />
</label>
<p>
<label><strong>Fjalekalimi:</strong>
<input type="password" name="pass" />
</label>
</p>
<p>
<label>
<input type="checkbox" name="checkbox" value="checkbox" />
Me Mbaj Mend te Ky Kompjuter</label>
</p>
<p>
<label style="float:right;">
<input type="submit" value="Identifikohu" />
</label>
</p>
</form><p style="text-align:center; color:darkred; background:grey"> <b>'.$textshtes.'</b></p>
</div>
</body>
');
}
?>
<html>
this should be shown when user and passord is correct :)
</html>
我试图一步一步地回应每一个变量,一切都很好,但事实上它不起作用
passdords txt文件是pasetkkadmin.txt- 它的模型是
超级管理员:a3b22231bbe113a948a349af09cea4e4129584de
第一行是:superadmin,密码是:albi 这个数据应该有用,但它没有
答案 0 :(得分:2)
本地使用WAMP(它是Windows),但在线服务器通常在Linux系统上运行。
区别在于,PHP_EOL在Windows(CR + LF)和Linux(LF)上具有不同的值,因此当您在Windows上创建并上传它时,您的pasetkkadmin.txt将无法像使用的PHP代码那样工作到linux服务器上。
示例pasetkkadmin.txt
foo:bar[CR][LF]
foo2:bar2
在Windows上,由PHP_EOL([CR][LF]
)拆分,它将是:
array(0=>foo:bar,
1=>foo2:bar2)
在linux上,由PHP_EOL([LF]
)拆分,它将是:
array(0=>foo:bar[CR],
1=>foo2:bar2)