require "../misc/mailFunc.php";
             sendSerialHdwMail($user->getUserName(), $serial);
             $result = array("result" => array("code" => 200, "data" => "Serial Generated"));
         } else {
             $result = array("result" => array("code" => 400, "data" => "Serial Generation Error"));
         }
     } else {
         $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command")));
     }
     echo json_encode($result);
     break;
 case "delFromUser":
     if (isset($_GET['hdwSerial'])) {
         require '../class/ChiconHardware.class.php';
         $hdwSerial = $_GET['hdwSerial'];
         $myHdw = ChiconHardware::toAssign($db, $hdwSerial);
         if ($myHdw->delFromUser($user->getUserId())) {
             $result = array("result" => array("code" => 200, "data" => "Hardware deleted"));
         } else {
             $result = array("result" => array("code" => 400, "data" => "Hardware deletion error"));
         }
     } else {
         $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command")));
     }
     echo json_encode($result);
     break;
 case "ledSelected":
     if (isset($_GET['hdwSerial']) and isset($_GET['led']) and $user->isUserHardware($_GET['hdwSerial'])) {
         require '../class/ChiconService.class.php';
         $mySrv = ChiconService::withHdwLedId($db, $_GET['led'], $_GET['hdwSerial']);
         if ($mySrv != null) {
Exemple #2
0
            $myHdw->getJsonConfig();
        } elseif (isset($_GET['led'])) {
            $mySrv = ChiconService::withHdwLedId($db, $_GET['led'], $myHdw->getSerialNumber());
            if ($mySrv != null) {
                $mySrv->runSelectedLed();
                $mySrv->run();
            } else {
                echo "{error:'Unknown service'}";
            }
        }
    } else {
        //TODO check if force registered is set, if yes force registered else send error
        echo "{error:'Unknown hdw'}";
    }
} else {
    if (isset($_GET['sHdw']) and isset($_GET['rgt'])) {
        $myHdw = ChiconHardware::withSerial($db, $_GET['sHdw']);
        if (!$myHdw->isEnrolled()) {
            if (isset($myHdw)) {
                $result = array("rgt" => array("mn" => $myHdw->generateMagicNumber()));
                echo json_encode($result);
            } else {
                echo "{error:'Unknown hdw'}";
            }
        } else {
            echo "{error:'Hdw Already Registered'}";
        }
    } else {
        echo "{error:'Bad arguments'}";
    }
}