Jump to content

Recommended Posts

Hello all,

 

I currently need a script that can export an .xml conents to a database. I need it to export a  script hosted on a remote server. To access it, you need usagemeter.php?username,password & when the login data is right, it will echo something like the following if correct:

 

username=username<br>data_down=15395.81 MB<br>data_up=2566.44 MB<br>free_data_down=27543.70 MB<br>free_data_up=6541.70 MB

 

Now I need to export the data_down & free_data_down to a MySQL database, just the figures.

 

Is their a script that can do that?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/121953-solved-exporting-xml-to-a-database/
Share on other sites

Going on what DarkWater said, try something like this:

 

<?php

$str = "username=username<br>data_down=15395.81 MB<br>data_up=2566.44 MB<br>free_data_down=27543.70 MB<br>free_data_up=6541.70 MB";

$tmp_explode = explode("<br>", $str);

$data = array();

foreach($tmp_explode as $line){
$tmp_line = explode("=", $line);
$data[$tmp_line[0]] = $tmp_line[1];
}

echo "<pre>";
print_r($data);
echo "</pre>";

?>

The usage meter is here: https://www.exetel.com.au/members/usagemeter.php

 

How could I obtain the data from that page where the $str = funtion is?

 

Also can just the 15395.81 MB be echoed on the page with removing everything else on it?

 

Thanks.

The usage meter is here: https://www.exetel.com.au/members/usagemeter.php

 

How could I obtain the data from that page where the $str = funtion is?

Sorry I'm not sure what you mean. Could you explain a bit more.

 

Also can just the 15395.81 MB be echoed on the page with removing everything else on it?

You can echo just the 15395.81 MB by doing this:

 

echo $data['data_down'];

<?php


$link = "https://www.exetel.com.au/members/usagemeter.php?username,password";

$http_response = "";
$url = parse_url($link);
$fp = fsockopen($url[host], 80, $err_num, $err_msg, 30) or
die("Socket-open
failed--error: ".$err_num." ".$err_msg);
fputs($fp, "GET /$url[path]?$url[query] HTTP/1.0\n");
fputs($fp, "Connection: close\n\n");
while(!feof($fp)) {
$http_response .= fgets($fp, 128);
}
fclose($fp);

$str = $http_response;

$tmp_explode = explode("<br>", $str);

$data = array();

foreach($tmp_explode as $line){
$tmp_line = explode("=", $line);
$data[$tmp_line[0]] = $tmp_line[1];
}

echo "<pre>";
echo $data['data_down'];
echo "</pre>";

?>

 

Would it be something like this or am I wrong?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.