Пример #1
0
function doGET($gpio, $vars)
{
    if ($vars[1] == "*") {
        writeJSON($gpio);
    } else {
        if ($vars[1] == "GPIO") {
            if (count($vars) != 4) {
                sendError(400, "Bad Request");
            }
            $pin = $vars[2];
            $cmd = $vars[3];
            checkGPIOPin($gpio, $pin);
            if ($cmd == "direction") {
                $ret = $gpio->getDirection($pin);
            } else {
                if ($cmd == "value") {
                    $ret = $gpio->getValue($pin);
                } else {
                    sendError(404, $cmd . " Not Found");
                }
            }
            header("Content-type: text/plain");
            echo $ret;
        } else {
            if ($vars[1] == "release") {
                $gpio->release();
            } else {
                sendError(404, $vars[1] . " Not Found");
            }
        }
    }
}
Пример #2
0
function doGET($gpio, $vars)
{
    if ($vars[1] == "*") {
        writeJSON($gpio);
    } else {
        sendError(404, "Not Found");
    }
}
Пример #3
0
                $idUsuario = $_POST['idUsuario'];
                $idCurso = $_POST['idCurso'];
                $idTema = $_POST['idTema'];
                $clase = crearClase($idUsuario, $idCurso, $uuid, $idTema, $file->name, $file->type);
                if (!is_null($clase)) {
                    //$file->url = $clase->archivo;
                    $file->url = "#";
                    $file->delete_url = "#";
                    $file->error = "";
                    $file->errorDetalle = "";
                } else {
                    $file->error = " ";
                    $file->errorDetalle = "Ocurrió un error al agregar el contenido. Intenta de nuevo más tarde";
                }
                $info[0] = $file;
                writeJSON($info);
            }
        }
        break;
    default:
        header('HTTP/1.1 405 Method Not Allowed');
}
function crearClase($idUsuario, $idCurso, $uuid, $idTema, $fileName, $fileType)
{
    require_once 'modulos/cursos/clases/Clase.php';
    require_once 'modulos/cursos/modelos/ClaseModelo.php';
    require_once 'modulos/usuarios/modelos/usuarioModelo.php';
    require_once 'modulos/cursos/modelos/CursoModelo.php';
    require_once 'modulos/cursos/modelos/TemaModelo.php';
    $filePath = "archivos/temporal/uploaderFiles/";
    if (getIdUsuarioDeCurso($idCurso) == $idUsuario && getIdUsuarioFromUuid($uuid) == $idUsuario && $idCurso == getIdCursoPerteneciente($idTema)) {
Пример #4
0
       - ID Values corrolate with menu ID in WP database
       - Loop through each language
       - Create a directory if needed
       - Write a new JSON file for each language's menu items
       - Write a link to the file
   */
//Assemble an array of languages, nest menu locations and wordpress menu ids
$menus = array('en' => array('header' => '9', 'footer1' => '19', 'footer2' => '20', 'footer3' => '21'), 'fr' => array('header' => '10', 'footer1' => '13', 'footer2' => '14', 'footer3' => '15'));
//Loop through languages
foreach ($menus as $lang => $value) {
    //Create a directory as needed
    makeDirectory($lang);
    //Loop through menu items sub-array
    foreach ($menus[$lang] as $menuLocation => $apiID) {
        //Package up vars to write JSON file at destination
        writeJSON($lang, $menuLocation, $apiID);
    }
}
//Function creates name spaced directory structure for languages
function makeDirectory($lang)
{
    if (!file_exists($lang)) {
        mkdir($lang, 0777, true);
    }
}
//Function calls JSON API, names the file destination, writes it to disk, calls the handler
function writeJSON($lang, $menuLocation, $apiID)
{
    //Prep the file input and output
    $jsonAPI = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/api/menus/get_menu/?menu_id=' . $apiID);
    $writeFile = $lang . '/' . $menuLocation . ".json";