<?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);
<?php use rpi\core\Pages; WS_print(Pages::i()->pages());
<?php /** * */ WS_print($shell->execute($_GET["cmd"]));
<?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);
<?php use rpi\core\services\Services; $servman = Services::i(); $services = $servman->services(); $response = []; foreach ($services as $s) { $response[] = $s->toArray(); } WS_print($response);
$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()));
<?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()]); }
<?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));
<?php /**************************************************** * Shutdown RPI ****************************************************/ exec("sudo halt", $output, $code); WS_print(array('msg' => empty($code) ? 'success' : 'failure'));