private function sendCameraEvents($id, $flags) { // retrieve session data $sdata = $this->__getObject("Sesiones", $id); if (!$sdata) { $this->myLogger->error("sendCameraEvents: invalid session id:{$id}"); return; } $evtmgr = new Eventos("Session::sendCameraEvents", $id, new AuthManager("Sesiones::sendCameraEvent")); $data = array('ID' => $id, 'Session' => $id, 'TimeStamp' => date('Y-m-d G:i:s'), 'Type' => "camera", 'Source' => $sdata->Nombre, 'Pru' => $sdata->Prueba, 'Jor' => $sdata->Jornada, 'Mng' => $sdata->Manga, 'Tnd' => $sdata->Tanda); if ($flags & 0x1) { $evtmgr->putEvent(array_merge($data, array("Mode" => "bg", "Value" => $sdata->Background))); } if ($flags & 0x2) { $evtmgr->putEvent(array_merge($data, array("Mode" => "h264", "Value" => $sdata->LiveStream))); } if ($flags & 0x4) { $evtmgr->putEvent(array_merge($data, array("Mode" => "ogv", "Value" => $sdata->LiveStream2))); } if ($flags & 0x8) { $evtmgr->putEvent(array_merge($data, array("Mode" => "webm", "Value" => $sdata->LiveStream3))); } }
try { $result = null; $am = new AuthManager("eventsFunctions"); $operation = http_request("Operation", "s", null); $data = array('ID' => http_request("ID", "i", 0), 'Session' => http_request("Session", "i", 0), 'TimeStamp' => http_request("TimeStamp", "i", 0), 'Type' => http_request("Type", "s", ""), 'Source' => http_request("Source", "s", ""), 'Pru' => http_request("Prueba", "i", 0), 'Jor' => http_request("Jornada", "i", 0), 'Mng' => http_request("Manga", "i", 0), 'Tnd' => http_request("Tanda", "i", 0), 'Dog' => http_request("Perro", "i", 0), 'Drs' => http_request("Dorsal", "i", 0), 'Hot' => http_request("Celo", "i", 0), 'Eqp' => http_request("Equipo", "i", 0), 'Flt' => http_request("Faltas", "i", -1), 'Toc' => http_request("Tocados", "i", -1), 'Reh' => http_request("Rehuses", "i", -1), 'NPr' => http_request("NoPresentado", "i", -1), 'Eli' => http_request("Eliminado", "i", -1), 'Tim' => http_request("Tiempo", "d", -1), 'Value' => http_request("Value", "i", -1), 'stop' => http_request("stop", "i", 0), 'start' => http_request("start", "i", 0)); if ($operation === null) { throw new Exception("Call to eventFunctions without 'Operation' requested"); } $eventmgr = new Eventos("eventFunctions", $data['Session'], $am); switch ($operation) { case "getEvents": $result = $eventmgr->getEvents($data); break; case "putEvent": $am->access(PERMS_ASSISTANT); $result = $eventmgr->putEvent($data); break; case "chronoEvent": $am->access(PERMS_CHRONO); $result = $eventmgr->putEvent($data); break; case "listEvents": $result = $eventmgr->listEvents($data); break; case "connect": $result = $eventmgr->connect($data); break; default: throw new Exception("eventFunctions:: invalid operation: {$operation} provided"); } if ($result === null) {
/** * Authenticate user. * On Login success create session and if needed send login event * @param {string} $login user name * @param {string} $password user password * @param {integer} $sid requested session id to join to * @throws Exception if something goes wrong * @return {array} errorMessage or result data */ function login($login, $password, $sid = 0, $nosession = false) { /* access database to check user credentials */ $this->myLogger->enter(); $obj = $this->mySessionMgr->__selectObject("*", "Usuarios", "(Login='******')"); if (!$obj) { throw new Exception("Login: Unknown user: '******'"); } $pw = $obj->Password; if (strstr('--UNDEF--', $pw) !== FALSE) { throw new Exception("Seems that AgilityContest has not been properly configured. Please reinstall"); } else { if (strstr('--LOCK--', $pw) !== FALSE) { throw new Exception("Account '{$login}' is LOCKED"); } else { if (strstr('--NULL--', $pw) === FALSE) { // --NULL-- means no password required // unencode stored password $pass = base64_decode($pw); if (!password_verify($password, $pass)) { // check password against stored one throw new Exception("Login: invalid password for account '{$login}'"); } } } } /* Arriving here means login success */ // get & store permission level $this->level = $obj->Perms; //create a random session key $sk = random_password(16); // compose data for a new session $data = array('Operador' => $obj->ID, 'SessionKey' => $sk, 'Nombre' => http_request("Nombre", "s", ""), 'Prueba' => http_request("Prueba", "i", 0), 'Jornada' => http_request("Jornada", "i", 0), 'Manga' => http_request("Manga", "i", 0), 'Tanda' => http_request("Tanda", "i", 0), 'Perro' => http_request("Perro", "i", 0), 'UserID' => $obj->ID, 'Login' => $obj->Login, 'Password' => '', 'Gecos' => $obj->Gecos, 'Phone' => $obj->Phone, 'Email' => $obj->Email, 'Perms' => $obj->Perms, 'Type' => 'init', 'Source' => http_request("Source", "s", "AuthManager"), 'TimeStamp' => date('Y-m-d G:i:s')); // if "nosession" is requested, just check password, do not create any session if ($nosession == true) { return $data; } // create/join to a session if ($sid <= 0) { // if session id is not defined, create a new session // remove all other console sessions from same user $str = "DELETE FROM Sesiones WHERE ( Nombre='Console' ) AND ( Operador={$obj->ID} )"; $this->mySessionMgr->query($str); // insert new session $data['Nombre'] = "Console"; $data['Comentario'] = $obj->Login . " - " . $obj->Gecos; $this->mySessionMgr->insert($data); // and retrieve new session ID $data['SessionID'] = $this->mySessionMgr->conn->insert_id; } else { // to join to a named session we need at least Assistant permission level $this->access(PERMS_ASSISTANT); // on fail throw exception unset($data['Nombre']); // to avoid override Session Name // TODO: check and alert on busy session ID // else join to declared session $data['SessionID'] = $sid; $this->mySessionMgr->update($sid, $data); // and fire 'login' event $evtMgr = new Eventos("AuthManager", $sid, $this); $event = array("ID" => 0, "Session" => $sid, "TimeStamp" => $data['TimeStamp'], "Type" => $data['Type'], "Source" => $data['Source'], "Pru" => $data['Prueba'], "Jor" => $data['Jornada'], "Mng" => $data['Manga'], "Tnd" => $data['Tanda'], "Dog" => $data['Perro'], "Drs" => 0, "Hot" => 0, "Flt" => -1, "Toc" => -1, "Reh" => -1, "NPr" => -1, "Eli" => -1, "Tim" => -1, "Value" => 0); $evtMgr->putEvent($event); } // That's all. Return generated result data // $this->myLogger->info(json_encode($data)); $this->myLogger->leave(); $info = $this->getRegistrationInfo(); return array_merge($data, $info); }