David, I wanted to make my DigiX server available remotely as well, but have no idea how to go about it.
Could you explain a bit to me how the php code on your public server obtains your IP address (am I correct in understanding this will be the external address of your home/office network?), then links to the DigiX?
If you want to take the discussion off line, you can mail me at dbell () thebells () net
Thanks!
Dave
Sure, I am all about sharing. I am going to throw up a video tutorial about it once I have it working but here is the gist of it and some code.
You need to know your external ip address -
https://www.google.co.uk/search?q=what+is+my+ipBut if, like me, you are a home broadband user the your IP may change when your DCHP license expires or if you reset your router. Mine changes a lot because my router is crap and needs resetting daily which a lot of the time results in a new IP.
I have a website and the web host (vidaost) allows for mysql databases and php so I thought I would use that as a go between. You could just have your DigiX push data to your server regularly but I would prefer it to serve the information when required, this may end up being a bridge too far though.
My current approach to save the IP is to request this PHP page:
<?php
$val = $_SERVER['REMOTE_ADDR'];
$val = $val . ':8080';
$con=mysqli_connect("localhost","username","password","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE iptable SET ipaddress='$val' WHERE id = '1'");
mysqli_close($con);
echo $val;
?> This save the IP address and appends it with the port that is serving the data. I also had to set up port forwarding and a static IP address from my router to my DigiX. This means that when I connect the DigiX it always recieved the same IP on my home network and is routed as a HTTP server. through my public IP address. Unfortunately it also means that the default public URL routes to the DigiX on port 80, the login screen. Which is why I chose to hide all of that behind the PHP CURL stuff below.
<?php
$con=mysqli_connect("localhost","username","password","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$url2 = 0;
$result = mysqli_query($con,"Select ipaddress FROM iptable WHERE id = '1'");
while($row = mysqli_fetch_array($result))
{
$url2 = $row['ipaddress'];
}
mysqli_close($con);
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo get_data($url2);
?>In order to allow interaction with the DigiX you would need to expand it by adding other pages for various requests, always hiding the URL. I just chose a sub domain on my site to hide behind but a standard yourdomain.com/digix.php would also be fine.
I hope that helps but please feel free to ask more questions, there is no point in me keeping any of this to myself.
David