summaryrefslogtreecommitdiffstats
path: root/Under-Testing/Website/devconf.php
diff options
context:
space:
mode:
authorgsmselftest2011-11-16 18:06:02 +0100
committergsmselftest2011-11-16 18:06:02 +0100
commit8a7755d6f96e599fe75ac8e5e1c6994138f4b99e (patch)
tree9b320feb695cfbadd605808b2db5795e240e9399 /Under-Testing/Website/devconf.php
parent delete dummy comment (diff)
downloadgsm-selftest-8a7755d6f96e599fe75ac8e5e1c6994138f4b99e.tar.gz
gsm-selftest-8a7755d6f96e599fe75ac8e5e1c6994138f4b99e.tar.xz
gsm-selftest-8a7755d6f96e599fe75ac8e5e1c6994138f4b99e.zip
under Testing folder
Diffstat (limited to 'Under-Testing/Website/devconf.php')
-rw-r--r--Under-Testing/Website/devconf.php130
1 files changed, 130 insertions, 0 deletions
diff --git a/Under-Testing/Website/devconf.php b/Under-Testing/Website/devconf.php
new file mode 100644
index 0000000..bd13067
--- /dev/null
+++ b/Under-Testing/Website/devconf.php
@@ -0,0 +1,130 @@
+<?php
+
+//Connection stuff
+//DB
+include 'dbconnection.php';
+
+//Socket
+$port = 34500;
+$ip = 'localhost';
+
+$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
+mysql_select_db($dbname);
+//End of connection stuff
+include 'mutexFunctions.php'; //mutex functions, isfree, lock and release
+
+
+$nameOfLock = 'Webpage';
+$timeToKeepTheMutex = 360;
+
+$locking = isLocked($nameOfLock);//Check if the webpage is already open
+if ($locking == '1') //1 means nobody is on the website
+ {
+
+ $lockMe = Lock($nameOfLock,$timeToKeepTheMutex); //Set a mutex for the webpage
+ if ($lockMe == '1')
+ {
+
+ $softwareLock = 'SoftwareStarted';
+ $softwareRunning = isLocked($softwareLock);
+ if($softwareRunning == '1') //1 means software is not started yet, start it
+ {
+
+ $startApp = fsockopen($ip, 34600, $errno, $error, 5);
+ if (!$startApp)
+ {
+ printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!');
+ }
+ else
+ {
+
+ socket_set_timeout( $startApp, 50);
+ fwrite($startApp, "START APP");
+ usleep(2500);
+ fclose($startApp);
+ }
+ sleep(6);
+ $softwareRunning1 = isLocked($softwareLock);
+ if($softwareRunning1 == '0')
+ {
+ $fp = fsockopen($ip, $port, $errno, $error, 5);
+ if (!$fp)
+ {
+ echo 'Could not open the socket or connect to the testing software!';
+
+ }
+ else
+ {
+
+ socket_set_timeout($fp,50);
+ fwrite($fp, "UPDATE DEVICE");
+ if(!feof($fp))
+ {
+ while(!feof($fp))
+ {
+ $received = fgets($fp, 128);
+ if ($received == "CONFIRM\n")
+ {
+ flush();
+ }
+ elseif ($received == "TEST DONE\n")
+ {
+ flush();
+ usleep(100);
+ echo 'Update device Done';
+ fwrite($fp, 'DISCONNECT');
+ break;
+ }
+ else {
+ flush();
+ usleep(100);
+ echo ''.$received;
+ }
+
+ }
+ }
+ }
+ fclose($fp);
+ }
+ elseif($softwareRunning1 == '1')
+ {
+ echo 'Testing software was not started(didn\'t obtain the lock)! Check it!';
+ }
+ else
+ {
+ echo 'Testing software didn\'t obtain the lock';
+ }
+
+
+ }
+ elseif($softwareRunning == '0') //0 means the software is still running in the background
+ {
+ echo 'Testing software is still running! Maybe you should kill it (if not started manually!)';
+ }
+ else
+ {
+ echo 'We have an unknown error! Refresh te web page!';
+ }
+ }
+ elseif($lockMe == '0')
+ {
+ echo 'Someone was faster than you';
+ }
+ else
+ {
+
+ echo 'We have an error here';
+ }
+ }
+
+elseif ($locking == '0') //0 means somebody is already on the web site
+ {
+ echo 'Somebody is using the web site already!' . "<br>";
+ }
+else
+ {
+ echo 'We have some serious error here';
+ }
+?>
+
+