0

私は以下のphpを持っていますが、ローカルホストの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:&nbsp;</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>

私はすべての変数を1つずつエコーしようとしましたが、機能しないという事実を除いてすべて問題ありません

passdordstxtファイルはpasetkkadmin.txtです-そのモデルは

superadmin:a3b22231bbe113a948a349af09cea4e4129584de

最初の行は:superadminで、パスワードは:albiですが、そのデータは機能するはずですが、機能しません

4

1 に答える 1

2

ローカルではWAMP(ウィンドウ)を使用しますが、オンラインでは通常、サーバーはLinuxシステムで実行されます。

違いは、PHP_EOLはWindows(CR + LF)とLinux(LF)で異なる値を持っているため、Windowsで作成してLinuxにアップロードするときに、使用したPHPコードでpasetkkadmin.txtが期待どおりに機能しないことです。 -サーバ。

例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)
于 2012-04-06T01:17:58.757 に答える