summaryrefslogtreecommitdiffstats
path: root/Under-Testing/Website/devconf.php
diff options
context:
space:
mode:
Diffstat (limited to 'Under-Testing/Website/devconf.php')
-rw-r--r--Under-Testing/Website/devconf.php130
1 files changed, 0 insertions, 130 deletions
diff --git a/Under-Testing/Website/devconf.php b/Under-Testing/Website/devconf.php
deleted file mode 100644
index bd13067..0000000
--- a/Under-Testing/Website/devconf.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?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';
- }
-?>
-
-