Posted 12 April 2014 - 05:42 PM
Dear all,
I currently am playing FTB Monster and I run a massive powerplant for the people in the area and couple of times the system went down without me knowing. Meanwhile at school our final project for web development is basically something that combines HTML, CSS, JS, PHP and databases.
So I decided to make a website to remotely administrate and monitor the powerplant, including history (with charts, etc) and otherwise.
The data I will be sending every interval (approx 15s, will finalize later based on server load) to the database for storage is stored in a large array which will have new data/vars added as the powerplant grows and thus manually serializing the array is not really viable.
Question: What I was looking for was if the textutils.serialize(arg) function uses the same encoding format as the PHP serialize($arg) function so that I can just serialize the array with textutils and deserialize it with PHP's unserialize($arg) serverside orcan textutils encode it properly for automatic reception as $_POST by PHP.
This would be very helpful to know. I've searched the forums and google to no sucess.
Note: On my phone, will post code later.
Edit: Code examples:
I know the code above is semi-functional but it's hard for me to get a feel for it when you don't know if it works.
P.S. PHP Code is protected against SQL Injections so no worries.
Sincerely,
Blitzninja.
I currently am playing FTB Monster and I run a massive powerplant for the people in the area and couple of times the system went down without me knowing. Meanwhile at school our final project for web development is basically something that combines HTML, CSS, JS, PHP and databases.
So I decided to make a website to remotely administrate and monitor the powerplant, including history (with charts, etc) and otherwise.
The data I will be sending every interval (approx 15s, will finalize later based on server load) to the database for storage is stored in a large array which will have new data/vars added as the powerplant grows and thus manually serializing the array is not really viable.
Question: What I was looking for was if the textutils.serialize(arg) function uses the same encoding format as the PHP serialize($arg) function so that I can just serialize the array with textutils and deserialize it with PHP's unserialize($arg) serverside orcan textutils encode it properly for automatic reception as $_POST by PHP.
This would be very helpful to know. I've searched the forums and google to no sucess.
Note: On my phone, will post code later.
Edit: Code examples:
_POST = {}
cmd_interval = 15 -- time in seconds between each update
function initPOST()
-- First time initialization
_POST.steam_buffer = {0, 0} -- FOR ALL: (current, max)
_POST.energy_rf_main = {0, 0}
_POST.energy_rf_emer = {0, 0}
_POST.energy_eu_main = {0, 0}
_POST.energy_eu_emer = {0, 0}
_POST.action = "update"
_POST.init = true
end
function updateDB()
if (_POST.init ~= nil) then
-- Potential use of textutils.serialize()
_POST.action = "update"
return http.post("http://mywebserver.com/ftbinterface.php", textutils.serialize(_POST))
else
initPost()
return "error"
end
end
function reqCMDs()
if (_POST.init ~= nil) then
_POST.action = "getcmds"
return http.post("http://mywebserver.com/ftbinterface.php", textutils.serialize(_POST))
end
end
I know the code above is semi-functional but it's hard for me to get a feel for it when you don't know if it works.
P.S. PHP Code is protected against SQL Injections so no worries.
Sincerely,
Blitzninja.
Edited on 13 April 2014 - 01:29 AM