"; $tmpip = $_SERVER['REMOTE_ADDR']; $DB->Update("UPDATE adapterbox SET letzteverbindung=NOW(),tmpip='" . $DB->real_escape_string($tmpip) . "' WHERE seriennummer='" . $DB->real_escape_string($deviceid) . "' AND seriennummer!='' LIMIT 1"); switch ($cmd) { case "addJob": echo "$cmd"; $job = $_POST['job']; $request_id = $_GET['request_id']; $art = $_GET['art']; //file_put_contents("/tmp/bene","add job for $deviceid_destination deviceid $deviceid job $job"); if ($deviceid != "" && $deviceid_destination != "" && $job != "") { $job = base64_encode($job); $DB->Insert("INSERT INTO device_jobs (id,deviceidsource,deviceiddest,job,zeitstempel,request_id,art) VALUES ('','" . $DB->real_escape_string($deviceid) . "','" . $DB->real_escape_string($deviceid_destination) . "','" . $DB->real_escape_string($job) . "',NOW(),'" . $DB->real_escape_string($request_id) . "','" . $DB->real_escape_string($art) . "')"); echo "1"; } else { echo "0"; } break; case "getJob": echo "$cmd"; $tmp = $DB->SelectRow( sprintf( "SELECT `id`, `job`, `art` FROM `device_jobs` WHERE `deviceiddest` = '%s' AND `abgeschlossen` = '0' ORDER BY `zeitstempel` LIMIT 1", $DB->real_escape_string($deviceid) ) ); if (empty($tmp)) { echo '0'; break; } $DB->Delete(sprintf('DELETE FROM `device_jobs` WHERE `id` = %d LIMIT 1', $tmp['id'])); echo "" . $tmp['job'] . ""; echo "" . $tmp['art'] . ""; echo "" . $tmp['id'] . ""; echo "1"; if (rand(0, 1000) === 0) { //should be not necessary $DB->Delete("DELETE FROM `device_jobs` WHERE `abgeschlossen` = '1'"); } break; case "logOut": echo "$cmd"; break; case "state": echo "$cmd"; if ($deviceid_destination != "") $tmp = $DB->Select("SELECT COUNT(id) FROM device_jobs WHERE deviceiddest='" . $DB->real_escape_string($deviceid_destination) . "' AND abgeschlossen!='1'"); else $tmp = $DB->Select("SELECT COUNT(id) FROM device_jobs WHERE deviceiddest='" . $DB->real_escape_string($deviceid) . "' AND abgeschlossen!='1'"); echo "$tmp"; echo "$deviceid"; break; default: echo "unkown"; echo "
DEVICE ID: $deviceid L1 $L1 L2 $L2 L3 $L3
"; } echo ""; }