2016-04-13 33 views
1

ルールに違反するアカウントを禁止するための禁止機能を備えたCMSを作成しました。奇妙な問題。

しかし、誰かを禁止すると、私はユーザーだけでなく自分自身も禁止します。

You have been banned. 

、あなたが禁止されているユーザーなら、あなたは

Your account has been disabled and cannot be used anymore. 
You find the details below. 

Date: 13-04-2016 16:06:27 
Reason: Violation of the EULA. 

If you have questions, feel free to contact the administrator. 

を得るだろうそして今、それは不気味なってきた:あなたが管理者ならunstyledテキストにのみ表示されます上のテキストは私のスクリプトで唯一のテキストです。 「あなたは禁止されています」というのは古いアルファ版のテキストですが、まだまだ迫っています。 レコードのために、私はこのテキストをずっと前に削除しました。私はすべてのファイル、すべてのインクルード、すべてのデータベースを検索しました。

私は「あなたは禁止されました」という文章の検索を行っています。いいえ、何も見つかりませんでした!私もXAMPPとデータベースを再起動しました。また、ログアウトして再度ログインしました。どちらもうまくいきませんでした。


問題の詳細。

  • テキストは、何のスタイルや何でも完全にはブランコではありません。

  • のみadmin.php

  • に表示され、ユーザーが禁止されている場合に表示されます - 私はダブル禁止スクリプトをチェックして、すべてがOK実行されています。クエリは、テキストのみadmin.phpに表示されますので、我々はadmin.phpを見てみる必要がある


など、右のデータベースを指しています。これは520行のファイルです。

禁止スクリプトが上にある:

$sql = "SELECT * FROM bans WHERE user_name='".$_SESSION['user_name']."'"; 
$result = $conn->query($sql); 
if(mysqli_num_rows($result) != 0) { 
    if ($result->num_rows > 0) { 
     while($row = $result->fetch_assoc()) { 
      $blocked = " 
      <div class='modal-inner' style='width:500px'> 
      <h2>Account disabled</h2> 
      Your account has been disabled and cannot be used anymore.<br />You find the details below.<br /><br /> 
      Processed: ". $row["user_dateofban"] ."<br /> 
      Reason: ". $row["reason"] ."<br /><br /> 
      If you have questions, feel free to contact the administrator. 
      </div> 
      "; 
      exit($blocked); 
     } 
    } 
} 

は、誰かが私を助けることを願って、それは超イライラします!


admin.php

top.php & bot.php両方は単なるHTMLファイルです。いいえ、PHP。

<?php 
include("loginsys.php"); 

if ($login->isUserLoggedIn() == true) { 

//ban config 
$sql = "SELECT * FROM bans WHERE user_name='".$_SESSION['user_name']."'"; 
$result = $conn->query($sql); 
if(mysqli_num_rows($result) != 0) { 
    if ($result->num_rows > 0) { 
     while($row = $result->fetch_assoc()) { 
      $blocked = " 
      <div class='modal-inner' style='width:500px'> 
      <h2>Account disabled</h2> 
      Your account has been disabled and cannot be used anymore.<br />You find the details below.<br /><br /> 
      Processed: ". $row["user_dateofban"] ."<br /> 
      Reason: ". $row["reason"] ."<br /><br /> 
      If you have questions, feel free to contact the administrator. 
      </div> 
      "; 
      exit($blocked); 
     } 
    } 
} 

    if(isset($_SESSION['user_rank']) && $_SESSION['user_rank'] == "3") { 
if(isset($_GET["page"]) && $_GET["page"] == "customization") { 
    include("assets/top.php"); 

      if(isset($_POST['editcustom'])) { 
       $sql = "UPDATE customization SET iam='".$_POST["iam"]."', iam2='".$_POST["iam2"]."', about='".$_POST["about"]."', about2='".$_POST["about2"]."', about3='".$_POST["about3"]."', recentwork='".$_POST["recentwork"]."', recentwork2='".$_POST["recentwork2"]."', getintouch='".$_POST["getintouch"]."', getintouch2='".$_POST["getintouch2"]."', address='".$_POST["address"]."', phone='".$_POST["phone"]."', email='".$_POST["email"]."', sendbutton='".$_POST["sendbutton"]."', copyright='".$_POST["copyright"]."'"; 
       $updateuser = $conn->query($sql); 
       if ($updateuser) { 
        echo '<div class="alert alert-success">Settings saved.</div>'; 
       } else { 
        echo '<div class="alert alert-danger">Something went wrong executing the query. Try again.</div>'; 
       } 
      } 

    $sql = "SELECT * FROM customization LIMIT 1"; 
    $result = $conn->query($sql); 
    if ($result->num_rows > 0) { 
     while($row = $result->fetch_assoc()) { 
      ?> 
<h1>Header</h1> 
<form method="post"> 
<table> 
    <tr> 
     <td>Header 1</td> 
     <td><input type="text" value="<?php echo $row["iam"]; ?>" name="iam" /> 
    </tr> 
    <tr> 
     <td>Header 2</td> 
     <td><input type="text" value="<?php echo $row["iam2"]; ?>" name="iam2" /> 
    </tr> 
</table> 
<h1>About</h1> 
<table> 
    <tr> 
     <td>About heading</td> 
     <td><input type="text" value="<?php echo $row["about"]; ?>" name="about" /> 
    </tr> 
    <tr> 
     <td>About text</td> 
     <td><input type="text" value="<?php echo $row["about2"]; ?>" name="about2" /> 
    </tr> 
    <tr> 
     <td>About button</td> 
     <td><input type="text" value="<?php echo $row["about3"]; ?>" name="about3" /> 
    </tr> 
</table> 
<h1>Recent Work</h1> 
<table> 
    <tr> 
     <td>Recent Work heading</td> 
     <td><input type="text" value="<?php echo $row["recentwork"]; ?>" name="recentwork" /> 
    </tr> 
    <tr> 
     <td>Recent Work button</td> 
     <td><input type="text" value="<?php echo $row["recentwork2"]; ?>" name="recentwork2" /> 
    </tr> 
</table> 
<h1>Contact</h1> 
<table> 
    <tr> 
     <td>Heading</td> 
     <td><input type="text" value="<?php echo $row["getintouch"]; ?>" name="getintouch" /> 
    </tr> 
    <tr> 
     <td>Text</td> 
     <td><input type="text" value="<?php echo $row["getintouch2"]; ?>" name="getintouch2" /> 
    </tr> 
    <tr> 
     <td>Address</td> 
     <td><input type="text" value="<?php echo $row["address"]; ?>" name="address" /> 
    </tr> 
    <tr> 
     <td>Phone</td> 
     <td><input type="text" value="<?php echo $row["phone"]; ?>" name="phone" /> 
    </tr> 
    <tr> 
     <td>Email</td> 
     <td><input type="text" value="<?php echo $row["email"]; ?>" name="email" /> 
    </tr> 
    <tr> 
     <td>Button text</td> 
     <td><input type="text" value="<?php echo $row["sendbutton"]; ?>" name="sendbutton" /> 
    </tr> 
</table> 
<h1>Copyright</h1> 
<table> 
    <tr> 
     <td>Copyright</td> 
     <td><input type="text" value="<?php echo $row["copyright"]; ?>" name="copyright" /> 
    </tr> 
</table> 
<input type="submit" value="Save changes" name="editcustom" /> 
</form> 
      <?php   
     } 
    } else { 
     echo "No customization yet."; 
    } 

    include("assets/bot.php"); 
} else { 
?> 
<iframe src="admin.php?page=dashboard" style="width:700px;height:500px;"> 
    Your browser doesn't support iframes. Please upgrade. 
</iframe> 
<?php 
} 
    } else { 
     echo "Error: No permissions"; 
    } 
} else { 
    echo "Error: Not signed in"; 
} 
?> 
+0

ファイルを単に「hello」などに変更すると、「あなたは禁止されました。」というメッセージが表示されます。また、準備されたステートメントを使用する必要があります。 – chris85

+0

@ chris85はい、まだファイル名を変更した後にエラーが発生します –

+0

新しく名前が付けられたファイルをロードして同じ出力を得ていない限り、名前、内容... – chris85

答えて

0

これは、おそらくエラーが蒸発したり、より容易に識別されています、それを通してあなたのコード、改善するための小さなガイドです:

順不同:

  • 実行をError Logging on your PHP !!!真剣に。学ぶ最初の基礎の一つ。あなたのコードを意味しますが、HTML5で書くべきである

  • は正しい構文はそう<br/><br>になり、タグの/>決算は、スラッシュを必要としない必要があります。あなたのHTML内

  • 使用正しい属性は、あなたの<form>enctypeactionacceptが最小として属性を持っている必要があります。同様に、他のHTMLタグは、関連するより正確な属性を持つことで可能です。

    • iframeの使用を中止します。現在、XSSで深刻な問題があるため、広くサポートされていません。代わりに、CSSやPHPを使用してください。
  • select *を試してみて、代わりに選択する必要がある各MySQL列の名前を指定してください。それはもう少し長いですが、大規模なプロジェクトでは「umms」と「aahs」をたくさん保存します。

  • グッドポイント:あなたが正しくPHP変数の配置をエスケープしていて、オブジェクト指向DB接続を使用している、しかしあなたのデータベースクエリを設定する方法は、非常に安全ではないと優先して改善する必要があります。

    • 変数をクエリ文字列に直接入れるのではなく、クエリに直接バインドする必要があります。 please research this with prejudice(接続方法によって異なる方法)あなたは本当に、本当に合理的に可能な限りあなたの入力/ POSTデータをクリーニングする必要があり、上記の点からの大手

    • は、これまで任意のユーザー入力を信用したことがない、これまで$_POSTの値は何でもかまいません。フォームやテキストの入力から不要な/有害な文字を削除するには、REGEXクリーナーまたはPHPクリーニング機能を使用してください。

  • MySQLのコマンドとfeedback errors to your eyesを照会するための行を追加します。