Datuve :: Forums :: Arhīvs :: skripts, kas nosūtīa POST datus, bez formas

Datuve

Mana Datuve

Reģistrācija | Noteikumi | Paroles atjaunošana



Forums

Ieskaties


Raksti

Lietotāji online

Lietotāji online: 63

Reģistrētie lietotāji online: 0

Viesi online: 63

Datuve.lv video
Top.LV

skripts, kas nosūtīa POST datus, bez formas

Ievietoja: Ivchikx @ 2006.10.25 23:03  

Vajag bez formas aizpildīšanas un submit pogas veidošanas aizpildīt un nosūtīt POST datus serverim. Mēģināju dažādus skriptus sākot ar:

<html>
<head>
<script type="text/javascript">
<!--
formSubmit()
{
  documents.forma.submit();
}
-->
</head>
<body>
<form action="/pidb/" method="post" name="forma">
<input type="hidden" name="data1" value="bla1" />
<input type="hidden" name="data2" value="bla2" />
</form>
<a href="#" onClick='formSubmit();'>POST the data :D</a>
</body>
</html>

līdz pat:

<?php
function sendToHost($host,$method,$path,$data,$useragent=0)
{
   // Supply a default method of GET if the one passed was empty
   if (empty($method)) {
       $method = 'GET';
   }
   $method = strtoupper($method);
   $fp = fsockopen($host, 80);
   if ($method == 'GET') {
       $path .= '?' . $data;
   }
   fputs($fp, "$method $path HTTP/1.1\r\n");
   fputs($fp, "Host: $host\r\n");
   fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
   fputs($fp, "Content-length: " . strlen($data) . "\r\n");
   if ($useragent) {
       fputs($fp, "User-Agent: MSIE\r\n");
   }
   fputs($fp, "Connection: close\r\n\r\n");
   if ($method == 'POST') {
       fputs($fp, $data);
   }

   while (!feof($fp)) {
       $buf .= fgets($fp,128);
   }
   fclose($fp);
   return $buf;
}

sendToHost('www.example.com', 'post', '/some_script.php', 'param=First+Param&second=Second+param');
?>

bet diemžēl bez veiksmīgiem rezultātiem... Varbūt ir kādas idejas kā to lietu izdarīt?

PS. Un, nē, šis nav mēģinājums taisīt kkādus web-hack vai tml...