Ejemplo n.º 1
0
function processSMSCommand($from, $SMSCommand = "", $playlistName = "")
{
    global $gv, $DEBUG;
    $FPPDStatus = false;
    $output = "";
    //   if($playlistName != "") {
    $PLAYLIST_NAME = trim($playlistName);
    //  } else {
    //           logEntry("No playlist name specified, using Plugin defined playlist: ".$PLAYLIST_NAME);
    //   }
    logEntry("Processing command: " . $SMSCommand . " for playlist: " . $PLAYLIST_NAME);
    $FPPDStatus = isFPPDRunning();
    logEntry("FPPD status: " . $FPPDStatus);
    if ($FPPDStatus != "RUNNING") {
        logEntry("FPPD NOT RUNNING: Sending message to : " . $from . " that FPPD status: " . $FPPDStatus);
        //send a message that the daemon is not running and cannot execute the command
        $gv->sendSMS($from, "FPPD is not running, cannot execute cmd: " . $SMSCommand);
        sleep(1);
        processReadSentMessages();
        return;
    } else {
        logEntry("Sending message to : " . $from . " that FPPD status: " . $FPPDStatus);
        $gv->sendSMS($from, "FPPD is running, I will execute command: " . $SMSCommand);
        sleep(1);
        //if sending a message.. need to clear it as it may hose up the next queue of messages
        processReadSentMessages();
    }
    $cmd = "/opt/fpp/bin/fpp ";
    switch (trim(strtoupper($SMSCommand))) {
        case "PLAY":
            $cmd .= "-P \"" . $PLAYLIST_NAME . "\"";
            break;
        case "STOP":
            $cmd .= "-c stop";
            break;
        case "REPEAT":
            $cmd .= "-p \"" . $PLAYLIST_NAME . "\"";
            break;
        case "STATUS":
            $playlistName = getRunningPlaylist();
            if ($playlistName == null) {
                $playlistName = " No current playlist active or FPPD starting, please try your command again in a few";
            }
            logEntry("Sending SMS to : " . $from . " playlist: " . $playlistName);
            $gv->sendSMS($from, "Playlist STATUS: " . $playlistName);
            break;
        default:
            $cmd = "";
            break;
    }
    if ($cmd != "") {
        logEntry("Executing SMS command: " . $cmd);
        exec($cmd, $output);
        //system($cmd,$output);
    }
    logEntry("Processing command: " . $cmd);
}
#!/usr/bin/php
<?php 
error_reporting(0);
$pluginName = "SMS";
$DEBUG = false;
$myPid = getmypid();
$skipJSsettings = 1;
include_once "/opt/fpp/www/config.php";
include_once "/opt/fpp/www/common.php";
include_once "functions.inc.php";
$logFile = $settings['logDirectory'] . "/" . $pluginName . ".log";
$FPPDStatus = isFPPDRunning();
do {
    $cmd = "sudo /opt/fpp/bin/fpp -s > /tmp/FPP.playlist";
    exec($cmd, $tmp);
    sleep(1);
    $playlistName = file_get_contents("/tmp/FPP.playlist");
    logEntry("Playlist name = " . $playlistName);
    if ($playlistName == "false" && $FPPDStatus == "RUNNING") {
        logEntry("looping... playlist name should not be false..is FPPD running?");
    }
    if ($playlistName == "false" && $FPPDStatus != "RUNNING") {
        logEntry("FPPD Daemon is not running..exiting");
        exit(0);
    }
} while ($playlistName == "false");
$playlistName = getRunningPlaylist();
logEntry("We got a valid playlist status from fpp -s ");
Ejemplo n.º 3
0
$ENABLED = "";
$ENABLED = trim(urldecode(ReadSettingFromFile("ENABLED", $pluginName)));
if ($ENABLED != "on" && $ENABLED != "1") {
    logEntry("Plugin Status: DISABLED Please enable in Plugin Setup to use & Restart FPPD Daemon");
    exit(0);
}
$EMAIL = urldecode(ReadSettingFromFile("EMAIL", $pluginName));
$PASSWORD = urldecode(ReadSettingFromFile("PASSWORD", $pluginName));
$PLAYLIST_NAME = urldecode(ReadSettingFromFile("PLAYLIST_NAME", $pluginName));
$WHITELIST_NUMBERS = urldecode(ReadSettingFromFile("WHITELIST_NUMBERS", $pluginName));
$CONTROL_NUMBERS = urldecode(ReadSettingFromFile("CONTROL_NUMBERS", $pluginName));
$REPLY_TEXT = urldecode(ReadSettingFromFile("REPLY_TEXT", $pluginName));
$VALID_COMMANDS = urldecode(ReadSettingFromFile("VALID_COMMANDS", $pluginName));
$COMMAND_ARRAY = explode(",", trim(strtoupper($VALID_COMMANDS)));
$CONTROL_NUMBER_ARRAY = explode(",", $CONTROL_NUMBERS);
$PLAYLIST_NAME = getRunningPlaylist();
//none at this time
$callbackRegisters = "media";
//$callbackRegisters = "playlist,media";
//var_dump($argv);
$FPPD_COMMAND = $argv[1];
//echo "FPPD Command: ".$FPPD_COMMAND."<br/> \n";
if ($FPPD_COMMAND == "--list") {
    echo $callbackRegisters;
    logEntry("FPPD List Registration request: responded:" . $callbackRegisters);
    exit(0);
}
if ($FPPD_COMMAND == "--type") {
    logEntry("type callback requested");
    //we got a register request message from the daemon
    processCallback($argv);