try { $result = null; $inscripciones = new Inscripciones("inscripcionFunctions", http_request("Prueba", "i", 0)); $am = new AuthManager("inscripcionesFunctions"); $operation = http_request("Operation", "s", null); $perro = http_request("Perro", "i", 0); $equipo = http_request("Equipo", "i", 0); $jornada = http_request("Jornada", "i", 0); $olddorsal = http_request("Dorsal", "i", 0); $newdorsal = http_request("NewDorsal", "i", 0); if ($operation === null) { throw new Exception("Call to inscripcionFunctions without 'Operation' requested"); } switch ($operation) { case "insert": $am->access(PERMS_OPERATOR); $result = $inscripciones->insert($perro); break; // nueva inscripcion // nueva inscripcion case "update": $am->access(PERMS_OPERATOR); $result = $inscripciones->update($perro); break; // editar inscripcion ya existente // editar inscripcion ya existente case "delete": $am->access(PERMS_OPERATOR); $result = $inscripciones->delete($perro); break; // borrar inscripcion
// tanda ID $d = http_request("Dorsal", "i", 0); $s = http_request("Sesion", "i", 0); // default is no session $a = http_request("Pendientes", "i", 0); // los siguiente campos se usan para drag and drop $f = http_request("From", "i", 0); $t = http_request("To", "i", 0); $w = http_request("Where", "i", 0); // 0:up 1:down if ($p <= 0 || $j <= 0) { throw new Exception("Call to tandasFunctions with Invalid Prueba:{$p} or Jornada:{$j} ID"); } switch ($operation) { case "insert": $am->access(PERMS_OPERATOR); $result = $ot->insert($ot->getHttpData()); break; case "update": $am->access(PERMS_ASSISTANT); $result = $ot->update($id, $ot->getHttpData()); break; case "delete": $am->access(PERMS_OPERATOR); $result = $ot->delete($id); break; /* DO NOT CALL These functions from client side case "populateJornada": case "deleteJornada": */ /* DO NOT CALL These functions from client side
require_once __DIR__ . "/classes/Eventos.php"; 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"); }
try { $result = null; $users = new Usuarios("userFunctions"); $am = new AuthManager("userFunctions"); $operation = http_request("Operation", "s", null); $id = http_request("ID", "i", 0); $user = http_request("Username", "s", null); $pass = http_request("Password", "s", null); $sid = http_request("Session", "i", 0); $sk = http_request("SessionKey", "s", ""); if ($operation === null) { throw new Exception("Call to userFunctions without 'Operation' requested"); } switch ($operation) { case "insert": $am->access(PERMS_ADMIN); $result = $users->insert(); break; case "update": $am->access(PERMS_ADMIN); $result = $users->update($id); break; case "delete": $am->access(PERMS_ADMIN); $result = $users->delete($id); break; case "password": $result = $am->setPassword($id, $pass, $sk); break; // access checks are done inside method // access checks are done inside method
$operation = http_request("Operation", "s", ""); $perms = http_request("Perms", "i", PERMS_NONE); if ($operation === null) { throw new Exception("Call to adminFunctions without 'Operation' requested"); } if ($operation === "progress") { // retrieve last line of progress file $lines = file(RESTORE_LOG, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); echo json_encode(array('progress' => strval($lines[count($lines) - 1]))); return; } $am = new AuthManager("adminFunctions"); $adm = new Admin("adminFunctions", $am); switch ($operation) { case "access": $am->access($perms); $result = array('success' => true); break; case "backup": /* $am->access(PERMS_ADMIN); */ $result = $adm->backup(); break; case "restore": $am->access(PERMS_ADMIN); $result = $adm->restore(); break; case "reset": $am->access(PERMS_ADMIN); $result = $adm->clearDatabase(); break; case "clear":
/** * Funcion de procesado de inscripciones * revisa la inscripcion * ajusta orden de salida * crea entradas en tabla de resultados * @param {integer} $p ID de prueba * @param {integer} $i ID de inscripcion */ function procesaInscripcion($p, $i) { $myConfig = Config::getInstance(); $myLogger = new Logger("procesaInscripcion", $myConfig->getEnv("debug_level")); $am = new AuthManager("procesaInscripcion"); // si la prueba o la inscripcion son nulas genera error try { if ($p <= 0) { throw new Exception("ID de prueba invalida: {$p}"); } if ($i <= 0) { throw new Exception("ID de inscripcion invalida"); } $am->access(PERMS_OPERATOR); // grant access or throw exception // buscamos las jornadas de que consta la Prueba $jobject = new Jornadas("procesaInscripcion", $p); $jp = $jobject->searchByPrueba(); if (!$jp) { throw new Exception("No encuentro jornadas para la prueba: {$p}"); } // buscamos las jornadas en las que esta inscrito $iobject = new Inscripciones("procesaInscripcion", $p); $inscripcion = $iobject->selectByID($i); if (!$inscripcion) { throw new Exception("No encuentro la inscripcion con ID: {$i}"); } $idp = $inscripcion['Perro']; // obtenemos los datos del perro $pobj = new Dogs("procesaInscripcion()"); $perro = $pobj->selectByID($idp); if (!$perro) { throw new Exception("No hay datos para el perro a inscribir con id: {$idp}"); } // TODO: check Dog Federation against Prueba Federation // contrastamos la lista de jornadas de la prueba con la lista de jornadas en las que esta inscrito foreach ($jp['rows'] as $jornada) { $numj = $jornada['Numero'] - 1; // obtenemos el numero de jornada $idj = $jornada['ID']; if ($jornada['Cerrada'] == 1) { $myLogger->info("La jornada {$idj} de la prueba {$p} esta cerrada"); continue; // no tocamos las jornadas cerradas } if (($inscripcion['Jornadas'] & 1 << $numj) != 0) { $myLogger->info("El perro {$idp} esta inscrito en la jornada {$idj} de la prueba {$p}"); inscribePerroEnJornada($inscripcion, $jornada, $perro); } else { $myLogger->info("El perro {$idp} NO esta inscrito en la jornada {$idj} de la prueba {$p}"); borraPerroDeJornada($inscripcion, $jornada, $perro); } } } catch (Exception $e) { do_log($e->getMessage()); echo json_encode(array('errorMsg' => $e->getMessage())); } }