Example #1
0
<?php

$source = '/home/pi/videos/P2P';
$dest = '/home/pi/videos/Series';
exec('sh ' . MOD_DIR . '/services/scripts/movieclassify.sh ' . $source . ' ' . $dest, $output, $ret);
if ($ret != 0) {
    http_response_code(400);
    WS_print(['error' => $output]);
}
WS_print(true);
Example #2
0
<?php

use rpi\core\Pages;
WS_print(Pages::i()->pages());
Example #3
0
<?php

/**
 * 
 */
WS_print($shell->execute($_GET["cmd"]));
Example #4
0
<?php

use rpi\core\Config;
$modules = Config::modules();
$ws = [];
foreach ($modules as $name => $mod) {
    $wsdir = MOD_DIR . '/' . $name . '/ws';
    if (!is_dir($wsdir)) {
        continue;
    }
    $d = @opendir($wsdir);
    while ($f = readdir($d)) {
        if ($f[0] == '.') {
            continue;
        }
        $ws[] = $name . '/' . str_replace('.php', '', $f);
    }
    closedir($d);
}
WS_print($ws);
Example #5
0
<?php

use rpi\core\services\Services;
$servman = Services::i();
$services = $servman->services();
$response = [];
foreach ($services as $s) {
    $response[] = $s->toArray();
}
WS_print($response);
Example #6
0
$action = $_REQUEST["action"];
$service = $_REQUEST["service"];
use rpi\core\services\Services;
$servman = Services::i();
/**
 * Check if exists
 */
if (!$servman->has($service)) {
    http_response_code(400);
    WS_print(array('error' => 'not_exists'));
}
$service = $servman->get($service);
/****************************************************
 * Operations
 ****************************************************/
/**
 * Start/Stop
 */
if ($action == "start") {
    $result = $service->start();
} elseif ($action == "stop") {
    $result = $service->stop();
} else {
    http_response_code(400);
    WS_print(array('error' => 'unsupported_action'));
}
/**
 * Result
 */
WS_print(array('result' => $result ? 'success' : 'fail', 'started' => $service->enabled()));
Example #7
0
<?php

require 'mod.inc.php';
set_time_limit(0);
/**
 * Check if this view exists
 */
$view = MOD_DIR . '/' . $module . '/ws/' . $page . '.php';
if (!is_file($view)) {
    exit('Webservice inexistante');
}
header("Content-Type: application/json");
try {
    require $view;
} catch (\Exception $e) {
    WS_print(['error' => $e->getMessage()]);
}
Example #8
0
<?php

use rpi\core\Pages;
$page = @$_GET['page'] ?: 'index';
$zone = @$_GET['zone'];
$model = Pages::i()->get($page);
$contents = $model->getContents($zone);
WS_print(array_values($contents));
Example #9
0
<?php

/****************************************************
 * Shutdown RPI
 ****************************************************/
exec("sudo halt", $output, $code);
WS_print(array('msg' => empty($code) ? 'success' : 'failure'));