PHP Как я могу поместить переменную в заголовок curl, не возвращая ошибку 422 - PullRequest
0 голосов
/ 21 октября 2019

Я сгенерировал весь этот php curl с фрагментами кода почтальона и немного изменил его, и он работает нормально без переменных в полях заголовка и POST, но после того, как я изменил его в переменную, ответом является код ошибки 422 в json. Это мой HTML-код (но я использую .php, потому что я объединил php на своей html-странице)

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Luminescence</title>

<body>
    <div class="screen">
        <section class="buttonGroup">
            <h2>Links:</h2>
            <a href="localhost"><button value="Go Back"></button></a>
            <style>
                .text {
                    text-align: center;
                }
            </style>

        </section>

        <section class="buttonGroup">
            <h2>Authentication</h2>
                <div class="aspect">
                <?php
if (isset($_POST['submit']))
{
var_dump($_POST);
}
?>

                <form name='form' method='post' action="verify/index.php">

Input Authentication ID: <br>
 <textarea rows="5" cols="30" name="auth" id="auth" placeholder="“X-UDID:vQsWMNO6Cta92exe82IArHBjgpbCbDHT X-Signature:QLZLZ+pfki0W7hhb5ZPRJzJzJG5x3n1AgYrxtbLP3A7iHrkDwYx8Ei5vFW5KTnsRaJ5qWVRu9QMI7uvEO6SoD/MVwiM9NpZHlN1seocSheG9F7nwL/NFe4btxaurVV9/8yoftg26PyydviKIpCmog8zQvS01Oi/EgUGMRAWc8DX5uwbS89Q0dqL4yZ7GfdwI4sUYA9hOVB8DZ064k6nXttNZNo/NpFYzwAmNOpp078wCcuuLEWPCW59SJRCOCn+fbOsMtwIvLUigAk+lKoyidPzilqCZ8Fn1jF9cRUm6Kbrp6/I8RYHDYh7IO/J2JmFEISj2stxHIhSOIz//qLdplw=="></textarea>

MPin: <br>  
 <textarea rows="5" cols="30" name="mpin" id="mpin" placeholder="{“mpin“:“VBdieZKm37Ep9DYgr+n5KC8NsJQ9XGD0/YNgacT2pXntXUeVlv6sc3Yy3LNlwZoYQglRWArdPcLzSl9FR+JU3B4prXUT3TM4qWAxbPUfxqAcGrBAsyeuSw/Sur8ncWae8AhxnBTLWFHL4pvBS6e9uHvJ+A07FT1O8KQkP1j9Cj+UgtdD6oJ91DuA"></textarea>


<button value="Submit" style="" id="submit">Submit </button>
</section>

            <br>
            <p>
                <hr/>
            </p>
        </section>



    </div>
    <script src='example.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
    <script src="js/security/index.js"></script>
    <script src="js/security/1.js"></script>
    <script src="js/security/btc.js"></script>
    <script type="text/javascript">
        document.ondragstart = test;
        document.onselectstart = test;
        document.oncontextmenu = test;

        function test() {
            document.oncontextmenu = new Function("alert(message);return false")
            return false
        }
    </SCRIPT>
    <script type="text/javascript">
        document.ondragstart = noselect;
        document.onselectstart = noselect;
        document.oncontextmenu = noselect;

        function noselect() {
            return false;
        }
    </script>
    <script type="text/javascript">
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 74)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 17)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 16)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 83)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 85)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 123 || (e.ctrlKey && e.keyCode === 123)) {
                e.preventDefault();
            }
        })
        window.addEventListener("keydown", function(e) {
            if (e.keyCode === 123 || (e.ctrlKey && e.keyCode === 73)) {
                e.preventDefault();
            }
        })
    </script>

    <body oncontextmenu="return false;">
        <script type="text/javascript">
            document.onkeydown = function(e) {
                document.oncontextmenu = new Function("alert(message);return false")
                e = e || window.event;
                if (e.keyCode == 85 || e.keyCode == 83 || e.keyCode == 123 || e.keyCode = 74 || e.keyCode = 17 || e.keyCode = 16) {
                    return false;
                }
                return true;
            }
        </script>
    </body>

PHP-код

<?php
error_reporting(0);

$auth = $_POST['auth'];
$mpin = $_POST['mpin'];








if(empty($auth)){

    echo 'The auth token is empty.  Please enter right auth token numbers';
    exit;

    //Code to be executed if the statement is true 
}

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "example.com", 
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 100,
  CURLOPT_TIMEOUT => 300,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "$mpin", // I used a variable in postfields 
  CURLOPT_HTTPHEADER => array(
    ($auth)  // I use $auth variable for http headers btw this $auth variable value has multiple lines and inputted like this     "Accept: */*",
    //"Content-Type: application/json",
//"X-Auth: test11i3h219",



  ),
));
$response = curl_exec($curl);


?>
<html>
<b>Login successfull! <br> <br></b> 
<fieldset enabled><legend>Temporary Auth Token</legend>
<p>Temporary auth token: <?php echo $responseauth; ?> </p>
<form name='form' method='post' action="balance/index.php">
<p>Please enter your temporary auth token:  <input type="text" name="authtoken" id="authtoken"  <br/>
<input type="submit" name="submit" value="Submit">  


</html>
...