So I have a TXT file that is disjointed. How do I parse it so that it can use string matches to figure out data?
From the sample below I want:
timestamp =
src=
dst=
user=
agent=
request:
url=
The value should be NULL if it was not found on the line. I tried using preg_match() but it does not execute the entire file. No outputs.
Thank you.
Sample.txt
2016-02-24 13:54:23 Local0.Info 172.16.120.4 1 1456311263.806656820
ASD_MX600 flows src=108.177.15.189 dst=213.130.115.218 protocol=udp
sport=443 dport=61907 pattern: 1 all
2016-02-24 13:54:23 Local0.Info 172.16.120.4 1 1456311263.500015263
ASD_MX600 urls src=172.16.41.15:62490 dst=144.76.76.148:80
mac=00:1B:0D:63:84:00
user=CN=Smith\John,OU=S-HS,OU=SAcc,DC=abc,DC=org,DC=ab
agent='Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101
seb/2.0 SEBKEY' request: GET
http://something.com/theme/image.php/clean/page/1455532301/icon
2016-02-24 14:29:14 Local0.Info 172.16.120.4 1 1456313354.489880924
ASD_MX600 urls src=172.16.41.143:57256 dst=74.125.232.155:443
mac=00:1C:B0:10:A8:00 request: UNKNOWN
https://4780928.fls.doubleclick.net/...
Also, I had asked a similar question here -> Complex parsing a text file in PHP - but there was no room to ask an additional extension to the same so posting a new question. Thank you.
SK
PS: Code I have tried but does not work.
EXAMPLE 1
$myfile = fopen("C:\Documents and Settings\Administrator\Desktop\LogCatcher Script\SyslogCatchAll-2016-02-25.txt", "r") or die("Unable to open file!");
// Output one line until end-of-file
while(!feof($myfile)) {
$line = fgets($myfile) . "<br>";// you can do the explode and assignment here.
//example
$row_data = explode(" ", $line); //FIRST BLAST
$timestamp = $row_data[0] ; //Pick up the timestamp for Column 1
$timestamp;
//SECOND BLAST
$remainingData = explode(" ",$row_data[3]); //chop it off
$src = $remainingData[4];
$src = ltrim($src, "src=");
$dst= $remainingData[5];
$dst = ltrim($dst, "dst=");
$usr = $remainingData[7];
if (preg_match('/user=/',$usr))
{
$usr = ltrim($usr, "user=");
}
else {
$usr = "No User Found";
}
... This is where it starts to spasm out since not every line has"user="...
EXAMPLE 2
Another way I tried using another user's code.
<?php
$rows = explode("\n", file_get_contents('sample.txt'));
$result = array();
foreach ($rows as $row) {
if (trim($row) == "") {
continue;
}
$timeMatches = array();
$reTime = "/([0-9-]* [0-9:]*) /";
preg_match($reTime, $row, $timeMatches);
$re = "/src=(.*) dst=(.*) mac=(.*) user=(.*) agent=(.*) request: (.*) (.*)/";
$matches = array();
preg_match($re, $row, $matches);
$result[] = array('time' => $timeMatches[1], 'src' => $matches[1]
, 'dst' => $matches[2], 'mac' => $matches[3]
, 'user' => $matches[4], 'agent' => $matches[5]
, 'method' => $matches[6], 'url' => $matches[7]);
}
var_dump($result);
?>
Runs and displays nothing. Just ends.
Related
I'm trying to parse a CSV file.
<?php
$url = 'https://flux.netaffiliation.com/feed.php?maff=3E9867FCP3CB0566CA125F7935102835L51118FV4';
$csv = array_map('str_getcsv', file($url), ["|"]);
echo '<pre>'; echo print_r ($csv); echo '</pre>';
?>
Here is a sample of what i get :
[1] => Array
(
[0] => 5016488133494|Ary And The Secret Of Seasons PS4|100001|9.99||Jeu > PS4|https://xht.micromania.fr/?P3CB0566CA125FS1UD41282b0253295V4|https://edge.disstg.commercecloud.salesforce.com/dw/image/v2/BCRB_STG/on/demandware.static/-/Sites-masterCatalog_Micromania/default/dw65159733/images/high-res/100001.jpg?sw=1000|JUST FOR GAMES|JUST FOR GAMES|Explorez le monde merveilleux de Valdi !||new|4.99|||||||2
)
Apparently, the parser doesn't take every "|" into account.
If you inspect your output, you'll notice that the split works on your first row. This is because (oddly) PHP only uses the extra args once per iteration, so you'd need to specify them for each row:
array_map('str_getcsv', file($url), ["|", "|", "|", ...]);
... which makes not a whole lot of sense to me, as you don't know how many rows you have. I'd just call it explicitly like this instead:
$csv = array_map(fn($line) => str_getcsv($line, '|'), file($file));
Or the older style:
$csv = array_map(function($line) { return str_getcsv($line, '|'); }, file($file));
Here's a script I suggest. It assembles csvArray as result, I hope you'll handle further:
<?php
$url='https://flux.netaffiliation.com/feed.php?maff=3E9867FCP3CB0566CA125F7935102835L51118FV4';
$file_name = 'csvToParse.csv';
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
file_put_contents($file_name, file_get_contents($url, false,
stream_context_create($arrContextOptions)));
$fopenCSVHandle=fopen($file_name, 'r');
$csvArray=array();
if ($fopenCSVHandle !== false){
while (($data = fgetcsv($fopenCSVHandle, 1000, "|")) !== FALSE) {
//echo('<br />single row $data=<br />');
//print_r($data);
$csvArray[]=$data;
}
//echo('<br />We got this $data from CSV:<br />');
//print_r($csvArray);
}
?>
I'll try to be little more clear in my text than in title.
I've build a php page that scrape another internet site and store results in array, than in database (the is repeated for 155 times and these multiple calls are based on another array).
In order to obtain faster result I've implemented another php page that using fopen() call "scraping page" multiple times (about 5 five times) dividing the original array in 5 parts.
Everything works everytime I call the scraping page iterating for the 155 times, one by one. But when I use fopen() it starts returning me (sometimes) this error:
Fatal error: Call to a member function getElementsByTagName() on a non-object
So I guess it should be a metter of "multiprocessing" so If I activate scrape too many time togheter, it returns me error.
So I've tried to call "scraping page" 3 or 2 times togheter than giving a rest to the script (sleep(1)) and than call other 2/3 times the scraping page.
In this case too, sometime I obtain all the script working perfectly, other time I have always the same error again.
This is part of my code.
FROM SCRAPING PAGE (scrape script):
function taxExtract($countryList,$urlTax,$countryID,$countryName,$countryTag) {
echo $urlTax;
$optionsTax = Array(
CURLOPT_RETURNTRANSFER => TRUE, // Setting cURL's option to return the webpage data
CURLOPT_FOLLOWLOCATION => TRUE, // Setting cURL to follow 'location' HTTP headers
CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers
CURLOPT_CONNECTTIMEOUT => 300, // Setting the amount of time (in seconds) before the request times out
CURLOPT_TIMEOUT => 300, // Setting the maximum amount of time for cURL to execute queries
CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow
CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8", // Setting the useragent
CURLOPT_URL => $urlTax, // Setting cURL's URL option with the $url variable passed into the function
);
$TaxCurl = curl_init($urlTax);
curl_setopt_array($TaxCurl, $optionsTax); // Setting cURL's options using the previously assigned array data in $options
$resultTaxCurl = curl_exec($TaxCurl);
$htmlTax = $resultTaxCurl;
$domTax = new DOMDocument();
$htmlTax = $domTax->loadHTML($htmlTax);
$domTax->preserveWhiteSpace = false;
$taxFullArr = array();
$taxFullArr[] = array (
'countryID' => $countryID,
'countryName' => $countryName,
'countryTag' => $countryTag);
$alltaxtables = $domTax->getElementsByTagName('table');
if($alltaxtables->length > 1) { // GET ONLY THE FIRST TABLE IF THERE ARE MORE THAN 1
$taxtable = $alltaxtables->item(2);
}
$taxrows = $taxtable->getElementsByTagName("tr");
foreach($taxrows as $taxrow) {
$taxcols = $taxrow->getElementsByTagName('td');
if (($taxcols->item(0)->nodeValue != "Resource") and ($taxcols->item(1)->nodeValue != "VAT") and ($taxcols->item(2)->nodeValue != "Import Tax") and ($taxcols->item(3)->nodeValue != "Income Tax")) {
echo "this is Country ID: ".$countryID." - ";
echo "this is Country Name: ".$countryName." - ";
echo "this is Country Tag: ".$countryTag." - ";
echo "this is Resource: ".$taxRes = $taxcols->item(0)->nodeValue." - ";
echo "this is Vat tax: ".trim($taxIva = $taxcols->item(1)->nodeValue)." - ";
echo "this is Import tax: ".trim($taxImport = $taxcols->item(2)->nodeValue)." - ";
echo "this is Work tax: ".trim($taxWork = $taxcols->item(3)->nodeValue)." - ";
$taxList[] = array (
'taxRes' => $taxRes,
'taxVat' => $taxIva,
'taxImport' => $taxImport,
'taxIncome' => $taxWork
);
}}
$taxFullArr[] = $taxList;
};
ERROR IS ALWAYS RELATED TO THIS PART OF THE CODE:
$taxrows = $taxtable->getElementsByTagName("tr");
FROM MULTY PROCESS PAGE (multiprocess script):
if (($totC > 150) && ($totC <= 200)) {
echo "<br>do something it's between 151-200";
//> 150 - 5 array
$part1 = array();
$part2 = array();
$part3 = array();
$part4 = array();
$part5 = array();
list($part1, $part2, $part3, $part4, $part5) = array_chunk($countryList, ceil(count($countryList) / 5));
echo "<br><br>ARRAY 1: <br>";
print_r($part1);
echo "<br>total count for part1 = ".count($part1);
$data1 = extractTax($server,$part1); sleep(1);
echo "<br><br>ARRAY 2: <br>";
print_r($part2);
echo "<br>total count for part2 = ".count($part2);
$data2 = extractTax($server,$part2); sleep(1);
resp($data1);
echo_flush();
resp($data2);
echo_flush();
echo "<br><br>ARRAY 3: <br>";
print_r($part3);
echo "<br>total count for part3 = ".count($part3);
$data3 = extractTax($server,$part3); sleep(1);
echo "<br><br>ARRAY 4: <br>";
print_r($part4);
echo "<br>total count for part4 = ".count($part4);
$data4 = extractTax($server,$part4); sleep(1);
resp($data3);
echo_flush();
resp($data4);
echo_flush();
echo "<br><br>ARRAY 5: <br>";
print_r($part5);
echo "<br>total count for part5 = ".count($part5);
$data5 = extractTax($server,$part5); sleep(1);
resp($data5);
echo_flush();
}
function extractTax($server,$cList) {
echo "<br><br><i>***** Country List Updater ******</i></p><br>";
echo "<i>***** Server $server *****</i><br>";
echo "<br><i><p class='start'>** Launched process $server **</i></p>";
$cLists = base64_encode(serialize($cList));
$url = "[...url...]/cData.php?server=".$server."&cList=".$cLists;
$child = fopen($url, 'r');
if ($child == TRUE) {
echo "<br>Worked! Move on...<br>";
} else {
$i = 0;
while ($child == FALSE && $i<=3) {
echo "There's problem with fopen(), waiting for next try<br>";
sleep(60);
$i++;
echo "<br>Attempt $i/3 (after the 3rd, I'll move on)<br>";
$child = fopen($url, 'r');
}
if ($child == TRUE) {
echo "<br>Finally worked! Moving on...<br>";
}
if ($child == FALSE && $i == 3) {
echo "After 3 usuccessful attempts, I'm moving on...<br>";
}
} return $child;
};
function resp($data) {
// get response from child (if any) as soon at it's ready:
$response = stream_get_contents($data);
echo "<br><b><p class='buytitles'>+++This is RESPONSE from process+++</b></p>";
echo "<br>".$response;
echo "<br><b><p class='buyendtitles'>---RESPONSE END process ---</b><br></p>";
fclose($data);
echo_flush();
}
Do you know why does it happens? Do you know how could I correct it?
Pls ask for further explanation, sorry if I haven't been enough clear.
Alberto
if (!taxtable) throw new SomeException();
Put your scraping logic in a function then try that function and check your errors that way.
Can't really help you scrape a webpage that I don't know the data on. Can you give example data from your curl request and a sample table?
I have probably spent all day trying to figure this out. I have read multiple questions here on stack and also have been reading articles and checking on documentation, but I can't seem to figure out why this batch of code just produces a null output. Am I missing brackets, calling something wrong, ect?
<?php
$url = "http://api.openweathermap.org/data/2.5/weather?id=4879890&units=imperial";
$str = file_get_contents($url);
$json = json_decode($str);
$temp = $json['main']['temp_min'];
$content = $temp;
$array = array(
"content" => $content,
refresh_requency => 30
);
echo json_encode($array);
?>
Again what I'm asking is can someone point out to me or tell me what I'm doing wrong. Is it my server that's just not handling the data correctly? That could be a possibility.
One other thing I've tried is to just print out $temp and/or the other variable like $str. When I do that though they don't even show up so that's what I think my problem is just not sure how to fix it.
Update
I've come to the conclusion that it's my web hosting service. As if I add var_dump($json) I get a null output null output.
Also to confirm that its my webhost if I run error_reporting(E_ALL); ini_set('display_errors', 1); it points to the file php.ini not allowing outgoing connections. I edited that same file on my local home server(raspberry pi) ran the same file and it works fine.
Below is the working solution for your above code:
<?php
$url = "http://api.openweathermap.org/data/2.5/weather?id=4879890&units=imperial";
$str = file_get_contents($url);
$json = json_decode($str, true);
$temp = $json['main']['temp_min'];
$content = $temp;
$array = array(
"content" => $content,
"refresh_requency" => 30
);
echo json_encode($array);
?>
When I executed your code, I found 2 problem into your code snippet:
1) You were trying to use object of type stdClass as array.
Solution:
<?php
$url = "http://api.openweathermap.org/data/2.5/weather?id=4879890&units=imperial";
$str = file_get_contents($url);
$json = json_decode($str);
$temp = $json->main->temp_min;
$content = $temp;
$array = array(
"content" => $content,
"refresh_requency" => 30
);
echo json_encode($array);
?>
2) You did not put array key into quotes:
$array = array(
"content" => $content,
refresh_requency => 30
);
It should be :
$array = array(
"content" => $content,
"refresh_requency" => 30
);
Access $temp like this
$temp = $json->main->temp_min;
you will get the desired output.
Also, you need to allow allow_url_fopen in your php.ini config file. Some hosts disallow it for security reasons
$json = json_decode($str, true);
You need second argument to convert json string into associative array instead of the object. And you are trying to use array ($json['main']['temp_min']), not object. Also
$array = array(
"content" => $content,
"refresh_requency" => 30
);
The code looks like
<?php
$url = "http://api.openweathermap.org/data/2.5/weather?id=4879890&units=imperial";
$str = file_get_contents($url);
$json = json_decode($str, true);
$content = $json['main']['temp_min'];
$array = array(
"content" => $content,
"refresh_requency" => 30
);
echo json_encode($array);
And result is http://codepad.viper-7.com/euBNAk :
{"content":44.6,"refresh_requency":30}
The second parameter of json_decode() is assoc (associative). By default it is 0. When it is 0 (default) the json_decode() will return an object, not an array. That's why you are unable to access temp_min by using $json['main']['temp_min'];
However If you use with the value 1 as second parameter, the function will return an array. Parameter 1 means setting associative to 1 (true). So use $json = json_decode($str, true); instead of $json = json_decode($str);. You will be able to access with $json['main']['temp_min']; now.
Also you forgot double quote on line 13 (refresh_requency). Goodluck.
<?php
$url = "http://api.openweathermap.org/data/2.5/weather?id=4879890&units=imperial";
$str = file_get_contents($url);
$json = json_decode($str, true);
$temp = $json['main']['temp_min'];
$content = $temp;
$array = array(
"content" => $content,
"refresh_requency" => 30
);
echo json_encode($array);
Just want help
I change your code like this and that be correctly
<?php
$url = "http://api.openweathermap.org/data/2.5/weather?id=4879890&units=imperial";
$str = file_get_contents($url);
$json = json_decode($str, TRUE); // Wrong here
$temp = $json['main']['temp_min'];
$content = $temp;
$array = array(
"content" => $content,
"refresh_requency" => 30 // And wrong here, it's must string
);
echo json_encode($array);
?>
More information about json decode in php to array or object http://php.net/manual/en/function.json-decode.php
I am using the following code to pull a CSV file from a website that i do not have control over. and many of times i get the undefined index or headers already sent but all the data is there at the bottom. i want to write a script to open the file and remove all lines until it gets to the actual header line that should be in a csv.
the # of lines changes every time i pull it...
the current example has 49107 lines that i don't need before the part i want to parse.. This is a small part of the first 15 lines of code and about 20 lines of code before what i REALLY WANT from the file.
<pre class="cake-debug"><b>Notice</b> (8): Undefined index: name [<b>APP/controllers/loads_controller.php</b> line <b>327</b>]<div id="cakeErr1-trace" class="cake-stack-trace" style="display: none;">Code | Context<div id="cakeErr1-code" class="cake-code-dump" style="display: none;"><pre><code><span style="color: #000000"> $data[$i]['Load']['drop_date'] = date('m/d/Y' strtotime($value['Load']['drop']));</span></code>
<code><span style="color: #000000"> $data[$i]['Load']['pickup_city'] = $value['Pickup']['city'];</span></code>
"<span class=""code-highlight""><code><span style=""color: #000000""> $data[$i]['Load']['pickup_state'] = $value['Pickup']['State']['name'];</span></code></span></pre></div><pre id=""cakeErr1-context"" class=""cake-context"" style=""display: none;"">$order = ""Load.load_number ASC"""
"$fields = array("
" ""*"""
)
"$conditions = array("
" ""Load.active"" => true"
)
"$results = array("
" array("
" ""Load"" => array()"
" ""Pickup"" => array()"
" ""Destination"" => array()"
)
$result = array(
"Load" => array(
"name" => "ICE CREAM OR RELATED",
"load_number" => "8891517",
"trailer_type" => "R",
"phone_number1" => "800-555-8287",
"phone_number2" => "800-555-8287",
"pickup_date" => "03/09/2014",
"drop_date" => "03/09/2014",
"pickup_city" => "Indianapolis",
"pickup_state" => "Indiana",
"pickup_zipcode" => "46201",
"destination_city" => "London",
"destination_state" => "Kentucky",
"destination_zipcode" => "40741"
)
)
$fp=</pre><pre class="stack-trace">header - [internal], line ??
LoadsController::csv() - APP/controllers/loads_controller.php, line 360
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 170
[main] - APP/webroot/index.php, line 83</pre></div>
</pre>name,load_number,trailer_type,phone_number1,phone_number2,pickup_date,drop_date,pickup_city,pickup_state,pickup_zipcode,destination_city,destination_state,destination_zipcode
"FOOD OR KINDRED PROD",8831029,R,800-555-8287,800-555-8287,03/09/2014,03/10/2014,Aurora,Illinois,60504,"West Memphis",Arkansas,72301
"FOOD OR KINDRED PROD",8831031,R,800-555-8287,800-555-8287,03/12/2014,03/13/2014,Aurora,Illinois,60504,Ashley,Indiana,46705
This is how I would like the file to look after removing the lines that should not be there...
name,load_number,trailer_type,phone_number1,phone_number2,pickup_date,drop_date,pickup_city,pickup_state,pickup_zipcode,destination_city,destination_state,destination_zipcode
FOOD OR KINDRED PROD,8831029,R,800-555-8287,800-555-8287,3/9/2014,3/10/2014,Aurora,Illinois,60504,West Memphis,Arkansas,72301
FOOD OR KINDRED PROD,8831031,R,800-555-5555,800-555-5555,3/12/2014,3/13/2014,Aurora,Illinois,60504,Ashley,Indiana,46705
Currently i am using this code to get my CSV
set_time_limit (24 * 60 * 60);
// folder to save downloaded files to. must end with slash
$destination_folder = 'downloads/';
$url = 'http://www.somesite.com/loads/csv';
$newfname = $destination_folder . 'loads1.csv';
$file = fopen ($url, "rb");
if ($file) {
$newf = fopen ($newfname, "wb");
if ($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
and this Code to parse it
$selectfile1 = "https://www.somesite.com/downloads/loads1.csv";
// check mime type - application/octet-stream
$content = file($selectfile1);
$posted_content = array();
list($rownum, $row) = each($content);
$posted_content[0] = explode(",", $row);
array_push($posted_content[0], "ID");
$count = 0;
// iterate each row (1 post)
while (list($rownum, $row) = each($content))
{
$count++;
$cols = "ShipAfterDate, ShipBeforeDate, EquipmentID, LengthID, VendorCode, LoadCount, Rate, CargoDescription, Notes,Phone1, Phone2, PostDate,";
$vals = "";
// extract fields from row columns
$items = explode(",", $row);
list( $Description, $OrderNumber, $EquipmentCode, $Phone1, $Phone2, $ShipDate, $DeliveryDate, $OriginCity, $OriginState, $OriginZip, $DestinationCity, $DestinationState, $DestinationZip
) = $items;
array_push($posted_content, $items);
Check out 'fgetcsv' (PHP manual) which just returns false if there's a parse error or the actual CSV values if not. It might be not the fastest solution to unsuccessfully parse 50k lines, but I think it should work nevertheless
I am trying to download a rapidshare file using its "download" subroutine as a free user. The following is the code that I use to get response from the subroutine.
function rs_download($params)
{
$url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=".$params['fileid']."&filename=".$params['filename'];
$reply = #file_get_contents($url);
if(!$reply)
{
return false;
}
$result_arr = array();
$result_keys = array(0=> 'hostname', 1=>'dlauth', 2=>'countdown_time', 3=>'md5hex');
if( preg_match("/DL:(.*)/", $reply, $reply_matches) )
{
$reply_altered = $reply_matches[1];
}
else
{
return false;
}
foreach( explode(',', $reply_altered) as $index => $value )
{
$result_arr[ $result_keys[$index] ] = $value;
}
return $result_arr;
}
For instance; trying to download this...
http://rapidshare.com/files/440817141/AutoRun__live-down.com_Champ.rar
I pass the fileid(440817141) and filename(AutoRun__live-down.com_Champ.rar) to rs_download(...) and I get a response just as rapidshare's api doc says.
The rapidshare api doc (see "sub=download") says call the server hostname with the download authentication string but I couldn't figure out what form the url should take.
Any suggestions?, I tried
$download_url = "http://$the-hostname/$the-dlauth-string/files/$fileid/$filename"
and a couple other variations of the above, nothing worked.
I use curl to download the file, like the following;
$cr = curl_init();
$fp = fopen ("d:/downloaded_files/file1.rar", "w");
// set curl options
$curl_options = array(
CURLOPT_URL => $download_url
,CURLOPT_FILE => $fp
,CURLOPT_HEADER => false
,CURLOPT_CONNECTTIMEOUT => 0
,CURLOPT_FOLLOWLOCATION => true
);
curl_setopt_array($cr, $curl_options);
curl_exec($cr);
curl_close($cr);
fclose($fp);
The above curl code doesn't seem to work, nothing gets downloaded. Probably its the download url that is incorrect.
Also tried this format for the download url:
"http://rs$serverid$shorthost.rapidshare.com/files/$fileid/$filename"
With this curl writes a file entry but that is all it does(writes a 0/1 kb file).
Here is the code that I use to get the serverid, shorthost, among a few other values from rapidshare.
function rs_checkfile($params)
{
$url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=".$params['fileids']."&filenames=".$params['filenames'];
// the response from rapishare would a string something like:
// 440817141,AutoRun__live-down.com_Champ.rar,47768,20,1,l3,0
$reply = #file_get_contents($url);
if(!$reply)
{
return false;
}
$result_arr = array();
$result_keys = array(0=> 'file_id', 1=>'file_name', 2=>'file_size', 3=>'server_id', 4=>'file_status', 5=>'short_host'
, 6=>'md5');
foreach( explode(',', $reply) as $index => $value )
{
$result_arr[ $result_keys[$index] ] = $value;
}
return $result_arr;
}
rs_checkfile(...) takes comma seperated fileids and filenames(no commas if calling for a single file)
Thanks in advance for any suggestions.
You start by requesting ?sub=download&fileid=X&filename=Y, and it returns $hostname,$dlauth,$countdown,$md5hex.. since you're a free user you have to delay for $countdown seconds, and then call ?sub=download&fileid=X&filename=Y&dlauth=Z to perform the download.
There's a working implementation in python here that would probably answer any of your other questions.